only tested on dev so far but should be stable probably. rtv is now not disabled even if there is not enough time left over and the last round ends. instead the final round gets delayed until the rtv map vote is over

This commit is contained in:
jenz 2026-02-26 21:20:00 +01:00
parent 01fad8b648
commit c0fb1dd61a

View File

@ -141,6 +141,7 @@ bool g_MapVoteCompleted;
bool g_ChangeMapInProgress;
bool g_HasIntermissionStarted = false;
bool g_SaveCDOnMapEnd = true;
bool g_RtvInitiated = false;
int g_iNextmapState = 0; //0 = nothing. 1 = rtv succesfull. 2 = admin used setnextmap. 3 = did not extend or used all extends. 4 = vote at end of map is going on.
int g_mapFileSerial = -1;
int g_iPlayerCount_excludeSpec;
@ -509,6 +510,7 @@ public Action GetInternalGetCvars(Handle timer)
public void OnMapStart()
{
g_iNextmapState = 0;
g_RtvInitiated = false;
CreateTimer(1.0, GetInternalGetCvars);
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
@ -612,6 +614,7 @@ public void OnConfigsExecuted()
public void OnMapEnd()
{
g_iNextmapState = 0;
g_RtvInitiated = false;
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
ServerCommand("sm_cvar mp_chattime %i", total_time);
@ -967,6 +970,21 @@ public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
//0 timeleft and admin did setnextmap.
//0 timeleft and rtv already picked a map. (round_end event forces the nextmap)
//0 timeleft and all extends used or map was not extended. (we do the map vote at map end)
//0 timeleft and rtv is ongoing still
if (timeleft <= 0 && g_RtvInitiated && g_iNextmapState < 4) //last round was terminated, rtv is going on and we did not set g_i Nextmapstate yet.
{
//extra time in case of rtv, rtv run-off (there is no dont change option here as we already used all extends or people voted dont extend)
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
g_iNextmapState = 4; //rtv vote going on already, so lets not repeat that.
CreateTimer(1.0, unfreeze_players, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
//extending the map allows players to run around instead of being frozen. should just be careful about it running into edicts limits
CreateTimer(float(total_time + 10), Timer_fall_back_map_switch, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
delay = float(total_time);
return Plugin_Changed;
}
if (timeleft <= 0 && g_iNextmapState >= 3)
{
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
@ -991,6 +1009,7 @@ public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
return Plugin_Changed;
}
//when you join the ze server as the first player and theres 0 timeleft and no map was selected the server can get stuck for 2 minutes.
//that is rather problematic because it often leads to the very first people connecting wanting to leave again because the game is stuck.
if (timeleft < 0 && g_iNextmapState == 0)
@ -1673,6 +1692,9 @@ public void Handler_VoteFinishedGeneric(char[] map,
}
else if(strcmp(map, VOTE_DONTCHANGE, false) == 0)
{
//dont change option in rtv cannot happen after the last extend was used or after people voting dong extend
//so there is no risk of a mapend rtv having the dont change option possible.
g_RtvInitiated = false; //reset the bool again
PrintToChatAll("[MCE] Current map continues! The Vote has spoken! (Received %i/%i of votes)", map_votes, num_votes);
LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
@ -1698,8 +1720,22 @@ public void Handler_VoteFinishedGeneric(char[] map,
}
else // MapChange_RoundEnd
{
g_iNextmapState = 1; //rtv was performed.
SetNextMap(map);
if (g_iNextmapState == 4 && g_RtvInitiated) //timeleft is 0, the last round was terminated but rtv still on going. go to the rtv map now.
{
PrintToChatAll("[MCE] Next Map: %s", map);
PrintToChatAll("[MCE] Next Map: %s", map);
PrintToChatAll("[MCE] Next Map: %s", map);
Handle data;
CreateDataTimer(4.0, Timer_ChangeMap, data);
WritePackString(data, map);
g_ChangeMapInProgress = false;
}
else
{
g_iNextmapState = 1; //rtv was performed.
SetNextMap(map);
}
g_RtvInitiated = false;
}
g_HasVoteStarted = false;
@ -2372,14 +2408,14 @@ public int Native_InitiateVote(Handle plugin, int numParams)
MapChange when = view_as<MapChange>(GetNativeCell(1));
Handle inputarray = view_as<Handle>(GetNativeCell(2));
int timeleft;
GetMapTimeLeft(timeleft);
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
if (timeleft <= total_time)
//what is this used for? people care about being able to do rtv even if its the last round
//and even if the rtv should be going on after the last round ending
if (g_iNextmapState == 4)
{
PrintToChatAll("[RTVE] Rock the vote was cancelled due to not enough time left over.");
PrintToChatAll("Not doing rtv because end vote already is going on.");
return 0;
}
g_RtvInitiated = true;
SetupWarningTimer(WarningType_Vote, when, inputarray);
//LogMessage("SetupWarningTimer 9");
//PrintToChatAll("SetupWarningTimer 9");