Browse Source

Force reconnect uninitialized players

hlzbot-dirty
mittorn 8 years ago
parent
commit
d0cd6c8af5
  1. 29
      dlls/client.cpp
  2. 20
      dlls/multiplay_gamerules.cpp
  3. 3
      dlls/player.h
  4. 13
      dlls/triggers.cpp

29
dlls/client.cpp

@ -78,6 +78,20 @@ called when a player connects to a server
*/ */
BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ) BOOL ClientConnect( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] )
{ {
if( pEntity )
{
CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ) ;
if( pl )
{
pl->m_state = STATE_CONNECTED;
pl->RemoveAllItems( TRUE );
BecomeSpectator( pl );
ClientPutInServer( pl->edict() );
}
}
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason ); return g_pGameRules->ClientConnected( pEntity, pszName, pszAddress, szRejectReason );
// a client connecting during an intermission can cause problems // a client connecting during an intermission can cause problems
@ -125,6 +139,10 @@ void ClientDisconnect( edict_t *pEntity )
UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin ); UTIL_SetOrigin ( &pEntity->v, pEntity->v.origin );
g_pGameRules->ClientDisconnected( pEntity ); g_pGameRules->ClientDisconnected( pEntity );
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity );
if( pPlayer )
pPlayer->m_state = STATE_UNINITIALIZED;
} }
@ -198,17 +216,22 @@ void ClientPutInServer( edict_t *pEntity )
pPlayer = GetClassPtr((CBasePlayer *)pev); pPlayer = GetClassPtr((CBasePlayer *)pev);
pPlayer->SetCustomDecalFrames(-1); // Assume none; pPlayer->SetCustomDecalFrames(-1); // Assume none;
if( pPlayer->m_state == STATE_UNINITIALIZED )
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
pPlayer->m_state = STATE_CONNECTED; pPlayer->m_state = STATE_CONNECTED;
// Allocate a CBasePlayer for pev, and call spawn // Allocate a CBasePlayer for pev, and call spawn
pPlayer->Spawn(); pPlayer->Spawn();
pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer );
// Reset interpolation during first frame // Reset interpolation during first frame
pPlayer->pev->effects |= EF_NOINTERP; pPlayer->pev->effects |= EF_NOINTERP;
pPlayer->pev->iuser1 = 0; pPlayer->pev->iuser1 = 0;
pPlayer->pev->iuser2 = 0; pPlayer->pev->iuser2 = 0;
g_engfuncs.pfnQueryClientCvarValue2( pEntity, "touch_enable", 111 );
} }
@ -672,10 +695,10 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
// reset all players state // reset all players state
if( plr ) if( plr )
{ {
plr->m_state = STATE_CONNECTED; plr->m_state = STATE_UNINITIALIZED;
plr->RemoveAllItems( TRUE ); plr->RemoveAllItems( TRUE );
BecomeSpectator( plr ); BecomeSpectator( plr );
plr->pev->nextthink = gpGlobals->time + 1; plr->Spawn();
} }
} }
} }

20
dlls/multiplay_gamerules.cpp

