From 718837e7459658d876662a2a59c4df356f8cf288 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 4 Feb 2015 20:41:41 +1100 Subject: [PATCH] Add a fallback for TDM (untested potential fix to a nasty crash) --- qcsrc/server/mutators/gamemode_tdm.qc | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/qcsrc/server/mutators/gamemode_tdm.qc b/qcsrc/server/mutators/gamemode_tdm.qc index a4266fa48..8d50c654d 100644 --- a/qcsrc/server/mutators/gamemode_tdm.qc +++ b/qcsrc/server/mutators/gamemode_tdm.qc @@ -6,7 +6,7 @@ Keys: "cnt" Scoreboard color of the team (for example 4 is red and 13 is blue)... */ void spawnfunc_tdm_team() { - if(!g_tdm) { remove(self); return; } + if(!g_tdm || !self.cnt) { remove(self); return; } self.classname = "tdm_team"; self.team = self.cnt + 1; @@ -34,20 +34,31 @@ void tdm_DelayedInit() { print("No ""tdm_team"" entities found on this map, creating them anyway.\n"); - float numteams = min(4, autocvar_g_tdm_teams_override); - - if(numteams < 2) { numteams = autocvar_g_tdm_teams; } + float numteams = autocvar_g_tdm_teams_override; + if(numteams < 2 || numteams > 4) + numteams = autocvar_g_tdm_teams; numteams = bound(2, numteams, 4); - float i; - for(i = 1; i <= numteams; ++i) - tdm_SpawnTeam(Team_ColorName(Team_NumberToTeam(i)), Team_NumberToTeam(i) - 1); + tdm_SpawnTeam(NAME_TEAM_1, NUM_TEAM_1 - 1); + tdm_SpawnTeam(NAME_TEAM_2, NUM_TEAM_2 - 1); + if(numteams >= 3) + tdm_SpawnTeam(NAME_TEAM_3, NUM_TEAM_3 - 1); + if(numteams >= 4) + tdm_SpawnTeam(NAME_TEAM_4, NUM_TEAM_4 - 1); } } MUTATOR_HOOKFUNCTION(tdm_GetTeamCount) { ret_string = "tdm_team"; + if(find(world, classname, "tdm_team") == world) + { + // make it at least half accurate + ret_float = bound(2, ((autocvar_g_tdm_teams_override < 2) ? autocvar_g_tdm_teams : autocvar_g_tdm_teams_override), 4); + ret_string = string_null; + return FALSE; + } + return TRUE; } -- 2.39.2