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

Commit

Permalink
shell: fix crash when opening console too early
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Sep 30, 2024
1 parent b2682f3 commit 5f7b2c1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/decomp/decomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ void __cdecl Shell_Shutdown(void)
if (g_ErrorMessage[0]) {
MessageBoxA(NULL, g_ErrorMessage, NULL, MB_ICONWARNING);
}
Text_Shutdown();
UI_Shutdown();
Config_Shutdown();
}
Expand All @@ -572,7 +573,6 @@ int16_t __cdecl TitleSequence(void)
{
GF_N_LoadStrings(-1);

Text_Init();
TempVideoAdjust(1, 1.0);
g_NoInputCounter = 0;

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

Expand All @@ -31,7 +32,9 @@ BOOL __cdecl Shell_Main(void)
GameString_Init();
EnumMap_Init();
Config_Init();
Text_Init();
UI_Init();
Console_Init();

Config_Read();
if (!S_InitialiseSystem()) {
Expand Down
9 changes: 3 additions & 6 deletions src/game/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ void __cdecl Text_Init(void)
for (int32_t i = 0; i < MAX_TEXTSTRINGS; i++) {
m_TextStrings[i].flags.all = 0;
}
}

// TODO: move me outta here!
// instead Text_Init should be only called once per game launch, and
// everyone should clean up after themselves rather than creating dangling
// pointers.
Console_Shutdown();
Console_Init();
void Text_Shutdown(void)
{
}

TEXTSTRING *__cdecl Text_Create(
Expand Down
2 changes: 2 additions & 0 deletions src/game/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define TEXT_MAX_STRING_SIZE 64

void __cdecl Text_Init(void);
void Text_Shutdown(void);

TEXTSTRING *__cdecl Text_Create(
int32_t x, int32_t y, int32_t z, const char *string);
void __cdecl Text_ChangeText(TEXTSTRING *string, const char *text);
Expand Down

0 comments on commit 5f7b2c1

Please sign in to comment.