From: Mario Date: Sun, 25 Oct 2015 10:59:03 +0000 (+1000) Subject: Fix match not ending when score limit reached X-Git-Tag: xonotic-v0.8.2~1795 X-Git-Url: https://git.xonotic.org/?a=commitdiff_plain;h=0d07735ea456026e6d4cc1c8d38b2da82f2d44e4;p=xonotic%2Fxonotic-data.pk3dir.git Fix match not ending when score limit reached --- diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index c3932f3fb..c706a1bdd 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1709,85 +1709,6 @@ float WinningCondition_Assault() return status; } -// 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() -{ - entity head, head2; - float have_player; - float have_players; - float l; - - have_player = false; - have_players = false; - l = LMS_NewPlayerLives(); - - head = find(world, classname, "player"); - if(head) - have_player = true; - head2 = find(head, classname, "player"); - if(head2) - have_players = true; - - if(have_player) - { - // we have at least one player - if(have_players) - { - // two or more active players - continue with the game - } - else - { - // exactly one player? - - ClearWinners(); - SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out - - if(l) - { - // game still running (that is, nobody got removed from the game by a frag yet)? then continue - return WINNING_NO; - } - else - { - // a winner! - // and assign him his first place - PlayerScore_Add(head, SP_LMS_RANK, 1); - return WINNING_YES; - } - } - } - else - { - // nobody is playing at all... - if(l) - { - // wait for players... - } - else - { - // SNAFU (maybe a draw game?) - ClearWinners(); - LOG_TRACE("No players, ending game.\n"); - return WINNING_YES; - } - } - - // When we get here, we have at least two players who are actually LIVING, - // now check if the top two players have equal score. - WinningConditionHelper(); - - ClearWinners(); - if(WinningConditionHelper_winner) - WinningConditionHelper_winner.winning = true; - if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore) - return WINNING_NEVER; - - // Top two have different scores? Way to go for our beloved TIMELIMIT! - return WINNING_NO; -} - void ShuffleMaplist() { cvar_set("g_maplist", shufflewords(autocvar_g_maplist)); @@ -2092,11 +2013,11 @@ void CheckRules_World() int checkrules_status = WinningCondition_RanOutOfSpawns(); if(checkrules_status == WINNING_YES) bprint("Hey! Someone ran out of spawns!\n"); - else if(!MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit)) + else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit)) + checkrules_status = ret_float; + else checkrules_status = WinningCondition_Scores(fraglimit, leadlimit); - checkrules_status = ret_float; - if(checkrules_status == WINNING_STARTSUDDENDEATHOVERTIME) { checkrules_status = WINNING_NEVER; diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index efab45e3f..de11a6739 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -71,6 +71,85 @@ float LMS_NewPlayerLives() return bound(1, lms_lowest_lives, fl); } +// 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() +{ + entity head, head2; + float have_player; + float have_players; + float l; + + have_player = false; + have_players = false; + l = LMS_NewPlayerLives(); + + head = find(world, classname, "player"); + if(head) + have_player = true; + head2 = find(head, classname, "player"); + if(head2) + have_players = true; + + if(have_player) + { + // we have at least one player + if(have_players) + { + // two or more active players - continue with the game + } + else + { + // exactly one player? + + ClearWinners(); + SetWinners(winning, 0); // NOTE: exactly one player is still "player", so this works out + + if(l) + { + // game still running (that is, nobody got removed from the game by a frag yet)? then continue + return WINNING_NO; + } + else + { + // a winner! + // and assign him his first place + PlayerScore_Add(head, SP_LMS_RANK, 1); + return WINNING_YES; + } + } + } + else + { + // nobody is playing at all... + if(l) + { + // wait for players... + } + else + { + // SNAFU (maybe a draw game?) + ClearWinners(); + LOG_TRACE("No players, ending game.\n"); + return WINNING_YES; + } + } + + // When we get here, we have at least two players who are actually LIVING, + // now check if the top two players have equal score. + WinningConditionHelper(); + + ClearWinners(); + if(WinningConditionHelper_winner) + WinningConditionHelper_winner.winning = true; + if(WinningConditionHelper_topscore == WinningConditionHelper_secondscore) + return WINNING_NEVER; + + // Top two have different scores? Way to go for our beloved TIMELIMIT! + return WINNING_NO; +} + // mutator hooks MUTATOR_HOOKFUNCTION(lms, reset_map_global) {