diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2023-05-16 22:12:57 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2023-05-16 23:00:24 +0100 |
commit | cba9387c361c3d33dcf1b21ff0e5beb4b0a81ade (patch) | |
tree | c3b590a682447959a41c0d90f690e59b23365a3d /src/ac.c | |
parent | 182b36609acc44d3338f64ca3975e1604b50f619 (diff) |
Do some pedantic spring cleaning
- Use const in more places where it makes sense - not absolutely
everywhere because it can get a bit annoying
- Make all the instruction search loops a bit more readable by casting
the function pointer into a temporary variable to loop over
- Add a few more doc comments and fix a typo or two
- Make that RTTI thing flexibly-sized, finally
- Don't include gamedata.h in vcall.h for no reason; consequently
include gamedata.h in a bunch of places where it was implictly pulled
in before
- Fix dbg_toghidra() and ent_getedict() having mismatched return types
between their headers and respective source files
- Remove that one broken, hacky, secret Portal non-feature that probably
nobody even ended up using; it can be implemented properly later if
required
Diffstat (limited to 'src/ac.c')
-rw-r--r-- | src/ac.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -27,6 +27,7 @@ #include "errmsg.h" #include "event.h" #include "feature.h" +#include "gamedata.h" #include "intdefs.h" #include "mem.h" #include "os.h" @@ -242,10 +243,8 @@ static bool find_DispatchInputEvent(void) { return false; } void *cgame; - GetDesktopResolution_func GetDesktopResolution = - VFUNC(gameuifuncs, GetDesktopResolution); - for (uchar *p = (uchar *)GetDesktopResolution; - p - (uchar *)GetDesktopResolution < 16;) { + const uchar *insns = (const uchar*)VFUNC(gameuifuncs, GetDesktopResolution); + for (const uchar *p = insns; p - insns < 16;) { if (p[0] == X86_MOVRMW && p[1] == X86_MODRM(0, 1, 5)) { void **indirect = mem_loadptr(p + 2); cgame = *indirect; @@ -255,10 +254,8 @@ static bool find_DispatchInputEvent(void) { } errmsg_errorx("couldn't find pointer to CGame instance"); return false; -ok: DispatchAllStoredGameMessages_func DispatchAllStoredGameMessages = - VFUNC(cgame, DispatchAllStoredGameMessages); - for (uchar *p = (uchar *)DispatchAllStoredGameMessages; - p - (uchar *)DispatchAllStoredGameMessages < 128;) { +ok: insns = (const uchar *)VFUNC(cgame, DispatchAllStoredGameMessages); + for (const uchar *p = insns; p - insns < 128;) { if (p[0] == X86_CALL) { orig_DispatchInputEvent = (DispatchInputEvent_func)(p + 5 + mem_loadoffset(p + 1)); |