Crash Fixes

This commit is contained in:
Stephen 2023-03-21 18:50:23 -04:00
parent 038da8c96f
commit 5fe65853fc
3 changed files with 15 additions and 10 deletions

View File

@ -52,7 +52,8 @@ bool shouldTarget(CachedEntity *entity)
// Don't shoot players in truce // Don't shoot players in truce
if (isTruce()) if (isTruce())
return false; return false;
return shouldTargetSteamId(entity->player_info->friendsID); if (entity->player_info)
return shouldTargetSteamId(entity->player_info->friendsID);
} }
else if (entity->m_Type() == ENTITY_BUILDING) else if (entity->m_Type() == ENTITY_BUILDING)
// Don't shoot buildings in truce // Don't shoot buildings in truce
@ -75,7 +76,8 @@ bool shouldAlwaysRenderEsp(CachedEntity *entity)
{ {
if (entity->m_Type() == ENTITY_PLAYER) if (entity->m_Type() == ENTITY_PLAYER)
{ {
return shouldAlwaysRenderEspSteamId(entity->player_info->friendsID); if (entity->player_info)
return shouldAlwaysRenderEspSteamId(entity->player_info->friendsID);
} }
return false; return false;
@ -150,7 +152,8 @@ static CatCommand mark_betrayal("pl_mark_betrayal", "Mark a steamid32 as betraya
void onKilledBy(CachedEntity *entity) void onKilledBy(CachedEntity *entity)
{ {
onKilledBy(entity->player_info->friendsID); if (entity->player_info)
onKilledBy(entity->player_info->friendsID);
} }
class PlayerToolsEventListener : public IGameEventListener2 class PlayerToolsEventListener : public IGameEventListener2

View File

@ -364,8 +364,9 @@ static void cm()
if (!isValidTarget(entity)) if (!isValidTarget(entity))
continue; continue;
// No enemy check, since steamid is very specific // No enemy check, since steamid is very specific
if (steamid != entity->player_info->friendsID) // steamid check if (entity->player_info)
continue; if (steamid != entity->player_info->friendsID) // steamid check
continue;
if (startFollow(entity, isNavBotCM)) if (startFollow(entity, isNavBotCM))
{ {
navinactivity.update(); navinactivity.update();
@ -399,8 +400,9 @@ static void cm()
continue; continue;
if (entity->m_bEnemy()) if (entity->m_bEnemy())
continue; continue;
if (accountid != entity->player_info->friendsID) if (entity->player_info)
continue; if (accountid != entity->player_info->friendsID)
continue;
if (startFollow(entity, isNavBotCM)) if (startFollow(entity, isNavBotCM))
{ {
navinactivity.update(); navinactivity.update();

View File

@ -160,7 +160,7 @@ bool IsDefault(unsigned steamid)
bool IsDefault(CachedEntity *entity) bool IsDefault(CachedEntity *entity)
{ {
if (entity && entity->player_info->friendsID) if (entity && entity->player_info && entity->player_info->friendsID)
return IsDefault(entity->player_info->friendsID); return IsDefault(entity->player_info->friendsID);
return true; return true;
} }
@ -173,7 +173,7 @@ bool IsFriend(unsigned steamid)
bool IsFriend(CachedEntity *entity) bool IsFriend(CachedEntity *entity)
{ {
if (entity && entity->player_info->friendsID) if (entity && entity->player_info && entity->player_info->friendsID)
return IsFriend(entity->player_info->friendsID); return IsFriend(entity->player_info->friendsID);
return false; return false;
} }
@ -238,7 +238,7 @@ bool ChangeState(unsigned int steamid, k_EState state, bool force)
bool ChangeState(CachedEntity *entity, k_EState state, bool force) bool ChangeState(CachedEntity *entity, k_EState state, bool force)
{ {
if (entity && entity->player_info->friendsID) if (entity && entity->player_info && entity->player_info->friendsID)
return ChangeState(entity->player_info->friendsID, state, force); return ChangeState(entity->player_info->friendsID, state, force);
return false; return false;
} }