# HG changeset patch # User Michael McKoy # Date 1363651831 14400 # Node ID 40e1814dd3d643e06b448664728d2e9a1b2ce527 # Parent 3a72196e1a0f7ef66db1918f4dd2c88bed6d7884 Fixed mapchooser interaction with CS:GO winlimits (bug 5484, r=psychonic). diff -r 3a72196e1a0f -r 40e1814dd3d6 plugins/mapchooser.sp --- a/plugins/mapchooser.sp Mon Mar 18 20:03:17 2013 -0400 +++ b/plugins/mapchooser.sp Mon Mar 18 20:10:31 2013 -0400 @@ -61,6 +61,7 @@ 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_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 @@ 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 @@ { 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 @@ 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_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 @@ } } } + + 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)