From 01e64deda523525bc3e8b5c85975b1af7f084bf2 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Fri, 15 Dec 2023 06:26:01 +0300 Subject: [PATCH] Sort -> SortPredicate --- regamedll/dlls/multiplay_gamerules.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 1557c5efa..100ee14a6 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -5395,27 +5395,26 @@ void CHalfLifeMultiplay::GiveDefuserToRandomPlayer() candidates.AddToTail(pPlayer); } - + // randomly shuffle the list; this will keep the selection random in case of ties for (int i = 0; i < candidates.Count(); i++) { SWAP(candidates[i], candidates[RANDOM_LONG(0, candidates.Count() - 1)]); } // now sort the shuffled list into subgroups - candidates.Sort([](CBasePlayer *const *left, CBasePlayer *const *right) -> int { - // should we prioritize humans over bots? - if (cv_bot_defer_to_human.value != 0.0f) - { - if ((*left)->IsBot() && !(*right)->IsBot()) - return 1; - - if (!(*left)->IsBot() && (*right)->IsBot()) - return -1; - } + candidates.SortPredicate([](const CBasePlayer &pl1, const CBasePlayer &pl2) { + // should we prioritize humans over bots? + if (cv_bot_defer_to_human.value != 0.0f) + { + if (pl1.IsBot() && !pl2.IsBot()) + return true; - return 0; + if (!pl1.IsBot() && pl2.IsBot()) + return false; } - ); + + return true; + }); // give defusers to the first N candidates for (int i = 0; i < iDefusersToGive && i < candidates.Count(); ++i)