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/gameserver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gameserver.c') diff --git a/src/gameserver.c b/src/gameserver.c index 7cd7526..6f3d394 100644 --- a/src/gameserver.c +++ b/src/gameserver.c @@ -28,9 +28,10 @@ FEATURE() REQUIRE_GAMEDATA(vtidx_GetSpawnCount) -DECL_VFUNC_DYN(int, GetSpawnCount) +struct CGameServer; +DECL_VFUNC_DYN(struct CGameServer, int, GetSpawnCount) -static void *sv; +static struct CGameServer *sv; int gameserver_spawncount() { return GetSpawnCount(sv); } -- cgit v1.2.3-54-g00ecf