summaryrefslogtreecommitdiffhomepage
path: root/src/build/mkgamedata.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-07-15 21:24:15 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-07-23 18:51:28 +0100
commit5b9864c75c4f9221b418f46cab5934d36aeccef0 (patch)
tree35ff8b31d36f6bac4d06f9f53fbe6b82b6073460 /src/build/mkgamedata.c
parent4d1a3a021f1adbd493dbdb4858dc20066af4e0aa (diff)
Fix dodgy "has" initialisation case in mkgamedata
Diffstat (limited to 'src/build/mkgamedata.c')
-rw-r--r--src/build/mkgamedata.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/build/mkgamedata.c b/src/build/mkgamedata.c
index ce6490e..7d7a425 100644
--- a/src/build/mkgamedata.c
+++ b/src/build/mkgamedata.c
@@ -55,7 +55,8 @@ static noreturn die(const char *s) {
* then it should be obvious. :^)
*
* Note: if `default` isn't given in a conditional block, that piece of gamedata
- * is considered unavailable and modules that use it won't get initialised/used.
+ * is considered unavailable and modules that use it won't get initialised/used
+ * unless all the conditions are met.
*/
struct vec_ent VEC(struct ent *);
struct ent {
@@ -176,14 +177,13 @@ static void inits(FILE *out, const char *var, struct vec_ent *v, bool needhas,
int indent) {
for (struct ent *const *pp = v->data; pp - v->data < v->sz; ++pp) {
Fi("if (GAMETYPE_MATCHES(%s)) {", (*pp)->name)
- bool has = needhas && (*pp)->defexpr;
- if (has) {
-Fi(" has_%s = true;", var);
- }
if ((*pp)->defexpr) {
+ if (needhas) {
+Fi(" has_%s = true;", var);
+ }
Fi(" %s = %s;", var, (*pp)->defexpr);
}
- inits(out, var, &(*pp)->subents, !has, indent + 1);
+ inits(out, var, &(*pp)->subents, needhas && !(*pp)->defexpr, indent + 1);
_i("}")
}
}