diff options
author | 2025-09-29 23:11:55 +0100 | |
---|---|---|
committer | 2025-10-01 21:37:26 +0100 | |
commit | b3c359826ae519ea2816128dfe641032b9e9e97f (patch) | |
tree | 065368fa828bbfc45ceddc58ef10dd82e02a3698 /src/gametype.h | |
parent | 88f12ae363758c9214942335b4cdb4b5c0e559c9 (diff) | |
download | sst-b3c359826ae519ea2816128dfe641032b9e9e97f.tar.gz sst-b3c359826ae519ea2816128dfe641032b9e9e97f.zip |
While we're at it, come up with a way for certain gamedata matches to be
Windows-only. Somewhat reduces ifdef usage, although does not entirely
remove it of course.
Tested in HL2 2707. Haven't tested other HL2 builds, or Episode 1.
Doesn't seem to work in DMoMM yet either; not sure why.
A big list of stuff still to fix follows.
Hidden cvars are currently an issue. We still need to figure out what to
do with the flag bits because FCVAR_HIDDEN just doesn't exist in OE and
there's some other flag with the same value instead.
We also need to do something about the flag setting in fixes.c since
HIDDEN is again not a thing, and also DEVONLY is not a thing either.
When the plugin is autoloaded, all the initial log text gets eaten,
because there's some stupid crap we have to do to trick the engine into
displaying coloured text otherwise it just won't. Not even stuff from
Warning(). Very stupid, but Hayden already figured out a solution, so
that'll be done in another upcoming commit.
Apparently raw mouse input breaks the menu. We might need to bump up the
priority on making that hook only be active when there's no UI open -
something I wanted to do anyway due to the demo drive issues.
Big thanks to Hayden for doing a lot of the initial groundwork on this,
particularly the cvar registration stuff. He gets a copyright notice in
con_.c even though I ended up doing a lot of stuff differently because
quite a bit of his work is still in there.
Don't blame him for the self-modifying code though, that was my crazy
idea. Sorry, but, in my defence... Well, it works.
Diffstat (limited to 'src/gametype.h')
-rw-r--r-- | src/gametype.h | 73 |
1 files changed, 47 insertions, 26 deletions
diff --git a/src/gametype.h b/src/gametype.h index fa899c2..6f6a712 100644 --- a/src/gametype.h +++ b/src/gametype.h @@ -23,51 +23,66 @@ extern u32 _gametype_tag; -#define GAMETYPE_BASETAGS(X) \ +#define GAMETYPE_BASETAGS(ALL, WINDOWSONLY) \ /* general engine branches used in a bunch of stuff */ \ - X(OE) \ - X(OrangeBox) \ - X(2013) \ + WINDOWSONLY(OE) \ + ALL(OrangeBox) \ + ALL(2013) \ \ /* specific games with dedicated branches / engine changes */ \ /* TODO(compat): detect dmomm, if only to fail (VEngineServer broke) */ \ - X(DMoMM) \ - X(L4D1) \ - X(L4D2) \ - X(L4DS) /* Survivors (weird arcade port) */ \ - X(Portal2) \ + WINDOWSONLY(DMoMM) \ + WINDOWSONLY(L4D1) \ + ALL(L4D2) \ + WINDOWSONLY(L4DS) /* Survivors (weird arcade port) */ \ + ALL(Portal2) \ \ /* games needing game-specific stuff, but not tied to a singular branch */ \ - X(Portal1) \ - X(HL2series) /* HL2, episodes, mods */ \ + ALL(Portal1) \ + ALL(HL2series) /* HL2, episodes, mods */ \ \ /* VEngineClient versions */ \ - X(Client015) \ - X(Client014) \ - X(Client013) \ - X(Client012) \ + ALL(Client015) \ + ALL(Client014) \ + ALL(Client013) \ + ALL(Client012) \ \ /* VEngineServer versions */ \ - X(Server021) \ + ALL(Server021) \ \ /* ServerGameDLL versions */ \ - X(SrvDLL009) /* 2013-ish */ \ - X(SrvDLL005) /* mostly everything else, it seems */ \ + ALL(SrvDLL009) /* 2013-ish */ \ + ALL(SrvDLL005) /* mostly everything else, it seems */ \ \ /* games needing version-specific stuff */ \ - X(Portal1_3420) \ - X(L4D1_1015plus) /* Crash Course update */ \ - X(L4D1_1022plus) /* Mac update, bunch of code reshuffling */ \ - X(L4D2_2125plus) \ - X(TheLastStand) /* The JAiZ update */ \ + WINDOWSONLY(Portal1_3420) \ + WINDOWSONLY(L4D1_1015plus) /* Crash Course update */ \ + WINDOWSONLY(L4D1_1022plus) /* Mac update, bunch of code reshuffling */ \ + ALL(L4D2_2125plus) \ + ALL(TheLastStand) /* The JAiZ update */ \ enum { + // here we define the enum values in such a way that on linux, the windows- + // only tags are still defined as zero. that way we can use GAMETYPE_MATCHES + // checks in some cases without needing #ifdef _WIN32 and the optimiser can + // throw it out. #define _GAMETYPE_ENUMBIT(x) _gametype_tagbit_##x, -GAMETYPE_BASETAGS(_GAMETYPE_ENUMBIT) -#undef _GAMETYPE_ENUMBIT #define _GAMETYPE_ENUMVAL(x) _gametype_tag_##x = 1 << _gametype_tagbit_##x, -GAMETYPE_BASETAGS(_GAMETYPE_ENUMVAL) +#define _GAMETYPE_DISCARD(x) +#define _GAMETYPE_ZERO(x) _gametype_tag_##x = 0, +#ifdef _WIN32 +GAMETYPE_BASETAGS(_GAMETYPE_ENUMBIT, _GAMETYPE_ENUMBIT) +GAMETYPE_BASETAGS(_GAMETYPE_ENUMVAL, _GAMETYPE_ENUMVAL) +#else +GAMETYPE_BASETAGS(_GAMETYPE_ENUMBIT, _GAMETYPE_DISCARD) +GAMETYPE_BASETAGS(_GAMETYPE_ENUMVAL, _GAMETYPE_DISCARD) +GAMETYPE_BASETAGS(_GAMETYPE_DISCARD, _GAMETYPE_ZERO) +#endif +#define _GAMETYPE_ENUMVAL(x) _gametype_tag_##x = 1 << _gametype_tagbit_##x, +#undef _GAMETYPE_ZERO +#undef _GAMETYPE_DISCARD #undef _GAMETYPE_ENUMVAL +#undef _GAMETYPE_ENUMBIT }; /* Matches for any of multiple possible tags */ @@ -80,6 +95,12 @@ GAMETYPE_BASETAGS(_GAMETYPE_ENUMVAL) (_gametype_tag_OrangeBox | _gametype_tag_2013) #define _gametype_tag_Portal (_gametype_tag_Portal1 | _gametype_tag_Portal2) +/* Match for stuff that's specifically NOT OE. */ +// TODO(compat): maybe we should add a specific !Tag syntax to mkgamedata, +// which would make this redundant. as of now this is just a low-effort way to +// keep some cvar things undefined under OE to avoid confusion +#define _gametype_tag_NE (~_gametype_tag_OE) + #define GAMETYPE_MATCHES(x) !!(_gametype_tag & (_gametype_tag_##x)) #endif |