mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2024-12-23 01:59:43 +08:00
Implement CEntityHandle & CEntitySystem (#134)
Add CConcreteEntityList, CEntityComponent, CScriptComponent, CGameEntitySystem, rewrite IHandleEntity to use CEntityHandle instead of CBaseHandle, update NUM_SERIAL_NUM_BITS, comment out old CBaseEntity, obsolete basehandle.h
This commit is contained in:
parent
0ac0302c8e
commit
7931af02fa
40
entity2/entitysystem.cpp
Normal file
40
entity2/entitysystem.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "const.h"
|
||||
#include "entity2/entitysystem.h"
|
||||
|
||||
CBaseEntity* CEntitySystem::GetBaseEntity(CEntityIndex entnum)
|
||||
{
|
||||
if (entnum.Get() <= -1 || entnum.Get() >= (MAX_TOTAL_ENTITIES - 1))
|
||||
return nullptr;
|
||||
|
||||
CEntityIdentity* pChunkToUse = m_EntityList.m_pIdentityChunks[entnum.Get() / MAX_ENTITIES_IN_LIST];
|
||||
if (!pChunkToUse)
|
||||
return nullptr;
|
||||
|
||||
CEntityIdentity* pIdentity = &pChunkToUse[entnum.Get() % MAX_ENTITIES_IN_LIST];
|
||||
if (!pIdentity)
|
||||
return nullptr;
|
||||
|
||||
if (pIdentity->m_EHandle.GetEntryIndex() != entnum.Get())
|
||||
return nullptr;
|
||||
|
||||
return dynamic_cast<CBaseEntity*>(pIdentity->m_pInstance);
|
||||
}
|
||||
|
||||
CBaseEntity* CEntitySystem::GetBaseEntity(const CEntityHandle& hEnt)
|
||||
{
|
||||
if (!hEnt.IsValid())
|
||||
return nullptr;
|
||||
|
||||
CEntityIdentity* pChunkToUse = m_EntityList.m_pIdentityChunks[hEnt.GetEntryIndex() / MAX_ENTITIES_IN_LIST];
|
||||
if (!pChunkToUse)
|
||||
return nullptr;
|
||||
|
||||
CEntityIdentity* pIdentity = &pChunkToUse[hEnt.GetEntryIndex() % MAX_ENTITIES_IN_LIST];
|
||||
if (!pIdentity)
|
||||
return nullptr;
|
||||
|
||||
if (pIdentity->m_EHandle != hEnt)
|
||||
return nullptr;
|
||||
|
||||
return dynamic_cast<CBaseEntity*>(pIdentity->m_pInstance);
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
//====== Copyright © 1996-2004, Valve Corporation, All rights reserved. =======
|
||||
//====== Copyright <EFBFBD> 1996-2004, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose: Force feeback OS level handlers
|
||||
//
|
||||
//=============================================================================
|
||||
#include <windows.h>
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "UtlVector.h"
|
||||
#include "usercmd.h"
|
||||
#include "cdll_client_int.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include "cbase.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "utlvector.h"
|
||||
#include "cdll_client_int.h"
|
||||
#include "cdll_util.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "hud.h"
|
||||
#include "cdll_int.h"
|
||||
#include "kbutton.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "usercmd.h"
|
||||
#include "input.h"
|
||||
#include "iviewrender.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: TrackIR handling function
|
||||
//
|
||||
@ -21,7 +21,7 @@
|
||||
#include "vphysics_interface.h"
|
||||
#include <icvar.h>
|
||||
#include <baseentity_shared.h>
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "ehandle.h"
|
||||
#include "utlvector.h"
|
||||
#include "cdll_client_int.h"
|
||||
|
@ -11,6 +11,12 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "entityidentity.h"
|
||||
class CBaseEntity : public CEntityInstance
|
||||
{
|
||||
};
|
||||
|
||||
#if 0
|
||||
#define TEAMNUM_NUM_BITS 6
|
||||
|
||||
#include <ctype.h>
|
||||
@ -2906,4 +2912,6 @@ FORCEINLINE bool EntityNamesMatch( const char *pszQuery, string_t nameToMatch )
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // BASEENTITY_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -11,36 +11,24 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#if defined( _DEBUG ) && defined( GAME_DLL )
|
||||
#include "tier0/dbg.h"
|
||||
#include "cbase.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "entitylist_base.h"
|
||||
|
||||
|
||||
class IHandleEntity;
|
||||
|
||||
#include "entityhandle.h"
|
||||
#include "entity2/entitysystem.h"
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// Game-code CBaseHandle implementation.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
inline IHandleEntity* CBaseHandle::Get() const
|
||||
inline IHandleEntity* CEntityHandle::Get() const
|
||||
{
|
||||
extern CBaseEntityList *g_pEntityList;
|
||||
return g_pEntityList->LookupEntity( *this );
|
||||
extern CEntitySystem *g_pEntitySystem;
|
||||
return g_pEntitySystem->GetBaseEntity( *this );
|
||||
}
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// CHandle.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
template< class T >
|
||||
class CHandle : public CBaseHandle
|
||||
class CHandle : public CEntityHandle
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "tier1/utllinkedlist.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include "convar.h"
|
||||
#include "ispsharedmemory.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "isaverestore.h"
|
||||
|
||||
|
||||
|
@ -1,206 +0,0 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef BASEHANDLE_H
|
||||
#define BASEHANDLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include "const.h"
|
||||
#include "tier0/dbg.h"
|
||||
|
||||
|
||||
class IHandleEntity;
|
||||
|
||||
// Represents EHANDLE2 class
|
||||
// TODO: GAMMACASE: Replace old CBaseHandle with this
|
||||
class CEntityHandle
|
||||
{
|
||||
public:
|
||||
union
|
||||
{
|
||||
uint32 m_Index;
|
||||
struct
|
||||
{
|
||||
uint32 m_EntityIndex : 15;
|
||||
uint32 m_Serial : 17;
|
||||
} m_Parts;
|
||||
};
|
||||
};
|
||||
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
// CBaseHandle.
|
||||
// -------------------------------------------------------------------------------------------------- //
|
||||
|
||||
class CBaseHandle
|
||||
{
|
||||
friend class CBaseEntityList;
|
||||
|
||||
public:
|
||||
|
||||
CBaseHandle();
|
||||
CBaseHandle( const CBaseHandle &other );
|
||||
CBaseHandle( unsigned long value );
|
||||
CBaseHandle( int iEntry, int iSerialNumber );
|
||||
|
||||
void Init( int iEntry, int iSerialNumber );
|
||||
void Term();
|
||||
|
||||
// Even if this returns true, Get() still can return return a non-null value.
|
||||
// This just tells if the handle has been initted with any values.
|
||||
bool IsValid() const;
|
||||
|
||||
int GetEntryIndex() const;
|
||||
int GetSerialNumber() const;
|
||||
|
||||
int ToInt() const;
|
||||
bool operator !=( const CBaseHandle &other ) const;
|
||||
bool operator ==( const CBaseHandle &other ) const;
|
||||
bool operator ==( const IHandleEntity* pEnt ) const;
|
||||
bool operator !=( const IHandleEntity* pEnt ) const;
|
||||
bool operator <( const CBaseHandle &other ) const;
|
||||
bool operator <( const IHandleEntity* pEnt ) const;
|
||||
|
||||
// Assign a value to the handle.
|
||||
const CBaseHandle& operator=( const IHandleEntity *pEntity );
|
||||
const CBaseHandle& Set( const IHandleEntity *pEntity );
|
||||
|
||||
// Use this to dereference the handle.
|
||||
// Note: this is implemented in game code (ehandle.h)
|
||||
IHandleEntity* Get() const;
|
||||
|
||||
|
||||
protected:
|
||||
// The low NUM_SERIAL_BITS hold the index. If this value is less than MAX_EDICTS, then the entity is networkable.
|
||||
// The high NUM_SERIAL_NUM_BITS bits are the serial number.
|
||||
unsigned long m_Index;
|
||||
};
|
||||
|
||||
|
||||
#include "ihandleentity.h"
|
||||
|
||||
|
||||
inline CBaseHandle::CBaseHandle()
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline CBaseHandle::CBaseHandle( const CBaseHandle &other )
|
||||
{
|
||||
m_Index = other.m_Index;
|
||||
}
|
||||
|
||||
inline CBaseHandle::CBaseHandle( unsigned long value )
|
||||
{
|
||||
m_Index = value;
|
||||
}
|
||||
|
||||
inline CBaseHandle::CBaseHandle( int iEntry, int iSerialNumber )
|
||||
{
|
||||
Init( iEntry, iSerialNumber );
|
||||
}
|
||||
|
||||
inline void CBaseHandle::Init( int iEntry, int iSerialNumber )
|
||||
{
|
||||
Assert( iEntry >= 0 && (iEntry & ENT_ENTRY_MASK) == iEntry);
|
||||
Assert( iSerialNumber >= 0 && iSerialNumber < (1 << NUM_SERIAL_NUM_BITS) );
|
||||
|
||||
m_Index = iEntry | (iSerialNumber << NUM_SERIAL_NUM_SHIFT_BITS);
|
||||
}
|
||||
|
||||
inline void CBaseHandle::Term()
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::IsValid() const
|
||||
{
|
||||
return m_Index != INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline int CBaseHandle::GetEntryIndex() const
|
||||
{
|
||||
// There is a hack here: due to a bug in the original implementation of the
|
||||
// entity handle system, an attempt to look up an invalid entity index in
|
||||
// certain cirumstances might fall through to the the mask operation below.
|
||||
// This would mask an invalid index to be in fact a lookup of entity number
|
||||
// NUM_ENT_ENTRIES, so invalid ent indexes end up actually looking up the
|
||||
// last slot in the entities array. Since this slot is always empty, the
|
||||
// lookup returns NULL and the expected behavior occurs through this unexpected
|
||||
// route.
|
||||
// A lot of code actually depends on this behavior, and the bug was only exposed
|
||||
// after a change to NUM_SERIAL_NUM_BITS increased the number of allowable
|
||||
// static props in the world. So the if-stanza below detects this case and
|
||||
// retains the prior (bug-submarining) behavior.
|
||||
if ( !IsValid() )
|
||||
return NUM_ENT_ENTRIES-1;
|
||||
return m_Index & ENT_ENTRY_MASK;
|
||||
}
|
||||
|
||||
inline int CBaseHandle::GetSerialNumber() const
|
||||
{
|
||||
return m_Index >> NUM_SERIAL_NUM_SHIFT_BITS;
|
||||
}
|
||||
|
||||
inline int CBaseHandle::ToInt() const
|
||||
{
|
||||
return (int)m_Index;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator !=( const CBaseHandle &other ) const
|
||||
{
|
||||
return m_Index != other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator ==( const CBaseHandle &other ) const
|
||||
{
|
||||
return m_Index == other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator ==( const IHandleEntity* pEnt ) const
|
||||
{
|
||||
return Get() == pEnt;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator !=( const IHandleEntity* pEnt ) const
|
||||
{
|
||||
return Get() != pEnt;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator <( const CBaseHandle &other ) const
|
||||
{
|
||||
return m_Index < other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CBaseHandle::operator <( const IHandleEntity *pEntity ) const
|
||||
{
|
||||
unsigned long otherIndex = (pEntity) ? pEntity->GetRefEHandle().m_Index : INVALID_EHANDLE_INDEX;
|
||||
return m_Index < otherIndex;
|
||||
}
|
||||
|
||||
inline const CBaseHandle& CBaseHandle::operator=( const IHandleEntity *pEntity )
|
||||
{
|
||||
return Set( pEntity );
|
||||
}
|
||||
|
||||
inline const CBaseHandle& CBaseHandle::Set( const IHandleEntity *pEntity )
|
||||
{
|
||||
if ( pEntity )
|
||||
{
|
||||
*this = pEntity->GetRefEHandle();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
#endif // BASEHANDLE_H
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -15,7 +15,7 @@
|
||||
|
||||
#include "trace.h"
|
||||
#include "tier0/dbg.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
|
||||
struct edict_t;
|
||||
struct model_t;
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -74,7 +74,7 @@
|
||||
#define NUM_ENT_ENTRIES (1 << NUM_ENT_ENTRY_BITS)
|
||||
#define INVALID_EHANDLE_INDEX 0xFFFFFFFF
|
||||
|
||||
#define NUM_SERIAL_NUM_BITS 16 // (32 - NUM_ENT_ENTRY_BITS)
|
||||
#define NUM_SERIAL_NUM_BITS 17 // (32 - NUM_ENT_ENTRY_BITS)
|
||||
#define NUM_SERIAL_NUM_SHIFT_BITS (32 - NUM_SERIAL_NUM_BITS)
|
||||
#define ENT_ENTRY_MASK (( 1 << NUM_SERIAL_NUM_BITS) - 1)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -12,7 +12,7 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "utlvector.h" //need CUtlVector for IEngineTrace::GetBrushesIn*()
|
||||
#include "mathlib/vector4d.h"
|
||||
#include "bspflags.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//===== Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -14,7 +14,7 @@
|
||||
#include "interface.h"
|
||||
#include "mathlib/vector.h"
|
||||
#include "utlvector.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
27
public/entity2/concreteentitylist.h
Normal file
27
public/entity2/concreteentitylist.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef CONCRETEENTITYLIST_H
|
||||
#define CONCRETEENTITYLIST_H
|
||||
|
||||
#include "entityidentity.h"
|
||||
|
||||
class CConcreteEntityList
|
||||
{
|
||||
struct CList
|
||||
{
|
||||
CEntityIdentity* m_pHead;
|
||||
CEntityIdentity* m_pTail;
|
||||
uint64 unk;
|
||||
};
|
||||
public:
|
||||
CEntityIdentity* m_pIdentityChunks[MAX_ENTITY_LISTS];
|
||||
CEntityIdentity* m_pFirstActiveEntity; // 512
|
||||
CConcreteEntityList::CList m_usedList; // 520
|
||||
CConcreteEntityList::CList m_dormantList; // 544
|
||||
CConcreteEntityList::CList m_freeNetworkableList; // 568
|
||||
CConcreteEntityList::CList m_freeNonNetworkableList; // 592
|
||||
uint32 m_nNetworkableEntityLimit; // 0x268
|
||||
uint32 m_nNonNetworkableEntityLimit; // 0x26c
|
||||
uint32 m_nMaxPlayers;
|
||||
CBitVec<16384> m_PVSBits;
|
||||
};
|
||||
|
||||
#endif // CONCRETEENTITYLIST_H
|
26
public/entity2/entitycomponent.h
Normal file
26
public/entity2/entitycomponent.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef ENTITYCOMPONENT_H
|
||||
#define ENTITYCOMPONENT_H
|
||||
|
||||
#if _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
#include <tier0/platform.h>
|
||||
#include "tier1/utlsymbollarge.h"
|
||||
|
||||
class CEntityComponent
|
||||
{
|
||||
private:
|
||||
uint8 unknown[0x8]; // 0x0
|
||||
};
|
||||
|
||||
class CScriptComponent : public CEntityComponent
|
||||
{
|
||||
private:
|
||||
uint8 unknown[0x28]; // 0x8
|
||||
public:
|
||||
CUtlSymbolLarge m_scriptClassName; // 0x30
|
||||
};
|
||||
|
||||
#endif // ENTITYCOMPONENT_H
|
@ -5,11 +5,72 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#define MAX_ENTITIES_IN_LIST 512
|
||||
#define MAX_ENTITY_LISTS 64 // 0x3F
|
||||
#define MAX_TOTAL_ENTITIES MAX_ENTITIES_IN_LIST * MAX_ENTITY_LISTS // 0x8000
|
||||
|
||||
#include "eiface.h"
|
||||
#include "entitycomponent.h"
|
||||
#include "entityhandle.h"
|
||||
|
||||
class CEntityIdentity;
|
||||
|
||||
struct ChangeAccessorFieldPathIndex_t
|
||||
{
|
||||
int16 m_Value;
|
||||
};
|
||||
|
||||
typedef CUtlStringToken WorldGroupId_t;
|
||||
|
||||
class CEntityInstance : public IHandleEntity
|
||||
{
|
||||
public:
|
||||
// MNetworkDisable
|
||||
CUtlSymbolLarge m_iszPrivateVScripts; // 0x8
|
||||
// MNetworkEnable
|
||||
// MNetworkPriority "56"
|
||||
CEntityIdentity* m_pEntity; // 0x10
|
||||
private:
|
||||
void* m_hPrivateScope; // 0x18 - CEntityPrivateScriptScope
|
||||
uint8 unknown[0x8]; // 0x20
|
||||
public:
|
||||
// MNetworkEnable
|
||||
// MNetworkDisable
|
||||
CScriptComponent* m_CScriptComponent; // 0x28
|
||||
};
|
||||
|
||||
|
||||
// Size: 0x78
|
||||
class CEntityIdentity
|
||||
{
|
||||
public:
|
||||
|
||||
CEntityInstance* m_pInstance; // 0x0
|
||||
private:
|
||||
void* m_pClass; // 0x8 - CEntityClass
|
||||
public:
|
||||
CEntityHandle m_EHandle; // 0x10
|
||||
int32 m_nameStringableIndex; // 0x14
|
||||
CUtlSymbolLarge m_name; // 0x18
|
||||
CUtlSymbolLarge m_designerName; // 0x20
|
||||
private:
|
||||
uint64 m_hPublicScope; // 0x28 - CEntityPublicScriptScope
|
||||
public:
|
||||
uint32 m_flags; // 0x30
|
||||
private:
|
||||
SpawnGroupHandle_t m_hSpawnGroup; // 0x34
|
||||
public:
|
||||
WorldGroupId_t m_worldGroupId; // 0x38
|
||||
uint32 m_fDataObjectTypes; // 0x3c
|
||||
ChangeAccessorFieldPathIndex_t m_PathIndex; // 0x40
|
||||
private:
|
||||
uint16 m_Padding; // 0x42
|
||||
void* m_pAttributes; // 0x48 - CUtlObjectAttributeTable<CEntityIdentity, CUtlStringToken>
|
||||
void* m_pRenderAttrs; // 0x50 - CRenderAttributesDoubleBuffered
|
||||
public:
|
||||
CEntityIdentity* m_pPrev; // 0x58
|
||||
CEntityIdentity* m_pNext; // 0x60
|
||||
CEntityIdentity* m_pPrevByClass; // 0x68
|
||||
CEntityIdentity* m_pNextByClass; // 0x70
|
||||
};
|
||||
|
||||
#endif // ENTITYIDENTITY_H
|
181
public/entity2/entitysystem.h
Normal file
181
public/entity2/entitysystem.h
Normal file
@ -0,0 +1,181 @@
|
||||
#ifndef ENTITYSYSTEM_H
|
||||
#define ENTITYSYSTEM_H
|
||||
|
||||
#include "tier0/platform.h"
|
||||
#include "tier1/utlmemory.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "tier1/utldict.h"
|
||||
#include "entityhandle.h"
|
||||
#include "baseentity.h"
|
||||
#include "eiface.h"
|
||||
#include "concreteentitylist.h"
|
||||
#include "entitydatainstantiator.h"
|
||||
|
||||
class CEntityKeyValues;
|
||||
class IEntityResourceManifest;
|
||||
class IEntityPrecacheConfiguration;
|
||||
class IEntityResourceManifestBuilder;
|
||||
class ISpawnGroupEntityFilter;
|
||||
|
||||
typedef void (*EntityResourceManifestCreationCallback_t)(struct IEntityResourceManifest*, void*);
|
||||
|
||||
enum SpawnGroupEntityFilterType_t
|
||||
{
|
||||
SPAWN_GROUP_ENTITY_FILTER_FALLBACK = 0x0,
|
||||
SPAWN_GROUP_ENTITY_FILTER_MOD_SPECIFIC = 0x1,
|
||||
};
|
||||
|
||||
enum ClearEntityDatabaseMode_t
|
||||
{
|
||||
CED_NORMAL = 0x0,
|
||||
CED_NETWORKEDONLY_AND_DONTCLEARSTRINGPOOL = 0x1,
|
||||
};
|
||||
|
||||
enum ActivateType_t
|
||||
{
|
||||
ACTIVATE_TYPE_INITIAL_CREATION = 0x0,
|
||||
ACTIVATE_TYPE_DATAUPDATE_CREATION = 0x1,
|
||||
ACTIVATE_TYPE_ONRESTORE = 0x2,
|
||||
};
|
||||
|
||||
enum DataUpdateType_t
|
||||
{
|
||||
DATA_UPDATE_CREATED = 0x0,
|
||||
DATA_UPDATE_DATATABLE_CHANGED = 0x1,
|
||||
};
|
||||
|
||||
enum EntityDormancyType_t
|
||||
{
|
||||
ENTITY_NOT_DORMANT = 0x0,
|
||||
ENTITY_DORMANT = 0x1,
|
||||
ENTITY_SUSPENDED = 0x2,
|
||||
};
|
||||
|
||||
struct EntityNotification_t
|
||||
{
|
||||
CEntityIdentity* m_pEntity;
|
||||
};
|
||||
|
||||
struct EntityDormancyChange_t : EntityNotification_t
|
||||
{
|
||||
EntityDormancyType_t m_nPrevDormancyType;
|
||||
EntityDormancyType_t m_nNewDormancyType;
|
||||
};
|
||||
|
||||
struct EntitySpawnInfo_t : EntityNotification_t
|
||||
{
|
||||
const CEntityKeyValues* m_pKeyValues;
|
||||
};
|
||||
|
||||
struct EntityActivation_t : EntityNotification_t
|
||||
{
|
||||
};
|
||||
|
||||
struct EntityDeletion_t : EntityNotification_t
|
||||
{
|
||||
};
|
||||
|
||||
struct PostDataUpdateInfo_t : EntityNotification_t
|
||||
{
|
||||
DataUpdateType_t m_updateType;
|
||||
};
|
||||
|
||||
|
||||
struct CEntityPrecacheContext
|
||||
{
|
||||
const CEntityKeyValues* m_pKeyValues;
|
||||
IEntityPrecacheConfiguration* m_pConfig;
|
||||
IEntityResourceManifest* m_pManifest;
|
||||
};
|
||||
|
||||
class IEntityListener
|
||||
{
|
||||
public:
|
||||
virtual void OnEntityCreated(CBaseEntity* pEntity) {};
|
||||
virtual void OnEntitySpawned(CBaseEntity* pEntity) {};
|
||||
virtual void OnEntityDeleted(CBaseEntity* pEntity) {};
|
||||
};
|
||||
|
||||
struct CEntityResourceManifestLock
|
||||
{
|
||||
IEntityResourceManifestBuilder* m_pBuilder;
|
||||
matrix3x4a_t m_vSpawnGroupOffset;
|
||||
SpawnGroupHandle_t m_hSpawnGroup;
|
||||
IEntityPrecacheConfiguration* m_pConfig;
|
||||
IEntityResourceManifest* m_pManifest;
|
||||
bool m_bIsLocked;
|
||||
bool m_bPrecacheEnable;
|
||||
};
|
||||
|
||||
abstract_class IEntityResourceManifestBuilder
|
||||
{
|
||||
public:
|
||||
virtual void BuildResourceManifest(EntityResourceManifestCreationCallback_t callback, void* pContext, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest) = 0;
|
||||
virtual void BuildResourceManifest(const char* pManifestNameOrGroupName, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest) = 0;
|
||||
virtual void BuildResourceManifest(SpawnGroupHandle_t hSpawnGroup, const CUtlVector<const CEntityKeyValues*, CUtlMemory<const CEntityKeyValues*, int> >* pEntityKeyValues, const char* pFilterName, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest) = 0;
|
||||
virtual void BuildResourceManifest(SpawnGroupHandle_t hSpawnGroup, int nEntityKeyValueCount, const CEntityKeyValues** ppEntityKeyValues, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest) = 0;
|
||||
virtual void UnknownFunc004() = 0; // Another BuildResourceManifest function in 2018, but it is quite different now
|
||||
virtual void BuildResourceManifestForEntity(uint64 unknown1, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest, uint64 unknown2) = 0;
|
||||
virtual void InvokePrecacheCallback(void* hResource /* ResourceHandle_t */, const EntitySpawnInfo_t* const info, IEntityPrecacheConfiguration* pConfig, IEntityResourceManifest* pResourceManifest, char* unk, void* callback /* SecondaryPrecacheMemberCallback_t */) = 0;
|
||||
virtual void AddRefKeyValues(const CEntityKeyValues* pKeyValues) = 0;
|
||||
virtual void ReleaseKeyValues(const CEntityKeyValues* pKeyValues) = 0;
|
||||
virtual void LockResourceManifest(bool bLock, CEntityResourceManifestLock* const context) = 0;
|
||||
};
|
||||
|
||||
|
||||
// Size: 0x1510 (from constructor)
|
||||
class CEntitySystem : public IEntityResourceManifestBuilder
|
||||
{
|
||||
public:
|
||||
virtual ~CEntitySystem() = 0;
|
||||
virtual void ClearEntityDatabase(ClearEntityDatabaseMode_t eMode) = 0;
|
||||
virtual void FindEntityProcedural(const char* szName, CEntityInstance* pSearchingEntity, CEntityInstance* pActivator, CEntityInstance* pCaller) = 0;
|
||||
virtual void OnEntityParentChanged(CEntityInstance* pEntity, CEntityInstance* pNewParent) = 0; // empty function
|
||||
virtual void OnAddEntity(CEntityInstance* pEnt, CEntityHandle handle) = 0; // empty function
|
||||
virtual void OnRemoveEntity(CEntityInstance* pEnt, CEntityHandle handle) = 0; // empty function
|
||||
virtual int GetSpawnGroupWorldId(SpawnGroupHandle_t hSpawnGroup) = 0; // returns 0
|
||||
virtual void Spawn(int nCount, const EntitySpawnInfo_t* pInfo) = 0;
|
||||
virtual void Activate(int nCount, const EntityActivation_t* pActivates, ActivateType_t activateType) = 0;
|
||||
virtual void PostDataUpdate(int nCount, const PostDataUpdateInfo_t *pInfo) = 0;
|
||||
virtual void OnSetDormant(int nCount, const EntityDormancyChange_t* pInfo, bool bNotifyAddedToPVS) = 0;
|
||||
virtual void UpdateOnRemove(int nCount, const EntityDeletion_t *pDeletion) = 0;
|
||||
|
||||
public:
|
||||
CBaseEntity* GetBaseEntity(CEntityIndex entnum);
|
||||
|
||||
CBaseEntity* GetBaseEntity(const CEntityHandle& hEnt);
|
||||
|
||||
private:
|
||||
IEntityResourceManifest* m_pCurrentManifest;
|
||||
public:
|
||||
CConcreteEntityList m_EntityList;
|
||||
// CConcreteEntityList seems to be correct but m_CallQueue supposedly starts at offset 2664, which is... impossible?
|
||||
// Based on CEntitySystem::CEntitySystem found via string "MaxNonNetworkableEntities"
|
||||
uint8 unk2696[0xa88];
|
||||
};
|
||||
|
||||
// Size: 0x1580 (from constructor)
|
||||
class CGameEntitySystem : public CEntitySystem
|
||||
{
|
||||
struct SpawnGroupEntityFilterInfo_t
|
||||
{
|
||||
ISpawnGroupEntityFilter* m_pFilter;
|
||||
SpawnGroupEntityFilterType_t m_nType;
|
||||
};
|
||||
//typedef SpawnGroupEntityFilterInfo_t CUtlMap<char const*, SpawnGroupEntityFilterInfo_t, int, bool (*)(char const* const&, char const* const&)>::ElemType_t;
|
||||
|
||||
|
||||
public:
|
||||
virtual ~CGameEntitySystem() = 0;
|
||||
|
||||
public:
|
||||
int m_iMaxNetworkedEntIndex;
|
||||
int m_iNetworkedEntCount;
|
||||
int m_iNonNetworkedSavedEntCount;
|
||||
// int m_iNumEdicts; // This is no longer referenced in the server binary
|
||||
CUtlDict<CGameEntitySystem::SpawnGroupEntityFilterInfo_t, int> m_spawnGroupEntityFilters;
|
||||
CUtlVector<IEntityListener*, CUtlMemory<IEntityListener*, int> > m_entityListeners;
|
||||
uint8 unk5480[0x18];
|
||||
};
|
||||
|
||||
#endif // ENTITYSYSTEM_H
|
164
public/entityhandle.h
Normal file
164
public/entityhandle.h
Normal file
@ -0,0 +1,164 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ENTITYHANDLE_H
|
||||
#define ENTITYHANDLE_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include "const.h"
|
||||
#include "ihandleentity.h"
|
||||
|
||||
|
||||
class CEntityHandle
|
||||
{
|
||||
public:
|
||||
CEntityHandle();
|
||||
CEntityHandle(const CEntityHandle& other);
|
||||
CEntityHandle(uint32 value);
|
||||
CEntityHandle(int iEntry, int iSerialNumber);
|
||||
|
||||
void Init(int iEntry, int iSerialNumber);
|
||||
void Term();
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
int GetEntryIndex() const;
|
||||
int GetSerialNumber() const;
|
||||
|
||||
bool operator !=(const CEntityHandle& other) const;
|
||||
bool operator ==(const CEntityHandle& other) const;
|
||||
bool operator ==(const IHandleEntity* pEnt) const;
|
||||
bool operator !=(const IHandleEntity* pEnt) const;
|
||||
bool operator <(const CEntityHandle& other) const;
|
||||
bool operator <(const IHandleEntity* pEnt) const;
|
||||
|
||||
// Assign a value to the handle.
|
||||
const CEntityHandle& operator=(const IHandleEntity* pEntity);
|
||||
const CEntityHandle& Set(const IHandleEntity* pEntity);
|
||||
|
||||
// Use this to dereference the handle.
|
||||
// Note: this is implemented in game code (ehandle.h)
|
||||
IHandleEntity* Get() const;
|
||||
|
||||
protected:
|
||||
union
|
||||
{
|
||||
uint32 m_Index;
|
||||
struct
|
||||
{
|
||||
uint32 m_EntityIndex : 15;
|
||||
uint32 m_Serial : 17;
|
||||
} m_Parts;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
inline CEntityHandle::CEntityHandle()
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline CEntityHandle::CEntityHandle(const CEntityHandle& other)
|
||||
{
|
||||
m_Index = other.m_Index;
|
||||
}
|
||||
|
||||
inline CEntityHandle::CEntityHandle(uint32 value)
|
||||
{
|
||||
m_Index = value;
|
||||
}
|
||||
|
||||
inline CEntityHandle::CEntityHandle(int iEntry, int iSerialNumber)
|
||||
{
|
||||
Init(iEntry, iSerialNumber);
|
||||
}
|
||||
|
||||
inline void CEntityHandle::Init(int iEntry, int iSerialNumber)
|
||||
{
|
||||
m_Parts.m_EntityIndex = iEntry;
|
||||
m_Parts.m_Serial = iSerialNumber;
|
||||
}
|
||||
|
||||
inline void CEntityHandle::Term()
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::IsValid() const
|
||||
{
|
||||
return m_Index != INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
inline int CEntityHandle::GetEntryIndex() const
|
||||
{
|
||||
if (IsValid())
|
||||
{
|
||||
return m_Parts.m_EntityIndex;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
inline int CEntityHandle::GetSerialNumber() const
|
||||
{
|
||||
return m_Parts.m_Serial;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator !=(const CEntityHandle& other) const
|
||||
{
|
||||
return m_Index != other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator ==(const CEntityHandle& other) const
|
||||
{
|
||||
return m_Index == other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator ==(const IHandleEntity* pEnt) const
|
||||
{
|
||||
return Get() == pEnt;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator !=(const IHandleEntity* pEnt) const
|
||||
{
|
||||
return Get() != pEnt;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator <(const CEntityHandle& other) const
|
||||
{
|
||||
return m_Index < other.m_Index;
|
||||
}
|
||||
|
||||
inline bool CEntityHandle::operator <(const IHandleEntity* pEntity) const
|
||||
{
|
||||
unsigned long otherIndex = (pEntity) ? pEntity->GetRefEHandle().m_Index : INVALID_EHANDLE_INDEX;
|
||||
return m_Index < otherIndex;
|
||||
}
|
||||
|
||||
inline const CEntityHandle& CEntityHandle::operator=(const IHandleEntity* pEntity)
|
||||
{
|
||||
return Set(pEntity);
|
||||
}
|
||||
|
||||
inline const CEntityHandle& CEntityHandle::Set(const IHandleEntity* pEntity)
|
||||
{
|
||||
if (pEntity)
|
||||
{
|
||||
*this = pEntity->GetRefEHandle();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Index = INVALID_EHANDLE_INDEX;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // ENTITYHANDLE_H
|
||||
|
||||
typedef CEntityHandle CBaseHandle;
|
@ -1,4 +1,4 @@
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -10,26 +10,16 @@
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
|
||||
class CBaseHandle;
|
||||
|
||||
class CEntityHandle;
|
||||
|
||||
// An IHandleEntity-derived class can go into an entity list and use ehandles.
|
||||
class IHandleEntity
|
||||
{
|
||||
virtual void Schema_DynamicBinding(void**) = 0;
|
||||
public:
|
||||
virtual ~IHandleEntity() {}
|
||||
virtual void SetRefEHandle( const CBaseHandle &handle ) = 0;
|
||||
virtual const CBaseHandle& GetRefEHandle() const = 0;
|
||||
#ifdef _X360
|
||||
IHandleEntity() :
|
||||
m_bIsStaticProp( false )
|
||||
{
|
||||
}
|
||||
|
||||
bool m_bIsStaticProp;
|
||||
#endif
|
||||
virtual ~IHandleEntity() = 0;
|
||||
virtual const CEntityHandle GetRefEHandle() const = 0;
|
||||
};
|
||||
|
||||
|
||||
#endif // IHANDLEENTITY_H
|
||||
#endif // IHANDLEENTITY_H
|
@ -15,7 +15,7 @@
|
||||
#include "convar.h"
|
||||
|
||||
#if defined( CLIENT_DLL ) || defined( GAME_DLL )
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#endif
|
||||
|
||||
#if defined( COMPILER_MSVC )
|
||||
|
@ -1,4 +1,4 @@
|
||||
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//====== Copyright <EFBFBD> 1996-2005, Valve Corporation, All rights reserved. =======
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@ -13,7 +13,7 @@
|
||||
#include "tier0/interface.h"
|
||||
#include "tier1/utlvector.h"
|
||||
#include "Color.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "iclientrenderable.h"
|
||||
#include "engine/ishadowmgr.h"
|
||||
#include "engine/ivmodelinfo.h"
|
||||
|
@ -11,13 +11,10 @@
|
||||
#include "vector4d.h"
|
||||
#include "Color.h"
|
||||
#include "entity2/entityidentity.h"
|
||||
#include "basehandle.h"
|
||||
#include "entityhandle.h"
|
||||
#include "tier1/bufferstring.h"
|
||||
#include "tier1/utlscratchmemory.h"
|
||||
|
||||
// Forward declaration
|
||||
class CEntityInstance;
|
||||
|
||||
// Non-implemented classes/structs
|
||||
struct ResourceBindingBase_t;
|
||||
typedef const ResourceBindingBase_t *ResourceHandle_t;
|
||||
|
Loading…
Reference in New Issue
Block a user