From 5d386cf809dae730b55bd4db418a3b78d17b7cf6 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 8 Nov 2018 03:39:25 +0000 Subject: [PATCH] Workaround loading bugs --- dlls/client.cpp | 4 +++- dlls/coop.cpp | 32 +++++++++++++++++++++++++------- dlls/coop_util.h | 1 + dlls/gravgunmod.cpp | 8 ++++++++ dlls/gravgunmod.h | 3 ++- dlls/multiplay_gamerules.cpp | 9 +++++++++ 6 files changed, 48 insertions(+), 9 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 0992a024..3ed3b664 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -88,7 +88,7 @@ BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddres if( mp_coop.value && pEntity ) { CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ; - if( pl ) + if( pl && pl->m_ggm.iState != STATE_LOAD_FIX ) { pl->m_ggm.iState = STATE_UNINITIALIZED; pl->RemoveAllItems( TRUE ); @@ -703,6 +703,8 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) { GGM_SaveState( pPlayer ); pEntity->v.netname = pEntity->v.frags = 0; + if( pPlayer->m_ggm.iState == STATE_LOAD_FIX ) + return; pPlayer->m_ggm.pState = pState; pPlayer->m_ggm.iState = STATE_UNINITIALIZED; } diff --git a/dlls/coop.cpp b/dlls/coop.cpp index 3e31e1db..40e8dc25 100644 --- a/dlls/coop.cpp +++ b/dlls/coop.cpp @@ -485,13 +485,21 @@ void COOP_SetupLandmarkTransition( const char *szNextMap, const char *szNextSpot } } +bool COOP_PlayerSpawn( CBasePlayer *pPlayer ) +{ + if( g_CoopState.landmarkTransition.fLoading && pPlayer ) + pPlayer->m_ggm.iState = STATE_LOAD_FIX; + if( pPlayer->m_ggm.iState == STATE_LOAD_FIX ) + return true; + return false; +} + void COOP_ServerActivate( void ) { static float st_DupCheck; - if( g_CoopState.landmarkTransition.fLoading ) - { - st_DupCheck = gpGlobals->time; - } + + if( !mp_coop.value ) + return; if( st_DupCheck && gpGlobals->time && st_DupCheck == gpGlobals->time) { @@ -499,8 +507,10 @@ void COOP_ServerActivate( void ) return; } - if( !mp_coop.value ) - return; + if( g_CoopState.landmarkTransition.fLoading ) + { + st_DupCheck = gpGlobals->time; + } GGM_ConnectSaveBot(); @@ -530,13 +540,21 @@ void COOP_ServerActivate( void ) for( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *plr = (CBasePlayer*)UTIL_PlayerByIndex( i ); - // reset all players state if( plr ) { + + plr->m_ggm.iState = STATE_UNINITIALIZED; plr->RemoveAllItems( TRUE ); UTIL_BecomeSpectator( plr ); + if( g_CoopState.landmarkTransition.fLoading ) + { +// plr->Spawn(); +// CLIENT_COMMAND( plr->edict(), "reconnect\n"); + plr->m_ggm.iState = STATE_LOAD_FIX; + + } //plr->Spawn(); } } diff --git a/dlls/coop_util.h b/dlls/coop_util.h index 5696c8ee..d8af42bc 100644 --- a/dlls/coop_util.h +++ b/dlls/coop_util.h @@ -56,6 +56,7 @@ void COOP_AddDefaultWeapon( const char *pszClassName ); void COOP_WriteState( const char *path ); bool COOP_ReadState( const char *path ); void COOP_AutoSave( void ); +bool COOP_PlayerSpawn( CBasePlayer *pPlayer ); struct COOPChangelevelData *COOP_GetTriggerData( CBaseEntity *pTrigger ); #endif // COOP_UTIL_H diff --git a/dlls/gravgunmod.cpp b/dlls/gravgunmod.cpp index 21c1ffd0..55964bfe 100644 --- a/dlls/gravgunmod.cpp +++ b/dlls/gravgunmod.cpp @@ -636,6 +636,8 @@ const char *GGM_GetAuthID( CBasePlayer *pPlayer ) void GGM_ClientPutinServer( edict_t *pEntity, CBasePlayer *pPlayer ) { + if( pPlayer->m_ggm.iState == STATE_LOAD_FIX ) + return; if( mp_touchmenu.value && pPlayer->m_ggm.iState == STATE_UNINITIALIZED ) g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 ); @@ -1371,6 +1373,12 @@ void ClientPutInServer( edict_t *client ); bool GGM_PlayerSpawn( CBasePlayer *pPlayer ) { + if( mp_coop.value ) + if( COOP_PlayerSpawn( pPlayer ) ) + return true; + + if( pPlayer->m_ggm.iState == STATE_LOAD_FIX ) + return true; if( pPlayer->m_ggm.iState == STATE_UNINITIALIZED ) { ClientPutInServer( pPlayer->edict() ); diff --git a/dlls/gravgunmod.h b/dlls/gravgunmod.h index 0047c22d..1653a7b3 100644 --- a/dlls/gravgunmod.h +++ b/dlls/gravgunmod.h @@ -71,7 +71,8 @@ enum PlayerState STATE_SPECTATOR_BEGIN, STATE_SPAWNED, STATE_SPECTATOR, - STATE_POINT_SELECT + STATE_POINT_SELECT, + STATE_LOAD_FIX }; enum PlayerMenuState diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index d17c665e..7006d397 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -563,6 +563,15 @@ BOOL CHalfLifeMultiplay::FPlayerCanTakeDamage( CBasePlayer *pPlayer, CBaseEntity //========================================================= void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer ) { + if( pPlayer->m_ggm.iState == STATE_LOAD_FIX ) + if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) + { + CLIENT_COMMAND( pPlayer->edict(), "reconnect\n" ); + pPlayer->m_ggm.iState = STATE_UNINITIALIZED; + pPlayer->m_afButtonPressed = 0; + return; + } + if( !mp_coop.value && pPlayer->m_ggm.iState == STATE_SPECTATOR_BEGIN ) if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) UTIL_SpawnPlayer( pPlayer );