mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-10 17:42:29 +01:00
Windows: Call FreeConsole if one was attached.
This commit is contained in:
@@ -204,6 +204,7 @@ datetime64 platform_get_datetime_now_utc();
|
||||
#undef GetMessage
|
||||
|
||||
void platform_windows_open_console();
|
||||
void platform_windows_close_console();
|
||||
int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset);
|
||||
HWND windows_get_window_handle();
|
||||
void platform_setup_file_associations();
|
||||
|
||||
@@ -639,6 +639,10 @@ void platform_free()
|
||||
|
||||
platform_close_window();
|
||||
SDL_Quit();
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
platform_windows_close_console();
|
||||
#endif
|
||||
}
|
||||
|
||||
void platform_start_text_input(utf8* buffer, int max_length)
|
||||
|
||||
@@ -42,8 +42,9 @@
|
||||
// The name of the mutex used to prevent multiple instances of the game from running
|
||||
#define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX"
|
||||
|
||||
utf8 _userDataDirectoryPath[MAX_PATH] = { 0 };
|
||||
utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 };
|
||||
static utf8 _userDataDirectoryPath[MAX_PATH] = { 0 };
|
||||
static utf8 _openrctDataDirectoryPath[MAX_PATH] = { 0 };
|
||||
static bool _consoleIsAttached = false;
|
||||
|
||||
utf8 **windows_get_command_line_args(int *outNumArgs);
|
||||
|
||||
@@ -146,12 +147,23 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
|
||||
void platform_windows_open_console()
|
||||
{
|
||||
if (!AttachConsole(ATTACH_PARENT_PROCESS)) {
|
||||
AllocConsole();
|
||||
if (!AllocConsole()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
freopen("CONIN$", "r", stdin);
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
freopen("CONOUT$", "w", stderr);
|
||||
_consoleIsAttached = true;
|
||||
}
|
||||
|
||||
void platform_windows_close_console()
|
||||
{
|
||||
if (_consoleIsAttached) {
|
||||
_consoleIsAttached = false;
|
||||
FreeConsole();
|
||||
}
|
||||
}
|
||||
|
||||
utf8 **windows_get_command_line_args(int *outNumArgs)
|
||||
|
||||
Reference in New Issue
Block a user