Fixed mapchooser interaction with CS:GO winlimits (bug 5484, r=psychonic).
Fixed mapchooser interaction with CS:GO winlimits (
bug 5484, r=psychonic).
1.1 --- a/plugins/mapchooser.sp Mon Mar 18 20:03:17 2013 -0400
1.2 +++ b/plugins/mapchooser.sp Mon Mar 18 20:10:31 2013 -0400
1.3 @@ -61,6 +61,7 @@
1.4 new Handle:g_Cvar_Maxrounds = INVALID_HANDLE;
1.5 new Handle:g_Cvar_Fraglimit = INVALID_HANDLE;
1.6 new Handle:g_Cvar_Bonusroundtime = INVALID_HANDLE;
1.7 +new Handle:g_Cvar_MatchClinch = INVALID_HANDLE;
1.8
1.9 /* Plugin ConVars */
1.10 new Handle:g_Cvar_StartTime = INVALID_HANDLE;
1.11 @@ -97,6 +98,7 @@
1.12 new bool:g_MapVoteCompleted;
1.13 new bool:g_ChangeMapAtRoundEnd;
1.14 new bool:g_ChangeMapInProgress;
1.15 +new bool:g_HasIntermissionStarted = false;
1.16 new g_mapFileSerial = -1;
1.17
1.18 new g_NominateCount = 0;
1.19 @@ -148,6 +150,7 @@
1.20 g_Cvar_Maxrounds = FindConVar("mp_maxrounds");
1.21 g_Cvar_Fraglimit = FindConVar("mp_fraglimit");
1.22 g_Cvar_Bonusroundtime = FindConVar("mp_bonusroundtime");
1.23 + g_Cvar_MatchClinch = FindConVar("mp_match_can_clinch");
1.24
1.25 if (g_Cvar_Winlimit != INVALID_HANDLE || g_Cvar_Maxrounds != INVALID_HANDLE)
1.26 {
1.27 @@ -164,6 +167,12 @@
1.28 {
1.29 HookEvent("round_win", Event_RoundEnd);
1.30 }
1.31 + else if (strcmp(folder, "csgo") == 0)
1.32 + {
1.33 + HookEvent("round_end", Event_RoundEnd);
1.34 + HookEvent("cs_intermission", Event_Intermission);
1.35 + HookEvent("announce_phase_end", Event_PhaseEnd);
1.36 + }
1.37 else
1.38 {
1.39 HookEvent("round_end", Event_RoundEnd);
1.40 @@ -255,6 +264,7 @@
1.41 g_WaitingForVote = false;
1.42 g_ChangeMapAtRoundEnd = false;
1.43 g_ChangeMapInProgress = false;
1.44 + g_HasIntermissionStarted = false;
1.45
1.46 g_VoteTimer = INVALID_HANDLE;
1.47 g_RetryTimer = INVALID_HANDLE;
1.48 @@ -424,6 +434,26 @@
1.49 }
1.50 }
1.51 }
1.52 +
1.53 +public Event_Intermission(Handle:event, const String:name[], bool:dontBroadcast)
1.54 +{
1.55 + g_HasIntermissionStarted = true;
1.56 +}
1.57 +
1.58 +public Event_PhaseEnd(Handle:event, const String:name[], bool:dontBroadcast)
1.59 +{
1.60 + /* announce_phase_end fires for both half time and the end of the map, but intermission fires first for end of the map. */
1.61 + if (g_HasIntermissionStarted)
1.62 + {
1.63 + return;
1.64 + }
1.65 +
1.66 + /* No intermission yet, so this must be half time. Swap the score counters. */
1.67 + new t_score = g_winCount[2];
1.68 + g_winCount[2] = g_winCount[3];
1.69 + g_winCount[3] = t_score;
1.70 +}
1.71 +
1.72 /* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */
1.73 public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
1.74 {
1.75 @@ -481,6 +511,22 @@
1.76 }
1.77 }
1.78 }
1.79 +
1.80 + if (g_Cvar_MatchClinch != INVALID_HANDLE && g_Cvar_Maxrounds != INVALID_HANDLE)
1.81 + {
1.82 + new clinch = GetConVarInt(g_Cvar_MatchClinch);
1.83 +
1.84 + if (clinch)
1.85 + {
1.86 + new maxrounds = GetConVarInt(g_Cvar_Maxrounds);
1.87 + new winlimit = maxrounds / 2;
1.88 +
1.89 + if(winner_score > (winlimit - GetConVarInt(g_Cvar_StartRounds)))
1.90 + {
1.91 + InitiateVote(MapChange_MapEnd, INVALID_HANDLE);
1.92 + }
1.93 + }
1.94 + }
1.95 }
1.96
1.97 public CheckMaxRounds(roundcount)