hopefully the dread is finally over now

This commit is contained in:
jenz 2024-10-01 00:50:34 +02:00
parent 27dbbc9294
commit 3244412eed

View File

@ -138,13 +138,10 @@ int g_TotalRounds;
bool g_HasVoteStarted; bool g_HasVoteStarted;
bool g_WaitingForVote; bool g_WaitingForVote;
bool g_MapVoteCompleted; bool g_MapVoteCompleted;
bool g_ChangeMapAtRoundEnd;
bool g_ChangeMapInProgress; bool g_ChangeMapInProgress;
bool g_HasIntermissionStarted = false; bool g_HasIntermissionStarted = false;
bool g_SaveCDOnMapEnd = true; bool g_SaveCDOnMapEnd = true;
bool g_DidNotExtend = 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.
bool g_IniatedLastVote = false;
bool g_bNoLongerRTV = false;
int g_mapFileSerial = -1; int g_mapFileSerial = -1;
int g_iPlayerCount_excludeSpec; int g_iPlayerCount_excludeSpec;
int g_iMapsFromCasualPool; int g_iMapsFromCasualPool;
@ -512,13 +509,11 @@ public Action GetInternalGetCvars(Handle timer)
public void OnMapStart() public void OnMapStart()
{ {
g_bNoLongerRTV = false; g_iNextmapState = 0;
CreateTimer(1.0, GetInternalGetCvars); CreateTimer(1.0, GetInternalGetCvars);
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
ServerCommand("sm_cvar mp_chattime %i", total_time); //prevents map switching supposedly. ServerCommand("sm_cvar mp_chattime %i", total_time); //prevents map switching supposedly.
g_IniatedLastVote = false;
g_DidNotExtend = false;
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job. ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
g_iInterval = 0; g_iInterval = 0;
static char folder[64]; static char folder[64];
@ -615,17 +610,14 @@ public void OnConfigsExecuted()
public void OnMapEnd() public void OnMapEnd()
{ {
g_bNoLongerRTV = false; g_iNextmapState = 0;
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
ServerCommand("sm_cvar mp_chattime %i", total_time); ServerCommand("sm_cvar mp_chattime %i", total_time);
g_DidNotExtend = false;
ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job. ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
g_iInterval = 0; g_iInterval = 0;
g_HasVoteStarted = false; g_HasVoteStarted = false;
g_WaitingForVote = false; g_WaitingForVote = false;
g_IniatedLastVote = false;
g_ChangeMapAtRoundEnd = false;
g_ChangeMapInProgress = false; g_ChangeMapInProgress = false;
g_HasIntermissionStarted = false; g_HasIntermissionStarted = false;
@ -736,6 +728,7 @@ public Action Command_SetNextmap(int client, int args)
LogAction(client, -1, "\"%L\" changed nextmap to \"%s\"", client, map); LogAction(client, -1, "\"%L\" changed nextmap to \"%s\"", client, map);
SetNextMap(map); SetNextMap(map);
g_iNextmapState = 2; //admin set the next map
g_MapVoteCompleted = true; g_MapVoteCompleted = true;
//checking on MapStart and MapEnd is not good enough. Players are not considered alive and on teams at those points in time. //checking on MapStart and MapEnd is not good enough. Players are not considered alive and on teams at those points in time.
//therefore instead applying the bool here after the mapvote completed. //therefore instead applying the bool here after the mapvote completed.
@ -793,13 +786,22 @@ public void OnMapTimeLeftChanged()
{ {
if(GetArraySize(g_MapList)) if(GetArraySize(g_MapList))
{ {
//LogMessage("Mapchooser_extended_avg OnMapTimeLeftChanged call.");
SetupTimeleftTimer(); SetupTimeleftTimer();
} }
} }
void SetupTimeleftTimer() void SetupTimeleftTimer()
{ {
if (g_iNextmapState != 0)
{
if (g_VoteTimer != INVALID_HANDLE)
{
KillTimer(g_VoteTimer);
g_VoteTimer = INVALID_HANDLE;
}
return; //all extends were used or map was not extended or rtv was succesfull or admin set nextmap
}
int time; int time;
if(GetMapTimeLeft(time) && time > 0) if(GetMapTimeLeft(time) && time > 0)
{ {
@ -817,12 +819,9 @@ void SetupTimeleftTimer()
if(time - startTime < 0 && GetConVarBool(g_Cvar_EndOfMapVote) && !g_MapVoteCompleted && !g_HasVoteStarted && !g_WaitingForVote) if(time - startTime < 0 && GetConVarBool(g_Cvar_EndOfMapVote) && !g_MapVoteCompleted && !g_HasVoteStarted && !g_WaitingForVote)
{ {
if (!g_DidNotExtend && !g_IniatedLastVote) SetupWarningTimer(WarningType_Vote);
{ //LogMessage("SetupWarningTimer 1");
SetupWarningTimer(WarningType_Vote); //PrintToChatAll("SetupWarningTimer 1");
LogMessage("SetupWarningTimer 1");
//PrintToChatAll("SetupWarningTimer 1");
}
} }
else else
{ {
@ -834,12 +833,7 @@ void SetupTimeleftTimer()
g_VoteTimer = INVALID_HANDLE; g_VoteTimer = INVALID_HANDLE;
} }
//g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVoteTimer_StartMapVote, _, TIMER_FLAG_NO_MAPCHANGE); g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartWarningTimer, _, TIMER_FLAG_NO_MAPCHANGE);
//LogMessage("Mapchooser_extended_avg g_VoteTimer Timer_StartWarningTimer");
if (GetConVarInt(g_Cvar_Extend) - g_Extends > 0 && !g_DidNotExtend)
{
g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartWarningTimer, _, TIMER_FLAG_NO_MAPCHANGE);
}
} }
} }
} }
@ -849,21 +843,11 @@ public Action Timer_StartWarningTimer(Handle timer)
{ {
g_VoteTimer = INVALID_HANDLE; g_VoteTimer = INVALID_HANDLE;
int timeleft; if (!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
GetMapTimeLeft(timeleft);
if (timeleft <= 0 && !g_ChangeMapAtRoundEnd) //somehow a random vote might get triggered. this should prevent it
{ {
return Plugin_Stop; SetupWarningTimer(WarningType_Vote);
} //LogMessage("SetupWarningTimer 2");
//PrintToChatAll("SetupWarningTimer 2");
if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
{
if (!g_IniatedLastVote)
{
SetupWarningTimer(WarningType_Vote);
LogMessage("SetupWarningTimer 2");
//PrintToChatAll("SetupWarningTimer 2");
}
} }
return Plugin_Stop; return Plugin_Stop;
} }
@ -989,30 +973,23 @@ public void Event_WeaponRank(Handle event, const char[] name, bool dontBroadcast
public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason) public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
{ {
char map[PLATFORM_MAX_PATH];
//why does initiating rtv set a next map dxxxxxxxxxx
if (GetNextMap(map, sizeof(map)) && !g_bNoLongerRTV) //a nextmap is already set, no votes should be done.
{
return Plugin_Continue;
}
int timeleft; int timeleft;
GetMapTimeLeft(timeleft); GetMapTimeLeft(timeleft);
if (g_IniatedLastVote) //cases that can happen:
{ //0 timeleft and admin did setnextmap.
return Plugin_Handled; //just extra safety check //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)
if (timeleft <= 0 && !g_ChangeMapAtRoundEnd) if (timeleft <= 0 && g_iNextmapState >= 3)
{ {
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
if (!g_IniatedLastVote) if (g_iNextmapState == 3)
{ {
if (IsVoteInProgress()) //fucking admins being brain dead doing extend votes right when the map ends. if (IsVoteInProgress()) //fucking admins being brain dead doing extend votes right when the map ends.
{ {
PrintToChatAll("The admin slept on the job again. Should had made that extend vote 2-3 minutes before the timeleft ran out instead of panic extend voting the last second possible."); PrintToChatAll("The admin slept on the job again. Should had made that extend vote 2-3 minutes before the timeleft ran out instead of panic extend voting the last second possible.");
CancelVote(); CancelVote();
} }
g_IniatedLastVote = true; g_iNextmapState = 4; //started vote, so lets not repeat that.
CreateTimer(float(total_time + 10), Timer_fall_back_map_switch, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); CreateTimer(float(total_time + 10), Timer_fall_back_map_switch, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
//sometimes it will simply happen that theres a mapvote where nobody votes anything. //sometimes it will simply happen that theres a mapvote where nobody votes anything.
//have to prevent server from being stuck in those situations with this timer. //have to prevent server from being stuck in those situations with this timer.
@ -1052,26 +1029,13 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{ {
int timeleft; int timeleft;
GetMapTimeLeft(timeleft); GetMapTimeLeft(timeleft);
char map[PLATFORM_MAX_PATH]; if (g_iNextmapState == 1 || (g_iNextmapState == 2 && timeleft <= 0)) //rtv went through or admin used setnextmap
if (GetNextMap(map, sizeof(map)) && timeleft <= 0 && !g_bNoLongerRTV) //a nextmap is already set, if its also the last round we need to change the map.
{
g_ChangeMapAtRoundEnd = true;
}
if (g_ChangeMapAtRoundEnd)
{ {
char map[PLATFORM_MAX_PATH];
GetNextMap(map, sizeof(map)); GetNextMap(map, sizeof(map));
PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map);
PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map);
PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map);
}
if (g_RoundCounting == RoundCounting_ArmsRace)
return;
if (g_ChangeMapAtRoundEnd && !g_IniatedLastVote)
{
g_ChangeMapAtRoundEnd = false;
CreateTimer(2.0, Timer_ChangeMap, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); CreateTimer(2.0, Timer_ChangeMap, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE);
g_ChangeMapInProgress = true; g_ChangeMapInProgress = true;
} }
@ -1162,7 +1126,7 @@ public Action Event_PlayerDeath(Handle event, const char[] name, bool dontBroadc
if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE) if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
{ {
SetupWarningTimer(WarningType_Vote, MapChange_MapEnd); SetupWarningTimer(WarningType_Vote, MapChange_MapEnd);
LogMessage("SetupWarningTimer 5"); //LogMessage("SetupWarningTimer 5");
//PrintToChatAll("SetupWarningTimer 5"); //PrintToChatAll("SetupWarningTimer 5");
} }
} }
@ -1174,7 +1138,7 @@ public Action Command_Mapvote(int client, int args)
ShowActivity2(client, "[MCE] ", "%t", "Initiated Vote Map"); ShowActivity2(client, "[MCE] ", "%t", "Initiated Vote Map");
SetupWarningTimer(WarningType_Vote, MapChange_MapEnd, INVALID_HANDLE, true); SetupWarningTimer(WarningType_Vote, MapChange_MapEnd, INVALID_HANDLE, true);
LogMessage("SetupWarningTimer 6"); //LogMessage("SetupWarningTimer 6");
//PrintToChatAll("SetupWarningTimer 6"); //PrintToChatAll("SetupWarningTimer 6");
return Plugin_Handled; return Plugin_Handled;
@ -1721,8 +1685,9 @@ public void Handler_VoteFinishedGeneric(char[] map,
if (GetConVarInt(g_Cvar_Extend) - g_Extends < 1) if (GetConVarInt(g_Cvar_Extend) - g_Extends < 1)
{ {
g_DidNotExtend = true; //dont come with the map extend vote if all extends were used. g_iNextmapState = 3; //last extend was used
} }
SetupTimeleftTimer(); SetupTimeleftTimer();
} }
else if(strcmp(map, VOTE_DONTCHANGE, false) == 0) else if(strcmp(map, VOTE_DONTCHANGE, false) == 0)
@ -1730,7 +1695,6 @@ public void Handler_VoteFinishedGeneric(char[] map,
PrintToChatAll("[MCE] Current map continues! The Vote has spoken! (Received %i%s of votes)", RoundToFloor((map_votes /num_votes)*100.0), "%"); PrintToChatAll("[MCE] Current map continues! The Vote has spoken! (Received %i%s of votes)", RoundToFloor((map_votes /num_votes)*100.0), "%");
LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner"); LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
g_bNoLongerRTV = true;
g_RunoffCount = 0; g_RunoffCount = 0;
g_HasVoteStarted = false; g_HasVoteStarted = false;
SetupTimeleftTimer(); SetupTimeleftTimer();
@ -1739,10 +1703,9 @@ public void Handler_VoteFinishedGeneric(char[] map,
{ {
if(g_ChangeTime == MapChange_MapEnd) if(g_ChangeTime == MapChange_MapEnd)
{ {
//SetNextMap(map); //feature edit where MapChange_MapEnd is only used to decide if extend or not extend g_iNextmapState = 3; //map was not extended
g_DidNotExtend = true; //just so warningtimer wont start running again if an admin removes or adds time when players voted to not extend.
} }
else if(g_ChangeTime == MapChange_Instant) else if(g_ChangeTime == MapChange_Instant) //end of map voting ends up here because we change instantly.
{ {
PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map);
PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map);
@ -1754,9 +1717,8 @@ public void Handler_VoteFinishedGeneric(char[] map,
} }
else // MapChange_RoundEnd else // MapChange_RoundEnd
{ {
g_bNoLongerRTV = false; g_iNextmapState = 1; //rtv was performed.
SetNextMap(map); SetNextMap(map);
g_ChangeMapAtRoundEnd = true;
} }
g_HasVoteStarted = false; g_HasVoteStarted = false;
@ -2452,16 +2414,12 @@ public int Native_InitiateVote(Handle plugin, int numParams)
int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
if (timeleft <= total_time) if (timeleft <= total_time)
{ {
g_bNoLongerRTV = true; //somehow rtv sets the nextmap so this extra bool is needed
PrintToChatAll("[RTVE] Rock the vote was cancelled due to not enough time left over."); PrintToChatAll("[RTVE] Rock the vote was cancelled due to not enough time left over.");
return 0; return 0;
} }
if (!g_IniatedLastVote) SetupWarningTimer(WarningType_Vote, when, inputarray);
{ //LogMessage("SetupWarningTimer 9");
SetupWarningTimer(WarningType_Vote, when, inputarray); //PrintToChatAll("SetupWarningTimer 9");
LogMessage("SetupWarningTimer 9");
//PrintToChatAll("SetupWarningTimer 9");
}
return 0; return 0;
} }
@ -3016,11 +2974,9 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
{ {
/* Do we add any special items? */ /* Do we add any special items? */
// Moved for Mapchooser Extended // Moved for Mapchooser Extended
int timeleft; if (g_iNextmapState != 0) //we return if admin set next map. if all extends were used or map was not extended.
GetMapTimeLeft(timeleft);
if (timeleft <= 0 && !g_ChangeMapAtRoundEnd)
{ {
return; //dont add dont change or extend because the map is over so now we must go for other maps. return;
} }
if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange)) if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))