Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Gui/jkGUITitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ void jkGuiTitle_Shutdown()
// Added: clean reset
memset(jkGuiTitle_versionBuffer, 0, sizeof(jkGuiTitle_versionBuffer));
jkGuiTitle_loadPercent = 0;
for (int i = 0; i < 20; i++) // Added: the last level's loading-screen texts
{
if (jkGuiTitle_aTexts[i].str) {
STD_FREE(jkGuiTitle_aTexts[i].str);
jkGuiTitle_aTexts[i].str = NULL;
}
}
}

char jkGuiTitle_sub_4189A0(char *a1)
Expand Down Expand Up @@ -145,9 +152,9 @@ char16_t* jkGuiTitle_quicksave_related_func1(stdStrTable *strTable, char *jkl_fn
// Added: cleanup
for (int i = 0; i < 20; i++)
{
if (texts->str) {
STD_FREE(texts->str);
texts->str = NULL;
if (jkGuiTitle_aTexts[i].str) { // Added: each text (was texts[0] twenty times)
STD_FREE(jkGuiTitle_aTexts[i].str);
jkGuiTitle_aTexts[i].str = NULL;
}
}
_memset(jkGuiTitle_aTexts, 0, sizeof(jkGuiTitle_aTexts));
Expand Down
2 changes: 1 addition & 1 deletion src/Main/jkHudInv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ int jkHudInv_Shutdown()
jkHudInv_aBitmaps[2] = 0;
}

for (int i = 0; i < 100; i++)
for (int i = 0; i < SITHBIN_NUMBINS; i++) // Added: all the bins jkHudInv_LoadItemRes loads (was 100)
{
if ( (sithInventory_g_aTypes[i].flags & 0xA) != 0 && sithInventory_g_aTypes[i].hudBitmap )
{
Expand Down
13 changes: 6 additions & 7 deletions src/Platform/ESP32/Window_ESP32.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,16 @@ void Window_Main_Loop()

int jk_esp_engine_startup(const char* game_dir)
{
// Every engine global back to its boot value, as desktop's main.c does
// before each launch: tab5-emu runs the engine more than once per process.
// The session arrays (jk_esp_arrays_alloc, already made) keep their pointers
// and only have their contents zeroed (PLATFORM_SESSION_ARRAYS).
OpenJKDF2_Globals_Reset();

char cmdLine[256];
strncpy(cmdLine, jk_esp_engine_args(), sizeof(cmdLine) - 1);
cmdLine[sizeof(cmdLine) - 1] = 0;

Window_ESP32_ResetMsgHandlers(); // the table too, not only the count (see Window.c)
g_thing_two_some_dialog_count = 0;
g_should_exit = 0;
g_window_not_destroyed = 0;
g_hInstance = 0;
g_nShowCmd = 0;

// the engine opens everything relative to the working directory
if (game_dir && game_dir[0]) {
chdir(game_dir);
Expand Down
19 changes: 0 additions & 19 deletions src/Win95/Window.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,6 @@ int Window_RemoveMsgHandler(WindowHandler_t a1)
return 1;
}

#ifdef TARGET_ESP32
// Added: tab5-emu runs the engine more than once in a process. The handler
// table outlived a session (stdControl's handler is never removed, and
// jkGuiRend_Shutdown forgets the GUI's), but only the count was reset. The next
// session's adds were refused as duplicates, so dispatch, which visits
// g_handler_count slots, stopped before the GUI's handler. Keys and taps were
// ignored at the menus (only the on-screen pad still worked: jkGuiRend_UpdateController
// calls the GUI's handler directly), and Esc no longer opened the in-game menu.
void Window_ESP32_ResetMsgHandlers(void)
{
for (int i = 0; i < 16; i++)
{
Window_ext_handlers[i].handler = 0;
Window_ext_handlers[i].exists = 0;
}
g_handler_count = 0;
}
#endif

int Window_AddDialogHwnd(HWND a1)
{
int v1; // eax
Expand Down
3 changes: 0 additions & 3 deletions src/Win95/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ extern int Window_ySize;

int Window_AddMsgHandler(WindowHandler_t a1);
int Window_RemoveMsgHandler(WindowHandler_t a1);
#ifdef TARGET_ESP32
void Window_ESP32_ResetMsgHandlers(void);
#endif
int Window_AddDialogHwnd(HWND a1);
int Window_msg_main_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
int Window_Main(HINSTANCE hInstance, int a2, char *lpCmdLine, int nShowCmd, LPCSTR lpWindowName);
Expand Down