Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed duplicated stringPrintF util function. #209

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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