@ -578,6 +578,8 @@ BOOL CHalfLifeMultiplay::ClientConnected( edict_t *pEntity, const char *pszName,
extern int gmsgSayText; extern int gmsgSayText;
extern int gmsgGameMode; extern int gmsgGameMode;
void ClientPutInServer( edict_t *client );
void CHalfLifeMultiplay::UpdateGameMode( CBasePlayer *pPlayer ) void CHalfLifeMultiplay::UpdateGameMode( CBasePlayer *pPlayer )
{ {
MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() ); MESSAGE_BEGIN( MSG_ONE, gmsgGameMode, NULL, pPlayer->edict() );
@ -647,6 +649,9 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl )
MESSAGE_END(); MESSAGE_END();
} }
if( pl->m_state <= STATE_CONNECTED )
ClientPutInServer( pl->edict() );
if( pl->m_state == STATE_SPECTATOR_BEGIN ) if( pl->m_state == STATE_SPECTATOR_BEGIN )
{ {
@ -734,6 +739,15 @@ void CHalfLifeMultiplay::PlayerThink( CBasePlayer *pPlayer )
if( !mp_coop.value && pPlayer->m_state == STATE_SPECTATOR_BEGIN ) if( !mp_coop.value && pPlayer->m_state == STATE_SPECTATOR_BEGIN )
if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) ) if( pPlayer->m_afButtonPressed & ( IN_DUCK | IN_ATTACK | IN_ATTACK2 | IN_USE | IN_JUMP ) )
SpawnPlayer( pPlayer ); SpawnPlayer( pPlayer );
if( pPlayer->m_state == STATE_UNINITIALIZED )
if( pPlayer->m_afButtonPressed )
{
//ClientPutInServer( pPlayer->edict() );
// clean prediction lags after changelevel
CLIENT_COMMAND( pPlayer->edict(), "reconnect\n" );
pPlayer->m_afButtonPressed = 0;
return;
}
if( g_fGameOver ) if( g_fGameOver )
{ {
@ -755,6 +769,12 @@ void CHalfLifeMultiplay::PlayerSpawn( CBasePlayer *pPlayer )
BOOL addDefault; BOOL addDefault;
CBaseEntity *pWeaponEntity = NULL; CBaseEntity *pWeaponEntity = NULL;
if( pPlayer->m_state == STATE_UNINITIALIZED )
{
ClientPutInServer( pPlayer->edict() );
return;
}
if( pPlayer->m_state == STATE_CONNECTED ) if( pPlayer->m_state == STATE_CONNECTED )
{ {
pPlayer->m_state = STATE_SPECTATOR_BEGIN; pPlayer->m_state = STATE_SPECTATOR_BEGIN;

3
dlls/player.h

@ -85,7 +85,8 @@ enum sbar_data
enum PlayerState enum PlayerState
{ {
STATE_CONNECTED = 0, STATE_UNINITIALIZED = 0,
STATE_CONNECTED,
STATE_SPECTATOR_BEGIN, STATE_SPECTATOR_BEGIN,
STATE_SPAWNED, STATE_SPAWNED,
STATE_SPECTATOR, STATE_SPECTATOR,

13
dlls/triggers.cpp

@ -2007,7 +2007,7 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
}*/ }*/
// Create an entity to fire the changetarget // Create an entity to fire the changetarget
if( m_changeTarget ) if( m_changeTarget && pPlayer )
{ {
CFireAndDie *pFireAndDie = GetClassPtr( (CFireAndDie *)NULL ); CFireAndDie *pFireAndDie = GetClassPtr( (CFireAndDie *)NULL );
if( pFireAndDie ) if( pFireAndDie )
@ -2045,7 +2045,9 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
//ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) ); //ALERT( at_console, "Level touches %d levels\n", ChangeList( levels, 16 ) );
ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot ); ALERT( at_console, "CHANGE LEVEL: %s %s\n", st_szNextMap, st_szNextSpot );
// loop through all clients, count number of players g_iMenu = 0;
g_GlobalMenu.m_iConfirm = 0;
// loop through all clients, reset state
for( int i = 1; i <= gpGlobals->maxClients; i++ ) for( int i = 1; i <= gpGlobals->maxClients; i++ )
{ {
CBasePlayer *plr = (CBasePlayer*)UTIL_PlayerByIndex( i ); CBasePlayer *plr = (CBasePlayer*)UTIL_PlayerByIndex( i );
@ -2058,10 +2060,13 @@ void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator )
BecomeSpectator( plr ); BecomeSpectator( plr );
plr->SetThink( &CBasePlayer::Spawn ); plr->SetThink( &CBasePlayer::Spawn );
plr->pev->nextthink = gpGlobals->time + 1; plr->pev->nextthink = gpGlobals->time + 1;
//CLIENT_COMMAND( plr->edict(), "connect the-swank.pp.ua:27017\n" );
//MESSAGE_BEGIN( MSG_ONE, 2, NULL, plr->pev ); // svc_disconnect after stufftext
//MESSAGE_END();
//SERVER_COMMAND( UTIL_VarArgs( "kick %d\n", i-1 ) );
//SERVER_EXECUTE();
} }
} }
g_iMenu = 0;
g_GlobalMenu.m_iConfirm = 0;
CHANGE_LEVEL( st_szNextMap, st_szNextSpot ); CHANGE_LEVEL( st_szNextMap, st_szNextSpot );
} }

Loading…
Cancel
Save