aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-06-29 04:22:33 +0100
committerGitHub <noreply@github.com>2023-06-28 23:22:33 -0400
commitefd907105cf7906c78253631f75bf4fd83f769db (patch)
tree0516853204106852adb06ee1d69a74e8994309a0 /NorthstarDLL
parentb5c4e4e7ed81394070b05296ed087b6043d27667 (diff)
downloadNorthstarLauncher-efd907105cf7906c78253631f75bf4fd83f769db.tar.gz
NorthstarLauncher-efd907105cf7906c78253631f75bf4fd83f769db.zip
* turn implicit type casts into standard compliant explicit type casts * correct includes and library names * correct implicit use of std-namespaced functions * turn incomplete virtual implementations into pure virtuals (this also follows what the Source SDK tier0 header does) * define SqRecurseArgs ahead of implementation to fix templating problems * switch out removed getentity with getthisentity * fix calls to curl_easy_escape with wrong types * replace winapi-specific function with std starts_with function * format squirrel header
Diffstat (limited to 'NorthstarDLL')
-rw-r--r--NorthstarDLL/CMakeLists.txt2
-rw-r--r--NorthstarDLL/core/convar/concommand.cpp2
-rw-r--r--NorthstarDLL/core/convar/convar.cpp12
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.cpp6
-rw-r--r--NorthstarDLL/core/filesystem/rpakfilesystem.cpp6
-rw-r--r--NorthstarDLL/core/hooks.cpp10
-rw-r--r--NorthstarDLL/core/hooks.h2
-rw-r--r--NorthstarDLL/core/math/vector.h4
-rw-r--r--NorthstarDLL/core/tier0.h28
-rw-r--r--NorthstarDLL/dedicated/dedicated.cpp2
-rw-r--r--NorthstarDLL/engine/r2engine.h16
-rw-r--r--NorthstarDLL/logging/sourceconsole.cpp2
-rw-r--r--NorthstarDLL/masterserver/masterserver.cpp22
-rw-r--r--NorthstarDLL/plugins/plugins.cpp2
-rw-r--r--NorthstarDLL/squirrel/squirrel.h15
15 files changed, 73 insertions, 58 deletions
diff --git a/NorthstarDLL/CMakeLists.txt b/NorthstarDLL/CMakeLists.txt
index f9d61a2c..697cd8d8 100644
--- a/NorthstarDLL/CMakeLists.txt
+++ b/NorthstarDLL/CMakeLists.txt
@@ -148,7 +148,7 @@ add_library(NorthstarDLL SHARED
target_link_libraries(NorthstarDLL PRIVATE
${CMAKE_SOURCE_DIR}/include/MinHook.x64.lib
${CMAKE_SOURCE_DIR}/include/libcurl/lib/libcurl_a.lib
- Ws2_32.lib
+ WS2_32.lib
Crypt32.lib
Cryptui.lib
dbghelp.lib
diff --git a/NorthstarDLL/core/convar/concommand.cpp b/NorthstarDLL/core/convar/concommand.cpp
index 82594f04..ce198159 100644
--- a/NorthstarDLL/core/convar/concommand.cpp
+++ b/NorthstarDLL/core/convar/concommand.cpp
@@ -151,5 +151,5 @@ ON_DLL_LOAD("engine.dll", ConCommand, (CModule module))
ConCommandConstructor = module.Offset(0x415F60).As<ConCommandConstructorType>();
AddMiscConCommands();
- g_pPluginCommunicationhandler->m_sEngineData.ConCommandConstructor = ConCommandConstructor;
+ g_pPluginCommunicationhandler->m_sEngineData.ConCommandConstructor = (void*)ConCommandConstructor;
}
diff --git a/NorthstarDLL/core/convar/convar.cpp b/NorthstarDLL/core/convar/convar.cpp
index d4efc1a0..5069192e 100644
--- a/NorthstarDLL/core/convar/convar.cpp
+++ b/NorthstarDLL/core/convar/convar.cpp
@@ -40,10 +40,10 @@ ON_DLL_LOAD("engine.dll", ConVar, (CModule module))
R2::g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007");
R2::g_pCVar = *R2::g_pCVarInterface;
- g_pPluginCommunicationhandler->m_sEngineData.conVarMalloc = conVarMalloc;
- g_pPluginCommunicationhandler->m_sEngineData.conVarRegister = conVarRegister;
- g_pPluginCommunicationhandler->m_sEngineData.ConVar_Vtable = g_pConVar_Vtable;
- g_pPluginCommunicationhandler->m_sEngineData.IConVar_Vtable = g_pIConVar_Vtable;
+ g_pPluginCommunicationhandler->m_sEngineData.conVarMalloc = (void*)conVarMalloc;
+ g_pPluginCommunicationhandler->m_sEngineData.conVarRegister = (void*)conVarRegister;
+ g_pPluginCommunicationhandler->m_sEngineData.ConVar_Vtable = (void*)g_pConVar_Vtable;
+ g_pPluginCommunicationhandler->m_sEngineData.IConVar_Vtable = (void*)g_pIConVar_Vtable;
}
//-----------------------------------------------------------------------------
@@ -80,7 +80,7 @@ ConVar::ConVar(
this->m_ConCommandBase.s_pConCommandBases = (ConCommandBase*)g_pIConVar_Vtable;
conVarMalloc(&this->m_pMalloc, 0, 0); // Allocate new memory for ConVar.
- conVarRegister(this, pszName, pszDefaultValue, nFlags, pszHelpString, bMin, fMin, bMax, fMax, pCallback);
+ conVarRegister(this, pszName, pszDefaultValue, nFlags, pszHelpString, bMin, fMin, bMax, fMax, (void*)pCallback);
}
//-----------------------------------------------------------------------------
@@ -321,7 +321,7 @@ void ConVar::SetValue(const char* pszValue)
{
// Not a color, do the standard thing
float flNewValue = (float)atof(pszValue);
- if (!isfinite(flNewValue))
+ if (!std::isfinite(flNewValue))
{
spdlog::warn("Warning: ConVar '{}' = '{}' is infinite, clamping value.\n", GetBaseName(), pszValue);
flNewValue = FLT_MAX;
diff --git a/NorthstarDLL/core/filesystem/filesystem.cpp b/NorthstarDLL/core/filesystem/filesystem.cpp
index 88622e5d..d9c70476 100644
--- a/NorthstarDLL/core/filesystem/filesystem.cpp
+++ b/NorthstarDLL/core/filesystem/filesystem.cpp
@@ -179,7 +179,7 @@ ON_DLL_LOAD("filesystem_stdio.dll", Filesystem, (CModule module))
R2::g_pFilesystem = new SourceInterface<IFileSystem>("filesystem_stdio.dll", "VFileSystem017");
- AddSearchPathHook.Dispatch((*g_pFilesystem)->m_vtable->AddSearchPath);
- ReadFromCacheHook.Dispatch((*g_pFilesystem)->m_vtable->ReadFromCache);
- MountVPKHook.Dispatch((*g_pFilesystem)->m_vtable->MountVPK);
+ AddSearchPathHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->AddSearchPath);
+ ReadFromCacheHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->ReadFromCache);
+ MountVPKHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->MountVPK);
}
diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
index c863463c..e42d6826 100644
--- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
+++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
@@ -341,7 +341,7 @@ ON_DLL_LOAD("engine.dll", RpakFilesystem, (CModule module))
g_pakLoadApi = module.Offset(0x5BED78).Deref().As<PakLoadFuncs*>();
pUnknownPakLoadSingleton = module.Offset(0x7C5E20).As<void**>();
- LoadPakAsyncHook.Dispatch(g_pakLoadApi->LoadPakAsync);
- UnloadPakHook.Dispatch(g_pakLoadApi->UnloadPak);
- ReadFileAsyncHook.Dispatch(g_pakLoadApi->ReadFileAsync);
+ LoadPakAsyncHook.Dispatch((LPVOID*)g_pakLoadApi->LoadPakAsync);
+ UnloadPakHook.Dispatch((LPVOID*)g_pakLoadApi->UnloadPak);
+ ReadFileAsyncHook.Dispatch((LPVOID*)g_pakLoadApi->ReadFileAsync);
}
diff --git a/NorthstarDLL/core/hooks.cpp b/NorthstarDLL/core/hooks.cpp
index 9124d5af..4363c0e2 100644
--- a/NorthstarDLL/core/hooks.cpp
+++ b/NorthstarDLL/core/hooks.cpp
@@ -218,7 +218,7 @@ void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFun
spdlog::error("MH_CreateHook failed for function {}", pStrippedFuncName);
}
-AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, GetCommandLineA, LPSTR, WINAPI, ())
+AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, (LPVOID)GetCommandLineA, LPSTR, WINAPI, ())
{
static char* cmdlineModified;
static char* cmdlineOrg;
@@ -386,7 +386,7 @@ void CallAllPendingDLLLoadCallbacks()
}
// clang-format off
-AUTOHOOK_ABSOLUTEADDR(_LoadLibraryExA, LoadLibraryExA,
+AUTOHOOK_ABSOLUTEADDR(_LoadLibraryExA, (LPVOID)LoadLibraryExA,
HMODULE, WINAPI, (LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags))
// clang-format on
{
@@ -415,7 +415,7 @@ HMODULE, WINAPI, (LPCSTR lpLibFileName, HANDLE hFile, DWORD dwFlags))
}
// clang-format off
-AUTOHOOK_ABSOLUTEADDR(_LoadLibraryA, LoadLibraryA,
+AUTOHOOK_ABSOLUTEADDR(_LoadLibraryA, (LPVOID)LoadLibraryA,
HMODULE, WINAPI, (LPCSTR lpLibFileName))
// clang-format on
{
@@ -428,7 +428,7 @@ HMODULE, WINAPI, (LPCSTR lpLibFileName))
}
// clang-format off
-AUTOHOOK_ABSOLUTEADDR(_LoadLibraryExW, LoadLibraryExW,
+AUTOHOOK_ABSOLUTEADDR(_LoadLibraryExW, (LPVOID)LoadLibraryExW,
HMODULE, WINAPI, (LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags))
// clang-format on
{
@@ -441,7 +441,7 @@ HMODULE, WINAPI, (LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags))
}
// clang-format off
-AUTOHOOK_ABSOLUTEADDR(_LoadLibraryW, LoadLibraryW,
+AUTOHOOK_ABSOLUTEADDR(_LoadLibraryW, (LPVOID)LoadLibraryW,
HMODULE, WINAPI, (LPCWSTR lpLibFileName))
// clang-format on
{
diff --git a/NorthstarDLL/core/hooks.h b/NorthstarDLL/core/hooks.h
index d2cb7602..8721628a 100644
--- a/NorthstarDLL/core/hooks.h
+++ b/NorthstarDLL/core/hooks.h
@@ -197,7 +197,7 @@ class __autohook
case PROCADDRESS:
{
- targetAddr = GetProcAddress(GetModuleHandleA(pModuleName), pProcName);
+ targetAddr = (LPVOID)GetProcAddress(GetModuleHandleA(pModuleName), pProcName);
break;
}
}
diff --git a/NorthstarDLL/core/math/vector.h b/NorthstarDLL/core/math/vector.h
index 95eae7ca..112fabdf 100644
--- a/NorthstarDLL/core/math/vector.h
+++ b/NorthstarDLL/core/math/vector.h
@@ -1,3 +1,5 @@
+#include <cmath>
+
#pragma once
union Vector3
@@ -21,7 +23,7 @@ union Vector3
void MakeValid()
{
for (auto& fl : raw)
- if (isnan(fl))
+ if (std::isnan(fl))
fl = 0;
}
diff --git a/NorthstarDLL/core/tier0.h b/NorthstarDLL/core/tier0.h
index 92a63027..eebe98f2 100644
--- a/NorthstarDLL/core/tier0.h
+++ b/NorthstarDLL/core/tier0.h
@@ -29,23 +29,23 @@ namespace Tier0
public:
// based on the defs in the 2013 source sdk, but for some reason has an extra function (may be another CreateCmdLine overload?)
// these seem to line up with what they should be though
- virtual void CreateCmdLine(const char* commandline) {}
- virtual void CreateCmdLine(int argc, char** argv) {}
- virtual void unknown() {}
- virtual const char* GetCmdLine(void) const {}
+ virtual void CreateCmdLine(const char* commandline) = 0;
+ virtual void CreateCmdLine(int argc, char** argv) = 0;
+ virtual void unknown() = 0;
+ virtual const char* GetCmdLine(void) const = 0;
- virtual const char* CheckParm(const char* psz, const char** ppszValue = 0) const {}
- virtual void RemoveParm() const {}
- virtual void AppendParm(const char* pszParm, const char* pszValues) {}
+ virtual const char* CheckParm(const char* psz, const char** ppszValue = 0) const = 0;
+ virtual void RemoveParm() const = 0;
+ virtual void AppendParm(const char* pszParm, const char* pszValues) = 0;
- virtual const char* ParmValue(const char* psz, const char* pDefaultVal = 0) const {}
- virtual int ParmValue(const char* psz, int nDefaultVal) const {}
- virtual float ParmValue(const char* psz, float flDefaultVal) const {}
+ virtual const char* ParmValue(const char* psz, const char* pDefaultVal = 0) const = 0;
+ virtual int ParmValue(const char* psz, int nDefaultVal) const = 0;
+ virtual float ParmValue(const char* psz, float flDefaultVal) const = 0;
- virtual int ParmCount() const {}
- virtual int FindParm(const char* psz) const {}
- virtual const char* GetParm(int nIndex) const {}
- virtual void SetParm(int nIndex, char const* pParm) {}
+ virtual int ParmCount() const = 0;
+ virtual int FindParm(const char* psz) const = 0;
+ virtual const char* GetParm(int nIndex) const = 0;
+ virtual void SetParm(int nIndex, char const* pParm) = 0;
// virtual const char** GetParms() const {}
};
diff --git a/NorthstarDLL/dedicated/dedicated.cpp b/NorthstarDLL/dedicated/dedicated.cpp
index 1aff0f34..a28de0ec 100644
--- a/NorthstarDLL/dedicated/dedicated.cpp
+++ b/NorthstarDLL/dedicated/dedicated.cpp
@@ -1,7 +1,7 @@
#include "dedicated.h"
#include "dedicatedlogtoclient.h"
#include "core/tier0.h"
-#include "playlist.h"
+#include "shared/playlist.h"
#include "engine/r2engine.h"
#include "engine/hoststate.h"
#include "server/auth/serverauthentication.h"
diff --git a/NorthstarDLL/engine/r2engine.h b/NorthstarDLL/engine/r2engine.h
index ff8876b8..df0cda74 100644
--- a/NorthstarDLL/engine/r2engine.h
+++ b/NorthstarDLL/engine/r2engine.h
@@ -82,14 +82,14 @@ namespace R2
class CEngine
{
public:
- virtual void unknown() {} // unsure if this is where
- virtual bool Load(bool dedicated, const char* baseDir) {}
- virtual void Unload() {}
- virtual void SetNextState(EngineState_t iNextState) {}
- virtual EngineState_t GetState() {}
- virtual void Frame() {}
- virtual double GetFrameTime() {}
- virtual float GetCurTime() {}
+ virtual void unknown() = 0; // unsure if this is where
+ virtual bool Load(bool dedicated, const char* baseDir) = 0;
+ virtual void Unload() = 0;
+ virtual void SetNextState(EngineState_t iNextState) = 0;
+ virtual EngineState_t GetState() = 0;
+ virtual void Frame() = 0;
+ virtual double GetFrameTime() = 0;
+ virtual float GetCurTime() = 0;
EngineQuitState m_nQuitting;
EngineState_t m_nDllState;
diff --git a/NorthstarDLL/logging/sourceconsole.cpp b/NorthstarDLL/logging/sourceconsole.cpp
index 16080794..e436d1d4 100644
--- a/NorthstarDLL/logging/sourceconsole.cpp
+++ b/NorthstarDLL/logging/sourceconsole.cpp
@@ -71,7 +71,7 @@ void InitialiseConsoleOnInterfaceCreation()
{
(*g_pSourceGameConsole)->Initialize();
// hook OnCommandSubmitted so we print inputted commands
- OnCommandSubmittedHook.Dispatch((*g_pSourceGameConsole)->m_pConsole->m_vtable->OnCommandSubmitted);
+ OnCommandSubmittedHook.Dispatch((LPVOID)(*g_pSourceGameConsole)->m_pConsole->m_vtable->OnCommandSubmitted);
auto consoleSink = std::make_shared<SourceConsoleSink>();
if (g_bSpdLog_UseAnsiColor)
diff --git a/NorthstarDLL/masterserver/masterserver.cpp b/NorthstarDLL/masterserver/masterserver.cpp
index 015670e7..c2bbdfd8 100644
--- a/NorthstarDLL/masterserver/masterserver.cpp
+++ b/NorthstarDLL/masterserver/masterserver.cpp
@@ -1,6 +1,6 @@
#include "masterserver/masterserver.h"
#include "core/convar/concommand.h"
-#include "playlist.h"
+#include "shared/playlist.h"
#include "server/auth/serverauthentication.h"
#include "core/tier0.h"
#include "engine/r2engine.h"
@@ -1197,11 +1197,11 @@ void MasterServerPresenceReporter::InternalAddServer(const ServerPresence* pServ
// format every paramter because computers hate me
{
- char* nameEscaped = curl_easy_escape(curl, threadedPresence.m_sServerName.c_str(), NULL);
- char* descEscaped = curl_easy_escape(curl, threadedPresence.m_sServerDesc.c_str(), NULL);
- char* mapEscaped = curl_easy_escape(curl, threadedPresence.m_MapName, NULL);
- char* playlistEscaped = curl_easy_escape(curl, threadedPresence.m_PlaylistName, NULL);
- char* passwordEscaped = curl_easy_escape(curl, threadedPresence.m_Password, NULL);
+ char* nameEscaped = curl_easy_escape(curl, threadedPresence.m_sServerName.c_str(), 0);
+ char* descEscaped = curl_easy_escape(curl, threadedPresence.m_sServerDesc.c_str(), 0);
+ char* mapEscaped = curl_easy_escape(curl, threadedPresence.m_MapName, 0);
+ char* playlistEscaped = curl_easy_escape(curl, threadedPresence.m_PlaylistName, 0);
+ char* passwordEscaped = curl_easy_escape(curl, threadedPresence.m_Password, 0);
curl_easy_setopt(
curl,
@@ -1344,11 +1344,11 @@ void MasterServerPresenceReporter::InternalUpdateServer(const ServerPresence* pS
// send all registration info so we have all necessary info to reregister our server if masterserver goes down,
// without a restart this isn't threadsafe :terror:
{
- char* nameEscaped = curl_easy_escape(curl, threadedPresence.m_sServerName.c_str(), NULL);
- char* descEscaped = curl_easy_escape(curl, threadedPresence.m_sServerDesc.c_str(), NULL);
- char* mapEscaped = curl_easy_escape(curl, threadedPresence.m_MapName, NULL);
- char* playlistEscaped = curl_easy_escape(curl, threadedPresence.m_PlaylistName, NULL);
- char* passwordEscaped = curl_easy_escape(curl, threadedPresence.m_Password, NULL);
+ char* nameEscaped = curl_easy_escape(curl, threadedPresence.m_sServerName.c_str(), 0);
+ char* descEscaped = curl_easy_escape(curl, threadedPresence.m_sServerDesc.c_str(), 0);
+ char* mapEscaped = curl_easy_escape(curl, threadedPresence.m_MapName, 0);
+ char* playlistEscaped = curl_easy_escape(curl, threadedPresence.m_PlaylistName, 0);
+ char* passwordEscaped = curl_easy_escape(curl, threadedPresence.m_Password, 0);
curl_easy_setopt(
curl,
diff --git a/NorthstarDLL/plugins/plugins.cpp b/NorthstarDLL/plugins/plugins.cpp
index c2ac112b..1c426f09 100644
--- a/NorthstarDLL/plugins/plugins.cpp
+++ b/NorthstarDLL/plugins/plugins.cpp
@@ -62,7 +62,7 @@ std::optional<Plugin> PluginManager::LoadPlugin(fs::path path, PluginInitFuncs*
NS::log::PLUGINSYS->info("Failed to load library '{}': ", std::system_category().message(GetLastError()));
return std::nullopt;
}
- HRSRC manifestResource = FindResourceW(datafile, MAKEINTRESOURCEW(IDR_RCDATA1), MAKEINTRESOURCEW(RT_RCDATA));
+ HRSRC manifestResource = FindResourceW(datafile, MAKEINTRESOURCEW(IDR_RCDATA1), RT_RCDATA);
if (manifestResource == NULL)
{
diff --git a/NorthstarDLL/squirrel/squirrel.h b/NorthstarDLL/squirrel/squirrel.h
index 3d18d6c1..427eb03c 100644
--- a/NorthstarDLL/squirrel/squirrel.h
+++ b/NorthstarDLL/squirrel/squirrel.h
@@ -6,6 +6,19 @@
#include "plugins/plugin_abi.h"
#include "mods/modmanager.h"
+/*
+ definitions from hell
+ required to function
+*/
+
+template <ScriptContext context, typename T> inline void SqRecurseArgs(FunctionVector& v, T& arg);
+
+template <ScriptContext context, typename T, typename... Args> inline void SqRecurseArgs(FunctionVector& v, T& arg, Args... args);
+
+/*
+ sanity below
+*/
+
// stolen from ttf2sdk: sqvm types
typedef float SQFloat;
typedef long SQInteger;
@@ -280,7 +293,7 @@ class SquirrelManagerBase
template <typename T> inline SQBool getthisentity(HSquirrelVM* sqvm, T* ppEntity)
{
- return __sq_getentity(sqvm, (void**)ppEntity);
+ return __sq_getthisentity(sqvm, (void**)ppEntity);
}
template <typename T> inline T* getentity(HSquirrelVM* sqvm, SQInteger iStackPos)