From: Mario Date: Wed, 14 Oct 2015 13:34:38 +0000 (+1000) Subject: Fix another gamemode specific check X-Git-Tag: xonotic-v0.8.2~1801^2~31 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d55ed6ba14b3cd8a083ff72e7b674df9ffbf70f3;p=xonotic%2Fxonotic-data.pk3dir.git Fix another gamemode specific check --- diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 3b2af5d92..95262bcfa 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -572,13 +572,19 @@ float bot_fixcount() activerealplayers = 0; realplayers = 0; - FOR_EACH_REALCLIENT(head) + if(!MUTATOR_CALLHOOK(Bot_FixCount, activerealplayers, realplayers)) { - if(IS_PLAYER(head) || g_lms || head.caplayer == 1) - ++activerealplayers; - ++realplayers; + FOR_EACH_REALCLIENT(head) + { + if(IS_PLAYER(head)) + ++activerealplayers; + ++realplayers; + } } + activerealplayers = bot_activerealplayers; + realplayers = bot_realplayers; + // add/remove bots if needed to make sure there are at least // minplayers+bot_number, or remove all bots if no one is playing // But don't remove bots immediately on level change, as the real players diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 5ab1258e6..04ac5c28f 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -692,4 +692,15 @@ enum { MUT_SPECPREV_RETURN, // return this flag to make the function return (handled entirely by mutator) MUT_SPECPREV_FOUND // return this flag to make the function continue without default functions (handled mostly by mutator) }; + +/** called when player triggered kill (or is changing teams), return error to not do anything */ +#define EV_Bot_FixCount(i, o) \ + /**/ i(int, bot_activerealplayers) \ + /**/ o(int, bot_activerealplayers) \ + /**/ i(int, bot_realplayers) \ + /**/ o(int, bot_realplayers) \ + /**/ +int bot_activerealplayers; +int bot_realplayers; +MUTATOR_HOOKABLE(Bot_FixCount, EV_Bot_FixCount); #endif diff --git a/qcsrc/server/mutators/gamemode_ca.qc b/qcsrc/server/mutators/gamemode_ca.qc index dc6dca021..eb8831187 100644 --- a/qcsrc/server/mutators/gamemode_ca.qc +++ b/qcsrc/server/mutators/gamemode_ca.qc @@ -430,6 +430,19 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev) return MUT_SPECPREV_FOUND; } +MUTATOR_HOOKFUNCTION(ca, Bot_FixCount, CBC_ORDER_EXCLUSIVE) +{ + entity head; + FOR_EACH_REALCLIENT(head) + { + if(IS_PLAYER(head) || head.caplayer == 1) + ++bot_activerealplayers; + ++bot_realplayers; + } + + return true; +} + void ca_Initialize() { allowed_to_spawn = true; diff --git a/qcsrc/server/mutators/gamemode_lms.qc b/qcsrc/server/mutators/gamemode_lms.qc index 9660fcee7..e9297d88b 100644 --- a/qcsrc/server/mutators/gamemode_lms.qc +++ b/qcsrc/server/mutators/gamemode_lms.qc @@ -200,6 +200,18 @@ MUTATOR_HOOKFUNCTION(lms, ItemTouch) return MUT_ITEMTOUCH_CONTINUE; } +MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE) +{ + entity head; + FOR_EACH_REALCLIENT(head) + { + ++bot_activerealplayers; + ++bot_realplayers; + } + + return true; +} + // scoreboard stuff void lms_ScoreRules() {