From 244fea664121acf12871ab5858a5fe95a2606b52 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 10 Mar 2025 02:37:19 +0000 Subject: Rewrite and redesign codegen and feature system Also switch to somewhat proper C23 flags while we're at it. This is a huge change. It took me forever, in between being really busy. Sorry about that. But the good news is I'm now free to start integrating the various patches that have accumulated since last release. Well, at least in between still being really busy. Gotta manage expectations. The main benefit of introducing GAMESPECIFIC() is that features that don't apply to a particular game no longer show up *at all*, and less time is wasted on init. It also enables a cool optimisation wherein unnecessary REQUIRE_GAMEDATA() checks can elided at compile time whenever the gamedata is known up-front to always exist in supported games. The DEF_FEAT_CVAR macro family meanwhile makes it easier to manage the lifecycle of cvars/ccmds, with less manual registering, unhiding and such. Originally I was going to try and just hack these features into the existing codegen abomination, but it just got too terrible. This rewrite should make it easier to continue tweaking codegen behaviour in future. It also has slightly better error messages. --- src/nomute.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/nomute.c') diff --git a/src/nomute.c b/src/nomute.c index 4e5bcc4..a72f067 100644 --- a/src/nomute.c +++ b/src/nomute.c @@ -1,6 +1,6 @@ /* * Copyright © 2023 Willian Henrique - * Copyright © 2024 Michael Smith + * Copyright © 2025 Michael Smith * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -58,9 +58,9 @@ static long __stdcall hook_CreateSoundBuffer(IDirectSound *this, } PREINIT { - if (con_findvar("snd_mute_losefocus")) return false; - con_reg(snd_mute_losefocus); - return true; + if (con_findvar("snd_mute_losefocus")) return FEAT_SKIP; + con_regvar(snd_mute_losefocus); + return FEAT_OK; } INIT { @@ -69,14 +69,14 @@ INIT { if_cold (DirectSoundCreate(0, &ds_obj, 0) != DS_OK) { // XXX: can this error be usefully stringified? errmsg_errorx("couldn't create IDirectSound instance"); - return false; + return FEAT_OK; } ds_vt = ds_obj->lpVtbl; ds_obj->lpVtbl->Release(ds_obj); if_cold (!os_mprot(&ds_vt->CreateSoundBuffer, sizeof(void *), PAGE_READWRITE)) { errmsg_errorsys("couldn't make virtual table writable"); - return false; + return FEAT_OK; } orig_CreateSoundBuffer = ds_vt->CreateSoundBuffer; ds_vt->CreateSoundBuffer = &hook_CreateSoundBuffer; @@ -93,7 +93,7 @@ INIT { "audio settings or restarting the game with SST autoloaded in " "order to have an effect"); } - return true; + return FEAT_OK; } END { -- cgit v1.2.3-54-g00ecf