diff options
author | 2025-04-17 01:39:10 +0100 | |
---|---|---|
committer | 2025-04-17 20:02:18 +0100 | |
commit | 8a669bc96ffdb9d0f6f54e464da11e3375c80a55 (patch) | |
tree | 569dac0cd082ad25e779a69f0bcceff5ca212bb1 /src/democustom.c | |
parent | 0b40d4d9ea1cbfbb92795e0d6f26cf108f2dec5f (diff) | |
download | sst-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/democustom.c')
-rw-r--r-- | src/democustom.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/democustom.c b/src/democustom.c index 7ca8677..cae58a8 100644 --- a/src/democustom.c +++ b/src/democustom.c @@ -17,16 +17,13 @@ #include <string.h> #include "bitbuf.h" -#include "con_.h" #include "demorec.h" #include "engineapi.h" -#include "errmsg.h" #include "feature.h" #include "gamedata.h" #include "intdefs.h" #include "langext.h" #include "mem.h" -#include "ppmagic.h" #include "vcall.h" #include "x86.h" #include "x86util.h" @@ -88,7 +85,7 @@ void democustom_write(const void *buf, int len) { } static bool find_WriteMessages() { - const uchar *insns = (*(uchar ***)demorecorder)[vtidx_RecordPacket]; + const uchar *insns = (uchar *)demorecorder->vtable[vtidx_RecordPacket]; // RecordPacket calls WriteMessages right away, so just look for a call for (const uchar *p = insns; p - insns < 32;) { if (*p == X86_CALL) { @@ -100,7 +97,7 @@ static bool find_WriteMessages() { return false; } -DECL_VFUNC_DYN(int, GetEngineBuildNumber) +DECL_VFUNC_DYN(struct VEngineClient, int, GetEngineBuildNumber) INIT { // More UncraftedkNowledge: |