From dd58a710ee1a4725117feeae5d67d7df4f027082 Mon Sep 17 00:00:00 2001 From: Ted John Date: Tue, 24 Apr 2018 23:30:53 +0100 Subject: [PATCH] Make Console::Write functions atomic --- src/openrct2/core/Console.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/openrct2/core/Console.cpp b/src/openrct2/core/Console.cpp index 9887f920e7..2bf9ebc72e 100644 --- a/src/openrct2/core/Console.cpp +++ b/src/openrct2/core/Console.cpp @@ -15,6 +15,7 @@ #pragma endregion #include +#include #include "Console.hpp" #include "../platform/platform.h" @@ -33,10 +34,8 @@ namespace Console void WriteSpace(size_t count) { - for (size_t i = 0; i < count; i++) - { - Write(' '); - } + std::string sz(count, ' '); + Write(sz.c_str()); } void WriteFormat(const utf8 * format, ...) @@ -58,8 +57,8 @@ namespace Console va_list args; va_start(args, format); - vfprintf(stdout, format, args); - puts(""); + auto formatLn = std::string(format) + "\n"; + vfprintf(stdout, formatLn.c_str(), args); va_end(args); } @@ -99,8 +98,8 @@ namespace Console void WriteLine_VA(const utf8 * format, va_list args) { - vfprintf(stdout, format, args); - puts(""); + auto formatLn = std::string(format) + "\n"; + vfprintf(stdout, formatLn.c_str(), args); } } }