BunnymodXT
BunnymodXT copied to clipboard
restructuring: use save data to find offsets for the most of class variables
https://github.com/YaLTeR/BunnymodXT/blob/11963346953029d9882e04ad7f86ea0fbf6aea49/HLSDK/engine/eiface.h#L404-L411
- Find
SaveorRestoreclass function (e.g.CBasePlayer::Save) - There will definitely be a call(s) to the
CSave::WriteFieldsorCRestore::ReadFieldsdepending on the function you choose:
int CBasePlayer::Save( CSave &save )
{
if ( !CBaseMonster::Save(save) )
return 0;
return save.WriteFields( "PLAYER", this, m_playerSaveData, ARRAYSIZE(m_playerSaveData) );
}
- You need intercept
m_playerSaveDataand store total fields number that passed as last argument - Now you can iterate through it and get name/offset/size of class variable if it contains in that list
This will also help to remove this ugliest hardcoded offsets for Linux game versions and thereby allow you to play without issues from both versions (Valve added a variable at the end of CBaseMonster for the NPC turn fix, which is also inherited for CBasePlayer):
https://github.com/YaLTeR/BunnymodXT/blob/11963346953029d9882e04ad7f86ea0fbf6aea49/BunnymodXT/modules/ServerDLL.cpp#L991-L1003