Skip to content

Commit

Permalink
Add NULL checks to all DA-specific and SDK commands
Browse files Browse the repository at this point in the history
  • Loading branch information
TomyLobo committed Sep 19, 2018
1 parent b96c111 commit c33eb24
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
20 changes: 18 additions & 2 deletions mp/src/game/server/ai_concommands.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ ConVar npc_create_equipment("npc_create_equipment", "");
//------------------------------------------------------------------------------
void CC_NPC_Create( const CCommand &args )
{
CBasePlayer* pPlayer = UTIL_GetCommandClient();

if (!pPlayer)
return;

MDLCACHE_CRITICAL_SECTION();

bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
Expand All @@ -414,7 +419,6 @@ void CC_NPC_Create( const CCommand &args )

DispatchSpawn(baseNPC);
// Now attempt to drop into the world
CBasePlayer* pPlayer = UTIL_GetCommandClient();
trace_t tr;
Vector forward;
pPlayer->EyeVectors( &forward );
Expand Down Expand Up @@ -462,6 +466,11 @@ static ConCommand npc_create("npc_create", CC_NPC_Create, "Creates an NPC of the
//------------------------------------------------------------------------------
void CC_NPC_Create_Aimed( const CCommand &args )
{
CBasePlayer* pPlayer = UTIL_GetCommandClient();

if (!pPlayer)
return;

MDLCACHE_CRITICAL_SECTION();

bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
Expand All @@ -477,7 +486,6 @@ void CC_NPC_Create_Aimed( const CCommand &args )

// Now attempt to drop into the world
QAngle angles;
CBasePlayer* pPlayer = UTIL_GetCommandClient();
trace_t tr;
Vector forward;
pPlayer->EyeVectors( &forward );
Expand Down Expand Up @@ -632,6 +640,10 @@ CON_COMMAND(npc_thinknow, "Trigger NPC to think")
void CC_NPC_Teleport( void )
{
CBasePlayer* pPlayer = UTIL_GetCommandClient();

if (!pPlayer)
return;

trace_t tr;
Vector forward;
pPlayer->EyeVectors( &forward );
Expand Down Expand Up @@ -664,6 +676,10 @@ static ConVar npc_go_do_run( "npc_go_do_run", "1", 0, "Set whether should run on
void CC_NPC_Go( void )
{
CBasePlayer* pPlayer = UTIL_GetCommandClient();

if (!pPlayer)
return;

trace_t tr;
Vector forward;
pPlayer->EyeVectors( &forward );
Expand Down
3 changes: 3 additions & 0 deletions mp/src/game/server/player.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5811,6 +5811,9 @@ CBaseEntity *FindPickerEntity( CBasePlayer *pPlayer )
//-----------------------------------------------------------------------------
CAI_Node *FindPickerAINode( CBasePlayer *pPlayer, NodeType_e nNodeType )
{
if (!pPlayer)
return NULL;

Vector forward;
Vector origin;

Expand Down
3 changes: 3 additions & 0 deletions mp/src/game/server/sdk/bots/sdk_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ CON_COMMAND_F( bot_teleport, "Teleports the first bot to the player.", FCVAR_CHE
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

if (!pPlayer)
return;

Vector vecEye = pPlayer->GetAbsOrigin() + pPlayer->GetViewOffset();

Vector vecForward;
Expand Down
7 changes: 7 additions & 0 deletions mp/src/game/server/sdk/sdk_player.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4891,6 +4891,10 @@ CON_COMMAND( vr, "Turn VR mode on/off" )
return;

CSDKPlayer *pPlayer = ToSDKPlayer( UTIL_GetCommandClient() );

if (!pPlayer)
return;

pPlayer->m_bUsingVR = V_strcmp(args[1], "on") == 0;
}

Expand All @@ -4901,6 +4905,9 @@ CON_COMMAND( platform, "Indicate client platform" )

CSDKPlayer *pPlayer = ToSDKPlayer( UTIL_GetCommandClient() );

if (!pPlayer)
return;

pPlayer->m_iPlatform = 0;

if (V_strcmp(args[1], "windows") == 0)
Expand Down

0 comments on commit c33eb24

Please sign in to comment.