Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Functions You Might Like #10

Open
shekeru opened this issue Jun 14, 2019 · 2 comments
Open

Two Functions You Might Like #10

shekeru opened this issue Jun 14, 2019 · 2 comments

Comments

@shekeru
Copy link

shekeru commented Jun 14, 2019

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();
};
@LWSS
Copy link
Owner

LWSS commented Jun 15, 2019

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.

@shekeru
Copy link
Author

shekeru commented Jun 24, 2019

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
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants