hopefully the dread is finally over now
This commit is contained in:
		
							parent
							
								
									27dbbc9294
								
							
						
					
					
						commit
						3244412eed
					
				@ -138,13 +138,10 @@ int g_TotalRounds;
 | 
			
		||||
bool g_HasVoteStarted;
 | 
			
		||||
bool g_WaitingForVote;
 | 
			
		||||
bool g_MapVoteCompleted;
 | 
			
		||||
bool g_ChangeMapAtRoundEnd;
 | 
			
		||||
bool g_ChangeMapInProgress;
 | 
			
		||||
bool g_HasIntermissionStarted = false;
 | 
			
		||||
bool g_SaveCDOnMapEnd = true;
 | 
			
		||||
bool g_DidNotExtend = false;
 | 
			
		||||
bool g_IniatedLastVote = false;
 | 
			
		||||
bool g_bNoLongerRTV = 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.
 | 
			
		||||
int g_mapFileSerial = -1;
 | 
			
		||||
int g_iPlayerCount_excludeSpec;
 | 
			
		||||
int g_iMapsFromCasualPool;
 | 
			
		||||
@ -512,13 +509,11 @@ public Action GetInternalGetCvars(Handle timer)
 | 
			
		||||
 | 
			
		||||
public void OnMapStart()
 | 
			
		||||
{
 | 
			
		||||
    g_bNoLongerRTV = false;
 | 
			
		||||
    g_iNextmapState = 0;
 | 
			
		||||
    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_IniatedLastVote = false;
 | 
			
		||||
    g_DidNotExtend = false;
 | 
			
		||||
    ServerCommand("sm_cvar sm_vote_progress_hintbox 1"); //yeah its cheesy but does the job.
 | 
			
		||||
    g_iInterval = 0;
 | 
			
		||||
    static char folder[64];
 | 
			
		||||
@ -615,17 +610,14 @@ public void OnConfigsExecuted()
 | 
			
		||||
 | 
			
		||||
public void OnMapEnd()
 | 
			
		||||
{
 | 
			
		||||
    g_bNoLongerRTV = false;
 | 
			
		||||
    g_iNextmapState = 0;
 | 
			
		||||
    int total_time = (GetConVarInt(g_Cvar_VoteDuration) * 2) + GetConVarInt(g_Cvar_RunOffWarningTime) + 10;
 | 
			
		||||
    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.
 | 
			
		||||
    g_iInterval = 0;
 | 
			
		||||
    g_HasVoteStarted = false;
 | 
			
		||||
    g_WaitingForVote = false;
 | 
			
		||||
    g_IniatedLastVote = false;
 | 
			
		||||
    g_ChangeMapAtRoundEnd = false;
 | 
			
		||||
    g_ChangeMapInProgress = 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);
 | 
			
		||||
 | 
			
		||||
    SetNextMap(map);
 | 
			
		||||
    g_iNextmapState = 2; //admin set the next map
 | 
			
		||||
    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.
 | 
			
		||||
    //therefore instead applying the bool here after the mapvote completed.
 | 
			
		||||
@ -793,13 +786,22 @@ public void OnMapTimeLeftChanged()
 | 
			
		||||
{
 | 
			
		||||
    if(GetArraySize(g_MapList))
 | 
			
		||||
    {
 | 
			
		||||
        //LogMessage("Mapchooser_extended_avg OnMapTimeLeftChanged call.");
 | 
			
		||||
        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;
 | 
			
		||||
    if(GetMapTimeLeft(time) && time > 0)
 | 
			
		||||
    {
 | 
			
		||||
@ -816,14 +818,11 @@ void SetupTimeleftTimer()
 | 
			
		||||
            startTime = GetConVarInt(g_Cvar_StartTime) * 60;
 | 
			
		||||
 | 
			
		||||
        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");
 | 
			
		||||
            //LogMessage("SetupWarningTimer 1");
 | 
			
		||||
            //PrintToChatAll("SetupWarningTimer 1");
 | 
			
		||||
        }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            if(g_WarningTimer == INVALID_HANDLE)
 | 
			
		||||
@ -834,37 +833,22 @@ void SetupTimeleftTimer()
 | 
			
		||||
                    g_VoteTimer = INVALID_HANDLE;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                //g_VoteTimer = CreateTimer(float(time - startTime), Timer_StartMapVoteTimer_StartMapVote, _, 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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
public Action Timer_StartWarningTimer(Handle timer)
 | 
			
		||||
{
 | 
			
		||||
    g_VoteTimer = INVALID_HANDLE;
 | 
			
		||||
 | 
			
		||||
    int timeleft;
 | 
			
		||||
    GetMapTimeLeft(timeleft);
 | 
			
		||||
    if (timeleft <= 0 && !g_ChangeMapAtRoundEnd) //somehow a random vote might get triggered. this should prevent it
 | 
			
		||||
    {
 | 
			
		||||
        return Plugin_Stop;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if(!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
 | 
			
		||||
    {
 | 
			
		||||
        if (!g_IniatedLastVote)
 | 
			
		||||
    if (!g_WarningInProgress || g_WarningTimer == INVALID_HANDLE)
 | 
			
		||||
    {
 | 
			
		||||
        SetupWarningTimer(WarningType_Vote);
 | 
			
		||||
            LogMessage("SetupWarningTimer 2");
 | 
			
		||||
        //LogMessage("SetupWarningTimer 2");
 | 
			
		||||
        //PrintToChatAll("SetupWarningTimer 2");
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
    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)
 | 
			
		||||
{
 | 
			
		||||
    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;
 | 
			
		||||
    GetMapTimeLeft(timeleft);
 | 
			
		||||
    if (g_IniatedLastVote)
 | 
			
		||||
    {
 | 
			
		||||
        return Plugin_Handled; //just extra safety check
 | 
			
		||||
    }
 | 
			
		||||
    if (timeleft <= 0 && !g_ChangeMapAtRoundEnd)
 | 
			
		||||
    //cases that can happen:
 | 
			
		||||
    //0 timeleft and admin did setnextmap.
 | 
			
		||||
    //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_iNextmapState >= 3)
 | 
			
		||||
    {
 | 
			
		||||
        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. 
 | 
			
		||||
            {
 | 
			
		||||
                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();
 | 
			
		||||
            }
 | 
			
		||||
            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); 
 | 
			
		||||
            //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.
 | 
			
		||||
@ -1052,26 +1029,13 @@ public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
 | 
			
		||||
{
 | 
			
		||||
    int timeleft;
 | 
			
		||||
    GetMapTimeLeft(timeleft);
 | 
			
		||||
	if (g_iNextmapState == 1 || (g_iNextmapState == 2 && timeleft <= 0)) //rtv went through or admin used setnextmap
 | 
			
		||||
	{
 | 
			
		||||
        char map[PLATFORM_MAX_PATH];
 | 
			
		||||
    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)
 | 
			
		||||
	{
 | 
			
		||||
		GetNextMap(map, sizeof(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);
 | 
			
		||||
		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)
 | 
			
		||||
        {
 | 
			
		||||
            SetupWarningTimer(WarningType_Vote, MapChange_MapEnd);
 | 
			
		||||
            LogMessage("SetupWarningTimer 5");
 | 
			
		||||
            //LogMessage("SetupWarningTimer 5");
 | 
			
		||||
            //PrintToChatAll("SetupWarningTimer 5");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@ -1174,7 +1138,7 @@ public Action Command_Mapvote(int client, int args)
 | 
			
		||||
    ShowActivity2(client, "[MCE] ", "%t", "Initiated Vote Map");
 | 
			
		||||
 | 
			
		||||
    SetupWarningTimer(WarningType_Vote, MapChange_MapEnd, INVALID_HANDLE, true);
 | 
			
		||||
    LogMessage("SetupWarningTimer 6");
 | 
			
		||||
    //LogMessage("SetupWarningTimer 6");
 | 
			
		||||
    //PrintToChatAll("SetupWarningTimer 6");
 | 
			
		||||
 | 
			
		||||
    return Plugin_Handled;
 | 
			
		||||
@ -1721,8 +1685,9 @@ public void Handler_VoteFinishedGeneric(char[] map,
 | 
			
		||||
 | 
			
		||||
        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();
 | 
			
		||||
    }
 | 
			
		||||
    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), "%");
 | 
			
		||||
        LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
 | 
			
		||||
 | 
			
		||||
        g_bNoLongerRTV = true;
 | 
			
		||||
        g_RunoffCount = 0;
 | 
			
		||||
        g_HasVoteStarted = false;
 | 
			
		||||
        SetupTimeleftTimer();
 | 
			
		||||
@ -1739,10 +1703,9 @@ public void Handler_VoteFinishedGeneric(char[] map,
 | 
			
		||||
    {
 | 
			
		||||
        if(g_ChangeTime == MapChange_MapEnd)
 | 
			
		||||
        {
 | 
			
		||||
            //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.
 | 
			
		||||
            g_iNextmapState = 3; //map was not extended
 | 
			
		||||
        }
 | 
			
		||||
        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);
 | 
			
		||||
@ -1754,9 +1717,8 @@ public void Handler_VoteFinishedGeneric(char[] map,
 | 
			
		||||
        }
 | 
			
		||||
        else // MapChange_RoundEnd
 | 
			
		||||
        {
 | 
			
		||||
            g_bNoLongerRTV = false;
 | 
			
		||||
            g_iNextmapState = 1; //rtv was performed.
 | 
			
		||||
            SetNextMap(map);
 | 
			
		||||
            g_ChangeMapAtRoundEnd = true;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        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;
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
    SetupWarningTimer(WarningType_Vote, when, inputarray);
 | 
			
		||||
        LogMessage("SetupWarningTimer 9");
 | 
			
		||||
    //LogMessage("SetupWarningTimer 9");
 | 
			
		||||
    //PrintToChatAll("SetupWarningTimer 9");
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3016,11 +2974,9 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
 | 
			
		||||
{
 | 
			
		||||
	/* Do we add any special items? */
 | 
			
		||||
	// Moved for Mapchooser Extended
 | 
			
		||||
    int timeleft;
 | 
			
		||||
    GetMapTimeLeft(timeleft);
 | 
			
		||||
    if (timeleft <= 0 && !g_ChangeMapAtRoundEnd)
 | 
			
		||||
    if (g_iNextmapState != 0) //we return if admin set next map. if all extends were used or map was not extended. 
 | 
			
		||||
    {
 | 
			
		||||
        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))
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user