X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=make_dungeon.py;h=bc8751d3707472ac23eb1f35b4d8ff57e4baf7f2;hb=0aa70d04cf0f4edaaf10f2894d9181caf521bce0;hp=b893e4b266cf6c8c862d04db450b8fda5ffcdde3;hpb=50bbbbceee15210951842f5bd88b66167f43c0ca;p=open-adventure.git diff --git a/make_dungeon.py b/make_dungeon.py index b893e4b..bc8751d 100755 --- a/make_dungeon.py +++ b/make_dungeon.py @@ -144,6 +144,11 @@ typedef struct {{ const long message; }} action_t; +typedef struct {{ + const string_group_t words; + const char* message; +}} special_t; + typedef struct {{ const long motion; const long cond; @@ -156,8 +161,6 @@ typedef struct {{ * inherited from FORTRAN, someday. To understand these, read the * encoding description for travel. */ -#define T_DESTINATION(entry) (entry).dest -#define T_CONDITION(entry) (entry).cond #define T_NODWARVES(entry) (T_CONDITION(entry) == 100) #define T_TERMINATE(entry) ((entry).motion == 1) #define L_SPEAK(loc) ((loc) - 500) @@ -172,7 +175,7 @@ extern const hint_t hints[]; extern long conditions[]; extern const motion_t motions[]; extern const action_t actions[]; -extern const action_t specials[]; +extern const special_t specials[]; extern const travelop_t travel[]; extern const long tkey[]; extern const char *ignore; @@ -263,7 +266,7 @@ const action_t actions[] = {{ {} }}; -const action_t specials[] = {{ +const special_t specials[] = {{ {} }}; @@ -558,6 +561,35 @@ def get_actions(actions): act_str = act_str[:-1] # trim trailing newline return act_str +def get_specials(specials): + template = """ {{ + .words = {}, + .message = {}, + }}, +""" + spc_str = "" + for special in specials: + contents = special[1] + + if contents["words"] == None: + words_str = get_string_group([]) + else: + words_str = get_string_group(contents["words"]) + + if contents["message"] == None: + message = "NULL" + else: + message = make_c_string(contents["message"]) + + spc_str += template.format(words_str, message) + global ignore + if contents.get("oldstyle", True) == False: + for word in contents["words"]: + if len(word) == 1: + ignore += word.upper() + spc_str = spc_str[:-1] # trim trailing newline + return spc_str + def bigdump(arr): out = "" for (i, entry) in enumerate(arr): @@ -724,7 +756,7 @@ if __name__ == "__main__": get_condbits(db["locations"]), get_motions(db["motions"]), get_actions(db["actions"]), - get_actions(db["specials"]), + get_specials(db["specials"]), bigdump(tkey), get_travel(travel), ignore,