]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't waste 2 arrays for something that can be accomplished with just 2 ints and...
authorterencehill <piuntn@gmail.com>
Fri, 16 Jun 2017 21:00:38 +0000 (23:00 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 16 Jun 2017 21:00:38 +0000 (23:00 +0200)
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qh

index 5525c4d6a8f5d72e24acda5f2f96aae1b45b899a..d72efd137862c62b44949759c9ce043bbdd1d74e 100644 (file)
@@ -143,8 +143,8 @@ void onslaught_updatelinks()
        {
                l.islinked = false;
                l.isshielded = true;
-               int i;
-               for(i = 0; i < 17; ++i) { l.isgenneighbor[i] = false; l.iscpneighbor[i] = false; }
+               l.aregensneighbor = 0;
+               l.arecpsneighbor = 0;
                LOG_DEBUG(etos(l), " (point) belongs to team ", ftos(l.team));
                l.sprite.SendFlags |= 16;
        }
@@ -188,9 +188,9 @@ void onslaught_updatelinks()
                                l.enemy.isshielded = false;
                        }
                        if(l.goalentity.classname == "onslaught_generator")
-                               l.enemy.isgenneighbor[l.goalentity.team] = true;
+                               l.enemy.aregensneighbor |= BIT(l.goalentity.team);
                        else
-                               l.enemy.iscpneighbor[l.goalentity.team] = true;
+                               l.enemy.arecpsneighbor |= BIT(l.goalentity.team);
                }
                if (l.enemy.islinked)
                {
@@ -200,9 +200,9 @@ void onslaught_updatelinks()
                                l.goalentity.isshielded = false;
                        }
                        if(l.enemy.classname == "onslaught_generator")
-                               l.goalentity.isgenneighbor[l.enemy.team] = true;
+                               l.goalentity.aregensneighbor |= BIT(l.enemy.team);
                        else
-                               l.goalentity.iscpneighbor[l.enemy.team] = true;
+                               l.goalentity.arecpsneighbor |= BIT(l.enemy.team);
                }
        }
        // now update the generators
@@ -328,8 +328,8 @@ void ons_DelayedLinkSetup(entity this)
 
 int ons_ControlPoint_CanBeLinked(entity cp, int teamnumber)
 {
-       if(cp.isgenneighbor[teamnumber]) { return 2; }
-       if(cp.iscpneighbor[teamnumber]) { return 1; }
+       if(cp.aregensneighbor & BIT(teamnumber)) return 2;
+       if(cp.arecpsneighbor & BIT(teamnumber)) return 1;
 
        return 0;
 }
@@ -1308,7 +1308,7 @@ void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale
                        continue;
 
                // Ignore owned controlpoints
-               if(!(cp2.isgenneighbor[this.team] || cp2.iscpneighbor[this.team]))
+               if(!((cp2.aregensneighbor & BIT(this.team)) || (cp2.arecpsneighbor & BIT(this.team))))
                        continue;
 
                // Count team mates interested in this control point
index 5f05f7658bbb14b101b596ab10e6a74551da96dd..0757d7bc6014645c37260a1620563ea066aca9bf 100644 (file)
@@ -70,8 +70,8 @@ bool ons_stalemate;
 
 .float teleport_antispam;
 
-.bool isgenneighbor[17];
-.bool iscpneighbor[17];
+.int aregensneighbor;
+.int arecpsneighbor;
 float ons_notification_time[17];
 
 .float ons_overtime_damagedelay;