From 57469f083e4a6af4a074dd58046025b976f0f790 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 7 Sep 2024 12:18:38 +0200 Subject: [PATCH] text: do not nuke all textstrings on level load Resolves #164. --- src/decomp/decomp.c | 2 +- src/decomp/stats.c | 6 ++--- src/game/game.c | 1 + src/game/inventory/common.c | 48 +++++++++++++++++++++++++++---------- src/game/overlay.c | 9 +++++++ src/game/overlay.h | 1 + src/inject_exec.c | 1 - 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/decomp/decomp.c b/src/decomp/decomp.c index 698c767d..5b1c343e 100644 --- a/src/decomp/decomp.c +++ b/src/decomp/decomp.c @@ -1374,7 +1374,7 @@ int32_t __cdecl Level_Initialise( Effect_InitialiseArray(); LOT_InitialiseArray(); Inv_InitColors(); - Text_Init(); + Overlay_HideGameInfo(); Overlay_InitialisePickUpDisplay(); S_InitialiseScreen(level_type); g_HealthBarTimer = 100; diff --git a/src/decomp/stats.c b/src/decomp/stats.c index b1f407e0..2ce353e5 100644 --- a/src/decomp/stats.c +++ b/src/decomp/stats.c @@ -2,6 +2,7 @@ #include "game/input.h" #include "game/music.h" +#include "game/overlay.h" #include "game/requester.h" #include "game/text.h" #include "global/funcs.h" @@ -309,7 +310,7 @@ int32_t __cdecl LevelStats(const int32_t level_num) TempVideoAdjust(g_HiRes, 1.0); FadeToPal(30, g_GamePalette8); - Text_Init(); + Overlay_HideGameInfo(); S_CopyScreenToBuffer(); while (g_Input & IN_SELECT) { @@ -357,8 +358,7 @@ int32_t __cdecl GameStats(const int32_t level_num) start->statistics.secrets = g_SaveGame.statistics.secrets; start->statistics.medipacks = g_SaveGame.statistics.medipacks; - Text_Init(); - + Overlay_HideGameInfo(); while (g_Input & IN_SELECT) { Input_Update(); } diff --git a/src/game/game.c b/src/game/game.c index 21a042d9..f1848547 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -286,6 +286,7 @@ int32_t __cdecl Game_Loop(const bool demo_mode) g_GameMode = GAMEMODE_NOT_IN_GAME; + Overlay_HideGameInfo(); S_Audio_Sample_OutCloseAllTracks(); Music_Stop(); diff --git a/src/game/inventory/common.c b/src/game/inventory/common.c index f2a9944c..f8470f9d 100644 --- a/src/game/inventory/common.c +++ b/src/game/inventory/common.c @@ -28,9 +28,40 @@ static TEXTSTRING *m_VersionText = NULL; +static void Inv_RemoveItemsText(void); +static void Inv_RemoveAllText(void); static void Inv_ShowItemQuantity(const char *fmt, int32_t qty); static void Inv_ShowAmmoQuantity(const char *fmt, int32_t qty); +static void Inv_RemoveItemsText(void) +{ + for (int32_t i = 0; i < 2; i++) { + Text_Remove(g_Inv_ItemText[i]); + g_Inv_ItemText[i] = NULL; + } +} + +static void Inv_RemoveAllText(void) +{ + Inv_RemoveItemsText(); + + Text_Remove(g_Inv_TagText); + g_Inv_TagText = NULL; + Text_Remove(g_Inv_RingText); + g_Inv_RingText = NULL; + Text_Remove(g_Inv_UpArrow1); + g_Inv_UpArrow1 = NULL; + Text_Remove(g_Inv_UpArrow2); + g_Inv_UpArrow2 = NULL; + Text_Remove(g_Inv_DownArrow1); + g_Inv_DownArrow1 = NULL; + Text_Remove(g_Inv_DownArrow2); + g_Inv_DownArrow2 = NULL; + + Text_Remove(m_VersionText); + m_VersionText = NULL; +} + static void Inv_ShowItemQuantity(const char *const fmt, const int32_t qty) { if (g_Inv_ItemText[1] == NULL && !g_SaveGame.bonus_flag) { @@ -156,8 +187,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) return 0; } - Text_Remove(g_AmmoTextInfo); - g_AmmoTextInfo = NULL; + Overlay_HideGameInfo(); Output_AlterFOV(80 * PHD_DEGREE); g_Inv_Mode = inventory_mode; @@ -210,7 +240,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) do { if (g_GF_OverrideDir != (GAME_FLOW_DIR)-1) { INVENTORY_ITEM *inv_item = ring.list[ring.current_object]; - Inv_RemoveInventoryText(); + Inv_RemoveAllText(); Option_ShutdownInventory(inv_item); return GFD_OVERRIDE; } @@ -717,7 +747,7 @@ int32_t __cdecl Inv_Display(int32_t inventory_mode) } } while (imo.status != RNG_DONE); - Inv_RemoveInventoryText(); + Inv_RemoveAllText(); S_FinishInventory(); g_Inv_IsActive = 0; @@ -1216,13 +1246,5 @@ void __cdecl Inv_RingNotActive(const INVENTORY_ITEM *const inv_item) void __cdecl Inv_RingActive(void) { - Inv_RemoveInventoryText(); -} - -void __cdecl Inv_RemoveInventoryText(void) -{ - for (int32_t i = 0; i < 2; i++) { - Text_Remove(g_Inv_ItemText[i]); - g_Inv_ItemText[i] = NULL; - } + Inv_RemoveItemsText(); } diff --git a/src/game/overlay.c b/src/game/overlay.c index 067ab95d..5b99ce50 100644 --- a/src/game/overlay.c +++ b/src/game/overlay.c @@ -133,6 +133,15 @@ void __cdecl Overlay_DrawAirBar(const bool flash_state) } } +void Overlay_HideGameInfo(void) +{ + Text_Remove(g_AmmoTextInfo); + g_AmmoTextInfo = NULL; + + Text_Remove(g_DisplayModeTextInfo); + g_DisplayModeTextInfo = NULL; +} + void __cdecl Overlay_MakeAmmoString(char *const string) { for (char *c = string; *c != '\0'; c++) { diff --git a/src/game/overlay.h b/src/game/overlay.h index a51ce197..d8636f15 100644 --- a/src/game/overlay.h +++ b/src/game/overlay.h @@ -7,6 +7,7 @@ void __cdecl Overlay_DrawAssaultTimer(void); void __cdecl Overlay_DrawGameInfo(bool pickup_state); void __cdecl Overlay_DrawHealthBar(bool flash_state); void __cdecl Overlay_DrawAirBar(bool flash_state); +void Overlay_HideGameInfo(void); void __cdecl Overlay_MakeAmmoString(char *string); void __cdecl Overlay_DrawAmmoInfo(void); void __cdecl Overlay_InitialisePickUpDisplay(void); diff --git a/src/inject_exec.c b/src/inject_exec.c index 0db95c41..5cf2d9f5 100644 --- a/src/inject_exec.c +++ b/src/inject_exec.c @@ -634,7 +634,6 @@ static void Inject_Inventory(const bool enable) INJECT(enable, 0x00424CB0, Inv_RemoveAllItems); INJECT(enable, 0x00424CD0, Inv_RemoveItem); INJECT(enable, 0x00424DE0, Inv_GetItemOption); - INJECT(enable, 0x00424FD0, Inv_RemoveInventoryText); INJECT(enable, 0x00425000, Inv_Ring_Init); INJECT(enable, 0x00425110, Inv_Ring_GetView); INJECT(enable, 0x00425170, Inv_Ring_Light);