summaryrefslogtreecommitdiff
path: root/src/engineapi.h
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-17 01:39:10 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-17 20:02:18 +0100
commit8a669bc96ffdb9d0f6f54e464da11e3375c80a55 (patch)
tree569dac0cd082ad25e779a69f0bcceff5ca212bb1 /src/engineapi.h
parent0b40d4d9ea1cbfbb92795e0d6f26cf108f2dec5f (diff)
downloadsst-8a669bc96ffdb9d0f6f54e464da11e3375c80a55.tar.gz
sst-8a669bc96ffdb9d0f6f54e464da11e3375c80a55.zip
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.
Diffstat (limited to 'src/engineapi.h')
-rw-r--r--src/engineapi.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/engineapi.h b/src/engineapi.h
index c7a7e1f..ef716a9 100644
--- a/src/engineapi.h
+++ b/src/engineapi.h
@@ -38,15 +38,14 @@ extern ifacefactory factory_client, factory_server, factory_engine,
// various engine types {{{
-struct VEngineClient {
- void **vtable;
- /* opaque fields */
-};
-
-struct VEngineServer {
- void **vtable;
- /* opaque fields */
-};
+// Virtual classes with opaque members; vtables exposed for ease of hooking etc.
+struct ICvar { void **vtable; };
+struct VEngineClient { void **vtable; };
+struct VClient { void **vtable; };
+struct VEngineServer { void **vtable; };
+struct IServerGameDLL { void **vtable; };
+struct IInputSystem { void **vtable; };
+struct CEngineVGui { void **vtable; };
struct CUtlMemory {
void *mem;
@@ -124,9 +123,10 @@ struct ServerClass {
extern struct VEngineClient *engclient;
extern struct VEngineServer *engserver;
-extern void *srvdll;
-extern void *globalvars;
-extern void *inputsystem, *vgui;
+extern struct IServerGameDLL *srvdll;
+extern struct CGlobalVars *globalvars;
+extern struct IInputSystem *inputsystem;
+extern struct CEngineVGui *vgui;
// XXX: not exactly engine *API* but not curently clear where else to put this
struct CPlugin_common {