Two Functions You Might Like
CGameEntitySystem has virtual functions inherited from CEntitySystem, not sure what most of them are, but I only really cared about two of them. My code largely doesn't traverse the entity list anymore, rather instead inserting them as needed into sets tracking creeps, heroes, players, etc. Of course, if loaded mid game, the list should still be traversed.
CEntityInstance* OnAddEntity(CGameEntitySystem* ecx,
CEntityInstance* ptr, CEntityHandle index)
{
return vmt.entity->GetOriginalMethod(OnAddEntity)(ecx, ptr, index);
}
CEntityInstance* OnRemoveEntity(CGameEntitySystem* ecx,
CEntityInstance* ptr, CEntityHandle index)
{
return vmt.entity->GetOriginalMethod(OnRemoveEntity)(ecx, ptr, index);
}
class CGameEntitySystem : public CEntitySystem;
// Entity System
vmt.entity->HookVM(OnRemoveEntity, 15);
vmt.entity->HookVM(OnAddEntity, 14);
¯_(ツ)_/¯
class CEntitySystem {
public:
virtual void n_0();
virtual void BuildResourceManifest(void); // 01
virtual void n_2();
virtual void n_3();
virtual void n_4();
virtual void n_5();
virtual void n_6();
virtual void AddRefKeyValues(CEntityKeyValues const*); // 7
virtual void ReleaseKeyValues(CEntityKeyValues const*); // 8
virtual void n_9();
virtual void n_10();
virtual void ClearEntityDatabase(void); // 11
virtual CEntityInstance* FindEntityProcedural(const char *...);
virtual CEntityInstance* OnEntityParentChanged(CEntityInstance*, CEntityInstance*);
virtual CEntityInstance* OnAddEntity(CEntityInstance*, CEntityHandle); // 14
virtual CEntityInstance* OnRemoveEntity(CEntityInstance*, CEntityHandle); // 15
virtual void n_16();
virtual void SortEntities(int, EntitySpawnInfo_t *, int *, int *); // 17
virtual void n_18();
virtual void n_19();
virtual void n_20();
virtual void n_21();
};
yeah this seems kinda nice, I saw this on UC.
Maybe something like entity ptr if it's null, save it somewhere, in the OnRemoveEntity hook set it to null.
Unrelated, but TypeDescription seems to be only 104 bytes on windows. I might be wrong, but I'm guessing if one of the pads were made into a destructor, it would be cross platform?
class TypeDescription // 8 * 13 = 104 bytes
{
public:
fieldtype_t type; // 8
const char* fieldName; // 16
int fieldOffset[TD_OFFSET_COUNT]; // 24
// speculated
unsigned short fieldSize; // 26
unsigned short flags; // 28
const char* externalName; // 36
void* pSaveRestoreOps; // 44
void* inputFunc; // 52
// Fuck it
Datamap * td; // 60
int fieldSizeInBytes; // 64
void* override_field; // 72
int override_count; // 76
float fieldTolerance; // 80
int flatOffset[TD_OFFSET_COUNT]; // 92
// kill me
void* _padding; // 96
~TypeDescription(); // 104
};