Skip to content

Commit

Permalink
Fix warmup stuck at 0:01 issue by forcing map reload on match load (#999
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nickdnk committed Mar 20, 2023
1 parent 1d7abe7 commit fc435cd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ details.
immediately following the end of the series, but now waits until the restore timer fires. Get5 will be in `post_game`
until the timer runs out, similarly to when waiting for the next map. This means that GOTV broadcasts will have a
chance to finish before Get5 releases the server.
7. The map is now **always** reloaded when a match configuration is loaded, even if the server is already on the correct
map. Similarly, if doing in-game map selection (veto), the map is always changed to the first map in the series, even
if the server is already on that map. This reverts this change
from [0.13](https://github.com/splewis/get5/blob/development/CHANGELOG.md#0130).

### New Features / Changes 🎉

Expand Down
33 changes: 5 additions & 28 deletions scripting/get5/mapveto.sp
Original file line number Diff line number Diff line change
Expand Up @@ -89,36 +89,13 @@ static void FinishVeto() {
Get5_MessageToAll("%t", "MapIsInfoMessage", i + 1 - mapNumber, map);
}

char currentMapName[PLATFORM_MAX_PATH];
GetCleanMapName(currentMapName, sizeof(currentMapName));

char mapToPlay[PLATFORM_MAX_PATH];
g_MapsToPlay.GetString(0, mapToPlay, sizeof(mapToPlay));

// In case the sides don't match after selection, we check it here before writing the backup.
// Also required if the map doesn't need to change.
SetStartingTeams();
SetMatchTeamCvars();

if (!StrEqual(currentMapName, mapToPlay)) {
ResetReadyStatus();
float delay = 10.0;
g_MapChangePending = true;
if (g_DisplayGotvVetoCvar.BoolValue) {
// Players must wait for GOTV to end before we can change map, but we don't need to record that.
g_PendingMapChangeTimer = CreateTimer(float(GetTvDelay()) + delay, Timer_NextMatchMap);
} else {
g_PendingMapChangeTimer = CreateTimer(delay, Timer_NextMatchMap);
}
} else {
LOOP_CLIENTS(i) {
if (IsPlayer(i)) {
CheckClientTeam(i);
}
}
float delay = 7.0;
g_MapChangePending = true;
if (g_DisplayGotvVetoCvar.BoolValue) {
delay = float(GetTvDelay()) + delay;
}
g_PendingMapChangeTimer = CreateTimer(delay, Timer_NextMatchMap);
ChangeState(Get5State_Warmup);
WriteBackup(); // Write first pre-live backup after veto.
}

// Main Veto Controller
Expand Down
89 changes: 37 additions & 52 deletions scripting/get5/matchconfig.sp
Original file line number Diff line number Diff line change
Expand Up @@ -83,41 +83,27 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
return false;
}

bool gameModeReloadRequired = IsMapReloadRequiredForGameMode(g_Wingman);

if (g_SkipVeto) {
// Copy the first k maps from the maplist to the final match maps.
for (int i = 0; i < g_NumberOfMapsInSeries; i++) {
g_MapPoolList.GetString(i, mapName, sizeof(mapName));
g_MapsToPlay.PushString(mapName);

// Push a map side if one hasn't been set yet.
if (g_MapSides.Length < g_MapsToPlay.Length) {
if (g_MatchSideType == MatchSideType_Standard || g_MatchSideType == MatchSideType_AlwaysKnife) {
g_MapSides.Push(SideChoice_KnifeRound);
} else {
g_MapSides.Push(SideChoice_Team1CT);
if (!restoreBackup) {
if (g_SkipVeto) {
// Copy the first k maps from the maplist to the final match maps.
for (int i = 0; i < g_NumberOfMapsInSeries; i++) {
g_MapPoolList.GetString(i, mapName, sizeof(mapName));
g_MapsToPlay.PushString(mapName);

// Push a map side if one hasn't been set yet.
if (g_MapSides.Length < g_MapsToPlay.Length) {
if (g_MatchSideType == MatchSideType_Standard || g_MatchSideType == MatchSideType_AlwaysKnife) {
g_MapSides.Push(SideChoice_KnifeRound);
} else {
g_MapSides.Push(SideChoice_Team1CT);
}
}
}
}

if (!restoreBackup) {
ChangeState(Get5State_Warmup);
// When restoring from backup, changelevel is called after loading the match config.
g_MapPoolList.GetString(Get5_GetMapNumber(), mapName, sizeof(mapName));
char currentMap[PLATFORM_MAX_PATH];
GetCurrentMap(currentMap, sizeof(currentMap));
if (!StrEqual(mapName, currentMap)) {
gameModeReloadRequired = false; // we can skip this when the map is changed here.
SetCorrectGameMode();
ChangeMap(mapName);
}
} else {
ChangeState(Get5State_PreVeto);
}
} else if (!restoreBackup) {
ChangeState(Get5State_PreVeto);
}

if (g_GameState == Get5State_None) {
} else if (g_GameState == Get5State_None) {
// Make sure here that we don't run the code below in game state none, but also not overriding
// PreVeto. Currently, this could happen if you restored a backup with skip_veto:false.
ChangeState(Get5State_Warmup);
Expand All @@ -142,6 +128,7 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
ServerCommand("mp_backup_round_file backup_%s", serverId);

if (!restoreBackup) {
SetCorrectGameMode();
StopRecording(); // Ensure no recording is running when starting a match, as that prevents Get5 from starting one.
ExecCfg(g_WarmupCfgCvar);
StartWarmup();
Expand All @@ -150,6 +137,8 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
UnpauseGame();
}

Get5_MessageToAll("%t", "MatchConfigLoadedInfoMessage");

Stats_InitSeries();

Get5TeamWrapper team1 = new Get5TeamWrapper(g_TeamIDs[Get5Team_1], g_TeamNames[Get5Team_1]);
Expand All @@ -171,18 +160,23 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
LogError("Setting player auths in the \"players\" or \"coaches\" section has no impact with get5_check_auths 0");
}

// ExecuteMatchConfigCvars must be executed before we place players, as it might have
// get5_check_auths 1. We must also have called SetStartingTeams to get the sides right. When
// restoring from backup, assigning to teams is done after loading the match config as it
// depends on the sides being set correctly by the backup, so we put it inside this "if" here.
// When the match is loaded, we do not want to assign players on no team, as they may be in the
// process of joining the server, which is the reason for the timer callback. This has caused
// problems with players getting stuck on no team when using match config autoload, essentially
// recreating the "coaching bug". Adding a few seconds seems to solve this problem. We cannot just
// skip team none, as players may also just be on the team selection menu when the match is
// loaded, meaning they will never have a joingame hook, as it already happened, and we still
// want those players placed.
if (g_CheckAuthsCvar.BoolValue) {
// If we veto, the map will change after veto, otherwise we change it immediately.
if (g_SkipVeto) {
g_MapsToPlay.GetString(0, mapName, sizeof(mapName));
ChangeMap(mapName, 3.0);
} else if (g_CheckAuthsCvar.BoolValue) {
// ExecuteMatchConfigCvars must be executed before we place players, as it might have
// get5_check_auths 1. We must also have called SetStartingTeams to get the sides right. When
// restoring from backup, assigning to teams is done after loading the match config as it
// depends on the sides being set correctly by the backup, so we put it inside this "if" here.
// When the match is loaded, we do not want to assign players on no team, as they may be in the
// process of joining the server, which is the reason for the timer callback. This has caused
// problems with players getting stuck on no team when using match config autoload, essentially
// recreating the "coaching bug". Adding a few seconds seems to solve this problem. We cannot just
// skip team none, as players may also just be on the team selection menu when the match is
// loaded, meaning they will never have a joingame hook, as it already happened, and we still
// want those players placed.
// Move players to their right teams during veto.
LOOP_CLIENTS(i) {
if (IsPlayer(i)) {
if (GetClientTeam(i) == CS_TEAM_NONE) {
Expand All @@ -194,16 +188,7 @@ bool LoadMatchConfig(const char[] config, char[] error, bool restoreBackup = fal
}
}
}

strcopy(g_LoadedConfigFile, sizeof(g_LoadedConfigFile), config);

Get5_MessageToAll("%t", "MatchConfigLoadedInfoMessage");

if (gameModeReloadRequired && !restoreBackup) {
GetCurrentMap(mapName, sizeof(mapName));
SetCorrectGameMode();
ChangeMap(mapName, 3.0);
}
return true;
}

Expand Down

0 comments on commit fc435cd

Please sign in to comment.