Fix debugger on Windows

This commit is contained in:
kichikuou
2024-12-28 14:09:57 +09:00
parent 2b61798f99
commit 0841f36dfc
2 changed files with 15 additions and 4 deletions
+8
View File
@@ -10,6 +10,10 @@
#include "nact.h"
#include "ags.h"
#include "debugger/debugger.h"
#ifdef _WIN32
#include <fcntl.h>
#include <io.h>
#endif
using Json = nlohmann::json;
namespace debugger {
@@ -58,6 +62,10 @@ int read_command_thread(void*) {
class DapFrontend : public Frontend {
public:
DapFrontend(Debugger* backend, const DebugInfo& symbols) : Frontend(backend, symbols) {
#ifdef _WIN32
_setmode(_fileno(stdin), _O_BINARY);
_setmode(_fileno(stdout), _O_BINARY);
#endif
SDL_CreateThread(read_command_thread, "Debugger", NULL);
}
+7 -4
View File
@@ -41,13 +41,13 @@ void init_menu(bool mouse_move_enabled, const Config& config)
void init_console(int sys_ver)
{
#if defined(_DEBUG_CONSOLE)
AllocConsole();
freopen("CONOUT$", "w", stdout);
char title[] = "SYSTEM1 NACT Tracer";
freopen("CONOUT$", "w", stderr);
freopen("CONIN$", "r", stdin);
char title[] = "SYSTEM1 Debug Console";
title[6] = '0' + sys_ver;
SetConsoleTitle(title);
#endif
}
void save_screenshot(AGS* ags)
@@ -138,7 +138,10 @@ void NACT::text_dialog()
void NACT::platform_initialize()
{
init_menu(mouse_move_enabled, config);
init_console(game_id.sys_ver);
#ifndef _DEBUG_CONSOLE
if (config.debugger_mode == DebuggerMode::CLI)
#endif
init_console(game_id.sys_ver);
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
}