From 90ba38d57725f7b07184dbd4f4dac2b26bd5f4b2 Mon Sep 17 00:00:00 2001 From: mittorn Date: Mon, 30 Jul 2018 16:37:27 +0000 Subject: [PATCH] Fix vote --- dlls/client.cpp | 1 + dlls/coop.cpp | 42 ++++++++++++++++++++++++------------------ dlls/gravgunmod.cpp | 2 ++ dlls/subs.cpp | 2 +- dlls/triggers.cpp | 4 ++-- 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 4b471c83..c36eefd1 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -628,6 +628,7 @@ void ClientCommand( edict_t *pEntity ) }*/ pPlayer->RemoveAllItems(TRUE); UTIL_BecomeSpectator(pPlayer); + pPlayer->gravgunmod_data.m_state = STATE_SPECTATOR; } else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode { diff --git a/dlls/coop.cpp b/dlls/coop.cpp index bfdb6dff..87e0a2cf 100644 --- a/dlls/coop.cpp +++ b/dlls/coop.cpp @@ -382,43 +382,47 @@ void GlobalVote::Process( CBasePlayer *pPlayer, int imenu ) { if( pPlayer->pev->flags & FL_SPECTATOR ) return; - if( gpGlobals->time - m_flTime > 30 ) + if( gpGlobals->time - m_flTime > 20 ) { - g_iVote = 0; - m_iConfirm = 0; + COOP_ResetVote(); return; } - g_GlobalVote.m_flTime = gpGlobals->time; + //g_GlobalVote.m_flTime = gpGlobals->time; switch( g_iVote ) { case 1: // touch blue trigger m_iVoteCount++; - if( imenu == 1 ) // confirm + if( imenu == 0 ) // confirm { if( m_iBanCount >= 2 ) { UTIL_CoopKickPlayer( pPlayer ); m_iConfirm-= 5; + m_iBanCount = 0; return; } m_iConfirm++; UTIL_CoopPrintMessage( "%s^7 confirmed map change\n", UTIL_CoopPlayerName( pPlayer )); } - if( imenu == 2 ) // cancel + if( imenu == 1 ) // cancel { m_iConfirm--; if( pPlayer == m_pPlayer ) + { m_iConfirm -= 100; // player mistake + g_iVote = 0; + } } - if( imenu == 3 ) + if( imenu == 2 ) { m_iBanCount++; if( m_iBanCount >= 2 && m_iConfirm > -50 ) UTIL_CoopKickPlayer( m_pPlayer ); + g_iVote = 0; } break; } @@ -439,7 +443,7 @@ void GlobalVote::ShowGlobalMenu( const char *title, int count, const char **menu for( int j = 0; j < count; j++ ) { char cmd[32]; - sprintf(cmd, "votemenu %d", i ); + sprintf(cmd, "votemenu %d", j ); m.Add( menu[j], cmd ); } m.Show(); @@ -646,19 +650,16 @@ void COOP_ResetVote( void ) { g_iVote = 0; g_GlobalVote.m_iConfirm = 0; + g_GlobalVote.m_iBanCount = 0; g_GlobalVote.m_flTime = gpGlobals->time; } bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2, char *mapname ) { - if( gpGlobals->time - g_GlobalVote.m_flTime > 30 ) - { - g_iVote = 0; - g_GlobalVote.m_iConfirm = 0; - } - - g_GlobalVote.m_flTime = gpGlobals->time; + if( gpGlobals->time - g_GlobalVote.m_flTime > 10 ) + COOP_ResetVote(); + //g_GlobalVote.m_flTime = gpGlobals->time; if( g_iVote != 1 ) { @@ -666,7 +667,7 @@ bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2 { CBasePlayer *pPlayer = (CBasePlayer*)pActivator; - if( pPlayer->gravgunmod_data.m_iLocalConfirm == 0 ) + if( pPlayer->gravgunmod_data.m_iLocalConfirm <= 0 ) pPlayer->gravgunmod_data.m_iLocalConfirm = 1; if( pPlayer->gravgunmod_data.m_iLocalConfirm < 3 ) { @@ -676,7 +677,10 @@ bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2 .Show(); } else + { g_GlobalVote.ConfirmMenu(pPlayer, pTrigger, mapname ); + pPlayer->gravgunmod_data.m_iLocalConfirm = 0; + } } return false; } @@ -687,7 +691,7 @@ bool COOP_ConfirmMenu(CBaseEntity *pTrigger, CBaseEntity *pActivator, int count2 // do not allow go back if there are checkpoints, but not near changelevel if( g_checkpoints[0].time && (g_checkpoints[0].origin - VecBModelOrigin(pTrigger->pev)).Length() > 150 ) { - g_GlobalVote.m_iConfirm = 0; + COOP_ResetVote(); UTIL_CoopPlayerMessage( pActivator, 1, 5, 0xFF0000FF, 0xFF0000FF, 0, 0.7, "Changelevel back locked by checkpoint\nCheckpoint here to activate trigger!"); return false; } @@ -804,6 +808,8 @@ bool COOP_ClientCommand( edict_t *pEntity ) { if( !mp_coop_checkpoints.value ) return false; + if( pPlayer->gravgunmod_data.m_state != STATE_SPAWNED ) + return false; if( !UTIL_CoopIsBadPlayer( pPlayer ) ) COOP_NewCheckpoint( pPlayer->pev ); else @@ -821,7 +827,7 @@ bool COOP_ClientCommand( edict_t *pEntity ) { int i = atoi( CMD_ARGV(1) ); g_GlobalVote.Process(pPlayer, i); - return false; + return true; } return false; diff --git a/dlls/gravgunmod.cpp b/dlls/gravgunmod.cpp index de34101a..8a3fd33c 100644 --- a/dlls/gravgunmod.cpp +++ b/dlls/gravgunmod.cpp @@ -541,4 +541,6 @@ bool GGM_PlayerMenu::MenuSelect( int select ) GGM::Cmd_TokenizeString( m_items[select-1].command ); ClientCommand( pPlayer->edict() ); GGM::Cmd_Reset(); + + return true; } diff --git a/dlls/subs.cpp b/dlls/subs.cpp index 5aa95a5b..5d53f994 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -456,7 +456,7 @@ void CBaseToggle::LinearMoveDone( void ) float error = delta.Length(); if( error > 0.03125 ) { - LinearMove( m_vecFinalDest, 100 ); + LinearMove( m_vecFinalDest, 1000 ); return; } diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 724fb233..9a90a1eb 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1592,7 +1592,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) continue; // count only players spawned more 30 seconds ago - if( plr && plr->IsPlayer() && (pTrain || (gpGlobals->time -((CBasePlayer*)plr)->gravgunmod_data.m_flSpawnTime ) > 30 ) ) + if( plr && plr->IsPlayer() && (pTrain || (gpGlobals->time -((CBasePlayer*)plr)->gravgunmod_data.m_flSpawnTime ) > 30 ) && plr->pev->modelindex ) { count2++; @@ -1654,7 +1654,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) ALERT( at_console, "^3CHANGELEVEL:^7 %d %d\n", count2, count1 ); - if( count1 > 1 && count1 < count2 / 3 ) + if( !m_fIsBack && count1 > 1 && count1 < count2 / 3 ) return; //if( count1 <= 1 && count2 == 2 )