Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
libtrx: use new enum maps
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 29, 2024
1 parent 1933238 commit 397a7bc
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 36 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion src/config_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <libtrx/config/map.h>
// import order guard

#include "global/enum_str.h"
#include "global/types.h"

const CONFIG_OPTION g_ConfigOptionMap[] = {
Expand Down
10 changes: 5 additions & 5 deletions src/game/gameflow/gameflow_new.c
Original file line number Diff line number Diff line change
@@ -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 <libtrx/enum_map.h>
#include <libtrx/game/gameflow/types.h>
#include <libtrx/game/objects/names.h>
#include <libtrx/log.h>
Expand All @@ -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);
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/game/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "global/funcs.h"
#include "global/vars.h"

#include <libtrx/enum_map.h>
#include <libtrx/game/ui/common.h>
#include <libtrx/memory.h>

Expand All @@ -28,6 +29,7 @@ BOOL __cdecl Shell_Main(void)
g_GameSizerCopy = 1.0;

GameString_Init();
EnumMap_Init();
Config_Init();
UI_Init();

Expand Down Expand Up @@ -161,6 +163,7 @@ BOOL __cdecl Shell_Main(void)

S_SaveSettings();
GameBuf_Shutdown();
EnumMap_Shutdown();
GameString_Shutdown();
return true;
}
Expand Down
12 changes: 12 additions & 0 deletions src/global/enum_map.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <libtrx/enum_map.h>
#include <libtrx/game/objects/ids.h>

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 <libtrx/game/objects/ids.def>
}
Empty file added src/global/enum_map.def
Empty file.
3 changes: 0 additions & 3 deletions src/global/enum_str.c

This file was deleted.

14 changes: 0 additions & 14 deletions src/global/enum_str.def

This file was deleted.

11 changes: 0 additions & 11 deletions src/global/enum_str.h

This file was deleted.

2 changes: 1 addition & 1 deletion subprojects/libtrx

0 comments on commit 397a7bc

Please sign in to comment.