From 8a669bc96ffdb9d0f6f54e464da11e3375c80a55 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Thu, 17 Apr 2025 01:39:10 +0100 Subject: Add type-safety to virtual calls and accessors This probably should have been the design from the start. It's still possible to use void pointers, and this is done in a couple of places for simplicity, but wherever possible, we have actual structs for things now. Additionally, in places where vtables are fiddled with, e.g. vtable hooks, we have actual struct definitions with vtable pointers so there's need for pointer-casting horror. --- src/engineapi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/engineapi.c') diff --git a/src/engineapi.c b/src/engineapi.c index 54a6d8f..44713da 100644 --- a/src/engineapi.c +++ b/src/engineapi.c @@ -40,15 +40,16 @@ ifacefactory factory_client = 0, factory_server = 0, factory_engine = 0, struct VEngineClient *engclient; struct VEngineServer *engserver; -void *srvdll; +struct IServerGameDLL *srvdll; -DECL_VFUNC(void *, GetGlobalVars, 1) // seems to be very stable, thank goodness -void *globalvars; +DECL_VFUNC(void, struct CGlobalVars *, GetGlobalVars, 1) // seems very stable +struct CGlobalVars *globalvars; -void *inputsystem, *vgui; +struct IInputSystem *inputsystem; +struct CEngineVGui *vgui; struct CServerPlugin *pluginhandler; -DECL_VFUNC_DYN(void *, GetAllServerClasses) +DECL_VFUNC_DYN(struct IServerGameDLL, struct ServerClass *, GetAllServerClasses) #include // generated by build/mkentprops.c #include // generated by build/mkgamedata.c -- cgit v1.2.3-54-g00ecf