Skip to content

refactor: simplify g_cvar.h - #888

Open
WofWca wants to merge 4 commits into
ioquake:mainfrom
WofWca:single-line-cvars-2
Open

refactor: simplify g_cvar.h#888
WofWca wants to merge 4 commits into
ioquake:mainfrom
WofWca:single-line-cvars-2

Conversation

@WofWca

@WofWca WofWca commented Aug 9, 2026

Copy link
Copy Markdown

This is a follow-up to
#887.

Similar MR in another project:
https://github.com/ec-/baseq3a/pull/86.

WofWca and others added 4 commits August 9, 2026 13:04
Adding new CVARs is a big headache, let's fix it,
using clever macro trickery: include the same file in multiple places,
but make its output different depending on the surrounding `#define`s.

The approach is taken from OpenJK, apparently it was introduced in
JACoders/OpenJK@b319c52
Similar MR in another project: https://github.com/ec-/baseq3a/pull/25.

How this commit was made:
1. Create the `*_cvar.h` files
2. Move the lines from `cvarTable_t`s to the `*_cvar.h` files,
  do simple search and replace to format the lines.
3. Remove `vmCvar_t mycvar;` declarations
  (replace with `#include`).
4. Remove `extern vmCvar_t mycvar;` (replace with `#include`).

Note that this keeps `ui_serverFilterType` and `cg_gun_frame`
out of the CVAR table, so as to not change behavior,
although it would probably make sense to add them.
But let's keep that for another commit.

Regarding the copyright status of this:
the mentioned projects' licenses are not compatible
with GPL-2.0-or-later.
But basically all I took from those projects is the idea,
otherwise I've written this commit by hand.
I also tried to preserve the general coding style of those two projects,
so that they're easier to compare.
I'm adding @LegendaryGuard as a copyright owner
because they expressed the desire to license this
under GPL-2.0-or-later, see https://github.com/ec-/baseq3a/pull/25.

Co-authored-by: LegendaryGuard <rootuser999@gmail.com>
It's always 0, there is no need to specify it.
So that you don't have to go to declaration
every time you want to figure out what this `qfalse` and `qtrue`
is referring to.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant