diff --git a/meson.build b/meson.build index c87f17f..28b6d8b 100644 --- a/meson.build +++ b/meson.build @@ -169,7 +169,7 @@ dll_sources = [ 'src/game/ui/widgets/label.c', 'src/game/ui/widgets/prompt.c', 'src/game/ui/widgets/window.c', - 'src/global/enum_str.c', + 'src/global/enum_map.c', 'src/global/vars.c', 'src/inject_exec.c', 'src/inject_util.c', diff --git a/src/config_map.c b/src/config_map.c index a6e431f..82a3299 100644 --- a/src/config_map.c +++ b/src/config_map.c @@ -6,7 +6,6 @@ #include // import order guard -#include "global/enum_str.h" #include "global/types.h" const CONFIG_OPTION g_ConfigOptionMap[] = { diff --git a/src/game/gameflow/gameflow_new.c b/src/game/gameflow/gameflow_new.c index 174bb99..d8c39cf 100644 --- a/src/game/gameflow/gameflow_new.c +++ b/src/game/gameflow/gameflow_new.c @@ -1,10 +1,10 @@ #include "game/gameflow/gameflow_new.h" #include "game/game_string.h" -#include "global/enum_str.h" #include "global/types.h" #include "global/vars.h" +#include #include #include #include @@ -21,10 +21,10 @@ static void M_LoadGameStrings(const int32_t level_num); static void M_LoadObjectString(const char *const key, const char *const value) { - const GAME_OBJECT_ID object = - ENUM_STRING_GET(GAME_OBJECT_ID, key, NO_OBJECT); - if (object != NO_OBJECT) { - Object_SetName(object, value); + const GAME_OBJECT_ID object_id = + ENUM_MAP_GET(GAME_OBJECT_ID, key, NO_OBJECT); + if (object_id != NO_OBJECT) { + Object_SetName(object_id, value); } } diff --git a/src/game/shell.c b/src/game/shell.c index 13ca488..1f6eeee 100644 --- a/src/game/shell.c +++ b/src/game/shell.c @@ -13,6 +13,7 @@ #include "global/funcs.h" #include "global/vars.h" +#include #include #include @@ -28,6 +29,7 @@ BOOL __cdecl Shell_Main(void) g_GameSizerCopy = 1.0; GameString_Init(); + EnumMap_Init(); Config_Init(); UI_Init(); @@ -161,6 +163,7 @@ BOOL __cdecl Shell_Main(void) S_SaveSettings(); GameBuf_Shutdown(); + EnumMap_Shutdown(); GameString_Shutdown(); return true; } diff --git a/src/global/enum_map.c b/src/global/enum_map.c new file mode 100644 index 0000000..1acba19 --- /dev/null +++ b/src/global/enum_map.c @@ -0,0 +1,12 @@ +#include +#include + +void EnumMap_Init(void) +{ +#include "global/enum_map.def" + +#undef OBJ_ID_DEFINE +#define OBJ_ID_DEFINE(object_id, value) \ + EnumMap_Define("GAME_OBJECT_ID", object_id, #object_id); +#include +} diff --git a/src/global/enum_map.def b/src/global/enum_map.def new file mode 100644 index 0000000..e69de29 diff --git a/src/global/enum_str.c b/src/global/enum_str.c deleted file mode 100644 index c516b12..0000000 --- a/src/global/enum_str.c +++ /dev/null @@ -1,3 +0,0 @@ -#define ENUM_STR_IMPL - -#include "global/enum_str.h" diff --git a/src/global/enum_str.def b/src/global/enum_str.def deleted file mode 100644 index 02c6835..0000000 --- a/src/global/enum_str.def +++ /dev/null @@ -1,14 +0,0 @@ -// TODO: this is garbage -#ifdef ENUM_STR_IMPL -#define OBJ_NAME_DEFINE(id, str) \ - { \ - #id, \ - id, \ - }, -ENUM_STRING_MAP ENUM_STRING_MAP(GAME_OBJECT_ID)[] = { -#include - { NULL, -1 } -}; -#else -extern ENUM_STRING_MAP ENUM_STRING_MAP(GAME_OBJECT_ID)[]; -#endif diff --git a/src/global/enum_str.h b/src/global/enum_str.h deleted file mode 100644 index 44793bf..0000000 --- a/src/global/enum_str.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -// import order guard -#include -// import order guard - -// import order guard -#include "global/types.h" -// import order guard - -#include "global/enum_str.def" diff --git a/subprojects/libtrx b/subprojects/libtrx index ba38d9e..3e51422 160000 --- a/subprojects/libtrx +++ b/subprojects/libtrx @@ -1 +1 @@ -Subproject commit ba38d9e762ea7320e896e4eb02a9e382ce55f40b +Subproject commit 3e51422534f81fcc3178bb9516567ed0b15b8618