Skip to content

Commit

Permalink
Removed duplicated stringPrintF util function.
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC committed Sep 21, 2024
1 parent 4f49346 commit c01ac6c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 25 deletions.
8 changes: 4 additions & 4 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,13 @@ namespace CLEO

if (str != nullptr && (size_t)str <= CCustomOpcodeSystem::MinValidAddress)
{
CCustomOpcodeSystem::lastErrorMsg = stringPrintf("Writing string from invalid '0x%X' pointer", target.data);
CCustomOpcodeSystem::lastErrorMsg = StringPrintf("Writing string from invalid '0x%X' pointer", target.data);
return false;
}

if ((size_t)target.data <= CCustomOpcodeSystem::MinValidAddress)
{
CCustomOpcodeSystem::lastErrorMsg = stringPrintf("Writing string into invalid '0x%X' pointer argument", target.data);
CCustomOpcodeSystem::lastErrorMsg = StringPrintf("Writing string into invalid '0x%X' pointer argument", target.data);
return false;
}

Expand Down Expand Up @@ -428,7 +428,7 @@ namespace CLEO

if (opcodeParams[0].dwParam <= CCustomOpcodeSystem::MinValidAddress)
{
CCustomOpcodeSystem::lastErrorMsg = stringPrintf("Writing string into invalid '0x%X' pointer argument", opcodeParams[0].dwParam);
CCustomOpcodeSystem::lastErrorMsg = StringPrintf("Writing string into invalid '0x%X' pointer argument", opcodeParams[0].dwParam);
return result; // error
}

Expand Down Expand Up @@ -465,7 +465,7 @@ namespace CLEO
}
}

CCustomOpcodeSystem::lastErrorMsg = stringPrintf("Writing string, got argument %s", ToKindStr(paramType));
CCustomOpcodeSystem::lastErrorMsg = StringPrintf("Writing string, got argument %s", ToKindStr(paramType));
CLEO_SkipOpcodeParams(thread, 1); // skip unhandled param
return result; // error
}
Expand Down
17 changes: 0 additions & 17 deletions source/CDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@
CDebug Debug;
using namespace CLEO;

std::string stringPrintf(const char* format, ...)
{
va_list args;

va_start(args, format);
auto len = std::vsnprintf(nullptr, 0, format, args) + 1;
va_end(args);

std::string result(len, '\0');

va_start(args, format);
std::vsnprintf(result.data(), result.length(), format, args);
va_end(args);

return result;
}

void CDebug::Trace(CLEO::eLogLevel level, const char* msg)
{
std::lock_guard<std::mutex> guard(mutex);
Expand Down
2 changes: 0 additions & 2 deletions source/CDebug.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#pragma once
#include <mutex>

std::string stringPrintf(const char* format, ...);

namespace CLEO
{
class CRunningScript;
Expand Down
4 changes: 2 additions & 2 deletions source/CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ namespace CLEO
}
else // mission pack
{
MainScriptFileDir = Filepath_User + stringPrintf("\\MPACK\\MPACK%d", CGame::bMissionPackGame);
MainScriptFileDir = Filepath_User + StringPrintf("\\MPACK\\MPACK%d", CGame::bMissionPackGame);
MainScriptFileName = "scr.scm";
}

Expand Down Expand Up @@ -1066,7 +1066,7 @@ namespace CLEO

if(saveSlot == -1) return;

auto saveFile = FS::path(Filepath_Cleo).append(stringPrintf("cleo_saves\\cs%d.sav", saveSlot)).string();
auto saveFile = FS::path(Filepath_Cleo).append(StringPrintf("cleo_saves\\cs%d.sav", saveSlot)).string();

safe_info = nullptr;
stopped_info = nullptr;
Expand Down

0 comments on commit c01ac6c

Please sign in to comment.