From 27dbbc9294b457155a692e3d310f6a8755dd69e7 Mon Sep 17 00:00:00 2001 From: jenz Date: Sun, 29 Sep 2024 15:03:09 +0200 Subject: [PATCH] reworking the patchwork for rtv so it should seem normal. hopefully no more bugs --- .../mapchooser_extended_avg_mapend.sp | 42 +++++++++---------- .../scripting/rockthevote_extended_avg.sp | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp b/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp index 67ddeeb..45dcf28 100755 --- a/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp +++ b/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp @@ -143,8 +143,8 @@ bool g_ChangeMapInProgress; bool g_HasIntermissionStarted = false; bool g_SaveCDOnMapEnd = true; bool g_DidNotExtend = false; -bool g_DidRoundTerminate = false; bool g_IniatedLastVote = false; +bool g_bNoLongerRTV = false; int g_mapFileSerial = -1; int g_iPlayerCount_excludeSpec; int g_iMapsFromCasualPool; @@ -512,11 +512,11 @@ public Action GetInternalGetCvars(Handle timer) public void OnMapStart() { + g_bNoLongerRTV = false; CreateTimer(1.0, GetInternalGetCvars); 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. - g_DidRoundTerminate = false; g_IniatedLastVote = false; g_DidNotExtend = false; ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job. @@ -615,6 +615,7 @@ public void OnConfigsExecuted() public void OnMapEnd() { + g_bNoLongerRTV = false; int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; ServerCommand("sm_cvar mp_chattime %i", total_time); @@ -623,7 +624,6 @@ public void OnMapEnd() g_iInterval = 0; g_HasVoteStarted = false; g_WaitingForVote = false; - g_DidRoundTerminate = false; g_IniatedLastVote = false; g_ChangeMapAtRoundEnd = false; g_ChangeMapInProgress = false; @@ -990,18 +990,14 @@ public void Event_WeaponRank(Handle event, const char[] name, bool dontBroadcast public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason) { char map[PLATFORM_MAX_PATH]; - if (GetNextMap(map, sizeof(map))) //a nextmap is already set, no votes should be done. + //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; GetMapTimeLeft(timeleft); - if (g_WaitingForVote && timeleft <= 0) - { - g_DidRoundTerminate = true; - return Plugin_Handled; //it keeps retriggering this Action. - } if (g_IniatedLastVote) { return Plugin_Handled; //just extra safety check @@ -1020,6 +1016,7 @@ public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason) 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. //have to prevent server from being stuck in those situations with this timer. + InitiateVote(MapChange_Instant); //feature so mapvote happens at actual mapend CreateTimer(1.0, unfreeze_players, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); @@ -1028,7 +1025,6 @@ public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason) delay = float(total_time); return Plugin_Changed; } - g_DidRoundTerminate = false; return Plugin_Continue; } @@ -1057,13 +1053,12 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast) int timeleft; GetMapTimeLeft(timeleft); char map[PLATFORM_MAX_PATH]; - if (GetNextMap(map, sizeof(map)) && timeleft <= 0) //a nextmap is already set, if its also the last round we need to change the map. + 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; } - g_DidRoundTerminate = false; - if(g_ChangeMapAtRoundEnd) + if (g_ChangeMapAtRoundEnd) { GetNextMap(map, sizeof(map)); PrintToChatAll("[MCE] Next Map: %s", map); @@ -1071,10 +1066,10 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast) PrintToChatAll("[MCE] Next Map: %s", map); } - if(g_RoundCounting == RoundCounting_ArmsRace) + if (g_RoundCounting == RoundCounting_ArmsRace) return; - if(g_ChangeMapAtRoundEnd && !g_IniatedLastVote) + if (g_ChangeMapAtRoundEnd && !g_IniatedLastVote) { g_ChangeMapAtRoundEnd = false; CreateTimer(2.0, Timer_ChangeMap, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE); @@ -1732,9 +1727,10 @@ public void Handler_VoteFinishedGeneric(char[] map, } else if(strcmp(map, VOTE_DONTCHANGE, false) == 0) { - PrintToChatAll("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"); + g_bNoLongerRTV = true; g_RunoffCount = 0; g_HasVoteStarted = false; SetupTimeleftTimer(); @@ -1746,8 +1742,7 @@ public void Handler_VoteFinishedGeneric(char[] map, //SetNextMap(map); //feature edit where MapChange_MapEnd is only used to decide if extend or not extend 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 || g_DidRoundTerminate) //g_DidRoundTerminate implies that rtv vote is running while the last round already ended. - //therefore rtv vote has to switch map right now instead of roundend. + else if(g_ChangeTime == MapChange_Instant) { PrintToChatAll("[MCE] Next Map: %s", map); PrintToChatAll("[MCE] Next Map: %s", map); @@ -1759,6 +1754,7 @@ public void Handler_VoteFinishedGeneric(char[] map, } else // MapChange_RoundEnd { + g_bNoLongerRTV = false; SetNextMap(map); g_ChangeMapAtRoundEnd = true; } @@ -2259,7 +2255,9 @@ void CreateNextVote() bool CanVoteStart() { if(g_WaitingForVote || g_HasVoteStarted) + { return false; + } return true; } @@ -2449,12 +2447,13 @@ public int Native_InitiateVote(Handle plugin, int numParams) MapChange when = view_as(GetNativeCell(1)); Handle inputarray = view_as(GetNativeCell(2)); - LogAction(-1, -1, "Starting map vote because outside request"); - int timeleft; GetMapTimeLeft(timeleft); - if (timeleft <= 0 && !g_ChangeMapAtRoundEnd) //somehow a random vote might get triggered. this should prevent it + int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10; + 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."); return 0; } if (!g_IniatedLastVote) @@ -2466,6 +2465,7 @@ public int Native_InitiateVote(Handle plugin, int numParams) return 0; } +//CanMapChooserStartVote public int Native_CanVoteStart(Handle plugin, int numParams) { return CanVoteStart(); diff --git a/mapchooser_extended/scripting/rockthevote_extended_avg.sp b/mapchooser_extended/scripting/rockthevote_extended_avg.sp index 4dcec6a..145393f 100755 --- a/mapchooser_extended/scripting/rockthevote_extended_avg.sp +++ b/mapchooser_extended/scripting/rockthevote_extended_avg.sp @@ -423,7 +423,6 @@ void StartRTV() return; } - PrintToChatAll("Rock The Vote has begun!"); if (EndOfMapVoteEnabled() && HasEndOfMapVoteFinished()) { @@ -446,6 +445,7 @@ void StartRTV() if (CanMapChooserStartVote()) { + PrintToChatAll("[RTVE] Rock The Vote has begun!"); MapChange when = view_as(g_Cvar_ChangeTime.IntValue); InitiateMapChooserVote(when);