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/trace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/trace.c') diff --git a/src/trace.c b/src/trace.c index 2fe18c6..1118bdf 100644 --- a/src/trace.c +++ b/src/trace.c @@ -21,6 +21,7 @@ #include "gametype.h" #include "intdefs.h" #include "trace.h" +#include "vcall.h" FEATURE() // TODO(compat): limiting to tested branches for now; support others as needed @@ -35,10 +36,9 @@ struct ray { bool isray, isswept; }; -static void *srvtrace; - -DECL_VFUNC(void, TraceRay, 5, struct ray *, uint /*mask*/, void */*filter*/, - struct CGameTrace *) +static struct IEngineTraceServer *srvtrace; +DECL_VFUNC(struct IEngineTraceServer, void, TraceRay, 5, + struct ray *, uint /*mask*/, void */*filter*/, struct CGameTrace *) static inline bool nonzero(struct vec3f v) { union { struct vec3f v; struct { unsigned int x, y, z; }; } u = {v}; -- cgit v1.2.3-54-g00ecf