1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 23:04:36 +01:00

Fix REPL write line on Linux

This commit is contained in:
Ted John
2021-02-13 00:15:27 +00:00
parent 05cb106ee7
commit 3f5698b1e0
15 changed files with 82 additions and 30 deletions

View File

@@ -9,6 +9,7 @@
#include "Console.hpp"
#include "../Context.h"
#include "../platform/platform.h"
#include <cstdio>
@@ -49,10 +50,16 @@ namespace Console
void WriteLine(const utf8* format, ...)
{
va_list args;
va_start(args, format);
auto formatLn = std::string(format) + "\n";
vfprintf(stdout, formatLn.c_str(), args);
char buffer[4096];
std::vsnprintf(buffer, sizeof(buffer), format, args);
auto ctx = OpenRCT2::GetContext();
if (ctx != nullptr)
ctx->WriteLine(buffer);
else
std::printf("%s\n", buffer);
va_end(args);
}
@@ -92,8 +99,13 @@ namespace Console
void WriteLine_VA(const utf8* format, va_list args)
{
auto formatLn = std::string(format) + "\n";
vfprintf(stdout, formatLn.c_str(), args);
char buffer[4096];
std::vsnprintf(buffer, sizeof(buffer), format, args);
auto ctx = OpenRCT2::GetContext();
if (ctx != nullptr)
ctx->WriteErrorLine(buffer);
else
std::printf("%s\n", buffer);
}
} // namespace Error
} // namespace Console