diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-03 23:40:31 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-23 20:37:37 +0100 |
commit | 83da606072ce272eb053d4e1497d77e647cfecae (patch) | |
tree | 71d0110881ff8685184c5f4ab720cc8d49c24678 /src/demorec.c | |
parent | acbd30e0427b16f885f96aed59881ec04eff25bc (diff) |
Revise syntax macros and add a ton of branch hints
My new programming style is branch hints. All non-confusing branches
must be hinted when I can be bothered. It's faster, sometimes, maybe.
Also, start trying to use more signed sizes in at least some of the
places where it makes sense. Unsigned sizes are surprisingly
error-prone!
Diffstat (limited to 'src/demorec.c')
-rw-r--r-- | src/demorec.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/demorec.c b/src/demorec.c index 8abba77..4a8efb5 100644 --- a/src/demorec.c +++ b/src/demorec.c @@ -26,6 +26,7 @@ #include "gameinfo.h" #include "hook.h" #include "intdefs.h" +#include "langext.h" #include "mem.h" #include "os.h" #include "ppmagic.h" @@ -99,7 +100,7 @@ static struct con_cmd *cmd_record, *cmd_stop; static con_cmdcb orig_record_cb, orig_stop_cb; static void hook_record_cb(const struct con_cmdargs *args) { - if (!CHECK_DemoControlAllowed()) return; + if_cold (!CHECK_DemoControlAllowed()) return; bool was = *recording; if (!was && args->argc == 2 || args->argc == 3) { // safety check: make sure a directory exists, otherwise recording @@ -162,7 +163,7 @@ static void hook_record_cb(const struct con_cmdargs *args) { } static void hook_stop_cb(const struct con_cmdargs *args) { - if (!CHECK_DemoControlAllowed()) return; + if_cold (!CHECK_DemoControlAllowed()) return; wantstop = true; orig_stop_cb(args); wantstop = false; @@ -258,21 +259,21 @@ INIT { orig_record_cb = con_getcmdcb(cmd_record); cmd_stop = con_findcmd("stop"); orig_stop_cb = con_getcmdcb(cmd_stop); - if (!find_demorecorder()) { + if_cold (!find_demorecorder()) { errmsg_errorx("couldn't find demo recorder instance"); return false; } void **vtable = mem_loadptr(demorecorder); // XXX: 16 is totally arbitrary here! figure out proper bounds later - if (!os_mprot(vtable, 16 * sizeof(void *), PAGE_READWRITE)) { + if_cold (!os_mprot(vtable, 16 * sizeof(void *), PAGE_READWRITE)) { errmsg_errorsys("couldn't make virtual table writable"); return false; } - if (!find_recmembers(vtable[vtidx_StopRecording])) { + if_cold (!find_recmembers(vtable[vtidx_StopRecording])) { errmsg_errorx("couldn't find recording state variables"); return false; } - if (!find_demoname(vtable[vtidx_StartRecording])) { + if_cold (!find_demoname(vtable[vtidx_StartRecording])) { errmsg_errorx("couldn't find demo basename variable"); return false; } @@ -290,7 +291,7 @@ INIT { } END { - if (!sst_userunloaded) return; + if_hot (!sst_userunloaded) return; // avoid dumb edge case if someone somehow records and immediately unloads if (*recording && *demonum == 0) *demonum = 1; void **vtable = *(void ***)demorecorder; |