From: Mario Date: Thu, 31 Dec 2015 19:25:15 +0000 (+1000) Subject: Clean up some player loops X-Git-Tag: xonotic-v0.8.2~1342 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c97a3c9e3ad9823d193dfc02461fa19d6de70150;p=xonotic%2Fxonotic-data.pk3dir.git Clean up some player loops --- diff --git a/qcsrc/server/bot/waypoints.qc b/qcsrc/server/bot/waypoints.qc index 3f3a54dd3..998f08c78 100644 --- a/qcsrc/server/bot/waypoints.qc +++ b/qcsrc/server/bot/waypoints.qc @@ -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) diff --git a/qcsrc/server/campaign.qc b/qcsrc/server/campaign.qc index 9f867da0d..5dcd0ad93 100644 --- a/qcsrc/server/campaign.qc +++ b/qcsrc/server/campaign.qc @@ -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) { diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index 78d4514d5..c2bfe91ca 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -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)