aboutsummaryrefslogtreecommitdiff
path: root/src/build/gluegen.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-10-11 03:09:35 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-10-11 03:13:18 +0100
commit74f1309af5310fbfa346048f8ecfc7fe1e8a4571 (patch)
treef2c8eb715e0caea090fb69abfeaeee1ca55d6d8a /src/build/gluegen.c
parentb447f5879d0c4c49d72f167ed2cf0f1e44a52123 (diff)
downloadsst-74f1309af5310fbfa346048f8ecfc7fe1e8a4571.tar.gz
sst-74f1309af5310fbfa346048f8ecfc7fe1e8a4571.zip
Improve gamedata codegen and fix spurious cases
The old GAMESPECIFIC mechanism had worked in practice but was technically a little bit incorrect, oops.
Diffstat (limited to 'src/build/gluegen.c')
-rw-r--r--src/build/gluegen.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/src/build/gluegen.c b/src/build/gluegen.c
index 3d1eef8..5d02f48 100644
--- a/src/build/gluegen.c
+++ b/src/build/gluegen.c
@@ -767,48 +767,41 @@ F( " %sif (!GAMETYPE_MATCHES(%.*s)) status_%.*s = FEAT_SKIP;", else_,
else_ = "else ";
}
list_foreach (struct cmeta_slice, gamedata, mod_gamedata + mod) {
- // this is not a *totally* ideal way of doing this, but it's easy.
- // if we had some info about what gamedata was doing, we could avoid
- // having to ifdef these cases and could just directly generate the
- // right thing. but that'd be quite a bit of work, so... we don't!
if (mod_gamespecific[mod].s) {
-F( "#ifdef _GAMES_WITH_%.*s", gamedata.len, gamedata.s)
-F( " %sif (!(_gametype_tag_%.*s & _GAMES_WITH_%.*s) && !has_%.*s) {", else_,
- mod_gamespecific[mod].len, mod_gamespecific[mod].s,
- gamedata.len, gamedata.s, gamedata.len, gamedata.s)
+F( " %sif (!_HAS_%.*s(_gametype_tag_%.*s)) {", else_,
+ gamedata.len, gamedata.s,
+ mod_gamespecific[mod].len, mod_gamespecific[mod].s)
F( " status_%.*s = NOGD;", mod_names[mod].len, mod_names[mod].s)
_( " }")
-_( "#else")
}
-F( " %sif (!has_%.*s) status_%.*s = NOGD;", else_,
- gamedata.len, gamedata.s, mod_names[mod].len, mod_names[mod].s)
- if (mod_gamespecific[mod].s) {
-_( "#endif")
+ else {
+F( " %sif (!_HAS_%.*s(0)) status_%.*s = NOGD;", else_,
+ gamedata.len, gamedata.s, mod_names[mod].len, mod_names[mod].s)
}
else_ = "else ";
}
list_foreach (struct cmeta_slice, global, mod_globals + mod) {
F( " %sif (!(%.*s)) status_%.*s = NOGLOBAL;", else_,
- global.len, global.s, mod_names[mod].len, mod_names[mod].s)
+ global.len, global.s, mod_names[mod].len, mod_names[mod].s)
else_ = "else ";
}
list_foreach (s16, dep, mod_needs + mod) {
F( " %sif (status_%.*s != FEAT_OK) status_%.*s = REQFAIL;", else_,
- mod_names[dep].len, mod_names[dep].s,
- mod_names[mod].len, mod_names[mod].s)
+ mod_names[dep].len, mod_names[dep].s,
+ mod_names[mod].len, mod_names[mod].s)
else_ = "else ";
}
if (mod_flags[mod] & (HAS_END | HAS_EVENTS | HAS_OPTDEPS)) {
F( " %sif ((status_%.*s = _feat_init_%.*s()) == FEAT_OK) has_%.*s = true;",
- else_,
- mod_names[mod].len, mod_names[mod].s,
- mod_names[mod].len, mod_names[mod].s,
- mod_names[mod].len, mod_names[mod].s)
+ else_,
+ mod_names[mod].len, mod_names[mod].s,
+ mod_names[mod].len, mod_names[mod].s,
+ mod_names[mod].len, mod_names[mod].s)
}
else {
F( " %sstatus_%.*s = _feat_init_%.*s();", else_,
- mod_names[mod].len, mod_names[mod].s,
- mod_names[mod].len, mod_names[mod].s)
+ mod_names[mod].len, mod_names[mod].s,
+ mod_names[mod].len, mod_names[mod].s)
}
}
_( "")