Browse Source

Add null pointer checks, fix mp_spectator feature

hlzbot-dirty
mittorn 8 years ago
parent
commit
3b7ddbfd63
  1. 16
      dlls/client.cpp

16
dlls/client.cpp

@ -140,9 +140,10 @@ void ClientDisconnect( edict_t *pEntity )
if( mp_coop.value ) if( mp_coop.value )
{ {
CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity ); CBasePlayer *pPlayer = (CBasePlayer*)CBaseEntity::Instance( pEntity );
if( pPlayer ) if( pPlayer && !pPlayer->IsBot() )
pPlayer->m_state = STATE_UNINITIALIZED; pPlayer->m_state = STATE_UNINITIALIZED;
} }
if( TheBots )
TheBots->ClientDisconnect((CBasePlayer*)CBaseEntity::Instance( pEntity )); TheBots->ClientDisconnect((CBasePlayer*)CBaseEntity::Instance( pEntity ));
@ -229,10 +230,13 @@ void ClientPutInServer( edict_t *pEntity )
// AGHL-like spectator // AGHL-like spectator
if( mp_spectator.value ) if( mp_spectator.value )
{
if( !pPlayer->IsBot() )
{ {
pPlayer->RemoveAllItems( TRUE ); pPlayer->RemoveAllItems( TRUE );
BecomeSpectator( pPlayer ); BecomeSpectator( pPlayer );
} }
}
// Reset interpolation during first frame // Reset interpolation during first frame
pPlayer->pev->effects |= EF_NOINTERP; pPlayer->pev->effects |= EF_NOINTERP;
@ -429,9 +433,6 @@ void ClientCommand( edict_t *pEntity )
entvars_t *pev = &pEntity->v; entvars_t *pev = &pEntity->v;
if (TheBots->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd))
return;
if ( FStrEq(pcmd, "say" ) ) if ( FStrEq(pcmd, "say" ) )
{ {
Host_Say( pEntity, 0 ); Host_Say( pEntity, 0 );
@ -571,6 +572,10 @@ void ClientCommand( edict_t *pEntity )
// tell the user they entered an unknown command // tell the user they entered an unknown command
char command[128]; char command[128];
if ( TheBots && TheBots->ClientCommand(GetClassPtr((CBasePlayer *)pev), pcmd) )
return;
// check the length of the command (prevents crash) // check the length of the command (prevents crash)
// max total length is 192 ...and we're adding a string below ("Unknown command: %s\n") // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n")
strncpy( command, pcmd, 127 ); strncpy( command, pcmd, 127 );
@ -664,6 +669,7 @@ void ServerDeactivate( void )
// Peform any shutdown operations here... // Peform any shutdown operations here...
// //
if( TheBots )
TheBots->ServerDeactivate(); TheBots->ServerDeactivate();
} }
@ -722,6 +728,7 @@ void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax )
} }
} }
} }
if( TheBots )
TheBots->ServerActivate(); TheBots->ServerActivate();
} }
@ -820,6 +827,7 @@ void StartFrame( void )
gpGlobals->teamplay = teamplay.value; gpGlobals->teamplay = teamplay.value;
g_ulFrameCount++; g_ulFrameCount++;
if( TheBots )
TheBots->StartFrame(); TheBots->StartFrame();
} }

Loading…
Cancel
Save