aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgeni <me@geni.site>2021-12-31 14:41:53 +0200
committergeni <me@geni.site>2021-12-31 14:41:53 +0200
commit07fbef738274518dfcc60da3a624d03eb09dc015 (patch)
tree6c6ede533cb1fe461d59bb8eeb3041cd29c2a5b1
parentae2f240d4f5e0d0c6da777838a42bd3e457d2711 (diff)
downloadNorthstarLauncher-07fbef738274518dfcc60da3a624d03eb09dc015.tar.gz
NorthstarLauncher-07fbef738274518dfcc60da3a624d03eb09dc015.zip
Clean up
-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);
}
}
}