when to EXPORT an entity method Created 5 years ago2018-12-29 06:45:38 UTC by tschumann tschumann

Created 5 years ago2018-12-29 06:45:38 UTC by tschumann tschumann

Posted 5 years ago2018-12-29 06:45:38 UTC Post #341518
I've never quite understood it but by the looks of it you need to EXPORT a method if you pass it to SetThink/SetTouch/SetUse/SetBlocked?
It seems like things compile without the EXPORT but I guess save-games will screw up without it: it looks like Set* set m_pfn* which get serialised in the saverestore stuff.
Posted 5 years ago2018-12-29 08:54:34 UTC Post #341519
After having a quick look at it, it seems the engine looks up the names of DLL functions (and for this to work the functions need to be listed in the DLL exports table, which Half-Life achieves with the EXPORT macro) when pointers to those functions need to be (re)stored for the purposes of save files. The names of the functions, rather than the actual function pointers, are written to save files. So I'm guessing you only need to worry about EXPORT when you need to be able to (re)store a pointer to a function (i.e. anywhere you use DEFINE_FIELD with the FIELD_FUNCTION argument). The current think, touch, use and blocked functions of entities are good examples: https://github.com/ValveSoftware/halflife/blob/5d761709a31ce1e71488f2668321de05f791b405/dmc/dlls/cbase.cpp#L584

EXPORT is also used to enable the engine to find some functions it needs to call and knows to expect under certain names like HUD_Init and V_CalcRefdef.
It seems like things compile without the EXPORT but I guess save-games will screw up without it
I haven't tested, but from my quick glance at the code I agree
Oskar Potatis Oskar Potatis🦔
Posted 5 years ago2018-12-30 04:44:16 UTC Post #341522
Nice thanks.
You must be logged in to post a response.