From: terencehill Date: Sun, 22 Mar 2020 09:25:54 +0000 (+0100) Subject: Refactor frags remaining announcer code and make it work with leadlimit_and_fraglimit 1 X-Git-Tag: xonotic-v0.8.5~1144^2~6^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6a4524be3175ded00bb4cf97ea35300117f756c9;p=xonotic%2Fxonotic-data.pk3dir.git Refactor frags remaining announcer code and make it work with leadlimit_and_fraglimit 1 --- diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index aa4c5f505..89fee9051 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1737,8 +1737,7 @@ float WinningCondition_Scores(float limit, float leadlimit) limit = -limit; } - if(WinningConditionHelper_zeroisworst - || (!autocvar_leadlimit_and_fraglimit && limit && leadlimit >= fabs(limit))) + if(WinningConditionHelper_zeroisworst) leadlimit = 0; // not supported in this mode if(MUTATOR_CALLHOOK(Scores_CountFragsRemaining)) @@ -1747,39 +1746,40 @@ float WinningCondition_Scores(float limit, float leadlimit) if (leaderscore != WinningConditionHelper_topscore || secondscore != WinningConditionHelper_secondscore) { - int fragsleft = 0; + int fragsleft = 0, leadingfragsleft = 0; leaderscore = WinningConditionHelper_topscore; secondscore = WinningConditionHelper_secondscore; - if (limit) + if (leadlimit) + leadingfragsleft = secondscore + leadlimit - leaderscore; + if (autocvar_leadlimit_and_fraglimit && leadlimit && limit) { - if (leaderscore == limit - 1) - fragsleft |= BIT(1); - else if (leaderscore == limit - 2) - fragsleft |= BIT(2); - else if (leaderscore == limit - 3) - fragsleft |= BIT(3); + fragsleft = limit - leaderscore; + fragsleft = max(leadingfragsleft, fragsleft); } - if (leadlimit) + else { - if (leaderscore == leadlimit + secondscore - 1) - fragsleft |= BIT(1); - else if (leaderscore == leadlimit + secondscore - 2) - fragsleft |= BIT(2); - else if (leaderscore == leadlimit + secondscore - 3) - fragsleft |= BIT(3); + if (limit) + { + fragsleft = limit - leaderscore; + if (leadlimit) + fragsleft = min(fragsleft, leadingfragsleft); + } + else if (leadlimit) + fragsleft = leadingfragsleft; } - fragsleft = fragsleft & -fragsleft; // least significant bit where 1 is set + if (fragsleft > 3) + fragsleft = 0; if (fragsleft_last != fragsleft) // do not announce same remaining frags multiple times { - if (fragsleft & BIT(1)) + if (fragsleft == 1) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_1); - else if (fragsleft & BIT(2)) + else if (fragsleft == 2) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_2); - else if (fragsleft & BIT(3)) + else if (fragsleft == 3) Send_Notification(NOTIF_ALL, NULL, MSG_ANNCE, ANNCE_REMAINING_FRAG_3); fragsleft_last = fragsleft;