aboutsummaryrefslogtreecommitdiff
path: root/src/build/gluegen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/build/gluegen.c')
-rw-r--r--src/build/gluegen.c58
1 files changed, 34 insertions, 24 deletions
diff --git a/src/build/gluegen.c b/src/build/gluegen.c
index bc973fb..574aa92 100644
--- a/src/build/gluegen.c
+++ b/src/build/gluegen.c
@@ -749,6 +749,13 @@ F( " feats.preinit_%.*s = _feat_preinit_%.*s();",
_( "}")
_( "")
_( "static inline void initfeatures() {")
+ // note: hidden flag could be 0 on OE but it's useful to know which things
+ // *would* be hidden. in particular, GetHelpText currently checks for both
+ // CON_INIT_HIDDEN and _CON_NE_HIDDEN when deciding whether to prepend
+ // the unsupported marker to the help text. the value of CON_INIT_HIDDEN
+ // is otherwise unused in OE so won't do any harm being set all the time.
+_( " int _hiddenflag = GAMETYPE_MATCHES(OE) ?")
+_( " CON_INIT_HIDDEN : _CON_NE_HIDDEN;")
for (int i = 0; i < nfeatures; ++i) { // N.B.: this *should* be 0-indexed!
const char *else_ = "";
s16 mod = feat_initorder[i];
@@ -767,48 +774,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)
}
}
_( "")
@@ -820,7 +820,7 @@ F( " if (status_%.*s != FEAT_SKIP) {",
modname.len, modname.s)
F( " con_regvar(%.*s);",
cvar_names[i].len, cvar_names[i].s)
-F( " if (status_%.*s != FEAT_OK) %.*s->base.flags |= CON_HIDDEN;",
+F( " if (status_%.*s != FEAT_OK) %.*s->base.flags |= _hiddenflag;",
modname.len, modname.s, cvar_names[i].len, cvar_names[i].s)
_( " }")
}
@@ -869,8 +869,18 @@ _( "}")
_( "")
_( "static inline void freevars() {")
for (int i = 1; i < ncvars; ++i) {
-F( " extfree(%.*s->strval);", cvar_names[i].len, cvar_names[i].s)
+F( " extfree(con_getvarcommon(%.*s)->strval);",
+ cvar_names[i].len, cvar_names[i].s)
+ }
+_( "}")
+_( "")
+_( "static inline void shuntvars() {")
+_( "#ifdef _WIN32")
+ for (int i = 1; i < ncvars; ++i) {
+F( " memmove(&%.*s->v1, &%.*s->v2, sizeof(struct con_var_common));",
+ cvar_names[i].len, cvar_names[i].s, cvar_names[i].len, cvar_names[i].s)
}
+_( "#endif")
_( "}")
for (int i = 1; i < nevents; ++i) {
const char *prefix = event_predicateflags[i] ?