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

Commit

Permalink
text: do not nuke all textstrings on level load
Browse files Browse the repository at this point in the history
Resolves #164.
  • Loading branch information
rr- committed Sep 9, 2024
1 parent b4120a0 commit 57469f0
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/decomp/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions src/game/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
48 changes: 35 additions & 13 deletions src/game/inventory/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}
9 changes: 9 additions & 0 deletions src/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
1 change: 1 addition & 0 deletions src/game/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/inject_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 57469f0

Please sign in to comment.