]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Clean up some player loops
authorMario <mario@smbclan.net>
Thu, 31 Dec 2015 19:25:15 +0000 (05:25 +1000)
committerMario <mario@smbclan.net>
Thu, 31 Dec 2015 19:25:15 +0000 (05:25 +1000)
qcsrc/server/bot/waypoints.qc
qcsrc/server/campaign.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc

index 3f3a54dd390f3cd75d42d7eb1304ff52fb7ff514..998f08c785e73b9966cd016921bf31c58d026e6a 100644 (file)
@@ -810,23 +810,20 @@ entity waypoint_spawnpersonal(vector position)
 
 void botframe_showwaypointlinks()
 {
-       entity player, head, w;
+       entity head, w;
        if (time < botframe_waypointeditorlightningtime)
                return;
        botframe_waypointeditorlightningtime = time + 0.5;
-       player = find(world, classname, "player");
-       while (player)
-       {
-               if (!player.isbot)
-               if (IS_ONGROUND(player) || player.waterlevel > WATERLEVEL_NONE)
+       FOREACH_CLIENT(IS_PLAYER(it) && !it.isbot, LAMBDA(
+               if(IS_ONGROUND(it) || it.waterlevel > WATERLEVEL_NONE)
                {
                        //navigation_testtracewalk = true;
-                       head = navigation_findnearestwaypoint(player, false);
+                       head = navigation_findnearestwaypoint(it, false);
                //      print("currently selected WP is ", etos(head), "\n");
                        //navigation_testtracewalk = false;
                        if (head)
                        {
-                               w = head     ;if (w) te_lightning2(world, w.origin, player.origin);
+                               w = head     ;if (w) te_lightning2(world, w.origin, it.origin);
                                w = head.wp00;if (w) te_lightning2(world, w.origin, head.origin);
                                w = head.wp01;if (w) te_lightning2(world, w.origin, head.origin);
                                w = head.wp02;if (w) te_lightning2(world, w.origin, head.origin);
@@ -861,8 +858,7 @@ void botframe_showwaypointlinks()
                                w = head.wp31;if (w) te_lightning2(world, w.origin, head.origin);
                        }
                }
-               player = find(player, classname, "player");
-       }
+       ));
 }
 
 float botframe_autowaypoints_fixdown(vector v)
index 9f867da0dd5c432145c468750c8f14f56e87f376..5dcd0ad9359d353687409b097c3654a1f30cd65e 100644 (file)
@@ -184,25 +184,16 @@ void CampaignSaveCvar(string cvarname, float value)
 
 void CampaignPreIntermission()
 {
-       entity head;
-       float won;
-       float lost;
+       int won = 0;
+       int lost = 0;
        string savevar;
 
-       won = lost = 0;
-
-       head = findchain(classname, "player");
-       while(head)
-       {
-               if(IS_REAL_CLIENT(head))
-               {
-                       if(head.winning)
-                               won = won + 1;
-                       else
-                               lost = lost + 1;
-               }
-               head = head.chain;
-       }
+       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), LAMBDA(
+               if(it.winning)
+                       won += 1;
+               else
+                       lost += 1;
+       ));
 
        if(autocvar__campaign_testrun)
        {
index 78d4514d5ca88de52965027d7e48f4cb7baad78c..c2bfe91caeb6c9af69e15704b458e299c012a68c 100644 (file)
@@ -74,16 +74,13 @@ float LMS_NewPlayerLives()
 // LMS winning condition: game terminates if and only if there's at most one
 // one player who's living lives. Top two scores being equal cancels the time
 // limit.
-float WinningCondition_LMS()
+int WinningCondition_LMS()
 {
        entity head, head2;
-       float have_player;
-       float have_players;
-       float l;
+       bool have_player = false;
+       bool have_players = false;
 
-       have_player = false;
-       have_players = false;
-       l = LMS_NewPlayerLives();
+       int l = LMS_NewPlayerLives();
 
        head = find(world, classname, "player");
        if(head)