Skip to content

Commit

Permalink
Add Support For EP2 (Orange Box) Engine
Browse files Browse the repository at this point in the history
  • Loading branch information
caxanga334 committed Nov 9, 2023
1 parent be5f90f commit 0e6bae7
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/SDKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Any SDK version not listed is considered **Not Implemented**.
| SDK Version | Status |
|:-----------:|:------:|
|Episode 1|Not Implemented|
|Orange Box|Not Implemented|
|Orange Box|Compiles|
|Half-Life 2: Deathmatch|Compiles|
|Day of Defeat: Source|Compiles|
|Counter-Strike: Source|Compiles|
Expand Down
6 changes: 6 additions & 0 deletions extension/navmesh/nav_area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5743,7 +5743,13 @@ void CNavArea::ComputeVisibilityToMesh( void )
// nav mesh editing is limited to windows only

#ifdef WIN32

#if SOURCE_ENGINE != SE_ORANGEBOX
ParallelProcess("CNavArea::ComputeVisibilityToMesh", collector.m_area.Base(), collector.m_area.Count(), &ComputeVisToArea);
#else
ParallelProcess(collector.m_area.Base(), collector.m_area.Count(), &ComputeVisToArea);
#endif // SOURCE_ENGINE != SE_ORANGEBOX

#elif _LINUX
// Warn on linux until replaced with std::thread
Warning("Nav Mesh Fatal: Nav Mesh should only be edited/generated on a Windows Listen Server! \n");
Expand Down
15 changes: 15 additions & 0 deletions extension/navmesh/nav_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,9 @@ CNavArea *CNavMesh::GetNavArea( edict_t *pEntity, int nFlags, float flBeneathLim

#if SOURCE_ENGINE == SE_SDK2013
bool isPlayer = pEntity->m_EdictIndex > 0 && pEntity->m_EdictIndex <= gpGlobals->maxClients;
#elif SOURCE_ENGINE == SE_ORANGEBOX
int index = engine->IndexOfEdict(pEntity);
bool isPlayer = index > 0 && index <= gpGlobals->maxClients;
#else
bool isPlayer = pEntity->m_iIndex > 0 && pEntity->m_iIndex <= gpGlobals->maxClients;
#endif
Expand Down Expand Up @@ -1064,6 +1067,18 @@ CNavArea *CNavMesh::GetNearestNavArea( edict_t *pEntity, int nFlags, float maxDi
pEntity->m_EdictIndex > 0 && pEntity->m_EdictIndex <= gpGlobals->maxClients
? playerinfomanager->GetPlayerInfo(pEntity)->GetTeamIndex() : TEAM_ANY);

#elif SOURCE_ENGINE == SE_ORANGEBOX

int index = engine->IndexOfEdict(pEntity);

return pClose ? pClose
: GetNearestNavArea(pEntity->GetCollideable()->GetCollisionOrigin(),
maxDist,
(nFlags & GETNAVAREA_CHECK_LOS) != 0,
(nFlags & GETNAVAREA_CHECK_GROUND) != 0,
index > 0 && index <= gpGlobals->maxClients
? playerinfomanager->GetPlayerInfo(pEntity)->GetTeamIndex() : TEAM_ANY);

#else

return pClose ? pClose
Expand Down
3 changes: 2 additions & 1 deletion extension/navmesh/nav_pathfind.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include "nav_area.h"
#include "vstdlib/random.h"

#if defined(_LINUX) && (SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM)
#if defined(_LINUX) && (SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || \
SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_ORANGEBOX)

template< class T >
T Max(T const& val1, T const& val2)
Expand Down
2 changes: 2 additions & 0 deletions extension/util/UtilTrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ bool CTraceFilterNoNPCsOrPlayer::ShouldHitEntity(IHandleEntity *pHandleEntity,
#if SOURCE_ENGINE == SE_SDK2013
return pEntity->m_EdictIndex > 0
&& engine->IndexOfEdict(pEntity) > gpGlobals->maxClients; //TODO && !player->IsNPC()
#elif SOURCE_ENGINE == SE_ORANGEBOX
return engine->IndexOfEdict(pEntity) > gpGlobals->maxClients; // Orange box doesn't have CBaseEdict::m_EdictIndex
#else
return pEntity->m_iIndex > 0
&& engine->IndexOfEdict(pEntity) > gpGlobals->maxClients; //TODO && !player->IsNPC()
Expand Down

0 comments on commit 0e6bae7

Please sign in to comment.