diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index fface938..dddf4c42 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -28,7 +28,7 @@ namespace Components if (!rawfile || Game::DB_IsXAssetDefault(Game::XAssetType::ASSET_TYPE_RAWFILE, this->filePath.data())) return; this->buffer.resize(Game::DB_GetRawFileLen(rawfile)); - Game::DB_GetRawBuffer(rawfile, const_cast(this->buffer.data()), this->buffer.size()); + Game::DB_GetRawBuffer(rawfile, this->buffer.data(), static_cast(this->buffer.size())); } FileSystem::FileReader::FileReader(const std::string& file) : handle(0), name(file) diff --git a/src/Components/Modules/Logger.cpp b/src/Components/Modules/Logger.cpp index f43724f3..605a5510 100644 --- a/src/Components/Modules/Logger.cpp +++ b/src/Components/Modules/Logger.cpp @@ -77,16 +77,14 @@ namespace Components std::string Logger::Format(const char** message) { - const size_t bufferSize = 0x10000; - Utils::Memory::Allocator allocator; - char* buffer = allocator.allocateArray(bufferSize); + char buffer[4096] = {0}; va_list ap = reinterpret_cast(const_cast(&message[1])); - //va_start(ap, *message); - _vsnprintf_s(buffer, bufferSize, bufferSize, *message, ap); + + _vsnprintf_s(buffer, _TRUNCATE, *message, ap); va_end(ap); - return buffer; + return {buffer}; } void Logger::Flush() @@ -138,8 +136,8 @@ namespace Components { if (!data) return; - std::string buffer(data); - for (auto& addr : Logger::LoggingAddresses[gLog & 1]) + const std::string buffer(data); + for (const auto& addr : Logger::LoggingAddresses[gLog & 1]) { Network::SendCommand(addr, "print", buffer); } @@ -373,9 +371,9 @@ namespace Components Logger::MessageMutex.unlock(); // Flush the console log - if (int fh = *reinterpret_cast(0x1AD8F28)) + if (const auto logfile = *reinterpret_cast(0x1AD8F28)) { - Game::FS_FCloseFile(fh); + Game::FS_FCloseFile(logfile); } } } diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 1448ebc3..c65f8cb1 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -341,7 +341,7 @@ namespace Game typedef int(__cdecl * FS_FOpenFileReadForThread_t)(const char *filename, int *file, int thread); extern FS_FOpenFileReadForThread_t FS_FOpenFileReadForThread; - typedef int(__cdecl * FS_FCloseFile_t)(int fh); + typedef int(__cdecl * FS_FCloseFile_t)(int stream); extern FS_FCloseFile_t FS_FCloseFile; typedef bool(__cdecl * FS_FileExists_t)(const char* file);