Skip to content

Commit

Permalink
Update CGameEntitySystem (alliedmodders#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
komashchenko authored Oct 8, 2023
1 parent a138f7f commit edef920
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 17 deletions.
15 changes: 14 additions & 1 deletion entity2/entitysystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,17 @@ CBaseEntity* CEntitySystem::GetBaseEntity(const CEntityHandle& hEnt)
return nullptr;

return dynamic_cast<CBaseEntity*>(pIdentity->m_pInstance);
}
}

void CGameEntitySystem::AddListenerEntity(IEntityListener* pListener)
{
if (m_entityListeners.Find(pListener) == -1)
{
m_entityListeners.AddToTail(pListener);
}
}

void CGameEntitySystem::RemoveListenerEntity(IEntityListener* pListener)
{
m_entityListeners.FindAndRemove(pListener);
}
40 changes: 24 additions & 16 deletions public/entity2/entitysystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct EntityDormancyChange_t : EntityNotification_t
struct EntitySpawnInfo_t : EntityNotification_t
{
const CEntityKeyValues* m_pKeyValues;
uint64 unknown;
uint64 m_Unk1;
};

struct EntityActivation_t : EntityNotification_t
Expand All @@ -81,7 +81,6 @@ struct PostDataUpdateInfo_t : EntityNotification_t
DataUpdateType_t m_updateType;
};


struct CEntityPrecacheContext
{
const CEntityKeyValues* m_pKeyValues;
Expand All @@ -92,9 +91,10 @@ struct CEntityPrecacheContext
class IEntityListener
{
public:
virtual void OnEntityCreated(CBaseEntity* pEntity) {};
virtual void OnEntitySpawned(CBaseEntity* pEntity) {};
virtual void OnEntityDeleted(CBaseEntity* pEntity) {};
virtual void OnEntityCreated(CEntityInstance* pEntity) {};
virtual void OnEntitySpawned(CEntityInstance* pEntity) {};
virtual void OnEntityDeleted(CEntityInstance* pEntity) {};
virtual void OnEntityParentChanged(CEntityInstance* pEntity, CEntityInstance* pNewParent) {};
};

struct CEntityResourceManifestLock
Expand Down Expand Up @@ -123,8 +123,7 @@ abstract_class IEntityResourceManifestBuilder
virtual void LockResourceManifest(bool bLock, CEntityResourceManifestLock* const context) = 0;
};


// Size: 0x1510 (from constructor)
// Size: 0x1510 | 0x1540 (from constructor)
class CEntitySystem : public IEntityResourceManifestBuilder
{
public:
Expand Down Expand Up @@ -152,10 +151,15 @@ class CEntitySystem : public IEntityResourceManifestBuilder
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];

private:
uint8 pad2696[0xa88];
#ifdef PLATFORM_LINUX
uint8 pad5392[0x30];
#endif
};

// Size: 0x1580 (from constructor)
// Size: 0x1580 | 0x15B0 (from constructor)
class CGameEntitySystem : public CEntitySystem
{
struct SpawnGroupEntityFilterInfo_t
Expand All @@ -165,18 +169,22 @@ class CGameEntitySystem : public CEntitySystem
};
//typedef SpawnGroupEntityFilterInfo_t CUtlMap<char const*, SpawnGroupEntityFilterInfo_t, int, bool (*)(char const* const&, char const* const&)>::ElemType_t;


public:
virtual ~CGameEntitySystem() = 0;

void AddListenerEntity(IEntityListener* pListener);
void RemoveListenerEntity(IEntityListener* pListener);

public:
int m_iMaxNetworkedEntIndex;
int m_iNetworkedEntCount;
int m_iNonNetworkedSavedEntCount;
int m_iMaxNetworkedEntIndex; // 5392 | 5440
int m_iNetworkedEntCount; // 5396 | 5444
int m_iNonNetworkedSavedEntCount; // 5400 | 5448
// 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];
CUtlDict<SpawnGroupEntityFilterInfo_t> m_spawnGroupEntityFilters; // 5408 | 5456
CUtlVector<IEntityListener*> m_entityListeners; // 5448 | 5496

private:
uint8 pad5480[0x20];
};

#endif // ENTITYSYSTEM_H

0 comments on commit edef920

Please sign in to comment.