aboutsummaryrefslogtreecommitdiff
path: root/src/build/mkgamedata.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-10-11 01:35:54 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-10-11 01:36:16 +0100
commitb447f5879d0c4c49d72f167ed2cf0f1e44a52123 (patch)
tree7b20bb65b7acc2826591af01d531baf8281ae79b /src/build/mkgamedata.c
parente3716a68c1b4f1b189065dda1a1e998715c8ede9 (diff)
downloadsst-b447f5879d0c4c49d72f167ed2cf0f1e44a52123.tar.gz
sst-b447f5879d0c4c49d72f167ed2cf0f1e44a52123.zip
Handle negated gamedata tag matches properly
The NE thing wasn't really correct, because it would match hypothetical cases where OE and some other tag bit are both set. Now we simply use !OE instead. The _GAMES_WITH inversion case is correct, because it doesn't necessarily exclude OE from being included too.
Diffstat (limited to 'src/build/mkgamedata.c')
-rw-r--r--src/build/mkgamedata.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/build/mkgamedata.c b/src/build/mkgamedata.c
index d3b9c9c..de70c0b 100644
--- a/src/build/mkgamedata.c
+++ b/src/build/mkgamedata.c
@@ -182,8 +182,10 @@ F( "#line %d \"%" fS "\"", srclines[i], srcnames[srcfiles[i]])
// don't attempt to optimise for nested conditionals because that's
// way more complicated and also basically defeats the purpose.
if (indents[j] != 1) continue;
- if_cold (fprintf(out, "%s \\\n\t _gametype_tag_%s", pipe,
- sbase + tags[j]) < 0) {
+ bool neg = sbase[tags[j]] == '!';
+ const char *tilde = (const char *)"~" + !neg; // cast away warning
+ if_cold (fprintf(out, "%s \\\n\t %s_gametype_tag_%s", pipe, tilde,
+ sbase + tags[j] + neg) < 0) {
diewrite();
}
pipe = " |";
@@ -247,14 +249,16 @@ _i("}")
continue;
}
F( "#line %d \"%" fS "\"", srclines[i], srcnames[srcfiles[i]])
+ bool neg = sbase[tags[i]] == '!';
+ const char *excl = (const char *)"!" + !neg; // cast away warning
if (indents[i] > indents[i - 1]) {
-Fi(" if (GAMETYPE_MATCHES(%s)) {", sbase + tags[i])
+Fi(" if (%sGAMETYPE_MATCHES(%s)) {", excl, sbase + tags[i] + neg);
++indent;
}
else {
_i("}")
F( "#line %d \"%" fS "\"", srclines[i], srcnames[srcfiles[i]])
-Fi("else if (GAMETYPE_MATCHES(%s)) {", sbase + tags[i])
+Fi("else if (%sGAMETYPE_MATCHES(%s)) {", excl, sbase + tags[i] + neg);
}
if (exprs[i]) {
F( "#line %d \"%" fS "\"", srclines[i], srcnames[srcfiles[i]])