aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NorthstarDedicatedTest/convar.cpp2
-rw-r--r--NorthstarDedicatedTest/hooks.cpp18
-rw-r--r--NorthstarDedicatedTest/hookutils.cpp4
-rw-r--r--NorthstarDedicatedTest/modmanager.cpp2
4 files changed, 13 insertions, 13 deletions
diff --git a/NorthstarDedicatedTest/convar.cpp b/NorthstarDedicatedTest/convar.cpp
index ed7e8dac..de460662 100644
--- a/NorthstarDedicatedTest/convar.cpp
+++ b/NorthstarDedicatedTest/convar.cpp
@@ -20,7 +20,7 @@ ConVar* RegisterConVar(const char* name, const char* defaultValue, int flags, co
ConVar* newVar = new ConVar;
conVarConstructor(newVar, name, defaultValue, flags, helpString);
- g_CustomConvars.insert(std::make_pair(name, newVar));
+ g_CustomConvars.emplace(name, newVar);
return newVar;
}
diff --git a/NorthstarDedicatedTest/hooks.cpp b/NorthstarDedicatedTest/hooks.cpp
index 5723a8ab..19010e83 100644
--- a/NorthstarDedicatedTest/hooks.cpp
+++ b/NorthstarDedicatedTest/hooks.cpp
@@ -45,12 +45,12 @@ void InstallInitialHooks()
ENABLER_CREATEHOOK(hook, &LoadLibraryW, &LoadLibraryWHook, reinterpret_cast<LPVOID*>(&LoadLibraryWOriginal));
}
-char* cmdlineResult;
LPSTR GetCommandLineAHook()
{
+ static char* cmdlineModified;
static char* cmdlineOrg;
- if (cmdlineOrg == nullptr || cmdlineResult == nullptr)
+ if (cmdlineOrg == nullptr || cmdlineModified == nullptr)
{
cmdlineOrg = GetCommandLineAOriginal();
bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument
@@ -77,18 +77,18 @@ LPSTR GetCommandLineAHook()
}
auto len = args.length();
- cmdlineResult = reinterpret_cast<char*>(_malloc_base(len + 1));
- if (!cmdlineResult)
+ cmdlineModified = new char[len + 1];
+ if (!cmdlineModified)
{
spdlog::error("malloc failed for command line");
return cmdlineOrg;
}
- memcpy(cmdlineResult, args.c_str(), len + 1);
+ memcpy(cmdlineModified, args.c_str(), len + 1);
- spdlog::info("Command line: {}", cmdlineResult);
+ spdlog::info("Command line: {}", cmdlineModified);
}
- return cmdlineResult;
+ return cmdlineModified;
}
// dll load callback stuff
@@ -116,7 +116,7 @@ void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
{
for (auto& callbackStruct : dllLoadCallbacks)
{
- if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - strlen(callbackStruct->dll.c_str())), callbackStruct->dll.c_str()) != nullptr)
+ if (!callbackStruct->called && strstr(lpLibFileName + (strlen(lpLibFileName) - callbackStruct->dll.length()), callbackStruct->dll.c_str()) != nullptr)
{
callbackStruct->callback(moduleAddress);
callbackStruct->called = true;
@@ -130,7 +130,7 @@ void CallLoadLibraryWCallbacks(LPCWSTR lpLibFileName, HMODULE moduleAddress)
{
std::wstring wcharStrDll = std::wstring(callbackStruct->dll.begin(), callbackStruct->dll.end());
const wchar_t* callbackDll = wcharStrDll.c_str();
- if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcslen(callbackDll)), callbackDll) != nullptr)
+ if (!callbackStruct->called && wcsstr(lpLibFileName + (wcslen(lpLibFileName) - wcharStrDll.length()), callbackDll) != nullptr)
{
callbackStruct->callback(moduleAddress);
callbackStruct->called = true;
diff --git a/NorthstarDedicatedTest/hookutils.cpp b/NorthstarDedicatedTest/hookutils.cpp
index e86c671c..8ab24a3b 100644
--- a/NorthstarDedicatedTest/hookutils.cpp
+++ b/NorthstarDedicatedTest/hookutils.cpp
@@ -38,7 +38,7 @@ void HookEnabler::CreateHook(LPVOID ppTarget, LPVOID ppDetour, LPVOID* ppOrigina
else
{
if (targetName != nullptr)
- spdlog::error("MH_CreateHook failed for function %s", targetName);
+ spdlog::error("MH_CreateHook failed for function {}", targetName);
else
spdlog::error("MH_CreateHook failed for unknown function");
}
@@ -51,7 +51,7 @@ HookEnabler::~HookEnabler()
if (MH_EnableHook(hook->targetAddress) != MH_OK)
{
if (hook->targetName != nullptr)
- spdlog::error("MH_EnableHook failed for function %s", hook->targetName);
+ spdlog::error("MH_EnableHook failed for function {}", hook->targetName);
else
spdlog::error("MH_EnableHook failed for unknown function");
}
diff --git a/NorthstarDedicatedTest/modmanager.cpp b/NorthstarDedicatedTest/modmanager.cpp
index a9119075..92f32a43 100644
--- a/NorthstarDedicatedTest/modmanager.cpp
+++ b/NorthstarDedicatedTest/modmanager.cpp
@@ -309,7 +309,7 @@ void ModManager::LoadMods()
if (fs::is_regular_file(file))
{
std::string kvStr = file.path().lexically_relative(mod.ModDirectory / "keyvalues").lexically_normal().string();
- mod.KeyValues.insert(std::make_pair(std::hash<std::string>{}(kvStr), kvStr));
+ mod.KeyValues.emplace(std::hash<std::string>{}(kvStr), kvStr);
}
}
}