From 5625ad76b909cdfd631c04c79fced5154fe08dc7 Mon Sep 17 00:00:00 2001 From: Michael McKoy Date: Mon, 18 Mar 2013 20:10:31 -0400 Subject: [PATCH] Fixed mapchooser interaction with CS:GO winlimits (bug 5484, r=psychonic). --- plugins/mapchooser.sp | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/plugins/mapchooser.sp b/plugins/mapchooser.sp index bc58c432..8c01b7b1 100644 --- a/plugins/mapchooser.sp +++ b/plugins/mapchooser.sp @@ -61,6 +61,7 @@ new Handle:g_Cvar_Winlimit = INVALID_HANDLE; new Handle:g_Cvar_Maxrounds = INVALID_HANDLE; new Handle:g_Cvar_Fraglimit = INVALID_HANDLE; new Handle:g_Cvar_Bonusroundtime = INVALID_HANDLE; +new Handle:g_Cvar_MatchClinch = INVALID_HANDLE; /* Plugin ConVars */ new Handle:g_Cvar_StartTime = INVALID_HANDLE; @@ -97,6 +98,7 @@ new bool:g_WaitingForVote; new bool:g_MapVoteCompleted; new bool:g_ChangeMapAtRoundEnd; new bool:g_ChangeMapInProgress; +new bool:g_HasIntermissionStarted = false; new g_mapFileSerial = -1; new g_NominateCount = 0; @@ -148,6 +150,7 @@ public OnPluginStart() g_Cvar_Maxrounds = FindConVar("mp_maxrounds"); g_Cvar_Fraglimit = FindConVar("mp_fraglimit"); g_Cvar_Bonusroundtime = FindConVar("mp_bonusroundtime"); + g_Cvar_MatchClinch = FindConVar("mp_match_can_clinch"); if (g_Cvar_Winlimit != INVALID_HANDLE || g_Cvar_Maxrounds != INVALID_HANDLE) { @@ -164,6 +167,12 @@ public OnPluginStart() { HookEvent("round_win", Event_RoundEnd); } + else if (strcmp(folder, "csgo") == 0) + { + HookEvent("round_end", Event_RoundEnd); + HookEvent("cs_intermission", Event_Intermission); + HookEvent("announce_phase_end", Event_PhaseEnd); + } else { HookEvent("round_end", Event_RoundEnd); @@ -255,6 +264,7 @@ public OnMapEnd() g_WaitingForVote = false; g_ChangeMapAtRoundEnd = false; g_ChangeMapInProgress = false; + g_HasIntermissionStarted = false; g_VoteTimer = INVALID_HANDLE; g_RetryTimer = INVALID_HANDLE; @@ -424,6 +434,26 @@ public Event_TeamPlayWinPanel(Handle:event, const String:name[], bool:dontBroadc } } } + +public Event_Intermission(Handle:event, const String:name[], bool:dontBroadcast) +{ + g_HasIntermissionStarted = true; +} + +public Event_PhaseEnd(Handle:event, const String:name[], bool:dontBroadcast) +{ + /* announce_phase_end fires for both half time and the end of the map, but intermission fires first for end of the map. */ + if (g_HasIntermissionStarted) + { + return; + } + + /* No intermission yet, so this must be half time. Swap the score counters. */ + new t_score = g_winCount[2]; + g_winCount[2] = g_winCount[3]; + g_winCount[3] = t_score; +} + /* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */ public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) { @@ -481,6 +511,22 @@ public CheckWinLimit(winner_score) } } } + + if (g_Cvar_MatchClinch != INVALID_HANDLE && g_Cvar_Maxrounds != INVALID_HANDLE) + { + new clinch = GetConVarInt(g_Cvar_MatchClinch); + + if (clinch) + { + new maxrounds = GetConVarInt(g_Cvar_Maxrounds); + new winlimit = maxrounds / 2; + + if(winner_score > (winlimit - GetConVarInt(g_Cvar_StartRounds))) + { + InitiateVote(MapChange_MapEnd, INVALID_HANDLE); + } + } + } } public CheckMaxRounds(roundcount)