[Logger] Recycle length from _snprintf_

This commit is contained in:
Diavolo 2022-06-26 22:01:11 +02:00
parent e2170e96c2
commit f7cb8da352
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5

View File

@ -144,12 +144,14 @@ namespace Components
void Logger::NetworkLog(const char* data, bool gLog)
{
if (!data) return;
if (data == nullptr)
{
return;
}
const std::string buffer(data);
for (const auto& addr : Logger::LoggingAddresses[gLog & 1])
{
Network::SendCommand(addr, "print", buffer);
Network::SendCommand(addr, "print", data);
}
}
@ -167,12 +169,12 @@ namespace Components
const auto tens = Game::level->time / 1000 % 60 / 10;
const auto sec = Game::level->time / 1000 % 60 % 10;
_snprintf_s(string, _TRUNCATE, "%3i:%i%i %s",
const auto len = _snprintf_s(string, _TRUNCATE, "%3i:%i%i %s",
min, tens, sec, string2);
if (Game::level->logFile != nullptr)
{
Game::FS_Write(string, &string[std::strlen(string) + 1] - &string[1], reinterpret_cast<int>(Game::level->logFile));
Game::FS_Write(string, len, reinterpret_cast<int>(Game::level->logFile));
}
// Allow the network log to run even if logFile was not opened