Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/game/server/NextBot/NextBotVisionInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,22 @@ bool IVision::IsLineOfSightClear( const Vector &pos ) const
bool IVision::IsLineOfSightClearToEntity( const CBaseEntity *subject, Vector *visibleSpot ) const
{
#ifdef NEO
// Special case for Support-class bots to see through smoke
bool isSupport = false;
bool canSeeThroughSmoke = false;
if (auto player = ToNEOPlayer(GetBot()->GetEntity()))
{
isSupport = (player->GetClass() == NEO_CLASS_SUPPORT);
// Bot has thermal vision as a Support class
canSeeThroughSmoke = (player->GetClass() == NEO_CLASS_SUPPORT);
}
ScopedSmokeLOS smokeGuard(isSupport);
if (!canSeeThroughSmoke)
{
const auto *pSubjectPlayer = ToNEOPlayer(subject);
if (pSubjectPlayer && pSubjectPlayer->IsCarryingGhost())
{
// Ghoster is always visible through smoke
canSeeThroughSmoke = true;
}
}
ScopedSmokeLOS smokeGuard(canSeeThroughSmoke);
#endif

#ifdef TERROR
Expand Down
9 changes: 9 additions & 0 deletions src/game/server/neo/neo_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,13 @@ inline CNEO_Player *ToNEOPlayer(CBaseEntity *pEntity)
return assert_cast<CNEO_Player*>(pEntity);
}

inline const CNEO_Player *ToNEOPlayer(const CBaseEntity *pEntity)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have ToNEOPlayer in c_neo_player.h, maybe keep the declaration here and move both definitions to neo_player_shared.cpp?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I looked into this, and I'm not exactly sure what you mean by the relation with c_neo_player.h

I just needed the const for const CNEO_Player *, so that I can get a const pointer for my use case here.

I also wasn't sure how moving both definitions to neo_player_shared.cpp actually made things clearer, because with how I understand this, it would involve defining branches around #ifdef CLIENT_DLL, which I'm not sure is actually more readable, e.g.:

In neo_player_shared.h:

#ifdef CLIENT_DLL
class C_BaseEntity;
class C_NEO_Player;
C_NEO_Player *ToNEOPlayer(C_BaseEntity *pEntity);
#else
class CBaseEntity;
class CNEO_Player;
CNEO_Player *ToNEOPlayer(CBaseEntity *pEntity);
const CNEO_Player *ToNEOPlayer(const CBaseEntity *pEntity);
#endif

and in neo_player_shared.cpp:

#ifdef CLIENT_DLL
C_NEO_Player *ToNEOPlayer(C_BaseEntity *pEntity)
{
	if (!pEntity || !pEntity->IsPlayer())
	{
		return nullptr;
	}
#if _DEBUG
	Assert(dynamic_cast<C_NEO_Player*>(pEntity));
#endif
	return static_cast<C_NEO_Player*>(pEntity);
}
#else
CNEO_Player *ToNEOPlayer(CBaseEntity *pEntity)
{
	if (!pEntity || !pEntity->IsPlayer())
	{
		return nullptr;
	}
	return assert_cast<CNEO_Player*>(pEntity);
}

const CNEO_Player *ToNEOPlayer(const CBaseEntity *pEntity)
{
	if (!pEntity || !pEntity->IsPlayer())
	{
		return nullptr;
	}
	return assert_cast<const CNEO_Player*>(pEntity);
}
#endif

... if it's okay, maybe we can go with the original PR approach?

{
if (!pEntity || !pEntity->IsPlayer())
{
return nullptr;
}
return assert_cast<const CNEO_Player*>(pEntity);
}

#endif // NEO_PLAYER_H