From b447f5879d0c4c49d72f167ed2cf0f1e44a52123 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sat, 11 Oct 2025 01:35:54 +0100 Subject: 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. --- src/build/mkgamedata.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/build') 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]]) -- cgit v1.2.3-54-g00ecf