X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=newdungeon.py;h=dffb8d142b0d58d136c6234ca7ddfe68e780ad12;hb=6277b45d6bce6d416fc953fc76b23513fd4ff621;hp=136d941f9f9f28de3ff264ab5c337df84d7ec28f;hpb=ddb0df85b315cf60c529d0566254beb2c42cab2b;p=open-adventure.git diff --git a/newdungeon.py b/newdungeon.py index 136d941..dffb8d1 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -8,7 +8,11 @@ yaml_name = "adventure.yaml" h_name = "newdb.h" c_name = "newdb.c" -h_template = """#include +h_template = """/* Generated from adventure.yaml - do not hand-hack! */ +#ifndef NEWDB_H +#define NEWDB_H + +#include typedef struct {{ const char* inventory; @@ -56,9 +60,10 @@ extern turn_threshold_t turn_thresholds[]; extern obituary_t obituaries[]; extern hint_t hints[]; -extern size_t CLSSES; -extern int maximum_deaths; -extern int turn_threshold_count; +extern const size_t CLSSES; +extern const int maximum_deaths; +extern const int turn_threshold_count; +#define HINT_COUNT {} enum arbitrary_messages_refs {{ {} @@ -71,9 +76,13 @@ enum locations_refs {{ enum object_descriptions_refs {{ {} }}; + +#endif /* end NEWDB_H */ """ -c_template = """#include "{}" +c_template = """/* Generated from adventure.yaml - do not hand-hack! */ + +#include "{}" const char* arbitrary_messages[] = {{ {} @@ -103,9 +112,11 @@ hint_t hints[] = {{ {} }}; -size_t CLSSES = {}; -int maximum_deaths = {}; -int turn_threshold_count = {}; +const size_t CLSSES = {}; +const int maximum_deaths = {}; +const int turn_threshold_count = {}; + +/* end */ """ def make_c_string(string): @@ -245,6 +256,7 @@ if __name__ == "__main__": db = yaml.load(f) h = h_template.format( + len(db["hints"]), get_refs(db["arbitrary_messages"]), get_refs(db["locations"]), get_refs(db["object_descriptions"]), @@ -269,3 +281,5 @@ if __name__ == "__main__": with open(c_name, "w") as cf: cf.write(c) + +# end