refactor: single-line CVAR declarations - #887
Open
WofWca wants to merge 1 commit into
Open
Conversation
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>
Author
|
I understand that in this project we generally don't change the non-engine stuff. |
This was referenced Aug 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
#defines.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:
*_cvar.hfilescvarTable_ts to the*_cvar.hfiles,do simple search and replace to format the lines.
vmCvar_t mycvar;declarations(replace with
#include).extern vmCvar_t mycvar;(replace with#include).Note that this keeps
ui_serverFilterTypeandcg_gun_frameout 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.