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
4 changes: 4 additions & 0 deletions src/Devices/sithConsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ int sithConsole_Startup(int maxCmds)
{
sithConsole_maxCmds = maxCmds;
_memset(sithConsole_aCmds, 0, sizeof(stdDebugConsoleCmd) * maxCmds);
// Added: the count outlived the array; a second engine session in one
// process registered on top of the first one's count, and from the
// third on every command (cheats included) was refused as "full"
sithConsole_numRegisteredCmds = 0;
DebugGui_fnPrint = 0;
DebugGui_fnPrintUniStr = 0;
sithCommand_Startup();
Expand Down
1 change: 1 addition & 0 deletions src/Main/jkDev.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void jkDev_Startup()

jkDev_cheatHashtable = stdHashtbl_New(JKDEV_NUM_CHEATS*2);
_memset(jkDev_aCheatCmds, 0, sizeof(stdDebugConsoleCmd) * JKDEV_NUM_CHEATS);
jkDev_numCheats = 0; // Added: like sithConsole's count, it outlived the table

sithConsole_RegisterCommand(jkDev_CmdVersion, "version", 0);
sithConsole_RegisterCommand(jkDev_CmdTeam, "team", 0);
Expand Down
2 changes: 1 addition & 1 deletion src/Platform/ESP32/Window_ESP32.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int jk_esp_engine_startup(const char* game_dir)
strncpy(cmdLine, jk_esp_engine_args(), sizeof(cmdLine) - 1);
cmdLine[sizeof(cmdLine) - 1] = 0;

g_handler_count = 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;
Expand Down
19 changes: 19 additions & 0 deletions src/Win95/Window.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ 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: 3 additions & 0 deletions src/Win95/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ 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