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/inputhud.c | 56 +++++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'src/inputhud.c') diff --git a/src/inputhud.c b/src/inputhud.c index af3bb59..da96d5e 100644 --- a/src/inputhud.c +++ b/src/inputhud.c @@ -1,7 +1,7 @@ /* * Copyright © 2022 Matthew Wozniak * Copyright © 2022 Willian Henrique - * Copyright © 2024 Michael Smith base.flags &= ~CON_HIDDEN; - sst_inputhud_scale->base.flags &= ~CON_HIDDEN; - sst_inputhud_bgcolour_normal->base.flags &= ~CON_HIDDEN; sst_inputhud_bgcolour_normal->cb = &colourcb; - sst_inputhud_bgcolour_pressed->base.flags &= ~CON_HIDDEN; sst_inputhud_bgcolour_pressed->cb = &colourcb; - sst_inputhud_fgcolour->base.flags &= ~CON_HIDDEN; sst_inputhud_fgcolour->cb = &colourcb; - sst_inputhud_x->base.flags &= ~CON_HIDDEN; - sst_inputhud_y->base.flags &= ~CON_HIDDEN; - // HACK: default HUD position would clash with L4D player health HUDs and - // HL2 sprint HUD, so move it up. this currently has to be done in a super - // crappy, nasty way to get the defaults to display right in the console... - // TODO(opt): move PREINIT stuff to before cvar init and avoid this nonsense + // Default HUD position would clash with L4D player health HUDs and + // HL2 sprint HUD, so move it up. This is a bit yucky, but at least we don't + // have to go through all the virtual setter crap twice... if (GAMETYPE_MATCHES(L4D)) { sst_inputhud_y->defaultval = "0.82"; - con_setvarstr(sst_inputhud_y, "0.82"); + sst_inputhud_y->fval = 0.82f; + sst_inputhud_y->ival = 0; } else if (GAMETYPE_MATCHES(HL2series)) { sst_inputhud_y->defaultval = "0.75"; - con_setvarstr(sst_inputhud_y, "0.75"); + sst_inputhud_y->fval = 0.75f; + sst_inputhud_y->ival = 0; } - return true; + return FEAT_OK; } END { -- cgit v1.2.3-54-g00ecf