aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-20 13:24:07 +0000
committerGitHub <noreply@github.com>2023-12-20 14:24:07 +0100
commit0438b5c8cfa99ac01c7e142d959aa40f88f1cc70 (patch)
treebbfdded20f8686cf188dba148db4b6c1b1211872
parent210dab2b0e5c686829bafdc857d2910f6b216b85 (diff)
downloadNorthstarLauncher-1.21.2-rc2.tar.gz
NorthstarLauncher-1.21.2-rc2.zip
Cherry pick "remove unnecessary namespaces" from primedev (#618)v1.21.2-rc2
Cherry-picks the removal of unnecessary namespaces from `primedev` https://github.com/F1F7Y/NorthstarPrime/ Co-authored-by: F1F7Y <filip.bartos07@proton.me>
-rw-r--r--NorthstarDLL/client/clientauthhooks.cpp4
-rw-r--r--NorthstarDLL/client/demofixes.cpp6
-rw-r--r--NorthstarDLL/client/languagehooks.cpp2
-rw-r--r--NorthstarDLL/client/r2client.cpp12
-rw-r--r--NorthstarDLL/client/r2client.h12
-rw-r--r--NorthstarDLL/client/rejectconnectionfixes.cpp2
-rw-r--r--NorthstarDLL/core/convar/convar.cpp6
-rw-r--r--NorthstarDLL/core/convar/cvar.cpp8
-rw-r--r--NorthstarDLL/core/convar/cvar.h8
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.cpp54
-rw-r--r--NorthstarDLL/core/filesystem/filesystem.h10
-rw-r--r--NorthstarDLL/core/filesystem/rpakfilesystem.cpp4
-rw-r--r--NorthstarDLL/core/memalloc.cpp2
-rw-r--r--NorthstarDLL/core/tier0.cpp24
-rw-r--r--NorthstarDLL/core/tier0.h99
-rw-r--r--NorthstarDLL/dedicated/dedicated.cpp32
-rw-r--r--NorthstarDLL/dedicated/dedicatedlogtoclient.cpp14
-rw-r--r--NorthstarDLL/dedicated/dedicatedmaterialsystem.cpp2
-rw-r--r--NorthstarDLL/engine/host.cpp4
-rw-r--r--NorthstarDLL/engine/hoststate.cpp33
-rw-r--r--NorthstarDLL/engine/hoststate.h70
-rw-r--r--NorthstarDLL/engine/r2engine.cpp30
-rw-r--r--NorthstarDLL/engine/r2engine.h486
-rw-r--r--NorthstarDLL/engine/runframe.cpp2
-rw-r--r--NorthstarDLL/masterserver/masterserver.cpp12
-rw-r--r--NorthstarDLL/mods/compiled/kb_act.cpp2
-rw-r--r--NorthstarDLL/mods/compiled/modkeyvalues.cpp2
-rw-r--r--NorthstarDLL/mods/compiled/modpdef.cpp2
-rw-r--r--NorthstarDLL/mods/compiled/modscriptsrson.cpp2
-rw-r--r--NorthstarDLL/mods/modmanager.cpp6
-rw-r--r--NorthstarDLL/mods/modsavefiles.cpp4
-rw-r--r--NorthstarDLL/scripts/client/clientchathooks.cpp2
-rw-r--r--NorthstarDLL/scripts/client/scriptserverbrowser.cpp14
-rw-r--r--NorthstarDLL/scripts/scriptdatatables.cpp8
-rw-r--r--NorthstarDLL/scripts/scripthttprequesthandler.cpp6
-rw-r--r--NorthstarDLL/scripts/scriptutility.cpp4
-rw-r--r--NorthstarDLL/scripts/server/miscserverscript.cpp18
-rw-r--r--NorthstarDLL/scripts/server/scriptuserinfo.cpp20
-rw-r--r--NorthstarDLL/server/alltalk.cpp4
-rw-r--r--NorthstarDLL/server/auth/bansystem.cpp8
-rw-r--r--NorthstarDLL/server/auth/serverauthentication.cpp46
-rw-r--r--NorthstarDLL/server/auth/serverauthentication.h16
-rw-r--r--NorthstarDLL/server/buildainfile.cpp6
-rw-r--r--NorthstarDLL/server/r2server.cpp10
-rw-r--r--NorthstarDLL/server/r2server.h202
-rw-r--r--NorthstarDLL/server/serverchathooks.cpp12
-rw-r--r--NorthstarDLL/server/servernethooks.cpp6
-rw-r--r--NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp24
-rw-r--r--NorthstarDLL/shared/exploit_fixes/ns_limits.cpp56
-rw-r--r--NorthstarDLL/shared/exploit_fixes/ns_limits.h12
-rw-r--r--NorthstarDLL/shared/maxplayers.cpp16
-rw-r--r--NorthstarDLL/shared/maxplayers.h6
-rw-r--r--NorthstarDLL/shared/misccommands.cpp30
-rw-r--r--NorthstarDLL/shared/playlist.cpp2
-rw-r--r--NorthstarDLL/squirrel/squirrel.cpp10
-rw-r--r--NorthstarDLL/util/printcommands.cpp24
-rw-r--r--NorthstarDLL/util/printmaps.cpp10
-rw-r--r--NorthstarDLL/util/utils.cpp2
-rw-r--r--NorthstarDLL/util/utils.h5
59 files changed, 725 insertions, 810 deletions
diff --git a/NorthstarDLL/client/clientauthhooks.cpp b/NorthstarDLL/client/clientauthhooks.cpp
index adb2ab22..35ae3aa7 100644
--- a/NorthstarDLL/client/clientauthhooks.cpp
+++ b/NorthstarDLL/client/clientauthhooks.cpp
@@ -32,10 +32,10 @@ void, __fastcall, (void* a1))
// if player has agreed to send token and we aren't already authing, try to auth
if (Cvar_ns_has_agreed_to_send_token->GetInt() == AGREED_TO_SEND_TOKEN &&
!g_pMasterServerManager->m_bOriginAuthWithMasterServerInProgress)
- g_pMasterServerManager->AuthenticateOriginWithMasterServer(R2::g_pLocalPlayerUserID, R2::g_pLocalPlayerOriginToken);
+ g_pMasterServerManager->AuthenticateOriginWithMasterServer(g_pLocalPlayerUserID, g_pLocalPlayerOriginToken);
// invalidate key so auth will fail
- *R2::g_pLocalPlayerOriginToken = 0;
+ *g_pLocalPlayerOriginToken = 0;
}
AuthWithStryder(a1);
diff --git a/NorthstarDLL/client/demofixes.cpp b/NorthstarDLL/client/demofixes.cpp
index 65e48fc0..344764ba 100644
--- a/NorthstarDLL/client/demofixes.cpp
+++ b/NorthstarDLL/client/demofixes.cpp
@@ -11,15 +11,15 @@ ON_DLL_LOAD_CLIENT_RELIESON("client.dll", ClientDemoFixes, ConVar, (CModule modu
{
// change default values of demo cvars to enable them by default, but not autorecord
// this is before Host_Init, the setvalue calls here will get overwritten by custom cfgs/launch options
- ConVar* Cvar_demo_enableDemos = R2::g_pCVar->FindVar("demo_enabledemos");
+ ConVar* Cvar_demo_enableDemos = g_pCVar->FindVar("demo_enabledemos");
Cvar_demo_enableDemos->m_pszDefaultValue = "1";
Cvar_demo_enableDemos->SetValue(true);
- ConVar* Cvar_demo_writeLocalFile = R2::g_pCVar->FindVar("demo_writeLocalFile");
+ ConVar* Cvar_demo_writeLocalFile = g_pCVar->FindVar("demo_writeLocalFile");
Cvar_demo_writeLocalFile->m_pszDefaultValue = "1";
Cvar_demo_writeLocalFile->SetValue(true);
- ConVar* Cvar_demo_autoRecord = R2::g_pCVar->FindVar("demo_autoRecord");
+ ConVar* Cvar_demo_autoRecord = g_pCVar->FindVar("demo_autoRecord");
Cvar_demo_autoRecord->m_pszDefaultValue = "0";
Cvar_demo_autoRecord->SetValue(false);
}
diff --git a/NorthstarDLL/client/languagehooks.cpp b/NorthstarDLL/client/languagehooks.cpp
index 4251dbbd..35ca5659 100644
--- a/NorthstarDLL/client/languagehooks.cpp
+++ b/NorthstarDLL/client/languagehooks.cpp
@@ -57,7 +57,7 @@ char*, __fastcall, ())
bool& canOriginDictateLang = *(bool*)((char*)tier0Handle + 0xA9A90);
const char* forcedLanguage;
- if (Tier0::CommandLine()->CheckParm("-language", &forcedLanguage))
+ if (CommandLine()->CheckParm("-language", &forcedLanguage))
{
if (!CheckLangAudioExists((char*)forcedLanguage))
{
diff --git a/NorthstarDLL/client/r2client.cpp b/NorthstarDLL/client/r2client.cpp
index fea97d8e..c8e59d74 100644
--- a/NorthstarDLL/client/r2client.cpp
+++ b/NorthstarDLL/client/r2client.cpp
@@ -1,14 +1,8 @@
#include "r2client.h"
-using namespace R2;
-
-// use the R2 namespace for game funcs
-namespace R2
-{
- char* g_pLocalPlayerUserID;
- char* g_pLocalPlayerOriginToken;
- GetBaseLocalClientType GetBaseLocalClient;
-} // namespace R2
+char* g_pLocalPlayerUserID;
+char* g_pLocalPlayerOriginToken;
+GetBaseLocalClientType GetBaseLocalClient;
ON_DLL_LOAD("engine.dll", R2EngineClient, (CModule module))
{
diff --git a/NorthstarDLL/client/r2client.h b/NorthstarDLL/client/r2client.h
index 64ed6c61..ea263dbc 100644
--- a/NorthstarDLL/client/r2client.h
+++ b/NorthstarDLL/client/r2client.h
@@ -1,11 +1,7 @@
#pragma once
-// use the R2 namespace for game funcs
-namespace R2
-{
- extern char* g_pLocalPlayerUserID;
- extern char* g_pLocalPlayerOriginToken;
+extern char* g_pLocalPlayerUserID;
+extern char* g_pLocalPlayerOriginToken;
- typedef void* (*GetBaseLocalClientType)();
- extern GetBaseLocalClientType GetBaseLocalClient;
-} // namespace R2
+typedef void* (*GetBaseLocalClientType)();
+extern GetBaseLocalClientType GetBaseLocalClient;
diff --git a/NorthstarDLL/client/rejectconnectionfixes.cpp b/NorthstarDLL/client/rejectconnectionfixes.cpp
index 6adde8b6..1b326a3c 100644
--- a/NorthstarDLL/client/rejectconnectionfixes.cpp
+++ b/NorthstarDLL/client/rejectconnectionfixes.cpp
@@ -22,7 +22,7 @@ void,, (bool a1, const char* fmt, ...))
// not doing this gets our client in a pretty weird state so we need to shut it down manually here
// don't call Cbuf_Execute because we don't need this called immediately
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "disconnect", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "disconnect", cmd_source_t::kCommandSrcCode);
}
return COM_ExplainDisconnection(a1, "%s", buf);
diff --git a/NorthstarDLL/core/convar/convar.cpp b/NorthstarDLL/core/convar/convar.cpp
index 594989c2..e77ae1fd 100644
--- a/NorthstarDLL/core/convar/convar.cpp
+++ b/NorthstarDLL/core/convar/convar.cpp
@@ -38,14 +38,14 @@ ON_DLL_LOAD("engine.dll", ConVar, (CModule module))
g_pConVar_Vtable = module.Offset(0x67FD28);
g_pIConVar_Vtable = module.Offset(0x67FDC8);
- R2::g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007");
- R2::g_pCVar = *R2::g_pCVarInterface;
+ g_pCVarInterface = new SourceInterface<CCvar>("vstdlib.dll", "VEngineCvar007");
+ g_pCVar = *g_pCVarInterface;
g_pPluginCommunicationhandler->m_sEngineData.conVarMalloc = reinterpret_cast<PluginConVarMallocType>(conVarMalloc);
g_pPluginCommunicationhandler->m_sEngineData.conVarRegister = reinterpret_cast<PluginConVarRegisterType>(conVarRegister);
g_pPluginCommunicationhandler->m_sEngineData.ConVar_Vtable = reinterpret_cast<void*>(g_pConVar_Vtable);
g_pPluginCommunicationhandler->m_sEngineData.IConVar_Vtable = reinterpret_cast<void*>(g_pIConVar_Vtable);
- g_pPluginCommunicationhandler->m_sEngineData.g_pCVar = reinterpret_cast<void*>(R2::g_pCVar);
+ g_pPluginCommunicationhandler->m_sEngineData.g_pCVar = reinterpret_cast<void*>(g_pCVar);
}
//-----------------------------------------------------------------------------
diff --git a/NorthstarDLL/core/convar/cvar.cpp b/NorthstarDLL/core/convar/cvar.cpp
index 21f8d2ec..aa5f0365 100644
--- a/NorthstarDLL/core/convar/cvar.cpp
+++ b/NorthstarDLL/core/convar/cvar.cpp
@@ -22,9 +22,5 @@ std::unordered_map<std::string, ConCommandBase*> CCvar::DumpToMap()
return allConVars;
}
-// use the R2 namespace for game funcs
-namespace R2
-{
- SourceInterface<CCvar>* g_pCVarInterface;
- CCvar* g_pCVar;
-} // namespace R2
+SourceInterface<CCvar>* g_pCVarInterface;
+CCvar* g_pCVar;
diff --git a/NorthstarDLL/core/convar/cvar.h b/NorthstarDLL/core/convar/cvar.h
index 3a3e1815..09fa8591 100644
--- a/NorthstarDLL/core/convar/cvar.h
+++ b/NorthstarDLL/core/convar/cvar.h
@@ -34,9 +34,5 @@ class CCvar
std::unordered_map<std::string, ConCommandBase*> DumpToMap();
};
-// use the R2 namespace for game funcs
-namespace R2
-{
- extern SourceInterface<CCvar>* g_pCVarInterface;
- extern CCvar* g_pCVar;
-} // namespace R2
+extern SourceInterface<CCvar>* g_pCVarInterface;
+extern CCvar* g_pCVar;
diff --git a/NorthstarDLL/core/filesystem/filesystem.cpp b/NorthstarDLL/core/filesystem/filesystem.cpp
index e4da647f..b39939e4 100644
--- a/NorthstarDLL/core/filesystem/filesystem.cpp
+++ b/NorthstarDLL/core/filesystem/filesystem.cpp
@@ -7,48 +7,42 @@
AUTOHOOK_INIT()
-using namespace R2;
-
bool bReadingOriginalFile = false;
std::string sCurrentModPath;
ConVar* Cvar_ns_fs_log_reads;
-// use the R2 namespace for game funcs
-namespace R2
+SourceInterface<IFileSystem>* g_pFilesystem;
+
+std::string ReadVPKFile(const char* path)
{
- SourceInterface<IFileSystem>* g_pFilesystem;
+ // read scripts.rson file, todo: check if this can be overwritten
+ FileHandle_t fileHandle = (*g_pFilesystem)->m_vtable2->Open(&(*g_pFilesystem)->m_vtable2, path, "rb", "GAME", 0);
- std::string ReadVPKFile(const char* path)
+ std::stringstream fileStream;
+ int bytesRead = 0;
+ char data[4096];
+ do
{
- // read scripts.rson file, todo: check if this can be overwritten
- FileHandle_t fileHandle = (*g_pFilesystem)->m_vtable2->Open(&(*g_pFilesystem)->m_vtable2, path, "rb", "GAME", 0);
-
- std::stringstream fileStream;
- int bytesRead = 0;
- char data[4096];
- do
- {
- bytesRead = (*g_pFilesystem)->m_vtable2->Read(&(*g_pFilesystem)->m_vtable2, data, (int)std::size(data), fileHandle);
- fileStream.write(data, bytesRead);
- } while (bytesRead == std::size(data));
+ bytesRead = (*g_pFilesystem)->m_vtable2->Read(&(*g_pFilesystem)->m_vtable2, data, (int)std::size(data), fileHandle);
+ fileStream.write(data, bytesRead);
+ } while (bytesRead == std::size(data));
- (*g_pFilesystem)->m_vtable2->Close(*g_pFilesystem, fileHandle);
+ (*g_pFilesystem)->m_vtable2->Close(*g_pFilesystem, fileHandle);
- return fileStream.str();
- }
+ return fileStream.str();
+}
- std::string ReadVPKOriginalFile(const char* path)
- {
- // todo: should probably set search path to be g_pModName here also
+std::string ReadVPKOriginalFile(const char* path)
+{
+ // todo: should probably set search path to be g_pModName here also
- bReadingOriginalFile = true;
- std::string ret = ReadVPKFile(path);
- bReadingOriginalFile = false;
+ bReadingOriginalFile = true;
+ std::string ret = ReadVPKFile(path);
+ bReadingOriginalFile = false;
- return ret;
- }
-} // namespace R2
+ return ret;
+}
// clang-format off
HOOK(AddSearchPathHook, AddSearchPath,
@@ -175,7 +169,7 @@ ON_DLL_LOAD("filesystem_stdio.dll", Filesystem, (CModule module))
{
AUTOHOOK_DISPATCH()
- R2::g_pFilesystem = new SourceInterface<IFileSystem>("filesystem_stdio.dll", "VFileSystem017");
+ g_pFilesystem = new SourceInterface<IFileSystem>("filesystem_stdio.dll", "VFileSystem017");
AddSearchPathHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->AddSearchPath);
ReadFromCacheHook.Dispatch((LPVOID)(*g_pFilesystem)->m_vtable->ReadFromCache);
diff --git a/NorthstarDLL/core/filesystem/filesystem.h b/NorthstarDLL/core/filesystem/filesystem.h
index ac1c5986..9c4e891b 100644
--- a/NorthstarDLL/core/filesystem/filesystem.h
+++ b/NorthstarDLL/core/filesystem/filesystem.h
@@ -63,11 +63,7 @@ class IFileSystem
VTable2* m_vtable2;
};
-// use the R2 namespace for game funcs
-namespace R2
-{
- extern SourceInterface<IFileSystem>* g_pFilesystem;
+extern SourceInterface<IFileSystem>* g_pFilesystem;
- std::string ReadVPKFile(const char* path);
- std::string ReadVPKOriginalFile(const char* path);
-} // namespace R2
+std::string ReadVPKFile(const char* path);
+std::string ReadVPKOriginalFile(const char* path);
diff --git a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
index 8d50b07a..da72646b 100644
--- a/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
+++ b/NorthstarDLL/core/filesystem/rpakfilesystem.cpp
@@ -209,8 +209,8 @@ int, __fastcall, (char* pPath, void* unknownSingleton, int flags, void* pCallbac
// dedicated only needs common, common_mp, common_sp, and sp_<map> rpaks
// sp_<map> rpaks contain tutorial ghost data
// sucks to have to load the entire rpak for that but sp was never meant to be done on dedi
- if (IsDedicatedServer() && (Tier0::CommandLine()->CheckParm("-nopakdedi") ||
- strncmp(&originalPath[0], "common", 6) && strncmp(&originalPath[0], "sp_", 3)))
+ if (IsDedicatedServer() &&
+ (CommandLine()->CheckParm("-nopakdedi") || strncmp(&originalPath[0], "common", 6) && strncmp(&originalPath[0], "sp_", 3)))
{
if (bNeedToFreePakName)
delete[] pPath;
diff --git a/NorthstarDLL/core/memalloc.cpp b/NorthstarDLL/core/memalloc.cpp
index 69ce6f54..0a75bc2b 100644
--- a/NorthstarDLL/core/memalloc.cpp
+++ b/NorthstarDLL/core/memalloc.cpp
@@ -1,8 +1,6 @@
#include "core/memalloc.h"
#include "core/tier0.h"
-using namespace Tier0;
-
// TODO: rename to malloc and free after removing statically compiled .libs
extern "C" void* _malloc_base(size_t n)
diff --git a/NorthstarDLL/core/tier0.cpp b/NorthstarDLL/core/tier0.cpp
index 16709384..1f59722c 100644
--- a/NorthstarDLL/core/tier0.cpp
+++ b/NorthstarDLL/core/tier0.cpp
@@ -1,17 +1,12 @@
#include "tier0.h"
-// use the Tier0 namespace for tier0 funcs
-namespace Tier0
-{
- IMemAlloc* g_pMemAllocSingleton = nullptr;
+IMemAlloc* g_pMemAllocSingleton = nullptr;
- ErrorType Error;
- CommandLineType CommandLine;
- Plat_FloatTimeType Plat_FloatTime;
- ThreadInServerFrameThreadType ThreadInServerFrameThread;
-} // namespace Tier0
+CommandLineType CommandLine;
+Plat_FloatTimeType Plat_FloatTime;
+ThreadInServerFrameThreadType ThreadInServerFrameThread;
-typedef Tier0::IMemAlloc* (*CreateGlobalMemAllocType)();
+typedef IMemAlloc* (*CreateGlobalMemAllocType)();
CreateGlobalMemAllocType CreateGlobalMemAlloc;
// needs to be a seperate function, since memalloc.cpp calls it
@@ -20,7 +15,7 @@ void TryCreateGlobalMemAlloc()
// init memalloc stuff
CreateGlobalMemAlloc =
reinterpret_cast<CreateGlobalMemAllocType>(GetProcAddress(GetModuleHandleA("tier0.dll"), "CreateGlobalMemAlloc"));
- Tier0::g_pMemAllocSingleton = CreateGlobalMemAlloc(); // if it already exists, this returns the preexisting IMemAlloc instance
+ g_pMemAllocSingleton = CreateGlobalMemAlloc(); // if it already exists, this returns the preexisting IMemAlloc instance
}
ON_DLL_LOAD("tier0.dll", Tier0GameFuncs, (CModule module))
@@ -29,8 +24,7 @@ ON_DLL_LOAD("tier0.dll", Tier0GameFuncs, (CModule module))
TryCreateGlobalMemAlloc();
// setup tier0 funcs
- Tier0::Error = module.GetExport("Error").RCast<Tier0::ErrorType>();
- Tier0::CommandLine = module.GetExport("CommandLine").RCast<Tier0::CommandLineType>();
- Tier0::Plat_FloatTime = module.GetExport("Plat_FloatTime").RCast<Tier0::Plat_FloatTimeType>();
- Tier0::ThreadInServerFrameThread = module.GetExport("ThreadInServerFrameThread").RCast<Tier0::ThreadInServerFrameThreadType>();
+ CommandLine = module.GetExport("CommandLine").RCast<CommandLineType>();
+ Plat_FloatTime = module.GetExport("Plat_FloatTime").RCast<Plat_FloatTimeType>();
+ ThreadInServerFrameThread = module.GetExport("ThreadInServerFrameThread").RCast<ThreadInServerFrameThreadType>();
}
diff --git a/NorthstarDLL/core/tier0.h b/NorthstarDLL/core/tier0.h
index eebe98f2..047610b2 100644
--- a/NorthstarDLL/core/tier0.h
+++ b/NorthstarDLL/core/tier0.h
@@ -1,68 +1,63 @@
#pragma once
-namespace Tier0
+
+class IMemAlloc
{
- class IMemAlloc
+ public:
+ struct VTable
{
- public:
- struct VTable
- {
- void* unknown[1]; // alloc debug
- void* (*Alloc)(IMemAlloc* memAlloc, size_t nSize);
- void* unknown2[1]; // realloc debug
- void* (*Realloc)(IMemAlloc* memAlloc, void* pMem, size_t nSize);
- void* unknown3[1]; // free #1
- void (*Free)(IMemAlloc* memAlloc, void* pMem);
- void* unknown4[2]; // nullsubs, maybe CrtSetDbgFlag
- size_t (*GetSize)(IMemAlloc* memAlloc, void* pMem);
- void* unknown5[9]; // they all do literally nothing
- void (*DumpStats)(IMemAlloc* memAlloc);
- void (*DumpStatsFileBase)(IMemAlloc* memAlloc, const char* pchFileBase);
- void* unknown6[4];
- int (*heapchk)(IMemAlloc* memAlloc);
- };
-
- VTable* m_vtable;
+ void* unknown[1]; // alloc debug
+ void* (*Alloc)(IMemAlloc* memAlloc, size_t nSize);
+ void* unknown2[1]; // realloc debug
+ void* (*Realloc)(IMemAlloc* memAlloc, void* pMem, size_t nSize);
+ void* unknown3[1]; // free #1
+ void (*Free)(IMemAlloc* memAlloc, void* pMem);
+ void* unknown4[2]; // nullsubs, maybe CrtSetDbgFlag
+ size_t (*GetSize)(IMemAlloc* memAlloc, void* pMem);
+ void* unknown5[9]; // they all do literally nothing
+ void (*DumpStats)(IMemAlloc* memAlloc);
+ void (*DumpStatsFileBase)(IMemAlloc* memAlloc, const char* pchFileBase);
+ void* unknown6[4];
+ int (*heapchk)(IMemAlloc* memAlloc);
};
- class CCommandLine
- {
- 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) = 0;
- virtual void CreateCmdLine(int argc, char** argv) = 0;
- virtual void unknown() = 0;
- virtual const char* GetCmdLine(void) const = 0;
+ VTable* m_vtable;
+};
- 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;
+class CCommandLine
+{
+ 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) = 0;
+ virtual void CreateCmdLine(int argc, char** argv) = 0;
+ virtual void unknown() = 0;
+ virtual const char* GetCmdLine(void) const = 0;
- 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 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 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* 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 const char** GetParms() const {}
- };
+ 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;
- extern IMemAlloc* g_pMemAllocSingleton;
+ // virtual const char** GetParms() const {}
+};
- typedef void (*ErrorType)(const char* fmt, ...);
- extern ErrorType Error;
+extern IMemAlloc* g_pMemAllocSingleton;
- typedef CCommandLine* (*CommandLineType)();
- extern CommandLineType CommandLine;
+typedef CCommandLine* (*CommandLineType)();
+extern CommandLineType CommandLine;
- typedef double (*Plat_FloatTimeType)();
- extern Plat_FloatTimeType Plat_FloatTime;
+typedef double (*Plat_FloatTimeType)();
+extern Plat_FloatTimeType Plat_FloatTime;
- typedef bool (*ThreadInServerFrameThreadType)();
- extern ThreadInServerFrameThreadType ThreadInServerFrameThread;
-} // namespace Tier0
+typedef bool (*ThreadInServerFrameThreadType)();
+extern ThreadInServerFrameThreadType ThreadInServerFrameThread;
void TryCreateGlobalMemAlloc();
diff --git a/NorthstarDLL/dedicated/dedicated.cpp b/NorthstarDLL/dedicated/dedicated.cpp
index 34282f51..df6e5787 100644
--- a/NorthstarDLL/dedicated/dedicated.cpp
+++ b/NorthstarDLL/dedicated/dedicated.cpp
@@ -10,8 +10,6 @@
AUTOHOOK_INIT()
-using namespace R2;
-
bool IsDedicatedServer()
{
static bool result = strstr(GetCommandLineA(), "-dedicated");
@@ -43,15 +41,15 @@ void Sys_Printf(CDedicatedExports* dedicated, const char* msg)
void RunServer(CDedicatedExports* dedicated)
{
spdlog::info("CDedicatedExports::RunServer(): starting");
- spdlog::info(Tier0::CommandLine()->GetCmdLine());
+ spdlog::info(CommandLine()->GetCmdLine());
// initialise engine
g_pEngine->Frame();
// add +map if no map loading command is present
// don't manually execute this from cbuf as users may have it in their startup args anyway, easier just to run from stuffcmds if present
- if (!Tier0::CommandLine()->CheckParm("+map") && !Tier0::CommandLine()->CheckParm("+launchplaylist"))
- Tier0::CommandLine()->AppendParm("+map", g_pCVar->FindVar("match_defaultMap")->GetString());
+ if (!CommandLine()->CheckParm("+map") && !CommandLine()->CheckParm("+launchplaylist"))
+ CommandLine()->AppendParm("+map", g_pCVar->FindVar("match_defaultMap")->GetString());
// re-run commandline
Cbuf_AddText(Cbuf_GetCurrentPlayer(), "stuffcmds", cmd_source_t::kCommandSrcCode);
@@ -61,11 +59,11 @@ void RunServer(CDedicatedExports* dedicated)
double frameTitle = 0;
while (g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING)
{
- double frameStart = Tier0::Plat_FloatTime();
+ double frameStart = Plat_FloatTime();
g_pEngine->Frame();
std::this_thread::sleep_for(
- std::chrono::duration<double, std::ratio<1>>(g_pGlobals->m_flTickInterval - fmin(Tier0::Plat_FloatTime() - frameStart, 0.25)));
+ std::chrono::duration<double, std::ratio<1>>(g_pGlobals->m_flTickInterval - fmin(Plat_FloatTime() - frameStart, 0.25)));
}
}
@@ -215,13 +213,13 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul
// make sure it still gets registered
// add cmdline args that are good for dedi
- Tier0::CommandLine()->AppendParm("-nomenuvid", 0);
- Tier0::CommandLine()->AppendParm("-nosound", 0);
- Tier0::CommandLine()->AppendParm("-windowed", 0);
- Tier0::CommandLine()->AppendParm("-nomessagebox", 0);
- Tier0::CommandLine()->AppendParm("+host_preload_shaders", "0");
- Tier0::CommandLine()->AppendParm("+net_usesocketsforloopback", "1");
- Tier0::CommandLine()->AppendParm("+community_frame_run", "0");
+ CommandLine()->AppendParm("-nomenuvid", 0);
+ CommandLine()->AppendParm("-nosound", 0);
+ CommandLine()->AppendParm("-windowed", 0);
+ CommandLine()->AppendParm("-nomessagebox", 0);
+ CommandLine()->AppendParm("+host_preload_shaders", "0");
+ CommandLine()->AppendParm("+net_usesocketsforloopback", "1");
+ CommandLine()->AppendParm("+community_frame_run", "0");
// use presence reporter for console title
DedicatedConsoleServerPresence* presenceReporter = new DedicatedConsoleServerPresence;
@@ -231,7 +229,7 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul
RegisterCustomSink(std::make_shared<DedicatedServerLogToClientSink>());
// Disable Quick Edit mode to reduce chance of user unintentionally hanging their server by selecting something.
- if (!Tier0::CommandLine()->CheckParm("-bringbackquickedit"))
+ if (!CommandLine()->CheckParm("-bringbackquickedit"))
{
HANDLE stdIn = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode = 0;
@@ -253,7 +251,7 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul
spdlog::info("Quick Edit enabled by user request");
// create console input thread
- if (!Tier0::CommandLine()->CheckParm("-noconsoleinput"))
+ if (!CommandLine()->CheckParm("-noconsoleinput"))
consoleInputThreadHandle = CreateThread(0, 0, ConsoleInputThread, 0, 0, NULL);
else
spdlog::info("Console input disabled by user request");
@@ -288,7 +286,7 @@ ON_DLL_LOAD_DEDI("server.dll", DedicatedServerGameDLL, (CModule module))
{
AUTOHOOK_DISPATCH_MODULE(server.dll)
- if (Tier0::CommandLine()->CheckParm("-nopakdedi"))
+ if (CommandLine()->CheckParm("-nopakdedi"))
{
module.Offset(0x6BA350).Patch("C3"); // dont load skins.rson from rpak if we don't have rpaks, as loading it will cause a crash
module.Offset(0x6BA300).Patch(
diff --git a/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
index a48b1b39..bf2cf77a 100644
--- a/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
+++ b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
@@ -1,11 +1,11 @@
#include "dedicatedlogtoclient.h"
#include "engine/r2engine.h"
-void (*CGameClient__ClientPrintf)(R2::CBaseClient* pClient, const char* fmt, ...);
+void (*CGameClient__ClientPrintf)(CBaseClient* pClient, const char* fmt, ...);
void DedicatedServerLogToClientSink::custom_sink_it_(const custom_log_msg& msg)
{
- if (*R2::g_pServerState == R2::server_state_t::ss_dead)
+ if (*g_pServerState == server_state_t::ss_dead)
return;
enum class eSendPrintsToClient
@@ -15,17 +15,17 @@ void DedicatedServerLogToClientSink::custom_sink_it_(const custom_log_msg& msg)
ALL
};
- static const ConVar* Cvar_dedi_sendPrintsToClient = R2::g_pCVar->FindVar("dedi_sendPrintsToClient");
+ static const ConVar* Cvar_dedi_sendPrintsToClient = g_pCVar->FindVar("dedi_sendPrintsToClient");
eSendPrintsToClient eSendPrints = static_cast<eSendPrintsToClient>(Cvar_dedi_sendPrintsToClient->GetInt());
if (eSendPrints == eSendPrintsToClient::NONE)
return;
std::string sLogMessage = fmt::format("[DEDICATED SERVER] [{}] {}", level_names[msg.level], msg.payload);
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* pClient = &R2::g_pClientArray[i];
+ CBaseClient* pClient = &g_pClientArray[i];
- if (pClient->m_Signon >= R2::eSignonState::CONNECTED)
+ if (pClient->m_Signon >= eSignonState::CONNECTED)
{
CGameClient__ClientPrintf(pClient, sLogMessage.c_str());
@@ -44,5 +44,5 @@ void DedicatedServerLogToClientSink::flush_() {}
ON_DLL_LOAD_DEDI("engine.dll", DedicatedServerLogToClient, (CModule module))
{
- CGameClient__ClientPrintf = module.Offset(0x1016A0).RCast<void (*)(R2::CBaseClient*, const char*, ...)>();
+ CGameClient__ClientPrintf = module.Offset(0x1016A0).RCast<void (*)(CBaseClient*, const char*, ...)>();
}
diff --git a/NorthstarDLL/dedicated/dedicatedmaterialsystem.cpp b/NorthstarDLL/dedicated/dedicatedmaterialsystem.cpp
index 5bd6ea93..01078086 100644
--- a/NorthstarDLL/dedicated/dedicatedmaterialsystem.cpp
+++ b/NorthstarDLL/dedicated/dedicatedmaterialsystem.cpp
@@ -23,7 +23,7 @@ HRESULT, __stdcall, (
// really call gpu much even with renderthread still being a thing will be using this hook for actual d3d stubbing and stuff later
// note: this has been succeeded by the d3d11 and gfsdk stubs, and is only being kept around for posterity and as a fallback option
- if (Tier0::CommandLine()->CheckParm("-softwared3d11"))
+ if (CommandLine()->CheckParm("-softwared3d11"))
DriverType = 5; // D3D_DRIVER_TYPE_WARP
return D3D11CreateDevice(
diff --git a/NorthstarDLL/engine/host.cpp b/NorthstarDLL/engine/host.cpp
index 49cc3663..dacb8fc1 100644
--- a/NorthstarDLL/engine/host.cpp
+++ b/NorthstarDLL/engine/host.cpp
@@ -22,9 +22,9 @@ void, __fastcall, (bool bDedicated))
// client/server autoexecs on necessary platforms
// dedi needs autoexec_ns_server on boot, while non-dedi will run it on on listen server start
if (bDedicated)
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", cmd_source_t::kCommandSrcCode);
else
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", cmd_source_t::kCommandSrcCode);
}
ON_DLL_LOAD("engine.dll", Host_Init, (CModule module))
diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp
index 1734a1c3..ec728afb 100644
--- a/NorthstarDLL/engine/hoststate.cpp
+++ b/NorthstarDLL/engine/hoststate.cpp
@@ -12,13 +12,7 @@
AUTOHOOK_INIT()
-using namespace R2;
-
-// use the R2 namespace for game funcs
-namespace R2
-{
- CHostState* g_pHostState;
-} // namespace R2
+CHostState* g_pHostState;
std::string sLastMode;
@@ -35,15 +29,14 @@ void ServerStartingOrChangingMap()
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
if (sLastMode.length() &&
- CCommand__Tokenize(
- tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), R2::cmd_source_t::kCommandSrcCode))
+ CCommand__Tokenize(tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), cmd_source_t::kCommandSrcCode))
_Cmd_Exec_f(tempCommand, false, false);
memset(commandBuf, 0, sizeof(commandBuf));
if (CCommand__Tokenize(
tempCommand,
fmt::format("exec server/setup_gamemode_{}", sLastMode = Cvar_mp_gamemode->GetString()).c_str(),
- R2::cmd_source_t::kCommandSrcCode))
+ cmd_source_t::kCommandSrcCode))
{
_Cmd_Exec_f(tempCommand, false, false);
}
@@ -73,18 +66,18 @@ void, __fastcall, (CHostState* self))
// need to do this to ensure we don't go to private match
if (g_pServerAuthentication->m_bNeedLocalAuthForNewgame)
- SetCurrentPlaylist("tdm");
+ R2::SetCurrentPlaylist("tdm");
ServerStartingOrChangingMap();
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_NewGame(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
// setup server presence
g_pServerPresence->CreatePresence();
g_pServerPresence->SetMap(g_pHostState->m_levelName, true);
- g_pServerPresence->SetPlaylist(GetCurrentPlaylistName());
+ g_pServerPresence->SetPlaylist(R2::GetCurrentPlaylistName());
g_pServerPresence->SetPort(Cvar_hostport->GetInt());
g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false;
@@ -107,9 +100,9 @@ void, __fastcall, (CHostState* self))
g_pCVar->FindVar("net_data_block_enabled")->SetValue(true);
g_pServerAuthentication->m_bStartingLocalSPGame = true;
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_LoadGame(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
// no server presence, can't do it because no map name in hoststate
// and also not super important for sp saves really
@@ -126,9 +119,9 @@ void, __fastcall, (CHostState* self))
ServerStartingOrChangingMap();
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_ChangeLevelMP(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
g_pServerPresence->SetMap(g_pHostState->m_levelName);
}
@@ -151,7 +144,7 @@ void, __fastcall, (CHostState* self))
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
if (CCommand__Tokenize(
- tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), R2::cmd_source_t::kCommandSrcCode))
+ tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), cmd_source_t::kCommandSrcCode))
{
_Cmd_Exec_f(tempCommand, false, false);
Cbuf_Execute();
@@ -168,7 +161,7 @@ void, __fastcall, (CHostState* self, double flCurrentTime, float flFrameTime))
{
CHostState__FrameUpdate(self, flCurrentTime, flFrameTime);
- if (*R2::g_pServerState == R2::server_state_t::ss_active)
+ if (*g_pServerState == server_state_t::ss_active)
{
// update server presence
g_pServerPresence->RunFrame(flCurrentTime);
diff --git a/NorthstarDLL/engine/hoststate.h b/NorthstarDLL/engine/hoststate.h
index a77385ef..0536e91c 100644
--- a/NorthstarDLL/engine/hoststate.h
+++ b/NorthstarDLL/engine/hoststate.h
@@ -1,45 +1,41 @@
#pragma once
-// use the R2 namespace for game funxcs
-namespace R2
+enum class HostState_t
{
- enum class HostState_t
- {
- HS_NEW_GAME = 0,
- HS_LOAD_GAME,
- HS_CHANGE_LEVEL_SP,
- HS_CHANGE_LEVEL_MP,
- HS_RUN,
- HS_GAME_SHUTDOWN,
- HS_SHUTDOWN,
- HS_RESTART,
- };
+ HS_NEW_GAME = 0,
+ HS_LOAD_GAME,
+ HS_CHANGE_LEVEL_SP,
+ HS_CHANGE_LEVEL_MP,
+ HS_RUN,
+ HS_GAME_SHUTDOWN,
+ HS_SHUTDOWN,
+ HS_RESTART,
+};
- struct CHostState
- {
- public:
- HostState_t m_iCurrentState;
- HostState_t m_iNextState;
+struct CHostState
+{
+ public:
+ HostState_t m_iCurrentState;
+ HostState_t m_iNextState;
- float m_vecLocation[3];
- float m_angLocation[3];
+ float m_vecLocation[3];
+ float m_angLocation[3];
- char m_levelName[32];
- char m_mapGroupName[32];
- char m_landmarkName[32];
- char m_saveName[32];
- float m_flShortFrameTime; // run a few one-tick frames to avoid large timesteps while loading assets
+ char m_levelName[32];
+ char m_mapGroupName[32];
+ char m_landmarkName[32];
+ char m_saveName[32];
+ float m_flShortFrameTime; // run a few one-tick frames to avoid large timesteps while loading assets
- bool m_activeGame;
- bool m_bRememberLocation;
- bool m_bBackgroundLevel;
- bool m_bWaitingForConnection;
- bool m_bLetToolsOverrideLoadGameEnts; // During a load game, this tells Foundry to override ents that are selected in Hammer.
- bool m_bSplitScreenConnect;
- bool m_bGameHasShutDownAndFlushedMemory; // This is false once we load a map into memory, and set to true once the map is unloaded
- // and all memory flushed
- bool m_bWorkshopMapDownloadPending;
- };
+ bool m_activeGame;
+ bool m_bRememberLocation;
+ bool m_bBackgroundLevel;
+ bool m_bWaitingForConnection;
+ bool m_bLetToolsOverrideLoadGameEnts; // During a load game, this tells Foundry to override ents that are selected in Hammer.
+ bool m_bSplitScreenConnect;
+ bool m_bGameHasShutDownAndFlushedMemory; // This is false once we load a map into memory, and set to true once the map is unloaded
+ // and all memory flushed
+ bool m_bWorkshopMapDownloadPending;
+};
- extern CHostState* g_pHostState;
-} // namespace R2
+extern CHostState* g_pHostState;
diff --git a/NorthstarDLL/engine/r2engine.cpp b/NorthstarDLL/engine/r2engine.cpp
index 67a628fd..88500376 100644
--- a/NorthstarDLL/engine/r2engine.cpp
+++ b/NorthstarDLL/engine/r2engine.cpp
@@ -1,28 +1,22 @@
#include "r2engine.h"
-using namespace R2;
+Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
+Cbuf_AddTextType Cbuf_AddText;
+Cbuf_ExecuteType Cbuf_Execute;
-// use the R2 namespace for game funcs
-namespace R2
-{
- Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
- Cbuf_AddTextType Cbuf_AddText;
- Cbuf_ExecuteType Cbuf_Execute;
-
- bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, R2::cmd_source_t commandSource);
+bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, cmd_source_t commandSource);
- CEngine* g_pEngine;
+CEngine* g_pEngine;
- void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
- CBaseClient* g_pClientArray;
+void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
+CBaseClient* g_pClientArray;
- server_state_t* g_pServerState;
+server_state_t* g_pServerState;
- char* g_pModName =
- nullptr; // we cant set this up here atm since we dont have an offset to it in engine, instead we store it in IsRespawnMod
+char* g_pModName =
+ nullptr; // we cant set this up here atm since we dont have an offset to it in engine, instead we store it in IsRespawnMod
- CGlobalVars* g_pGlobals;
-} // namespace R2
+CGlobalVars* g_pGlobals;
ON_DLL_LOAD("engine.dll", R2Engine, (CModule module))
{
@@ -30,7 +24,7 @@ ON_DLL_LOAD("engine.dll", R2Engine, (CModule module))
Cbuf_AddText = module.Offset(0x1203B0).RCast<Cbuf_AddTextType>();
Cbuf_Execute = module.Offset(0x1204B0).RCast<Cbuf_ExecuteType>();
- CCommand__Tokenize = module.Offset(0x418380).RCast<bool (*)(CCommand&, const char*, R2::cmd_source_t)>();
+ CCommand__Tokenize = module.Offset(0x418380).RCast<bool (*)(CCommand&, const char*, cmd_source_t)>();
g_pEngine = module.Offset(0x7D70C8).Deref().RCast<CEngine*>();
diff --git a/NorthstarDLL/engine/r2engine.h b/NorthstarDLL/engine/r2engine.h
index df0cda74..91676b6b 100644
--- a/NorthstarDLL/engine/r2engine.h
+++ b/NorthstarDLL/engine/r2engine.h
@@ -1,264 +1,260 @@
#pragma once
#include "shared/keyvalues.h"
-// use the R2 namespace for game funcs
-namespace R2
+// Cbuf
+enum class ECommandTarget_t
{
- // Cbuf
- enum class ECommandTarget_t
- {
- CBUF_FIRST_PLAYER = 0,
- CBUF_LAST_PLAYER = 1, // MAX_SPLITSCREEN_CLIENTS - 1, MAX_SPLITSCREEN_CLIENTS = 2
- CBUF_SERVER = CBUF_LAST_PLAYER + 1,
-
- CBUF_COUNT,
- };
-
- enum class cmd_source_t
- {
- // Added to the console buffer by gameplay code. Generally unrestricted.
- kCommandSrcCode,
-
- // Sent from code via engine->ClientCmd, which is restricted to commands visible
- // via FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS.
- kCommandSrcClientCmd,
-
- // Typed in at the console or via a user key-bind. Generally unrestricted, although
- // the client will throttle commands sent to the server this way to 16 per second.
- kCommandSrcUserInput,
-
- // Came in over a net connection as a clc_stringcmd
- // host_client will be valid during this state.
- //
- // Restricted to FCVAR_GAMEDLL commands (but not convars) and special non-ConCommand
- // server commands hardcoded into gameplay code (e.g. "joingame")
- kCommandSrcNetClient,
+ CBUF_FIRST_PLAYER = 0,
+ CBUF_LAST_PLAYER = 1, // MAX_SPLITSCREEN_CLIENTS - 1, MAX_SPLITSCREEN_CLIENTS = 2
+ CBUF_SERVER = CBUF_LAST_PLAYER + 1,
- // Received from the server as the client
- //
- // Restricted to commands with FCVAR_SERVER_CAN_EXECUTE
- kCommandSrcNetServer,
+ CBUF_COUNT,
+};
- // Being played back from a demo file
- //
- // Not currently restricted by convar flag, but some commands manually ignore calls
- // from this source. FIXME: Should be heavily restricted as demo commands can come
- // from untrusted sources.
- kCommandSrcDemoFile,
-
- // Invalid value used when cleared
- kCommandSrcInvalid = -1
- };
-
- typedef ECommandTarget_t (*Cbuf_GetCurrentPlayerType)();
- extern Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
-
- typedef void (*Cbuf_AddTextType)(ECommandTarget_t eTarget, const char* text, cmd_source_t source);
- extern Cbuf_AddTextType Cbuf_AddText;
-
- typedef void (*Cbuf_ExecuteType)();
- extern Cbuf_ExecuteType Cbuf_Execute;
-
- extern bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, R2::cmd_source_t commandSource);
-
- // CEngine
-
- enum EngineQuitState
- {
- QUIT_NOTQUITTING = 0,
- QUIT_TODESKTOP,
- QUIT_RESTART
- };
-
- enum class EngineState_t
- {
- DLL_INACTIVE = 0, // no dll
- DLL_ACTIVE, // engine is focused
- DLL_CLOSE, // closing down dll
- DLL_RESTART, // engine is shutting down but will restart right away
- DLL_PAUSED, // engine is paused, can become active from this state
- };
-
- class CEngine
- {
- public:
- 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;
- EngineState_t m_nNextDllState;
- double m_flCurrentTime;
- float m_flFrameTime;
- double m_flPreviousTime;
- float m_flFilteredTime;
- float m_flMinFrameTime; // Expected duration of a frame, or zero if it is unlimited.
- };
+enum class cmd_source_t
+{
+ // Added to the console buffer by gameplay code. Generally unrestricted.
+ kCommandSrcCode,
+
+ // Sent from code via engine->ClientCmd, which is restricted to commands visible
+ // via FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS.
+ kCommandSrcClientCmd,
+
+ // Typed in at the console or via a user key-bind. Generally unrestricted, although
+ // the client will throttle commands sent to the server this way to 16 per second.
+ kCommandSrcUserInput,
+
+ // Came in over a net connection as a clc_stringcmd
+ // host_client will be valid during this state.
+ //
+ // Restricted to FCVAR_GAMEDLL commands (but not convars) and special non-ConCommand
+ // server commands hardcoded into gameplay code (e.g. "joingame")
+ kCommandSrcNetClient,
+
+ // Received from the server as the client
+ //
+ // Restricted to commands with FCVAR_SERVER_CAN_EXECUTE
+ kCommandSrcNetServer,
+
+ // Being played back from a demo file
+ //
+ // Not currently restricted by convar flag, but some commands manually ignore calls
+ // from this source. FIXME: Should be heavily restricted as demo commands can come
+ // from untrusted sources.
+ kCommandSrcDemoFile,
+
+ // Invalid value used when cleared
+ kCommandSrcInvalid = -1
+};
- extern CEngine* g_pEngine;
+typedef ECommandTarget_t (*Cbuf_GetCurrentPlayerType)();
+extern Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
- extern void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
+typedef void (*Cbuf_AddTextType)(ECommandTarget_t eTarget, const char* text, cmd_source_t source);
+extern Cbuf_AddTextType Cbuf_AddText;
+
+typedef void (*Cbuf_ExecuteType)();
+extern Cbuf_ExecuteType Cbuf_Execute;
+
+extern bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, cmd_source_t commandSource);
+
+// CEngine
+
+enum EngineQuitState
+{
+ QUIT_NOTQUITTING = 0,
+ QUIT_TODESKTOP,
+ QUIT_RESTART
+};
+
+enum class EngineState_t
+{
+ DLL_INACTIVE = 0, // no dll
+ DLL_ACTIVE, // engine is focused
+ DLL_CLOSE, // closing down dll
+ DLL_RESTART, // engine is shutting down but will restart right away
+ DLL_PAUSED, // engine is paused, can become active from this state
+};
+
+class CEngine
+{
+ public:
+ 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;
+ EngineState_t m_nNextDllState;
+ double m_flCurrentTime;
+ float m_flFrameTime;
+ double m_flPreviousTime;
+ float m_flFilteredTime;
+ float m_flMinFrameTime; // Expected duration of a frame, or zero if it is unlimited.
+};
+
+extern CEngine* g_pEngine;
+
+extern void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
#pragma once
- typedef enum
- {
- NA_NULL = 0,
- NA_LOOPBACK,
- NA_IP,
- } netadrtype_t;
+typedef enum
+{
+ NA_NULL = 0,
+ NA_LOOPBACK,
+ NA_IP,
+} netadrtype_t;
#pragma pack(push, 1)
- typedef struct netadr_s
- {
- netadrtype_t type;
- unsigned char ip[16]; // IPv6
- // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
- // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
- unsigned short port;
- } netadr_t;
+typedef struct netadr_s
+{
+ netadrtype_t type;
+ unsigned char ip[16]; // IPv6
+ // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
+ // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
+ unsigned short port;
+} netadr_t;
#pragma pack(pop)
#pragma pack(push, 1)
- typedef struct netpacket_s
- {
- netadr_t adr; // sender address
- // int source; // received source
- char unk[10];
- double received_time;
- unsigned char* data; // pointer to raw packet data
- void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- char unk2[16];
- int size;
-
- // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- // int size; // size in bytes
- // int wiresize; // size in bytes before decompression
- // bool stream; // was send as stream
- // struct netpacket_s* pNext; // for internal use, should be NULL in public
- } netpacket_t;
+typedef struct netpacket_s
+{
+ netadr_t adr; // sender address
+ // int source; // received source
+ char unk[10];
+ double received_time;
+ unsigned char* data; // pointer to raw packet data
+ void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ char unk2[16];
+ int size;
+
+ // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ // int size; // size in bytes
+ // int wiresize; // size in bytes before decompression
+ // bool stream; // was send as stream
+ // struct netpacket_s* pNext; // for internal use, should be NULL in public
+} netpacket_t;
#pragma pack(pop)
- // #56169 $DB69 PData size
- // #512 $200 Trailing data
- // #100 $64 Safety buffer
- const int PERSISTENCE_MAX_SIZE = 0xDDCD;
-
- // note: NOT_READY and READY are the only entries we have here that are defined by the vanilla game
- // entries after this are custom and used to determine the source of persistence, e.g. whether it is local or remote
- enum class ePersistenceReady : char
- {
- NOT_READY,
- READY = 3,
- READY_INSECURE = 3,
- READY_REMOTE
- };
-
- enum class eSignonState : int
- {
- NONE = 0, // no state yet; about to connect
- CHALLENGE = 1, // client challenging server; all OOB packets
- CONNECTED = 2, // client is connected to server; netchans ready
- NEW = 3, // just got serverinfo and string tables
- PRESPAWN = 4, // received signon buffers
- GETTINGDATA = 5, // respawn-defined signonstate, assumedly this is for persistence
- SPAWN = 6, // ready to receive entity packets
- FIRSTSNAP = 7, // another respawn-defined one
- FULL = 8, // we are fully connected; first non-delta packet received
- CHANGELEVEL = 9, // server is changing level; please wait
- };
-
- // clang-format off
- OFFSET_STRUCT(CBaseClient)
- {
- STRUCT_SIZE(0x2D728)
- FIELD(0x16, char m_Name[64])
- FIELD(0x258, KeyValues* m_ConVars)
- FIELD(0x2A0, eSignonState m_Signon)
- FIELD(0x358, char m_ClanTag[16])
- FIELD(0x484, bool m_bFakePlayer)
- FIELD(0x4A0, ePersistenceReady m_iPersistenceReady)
- FIELD(0x4FA, char m_PersistenceBuffer[PERSISTENCE_MAX_SIZE])
- FIELD(0xF500, char m_UID[32])
- };
- // clang-format on
-
- extern CBaseClient* g_pClientArray;
-
- enum server_state_t
- {
- ss_dead = 0, // Dead
- ss_loading, // Spawning
- ss_active, // Running
- ss_paused, // Running, but paused
- };
-
- extern server_state_t* g_pServerState;
-
- extern char* g_pModName;
-
- // clang-format off
- OFFSET_STRUCT(CGlobalVars)
- {
- FIELD(0x0,
- // Absolute time (per frame still - Use Plat_FloatTime() for a high precision real time
- // perf clock, but not that it doesn't obey host_timescale/host_framerate)
- double m_flRealTime);
-
- FIELDS(0x8,
- // Absolute frame counter - continues to increase even if game is paused
- int m_nFrameCount;
+// #56169 $DB69 PData size
+// #512 $200 Trailing data
+// #100 $64 Safety buffer
+const int PERSISTENCE_MAX_SIZE = 0xDDCD;
+
+// note: NOT_READY and READY are the only entries we have here that are defined by the vanilla game
+// entries after this are custom and used to determine the source of persistence, e.g. whether it is local or remote
+enum class ePersistenceReady : char
+{
+ NOT_READY,
+ READY = 3,
+ READY_INSECURE = 3,
+ READY_REMOTE
+};
+
+enum class eSignonState : int
+{
+ NONE = 0, // no state yet; about to connect
+ CHALLENGE = 1, // client challenging server; all OOB packets
+ CONNECTED = 2, // client is connected to server; netchans ready
+ NEW = 3, // just got serverinfo and string tables
+ PRESPAWN = 4, // received signon buffers
+ GETTINGDATA = 5, // respawn-defined signonstate, assumedly this is for persistence
+ SPAWN = 6, // ready to receive entity packets
+ FIRSTSNAP = 7, // another respawn-defined one
+ FULL = 8, // we are fully connected; first non-delta packet received
+ CHANGELEVEL = 9, // server is changing level; please wait
+};
+
+// clang-format off
+OFFSET_STRUCT(CBaseClient)
+{
+ STRUCT_SIZE(0x2D728)
+ FIELD(0x16, char m_Name[64])
+ FIELD(0x258, KeyValues* m_ConVars)
+ FIELD(0x2A0, eSignonState m_Signon)
+ FIELD(0x358, char m_ClanTag[16])
+ FIELD(0x484, bool m_bFakePlayer)
+ FIELD(0x4A0, ePersistenceReady m_iPersistenceReady)
+ FIELD(0x4FA, char m_PersistenceBuffer[PERSISTENCE_MAX_SIZE])
+ FIELD(0xF500, char m_UID[32])
+};
+// clang-format on
+
+extern CBaseClient* g_pClientArray;
+
+enum server_state_t
+{
+ ss_dead = 0, // Dead
+ ss_loading, // Spawning
+ ss_active, // Running
+ ss_paused, // Running, but paused
+};
+
+extern server_state_t* g_pServerState;
+
+extern char* g_pModName;
+
+// clang-format off
+OFFSET_STRUCT(CGlobalVars)
+{
+ FIELD(0x0,
+ // Absolute time (per frame still - Use Plat_FloatTime() for a high precision real time
+ // perf clock, but not that it doesn't obey host_timescale/host_framerate)
+ double m_flRealTime);
+
+ FIELDS(0x8,
+ // Absolute frame counter - continues to increase even if game is paused
+ int m_nFrameCount;
- // Non-paused frametime
- float m_flAbsoluteFrameTime;
+ // Non-paused frametime
+ float m_flAbsoluteFrameTime;
- // Current time
- //
- // On the client, this (along with tickcount) takes a different meaning based on what
- // piece of code you're in:
- //
- // - While receiving network packets (like in PreDataUpdate/PostDataUpdate and proxies),
- // this is set to the SERVER TICKCOUNT for that packet. There is no interval between
- // the server ticks.
- // [server_current_Tick * tick_interval]
- //
- // - While rendering, this is the exact client clock
- // [client_current_tick * tick_interval + interpolation_amount]
- //
- // - During prediction, this is based on the client's current tick:
- // [client_current_tick * tick_interval]
- float m_flCurTime;
- )
-
- FIELDS(0x30,
- // Time spent on last server or client frame (has nothing to do with think intervals)
- float m_flFrameTime;
-
- // current maxplayers setting
- int m_nMaxClients;
- )
-
- FIELDS(0x3C,
- // Simulation ticks - does not increase when game is paused
- uint32_t m_nTickCount; // this is weird and doesn't seem to increase once per frame?
-
- // Simulation tick interval
- float m_flTickInterval;
- )
-
- FIELDS(0x60,
- const char* m_pMapName;
- int m_nMapVersion;
- )
-
- //FIELD(0x98, double m_flRealTime); // again?
- };
- // clang-format on
-
- extern CGlobalVars* g_pGlobals;
-} // namespace R2
+ // Current time
+ //
+ // On the client, this (along with tickcount) takes a different meaning based on what
+ // piece of code you're in:
+ //
+ // - While receiving network packets (like in PreDataUpdate/PostDataUpdate and proxies),
+ // this is set to the SERVER TICKCOUNT for that packet. There is no interval between
+ // the server ticks.
+ // [server_current_Tick * tick_interval]
+ //
+ // - While rendering, this is the exact client clock
+ // [client_current_tick * tick_interval + interpolation_amount]
+ //
+ // - During prediction, this is based on the client's current tick:
+ // [client_current_tick * tick_interval]
+ float m_flCurTime;
+ )
+
+ FIELDS(0x30,
+ // Time spent on last server or client frame (has nothing to do with think intervals)
+ float m_flFrameTime;
+
+ // current maxplayers setting
+ int m_nMaxClients;
+ )
+
+ FIELDS(0x3C,
+ // Simulation ticks - does not increase when game is paused
+ uint32_t m_nTickCount; // this is weird and doesn't seem to increase once per frame?
+
+ // Simulation tick interval
+ float m_flTickInterval;
+ )
+
+ FIELDS(0x60,
+ const char* m_pMapName;
+ int m_nMapVersion;
+ )
+
+ //FIELD(0x98, double m_flRealTime); // again?
+};
+// clang-format on
+
+extern CGlobalVars* g_pGlobals;
diff --git a/NorthstarDLL/engine/runframe.cpp b/NorthstarDLL/engine/runframe.cpp
index 40a619bb..ddfd9253 100644
--- a/NorthstarDLL/engine/runframe.cpp
+++ b/NorthstarDLL/engine/runframe.cpp
@@ -7,7 +7,7 @@ AUTOHOOK_INIT()
// clang-format off
AUTOHOOK(CEngine__Frame, engine.dll + 0x1C8650,
-void, __fastcall, (R2::CEngine* self))
+void, __fastcall, (CEngine* self))
// clang-format on
{
CEngine__Frame(self);
diff --git a/NorthstarDLL/masterserver/masterserver.cpp b/NorthstarDLL/masterserver/masterserver.cpp
index 53a5fa9a..aa248464 100644
--- a/NorthstarDLL/masterserver/masterserver.cpp
+++ b/NorthstarDLL/masterserver/masterserver.cpp
@@ -64,7 +64,7 @@ void SetCommonHttpClientOptions(CURL* curl)
// seconds.
curl_easy_setopt(curl, CURLOPT_TIMEOUT, 30L);
// curl_easy_setopt(curl, CURLOPT_STDERR, stdout);
- if (Tier0::CommandLine()->FindParm("-msinsecure")) // TODO: this check doesn't seem to work
+ if (CommandLine()->FindParm("-msinsecure")) // TODO: this check doesn't seem to work
{
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
@@ -589,7 +589,7 @@ void MasterServerManager::AuthenticateWithOwnServer(const char* uid, const char*
if (m_bNewgameAfterSelfAuth)
{
// pretty sure this is threadsafe?
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "ns_end_reauth_and_leave_to_lobby", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "ns_end_reauth_and_leave_to_lobby", cmd_source_t::kCommandSrcCode);
m_bNewgameAfterSelfAuth = false;
}
@@ -897,12 +897,12 @@ void MasterServerManager::ProcessConnectionlessPacketSigreq1(std::string data)
return;
}
- if (pdata.length() > R2::PERSISTENCE_MAX_SIZE)
+ if (pdata.length() > PERSISTENCE_MAX_SIZE)
{
spdlog::error(
"failed to make Atlas connect pdata request {}: pdata is too large (max={} len={})",
token,
- R2::PERSISTENCE_MAX_SIZE,
+ PERSISTENCE_MAX_SIZE,
pdata.length());
return;
}
@@ -1022,7 +1022,7 @@ void MasterServerPresenceReporter::ReportPresence(const ServerPresence* pServerP
}
// Make sure to wait til the cooldown is over for DUPLICATE_SERVER failures.
- if (Tier0::Plat_FloatTime() < m_fNextAddServerAttemptTime)
+ if (Plat_FloatTime() < m_fNextAddServerAttemptTime)
{
return;
}
@@ -1124,7 +1124,7 @@ void MasterServerPresenceReporter::RunFrame(double flCurrentTime, const ServerPr
case MasterServerReportPresenceResult::FailedDuplicateServer:
++m_nNumRegistrationAttempts;
// Wait at least twenty seconds until we re-attempt to add the server.
- m_fNextAddServerAttemptTime = Tier0::Plat_FloatTime() + 20.0f;
+ m_fNextAddServerAttemptTime = Plat_FloatTime() + 20.0f;
break;
}
diff --git a/NorthstarDLL/mods/compiled/kb_act.cpp b/NorthstarDLL/mods/compiled/kb_act.cpp
index 3fc7ee30..6117fd28 100644
--- a/NorthstarDLL/mods/compiled/kb_act.cpp
+++ b/NorthstarDLL/mods/compiled/kb_act.cpp
@@ -14,7 +14,7 @@ void ModManager::BuildKBActionsList()
std::ofstream soCompiledKeys(GetCompiledAssetsPath() / KB_ACT_PATH, std::ios::binary);
// write vanilla file's content to compiled file
- soCompiledKeys << R2::ReadVPKOriginalFile(KB_ACT_PATH);
+ soCompiledKeys << ReadVPKOriginalFile(KB_ACT_PATH);
for (Mod& mod : m_LoadedMods)
{
diff --git a/NorthstarDLL/mods/compiled/modkeyvalues.cpp b/NorthstarDLL/mods/compiled/modkeyvalues.cpp
index fe262a60..e44a81d3 100644
--- a/NorthstarDLL/mods/compiled/modkeyvalues.cpp
+++ b/NorthstarDLL/mods/compiled/modkeyvalues.cpp
@@ -56,7 +56,7 @@ void ModManager::TryBuildKeyValues(const char* filename)
newKvs += "\"\n";
// load original file, so we can parse out the name of the root obj (e.g. WeaponData for weapons)
- std::string originalFile = R2::ReadVPKOriginalFile(filename);
+ std::string originalFile = ReadVPKOriginalFile(filename);
if (!originalFile.length())
{
diff --git a/NorthstarDLL/mods/compiled/modpdef.cpp b/NorthstarDLL/mods/compiled/modpdef.cpp
index 4b1b12b7..d268a063 100644
--- a/NorthstarDLL/mods/compiled/modpdef.cpp
+++ b/NorthstarDLL/mods/compiled/modpdef.cpp
@@ -15,7 +15,7 @@ void ModManager::BuildPdef()
fs::path MOD_PDEF_PATH = fs::path(GetCompiledAssetsPath() / MOD_PDEF_SUFFIX);
fs::remove(MOD_PDEF_PATH);
- std::string pdef = R2::ReadVPKOriginalFile(VPK_PDEF_PATH);
+ std::string pdef = ReadVPKOriginalFile(VPK_PDEF_PATH);
for (Mod& mod : m_LoadedMods)
{
diff --git a/NorthstarDLL/mods/compiled/modscriptsrson.cpp b/NorthstarDLL/mods/compiled/modscriptsrson.cpp
index cbe26651..d130745f 100644
--- a/NorthstarDLL/mods/compiled/modscriptsrson.cpp
+++ b/NorthstarDLL/mods/compiled/modscriptsrson.cpp
@@ -13,7 +13,7 @@ void ModManager::BuildScriptsRson()
fs::path MOD_SCRIPTS_RSON_PATH = fs::path(GetCompiledAssetsPath() / MOD_SCRIPTS_RSON_SUFFIX);
fs::remove(MOD_SCRIPTS_RSON_PATH);
- std::string scriptsRson = R2::ReadVPKOriginalFile(VPK_SCRIPTS_RSON_PATH);
+ std::string scriptsRson = ReadVPKOriginalFile(VPK_SCRIPTS_RSON_PATH);
scriptsRson += "\n\n// START MODDED SCRIPT CONTENT\n\n"; // newline before we start custom stuff
for (Mod& mod : m_LoadedMods)
diff --git a/NorthstarDLL/mods/modmanager.cpp b/NorthstarDLL/mods/modmanager.cpp
index 982f5068..8a0eb71d 100644
--- a/NorthstarDLL/mods/modmanager.cpp
+++ b/NorthstarDLL/mods/modmanager.cpp
@@ -760,7 +760,7 @@ void ModManager::LoadMods()
{
// make sure convar isn't registered yet, unsure if necessary but idk what
// behaviour is for defining same convar multiple times
- if (!R2::g_pCVar->FindVar(convar->Name.c_str()))
+ if (!g_pCVar->FindVar(convar->Name.c_str()))
{
new ConVar(convar->Name.c_str(), convar->DefaultValue.c_str(), convar->Flags, convar->HelpString.c_str());
}
@@ -769,7 +769,7 @@ void ModManager::LoadMods()
for (ModConCommand* command : mod.ConCommands)
{
// make sure command isnt't registered multiple times.
- if (!R2::g_pCVar->FindCommand(command->Name.c_str()))
+ if (!g_pCVar->FindCommand(command->Name.c_str()))
{
ConCommand* newCommand = new ConCommand();
std::string funcName = command->Function;
@@ -818,7 +818,7 @@ void ModManager::LoadMods()
modVpk.m_sVpkPath = (file.path().parent_path() / vpkName).string();
if (m_bHasLoadedMods && modVpk.m_bAutoLoad)
- (*R2::g_pFilesystem)->m_vtable->MountVPK(*R2::g_pFilesystem, vpkName.c_str());
+ (*g_pFilesystem)->m_vtable->MountVPK(*g_pFilesystem, vpkName.c_str());
}
}
}
diff --git a/NorthstarDLL/mods/modsavefiles.cpp b/NorthstarDLL/mods/modsavefiles.cpp
index f8e5848c..68e33864 100644
--- a/NorthstarDLL/mods/modsavefiles.cpp
+++ b/NorthstarDLL/mods/modsavefiles.cpp
@@ -561,9 +561,9 @@ ON_DLL_LOAD("engine.dll", ModSaveFFiles_Init, (CModule module))
{
savePath = fs::path(GetNorthstarPrefix()) / "save_data";
g_pSaveFileManager = new SaveFileManager;
- int parm = Tier0::CommandLine()->FindParm("-maxfoldersize");
+ int parm = CommandLine()->FindParm("-maxfoldersize");
if (parm)
- MAX_FOLDER_SIZE = std::stoi(Tier0::CommandLine()->GetParm(parm));
+ MAX_FOLDER_SIZE = std::stoi(CommandLine()->GetParm(parm));
}
int GetMaxSaveFolderSize()
diff --git a/NorthstarDLL/scripts/client/clientchathooks.cpp b/NorthstarDLL/scripts/client/clientchathooks.cpp
index df9497ef..e084f47e 100644
--- a/NorthstarDLL/scripts/client/clientchathooks.cpp
+++ b/NorthstarDLL/scripts/client/clientchathooks.cpp
@@ -30,7 +30,7 @@ void, __fastcall, (void* self, const char* message, int inboxId, bool isTeam, bo
payload = message + 1;
}
- NS::Utils::RemoveAsciiControlSequences(const_cast<char*>(message), true);
+ RemoveAsciiControlSequences(const_cast<char*>(message), true);
SQRESULT result = g_pSquirrel<ScriptContext::CLIENT>->Call(
"CHudChat_ProcessMessageStartThread", static_cast<int>(senderId) - 1, payload, isTeam, isDead, type);
diff --git a/NorthstarDLL/scripts/client/scriptserverbrowser.cpp b/NorthstarDLL/scripts/client/scriptserverbrowser.cpp
index 1945b3dc..a142c3f4 100644
--- a/NorthstarDLL/scripts/client/scriptserverbrowser.cpp
+++ b/NorthstarDLL/scripts/client/scriptserverbrowser.cpp
@@ -62,7 +62,7 @@ ADD_SQFUNC("void", NSTryAuthWithServer, "int serverIndex, string password = ''",
// do auth
g_pMasterServerManager->AuthenticateWithServer(
- R2::g_pLocalPlayerUserID,
+ g_pLocalPlayerUserID,
g_pMasterServerManager->m_sOwnClientAuthToken,
g_pMasterServerManager->m_vRemoteServers[serverIndex],
(char*)password);
@@ -95,9 +95,9 @@ ADD_SQFUNC("void", NSConnectToAuthedServer, "", "", ScriptContext::UI)
// set auth token, then try to connect
// i'm honestly not entirely sure how silentconnect works regarding ports and encryption so using connect for now
- R2::g_pCVar->FindVar("serverfilter")->SetValue(info.authToken);
- R2::Cbuf_AddText(
- R2::Cbuf_GetCurrentPlayer(),
+ g_pCVar->FindVar("serverfilter")->SetValue(info.authToken);
+ Cbuf_AddText(
+ Cbuf_GetCurrentPlayer(),
fmt::format(
"connect {}.{}.{}.{}:{}",
info.ip.S_un.S_un_b.s_b1,
@@ -106,7 +106,7 @@ ADD_SQFUNC("void", NSConnectToAuthedServer, "", "", ScriptContext::UI)
info.ip.S_un.S_un_b.s_b4,
info.port)
.c_str(),
- R2::cmd_source_t::kCommandSrcCode);
+ cmd_source_t::kCommandSrcCode);
g_pMasterServerManager->m_bHasPendingConnectionInfo = false;
return SQRESULT_NULL;
@@ -115,7 +115,7 @@ ADD_SQFUNC("void", NSConnectToAuthedServer, "", "", ScriptContext::UI)
ADD_SQFUNC("void", NSTryAuthWithLocalServer, "", "", ScriptContext::UI)
{
// do auth request
- g_pMasterServerManager->AuthenticateWithOwnServer(R2::g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken);
+ g_pMasterServerManager->AuthenticateWithOwnServer(g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken);
return SQRESULT_NULL;
}
@@ -125,7 +125,7 @@ ADD_SQFUNC("void", NSCompleteAuthWithLocalServer, "", "", ScriptContext::UI)
// literally just set serverfilter
// note: this assumes we have no authdata other than our own
if (g_pServerAuthentication->m_RemoteAuthenticationData.size())
- R2::g_pCVar->FindVar("serverfilter")->SetValue(g_pServerAuthentication->m_RemoteAuthenticationData.begin()->first.c_str());
+ g_pCVar->FindVar("serverfilter")->SetValue(g_pServerAuthentication->m_RemoteAuthenticationData.begin()->first.c_str());
return SQRESULT_NULL;
}
diff --git a/NorthstarDLL/scripts/scriptdatatables.cpp b/NorthstarDLL/scripts/scriptdatatables.cpp
index 532624f3..87a26dca 100644
--- a/NorthstarDLL/scripts/scriptdatatables.cpp
+++ b/NorthstarDLL/scripts/scriptdatatables.cpp
@@ -132,9 +132,9 @@ REPLACE_SQFUNC(GetDataTable, (ScriptContext::UI | ScriptContext::CLIENT | Script
diskAssetPath /= fs::path(pAssetName);
std::string sDiskAssetPath(diskAssetPath.string());
- if ((*R2::g_pFilesystem)->m_vtable2->FileExists(&(*R2::g_pFilesystem)->m_vtable2, sDiskAssetPath.c_str(), "GAME"))
+ if ((*g_pFilesystem)->m_vtable2->FileExists(&(*g_pFilesystem)->m_vtable2, sDiskAssetPath.c_str(), "GAME"))
{
- std::string sTableCSV = R2::ReadVPKFile(sDiskAssetPath.c_str());
+ std::string sTableCSV = ReadVPKFile(sDiskAssetPath.c_str());
if (!sTableCSV.size())
{
g_pSquirrel<context>->raiseerror(sqvm, fmt::format("Datatable \"{}\" is empty", pAssetName).c_str());
@@ -793,7 +793,7 @@ void DumpDatatable(const char* pDatatablePath)
return;
}
- std::string sOutputPath(fmt::format("{}/scripts/datatable/{}.csv", R2::g_pModName, fs::path(pDatatablePath).stem().string()));
+ std::string sOutputPath(fmt::format("{}/scripts/datatable/{}.csv", g_pModName, fs::path(pDatatablePath).stem().string()));
std::string sDatatableContents(DataTableToString(pDatatable));
fs::create_directories(fs::path(sOutputPath).remove_filename());
@@ -900,7 +900,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", SharedScriptDataTables, ConVar, (CModule modu
{
Cvar_ns_prefer_datatable_from_disk = new ConVar(
"ns_prefer_datatable_from_disk",
- IsDedicatedServer() && Tier0::CommandLine()->CheckParm("-nopakdedi") ? "1" : "0",
+ IsDedicatedServer() && CommandLine()->CheckParm("-nopakdedi") ? "1" : "0",
FCVAR_NONE,
"whether to prefer loading datatables from disk, rather than rpak");
diff --git a/NorthstarDLL/scripts/scripthttprequesthandler.cpp b/NorthstarDLL/scripts/scripthttprequesthandler.cpp
index 813bd50e..aa75127a 100644
--- a/NorthstarDLL/scripts/scripthttprequesthandler.cpp
+++ b/NorthstarDLL/scripts/scripthttprequesthandler.cpp
@@ -7,19 +7,19 @@ HttpRequestHandler* g_httpRequestHandler;
bool IsHttpDisabled()
{
- const static bool bIsHttpDisabled = Tier0::CommandLine()->FindParm("-disablehttprequests");
+ const static bool bIsHttpDisabled = CommandLine()->FindParm("-disablehttprequests");
return bIsHttpDisabled;
}
bool IsLocalHttpAllowed()
{
- const static bool bIsLocalHttpAllowed = Tier0::CommandLine()->FindParm("-allowlocalhttp");
+ const static bool bIsLocalHttpAllowed = CommandLine()->FindParm("-allowlocalhttp");
return bIsLocalHttpAllowed;
}
bool DisableHttpSsl()
{
- const static bool bDisableHttpSsl = Tier0::CommandLine()->FindParm("-disablehttpssl");
+ const static bool bDisableHttpSsl = CommandLine()->FindParm("-disablehttpssl");
return bDisableHttpSsl;
}
diff --git a/NorthstarDLL/scripts/scriptutility.cpp b/NorthstarDLL/scripts/scriptutility.cpp
index 054836ca..4b92fa02 100644
--- a/NorthstarDLL/scripts/scriptutility.cpp
+++ b/NorthstarDLL/scripts/scriptutility.cpp
@@ -18,9 +18,9 @@ ADD_SQFUNC(
ADD_SQFUNC(
"string", NSGetLocalPlayerUID, "", "Returns the local player's uid.", ScriptContext::UI | ScriptContext::CLIENT | ScriptContext::SERVER)
{
- if (R2::g_pLocalPlayerUserID)
+ if (g_pLocalPlayerUserID)
{
- g_pSquirrel<context>->pushstring(sqvm, R2::g_pLocalPlayerUserID);
+ g_pSquirrel<context>->pushstring(sqvm, g_pLocalPlayerUserID);
return SQRESULT_NOTNULL;
}
diff --git a/NorthstarDLL/scripts/server/miscserverscript.cpp b/NorthstarDLL/scripts/server/miscserverscript.cpp
index 3ea44ceb..ed6e4800 100644
--- a/NorthstarDLL/scripts/server/miscserverscript.cpp
+++ b/NorthstarDLL/scripts/server/miscserverscript.cpp
@@ -9,7 +9,7 @@
ADD_SQFUNC("void", NSEarlyWritePlayerPersistenceForLeave, "entity player", "", ScriptContext::SERVER)
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<context>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<context>->template getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
spdlog::warn("NSEarlyWritePlayerPersistenceForLeave got null player");
@@ -18,7 +18,7 @@ ADD_SQFUNC("void", NSEarlyWritePlayerPersistenceForLeave, "entity player", "", S
return SQRESULT_NOTNULL;
}
- R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1];
+ CBaseClient* pClient = &g_pClientArray[pPlayer->m_nPlayerIndex - 1];
if (g_pServerAuthentication->m_PlayerAuthenticationData.find(pClient) == g_pServerAuthentication->m_PlayerAuthenticationData.end())
{
g_pSquirrel<context>->pushbool(sqvm, false);
@@ -38,7 +38,7 @@ ADD_SQFUNC("bool", NSIsWritingPlayerPersistence, "", "", ScriptContext::SERVER)
ADD_SQFUNC("bool", NSIsPlayerLocalPlayer, "entity player", "", ScriptContext::SERVER)
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
spdlog::warn("NSIsPlayerLocalPlayer got null player");
@@ -47,8 +47,8 @@ ADD_SQFUNC("bool", NSIsPlayerLocalPlayer, "entity player", "", ScriptContext::SE
return SQRESULT_NOTNULL;
}
- R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1];
- g_pSquirrel<context>->pushbool(sqvm, !strcmp(R2::g_pLocalPlayerUserID, pClient->m_UID));
+ CBaseClient* pClient = &g_pClientArray[pPlayer->m_nPlayerIndex - 1];
+ g_pSquirrel<context>->pushbool(sqvm, !strcmp(g_pLocalPlayerUserID, pClient->m_UID));
return SQRESULT_NOTNULL;
}
@@ -65,7 +65,7 @@ ADD_SQFUNC(
"Disconnects the player from the server with the given reason",
ScriptContext::SERVER)
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<context>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<context>->template getentity<CBasePlayer>(sqvm, 1);
const char* reason = g_pSquirrel<context>->getstring(sqvm, 2);
if (!pPlayer)
@@ -77,7 +77,7 @@ ADD_SQFUNC(
}
// Shouldn't happen but I like sanity checks.
- R2::CBaseClient* pClient = &R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1];
+ CBaseClient* pClient = &g_pClientArray[pPlayer->m_nPlayerIndex - 1];
if (!pClient)
{
spdlog::warn("NSDisconnectPlayer(): player entity has null CBaseClient!");
@@ -88,11 +88,11 @@ ADD_SQFUNC(
if (reason)
{
- R2::CBaseClient__Disconnect(pClient, 1, reason);
+ CBaseClient__Disconnect(pClient, 1, reason);
}
else
{
- R2::CBaseClient__Disconnect(pClient, 1, "Disconnected by the server.");
+ CBaseClient__Disconnect(pClient, 1, "Disconnected by the server.");
}
g_pSquirrel<context>->pushbool(sqvm, true);
diff --git a/NorthstarDLL/scripts/server/scriptuserinfo.cpp b/NorthstarDLL/scripts/server/scriptuserinfo.cpp
index fac458a3..c53a9d22 100644
--- a/NorthstarDLL/scripts/server/scriptuserinfo.cpp
+++ b/NorthstarDLL/scripts/server/scriptuserinfo.cpp
@@ -7,7 +7,7 @@ ADD_SQFUNC("string", GetUserInfoKVString_Internal, "entity player, string key, s
"Gets the string value of a given player's userinfo convar by name", ScriptContext::SERVER)
// clang-format on
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, "player is null");
@@ -17,7 +17,7 @@ ADD_SQFUNC("string", GetUserInfoKVString_Internal, "entity player, string key, s
const char* pKey = g_pSquirrel<ScriptContext::SERVER>->getstring(sqvm, 2);
const char* pDefaultValue = g_pSquirrel<ScriptContext::SERVER>->getstring(sqvm, 3);
- const char* pResult = R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetString(pKey, pDefaultValue);
+ const char* pResult = g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetString(pKey, pDefaultValue);
g_pSquirrel<ScriptContext::SERVER>->pushstring(sqvm, pResult);
return SQRESULT_NOTNULL;
}
@@ -27,7 +27,7 @@ ADD_SQFUNC("asset", GetUserInfoKVAsset_Internal, "entity player, string key, ass
"Gets the asset value of a given player's userinfo convar by name", ScriptContext::SERVER)
// clang-format on
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, "player is null");
@@ -38,7 +38,7 @@ ADD_SQFUNC("asset", GetUserInfoKVAsset_Internal, "entity player, string key, ass
const char* pDefaultValue;
g_pSquirrel<ScriptContext::SERVER>->getasset(sqvm, 3, &pDefaultValue);
- const char* pResult = R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetString(pKey, pDefaultValue);
+ const char* pResult = g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetString(pKey, pDefaultValue);
g_pSquirrel<ScriptContext::SERVER>->pushasset(sqvm, pResult);
return SQRESULT_NOTNULL;
}
@@ -48,7 +48,7 @@ ADD_SQFUNC("int", GetUserInfoKVInt_Internal, "entity player, string key, int def
"Gets the int value of a given player's userinfo convar by name", ScriptContext::SERVER)
// clang-format on
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->template getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, "player is null");
@@ -58,7 +58,7 @@ ADD_SQFUNC("int", GetUserInfoKVInt_Internal, "entity player, string key, int def
const char* pKey = g_pSquirrel<ScriptContext::SERVER>->getstring(sqvm, 2);
const int iDefaultValue = g_pSquirrel<ScriptContext::SERVER>->getinteger(sqvm, 3);
- const int iResult = R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetInt(pKey, iDefaultValue);
+ const int iResult = g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetInt(pKey, iDefaultValue);
g_pSquirrel<ScriptContext::SERVER>->pushinteger(sqvm, iResult);
return SQRESULT_NOTNULL;
}
@@ -68,7 +68,7 @@ ADD_SQFUNC("float", GetUserInfoKVFloat_Internal, "entity player, string key, flo
"Gets the float value of a given player's userinfo convar by name", ScriptContext::SERVER)
// clang-format on
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, "player is null");
@@ -78,7 +78,7 @@ ADD_SQFUNC("float", GetUserInfoKVFloat_Internal, "entity player, string key, flo
const char* pKey = g_pSquirrel<ScriptContext::SERVER>->getstring(sqvm, 2);
const float flDefaultValue = g_pSquirrel<ScriptContext::SERVER>->getfloat(sqvm, 3);
- const float flResult = R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetFloat(pKey, flDefaultValue);
+ const float flResult = g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetFloat(pKey, flDefaultValue);
g_pSquirrel<ScriptContext::SERVER>->pushfloat(sqvm, flResult);
return SQRESULT_NOTNULL;
}
@@ -88,7 +88,7 @@ ADD_SQFUNC("bool", GetUserInfoKVBool_Internal, "entity player, string key, bool
"Gets the bool value of a given player's userinfo convar by name", ScriptContext::SERVER)
// clang-format on
{
- const R2::CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<R2::CBasePlayer>(sqvm, 1);
+ const CBasePlayer* pPlayer = g_pSquirrel<ScriptContext::SERVER>->getentity<CBasePlayer>(sqvm, 1);
if (!pPlayer)
{
g_pSquirrel<ScriptContext::SERVER>->raiseerror(sqvm, "player is null");
@@ -98,7 +98,7 @@ ADD_SQFUNC("bool", GetUserInfoKVBool_Internal, "entity player, string key, bool
const char* pKey = g_pSquirrel<ScriptContext::SERVER>->getstring(sqvm, 2);
const bool bDefaultValue = g_pSquirrel<ScriptContext::SERVER>->getbool(sqvm, 3);
- const bool bResult = R2::g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetInt(pKey, bDefaultValue);
+ const bool bResult = g_pClientArray[pPlayer->m_nPlayerIndex - 1].m_ConVars->GetInt(pKey, bDefaultValue);
g_pSquirrel<ScriptContext::SERVER>->pushbool(sqvm, bResult);
return SQRESULT_NOTNULL;
}
diff --git a/NorthstarDLL/server/alltalk.cpp b/NorthstarDLL/server/alltalk.cpp
index d71b0bae..74119309 100644
--- a/NorthstarDLL/server/alltalk.cpp
+++ b/NorthstarDLL/server/alltalk.cpp
@@ -4,12 +4,12 @@
size_t __fastcall ShouldAllowAlltalk()
{
// this needs to return a 64 bit integer where 0 = true and 1 = false
- static ConVar* Cvar_sv_alltalk = R2::g_pCVar->FindVar("sv_alltalk");
+ static ConVar* Cvar_sv_alltalk = g_pCVar->FindVar("sv_alltalk");
if (Cvar_sv_alltalk->GetBool())
return 0;
// lobby should default to alltalk, otherwise don't allow it
- return strcmp(R2::g_pGlobals->m_pMapName, "mp_lobby");
+ return strcmp(g_pGlobals->m_pMapName, "mp_lobby");
}
ON_DLL_LOAD_RELIESON("engine.dll", ServerAllTalk, ConVar, (CModule module))
diff --git a/NorthstarDLL/server/auth/bansystem.cpp b/NorthstarDLL/server/auth/bansystem.cpp
index 9b9d24c4..a45cde93 100644
--- a/NorthstarDLL/server/auth/bansystem.cpp
+++ b/NorthstarDLL/server/auth/bansystem.cpp
@@ -173,7 +173,7 @@ void ServerBanSystem::UnbanUID(uint64_t uid)
bool ServerBanSystem::IsUIDAllowed(uint64_t uid)
{
- uint64_t localPlayerUserID = strtoull(R2::g_pLocalPlayerUserID, nullptr, 10);
+ uint64_t localPlayerUserID = strtoull(g_pLocalPlayerUserID, nullptr, 10);
if (localPlayerUserID == uid)
return true;
@@ -186,14 +186,14 @@ void ConCommand_ban(const CCommand& args)
if (args.ArgC() < 2)
return;
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* player = &R2::g_pClientArray[i];
+ CBaseClient* player = &g_pClientArray[i];
if (!strcmp(player->m_Name, args.Arg(1)) || !strcmp(player->m_UID, args.Arg(1)))
{
g_pBanSystem->BanUID(strtoull(player->m_UID, nullptr, 10));
- R2::CBaseClient__Disconnect(player, 1, "Banned from server");
+ CBaseClient__Disconnect(player, 1, "Banned from server");
break;
}
}
diff --git a/NorthstarDLL/server/auth/serverauthentication.cpp b/NorthstarDLL/server/auth/serverauthentication.cpp
index d5653dcc..0d46426f 100644
--- a/NorthstarDLL/server/auth/serverauthentication.cpp
+++ b/NorthstarDLL/server/auth/serverauthentication.cpp
@@ -40,7 +40,7 @@ void ServerAuthenticationManager::AddRemotePlayer(std::string token, uint64_t ui
m_RemoteAuthenticationData[token] = newAuthData;
}
-void ServerAuthenticationManager::AddPlayer(R2::CBaseClient* pPlayer, const char* pToken)
+void ServerAuthenticationManager::AddPlayer(CBaseClient* pPlayer, const char* pToken)
{
PlayerAuthenticationData additionalData;
@@ -48,14 +48,14 @@ void ServerAuthenticationManager::AddPlayer(R2::CBaseClient* pPlayer, const char
if (remoteAuthData != m_RemoteAuthenticationData.end())
additionalData.pdataSize = remoteAuthData->second.pdataSize;
else
- additionalData.pdataSize = R2::PERSISTENCE_MAX_SIZE;
+ additionalData.pdataSize = PERSISTENCE_MAX_SIZE;
- additionalData.usingLocalPdata = pPlayer->m_iPersistenceReady == R2::ePersistenceReady::READY_INSECURE;
+ additionalData.usingLocalPdata = pPlayer->m_iPersistenceReady == ePersistenceReady::READY_INSECURE;
m_PlayerAuthenticationData.insert(std::make_pair(pPlayer, additionalData));
}
-void ServerAuthenticationManager::RemovePlayer(R2::CBaseClient* pPlayer)
+void ServerAuthenticationManager::RemovePlayer(CBaseClient* pPlayer)
{
if (m_PlayerAuthenticationData.count(pPlayer))
m_PlayerAuthenticationData.erase(pPlayer);
@@ -88,20 +88,20 @@ bool ServerAuthenticationManager::VerifyPlayerName(const char* pAuthToken, const
return true;
}
-bool ServerAuthenticationManager::IsDuplicateAccount(R2::CBaseClient* pPlayer, const char* pPlayerUid)
+bool ServerAuthenticationManager::IsDuplicateAccount(CBaseClient* pPlayer, const char* pPlayerUid)
{
if (m_bAllowDuplicateAccounts)
return false;
bool bHasUidPlayer = false;
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
- if (&R2::g_pClientArray[i] != pPlayer && !strcmp(pPlayerUid, R2::g_pClientArray[i].m_UID))
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
+ if (&g_pClientArray[i] != pPlayer && !strcmp(pPlayerUid, g_pClientArray[i].m_UID))
return true;
return false;
}
-bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
+bool ServerAuthenticationManager::CheckAuthentication(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
{
std::string sUid = std::to_string(iUid);
@@ -111,7 +111,7 @@ bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer,
return true;
// local server that doesn't need auth (probably sp) and local player
- if (m_bStartingLocalSPGame && !strcmp(sUid.c_str(), R2::g_pLocalPlayerUserID))
+ if (m_bStartingLocalSPGame && !strcmp(sUid.c_str(), g_pLocalPlayerUserID))
return true;
// don't allow duplicate accounts
@@ -126,7 +126,7 @@ bool ServerAuthenticationManager::CheckAuthentication(R2::CBaseClient* pPlayer,
return false;
}
-void ServerAuthenticationManager::AuthenticatePlayer(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
+void ServerAuthenticationManager::AuthenticatePlayer(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken)
{
// for bot players, generate a new uid
if (pPlayer->m_bFakePlayer)
@@ -142,31 +142,31 @@ void ServerAuthenticationManager::AuthenticatePlayer(R2::CBaseClient* pPlayer, u
if (authData != m_RemoteAuthenticationData.end())
{
// if we're resetting let script handle the reset with InitPersistentData() on connect
- if (!m_bForceResetLocalPlayerPersistence || strcmp(sUid.c_str(), R2::g_pLocalPlayerUserID))
+ if (!m_bForceResetLocalPlayerPersistence || strcmp(sUid.c_str(), g_pLocalPlayerUserID))
{
// copy pdata into buffer
memcpy(pPlayer->m_PersistenceBuffer, authData->second.pdata, authData->second.pdataSize);
}
// set persistent data as ready
- pPlayer->m_iPersistenceReady = R2::ePersistenceReady::READY_REMOTE;
+ pPlayer->m_iPersistenceReady = ePersistenceReady::READY_REMOTE;
}
// we probably allow insecure at this point, but make sure not to write anyway if not insecure
else if (Cvar_ns_auth_allow_insecure->GetBool() || pPlayer->m_bFakePlayer)
{
// set persistent data as ready
// note: actual placeholder persistent data is populated in script with InitPersistentData()
- pPlayer->m_iPersistenceReady = R2::ePersistenceReady::READY_INSECURE;
+ pPlayer->m_iPersistenceReady = ePersistenceReady::READY_INSECURE;
}
}
-bool ServerAuthenticationManager::RemovePlayerAuthData(R2::CBaseClient* pPlayer)
+bool ServerAuthenticationManager::RemovePlayerAuthData(CBaseClient* pPlayer)
{
if (!Cvar_ns_erase_auth_info->GetBool()) // keep auth data forever
return false;
// hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect
- if (m_bNeedLocalAuthForNewgame && !strcmp(pPlayer->m_UID, R2::g_pLocalPlayerUserID))
+ if (m_bNeedLocalAuthForNewgame && !strcmp(pPlayer->m_UID, g_pLocalPlayerUserID))
return false;
// we don't have our auth token at this point, so lookup authdata by uid
@@ -187,9 +187,9 @@ bool ServerAuthenticationManager::RemovePlayerAuthData(R2::CBaseClient* pPlayer)
return false;
}
-void ServerAuthenticationManager::WritePersistentData(R2::CBaseClient* pPlayer)
+void ServerAuthenticationManager::WritePersistentData(CBaseClient* pPlayer)
{
- if (pPlayer->m_iPersistenceReady == R2::ePersistenceReady::READY_REMOTE)
+ if (pPlayer->m_iPersistenceReady == ePersistenceReady::READY_REMOTE)
{
g_pMasterServerManager->WritePlayerPersistentData(
pPlayer->m_UID, (const char*)pPlayer->m_PersistenceBuffer, m_PlayerAuthenticationData[pPlayer].pdataSize);
@@ -240,7 +240,7 @@ ConVar* Cvar_ns_allowuserclantags;
// clang-format off
AUTOHOOK(CBaseClient__Connect, engine.dll + 0x101740,
-bool,, (R2::CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, void* a5, char pDisconnectReason[256], void* a7))
+bool,, (CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer, void* a5, char pDisconnectReason[256], void* a7))
// clang-format on
{
const char* pAuthenticationFailure = nullptr;
@@ -281,13 +281,13 @@ bool,, (R2::CBaseClient* self, char* pName, void* pNetChannel, char bFakePlayer,
// clang-format off
AUTOHOOK(CBaseClient__ActivatePlayer, engine.dll + 0x100F80,
-void,, (R2::CBaseClient* self))
+void,, (CBaseClient* self))
// clang-format on
{
// if we're authed, write our persistent data
// RemovePlayerAuthData returns true if it removed successfully, i.e. on first call only, and we only want to write on >= second call
// (since this func is called on map loads)
- if (self->m_iPersistenceReady >= R2::ePersistenceReady::READY && !g_pServerAuthentication->RemovePlayerAuthData(self))
+ if (self->m_iPersistenceReady >= ePersistenceReady::READY && !g_pServerAuthentication->RemovePlayerAuthData(self))
{
g_pServerAuthentication->m_bForceResetLocalPlayerPersistence = false;
g_pServerAuthentication->WritePersistentData(self);
@@ -299,7 +299,7 @@ void,, (R2::CBaseClient* self))
// clang-format off
AUTOHOOK(_CBaseClient__Disconnect, engine.dll + 0x1012C0,
-void,, (R2::CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...))
+void,, (CBaseClient* self, uint32_t unknownButAlways1, const char* pReason, ...))
// clang-format on
{
// have to manually format message because can't pass varargs to original func
@@ -333,7 +333,7 @@ void,, (R2::CBaseClient* self, uint32_t unknownButAlways1, const char* pReason,
void ConCommand_ns_resetpersistence(const CCommand& args)
{
- if (*R2::g_pServerState == R2::server_state_t::ss_active)
+ if (*g_pServerState == server_state_t::ss_active)
{
spdlog::error("ns_resetpersistence must be entered from the main menu");
return;
@@ -370,7 +370,7 @@ ON_DLL_LOAD_RELIESON("engine.dll", ServerAuthentication, (ConCommand, ConVar), (
CBaseServer__RejectConnection = module.Offset(0x1182E0).RCast<CBaseServer__RejectConnectionType>();
- if (Tier0::CommandLine()->CheckParm("-allowdupeaccounts"))
+ if (CommandLine()->CheckParm("-allowdupeaccounts"))
{
// patch to allow same of multiple account
module.Offset(0x114510).Patch("EB");
diff --git a/NorthstarDLL/server/auth/serverauthentication.h b/NorthstarDLL/server/auth/serverauthentication.h
index dd0e13af..32e1d0a8 100644
--- a/NorthstarDLL/server/auth/serverauthentication.h
+++ b/NorthstarDLL/server/auth/serverauthentication.h
@@ -33,7 +33,7 @@ class ServerAuthenticationManager
std::mutex m_AuthDataMutex;
std::unordered_map<std::string, RemoteAuthData> m_RemoteAuthenticationData;
- std::unordered_map<R2::CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData;
+ std::unordered_map<CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData;
bool m_bAllowDuplicateAccounts = false;
bool m_bNeedLocalAuthForNewgame = false;
@@ -43,16 +43,16 @@ class ServerAuthenticationManager
public:
void AddRemotePlayer(std::string token, uint64_t uid, std::string username, std::string pdata);
- void AddPlayer(R2::CBaseClient* pPlayer, const char* pAuthToken);
- void RemovePlayer(R2::CBaseClient* pPlayer);
+ void AddPlayer(CBaseClient* pPlayer, const char* pAuthToken);
+ void RemovePlayer(CBaseClient* pPlayer);
bool VerifyPlayerName(const char* pAuthToken, const char* pName, char pOutVerifiedName[64]);
- bool IsDuplicateAccount(R2::CBaseClient* pPlayer, const char* pUid);
- bool CheckAuthentication(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
+ bool IsDuplicateAccount(CBaseClient* pPlayer, const char* pUid);
+ bool CheckAuthentication(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
- void AuthenticatePlayer(R2::CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
- bool RemovePlayerAuthData(R2::CBaseClient* pPlayer);
- void WritePersistentData(R2::CBaseClient* pPlayer);
+ void AuthenticatePlayer(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken);
+ bool RemovePlayerAuthData(CBaseClient* pPlayer);
+ void WritePersistentData(CBaseClient* pPlayer);
};
extern ServerAuthenticationManager* g_pServerAuthentication;
diff --git a/NorthstarDLL/server/buildainfile.cpp b/NorthstarDLL/server/buildainfile.cpp
index d0143295..a7f59961 100644
--- a/NorthstarDLL/server/buildainfile.cpp
+++ b/NorthstarDLL/server/buildainfile.cpp
@@ -177,8 +177,8 @@ ConVar* Cvar_ns_ai_dumpAINfileFromLoad;
void DumpAINInfo(CAI_Network* aiNetwork)
{
- fs::path writePath(fmt::format("{}/maps/graphs", R2::g_pModName));
- writePath /= R2::g_pGlobals->m_pMapName;
+ fs::path writePath(fmt::format("{}/maps/graphs", g_pModName));
+ writePath /= g_pGlobals->m_pMapName;
writePath += ".ain";
// dump from memory
@@ -193,7 +193,7 @@ void DumpAINInfo(CAI_Network* aiNetwork)
spdlog::info("writing ainet version: {}", AINET_VERSION_NUMBER);
writeStream.write((char*)&AINET_VERSION_NUMBER, sizeof(int));
- int mapVersion = R2::g_pGlobals->m_nMapVersion;
+ int mapVersion = g_pGlobals->m_nMapVersion;
spdlog::info("writing map version: {}", mapVersion);
writeStream.write((char*)&mapVersion, sizeof(int));
spdlog::info("writing placeholder crc: {}", PLACEHOLDER_CRC);
diff --git a/NorthstarDLL/server/r2server.cpp b/NorthstarDLL/server/r2server.cpp
index cf7add0d..c52f396e 100644
--- a/NorthstarDLL/server/r2server.cpp
+++ b/NorthstarDLL/server/r2server.cpp
@@ -1,13 +1,7 @@
#include "r2server.h"
-using namespace R2;
-
-// use the R2 namespace for game funcs
-namespace R2
-{
- CBaseEntity* (*Server_GetEntityByIndex)(int index);
- CBasePlayer*(__fastcall* UTIL_PlayerByIndex)(int playerIndex);
-} // namespace R2
+CBaseEntity* (*Server_GetEntityByIndex)(int index);
+CBasePlayer*(__fastcall* UTIL_PlayerByIndex)(int playerIndex);
ON_DLL_LOAD("server.dll", R2GameServer, (CModule module))
{
diff --git a/NorthstarDLL/server/r2server.h b/NorthstarDLL/server/r2server.h
index 8fde7b9d..c40cdc1f 100644
--- a/NorthstarDLL/server/r2server.h
+++ b/NorthstarDLL/server/r2server.h
@@ -2,109 +2,105 @@
#include "core/math/vector.h"
-// use the R2 namespace for game funcs
-namespace R2
-{
- // server entity stuff
- class CBaseEntity;
- extern CBaseEntity* (*Server_GetEntityByIndex)(int index);
+// server entity stuff
+class CBaseEntity;
+extern CBaseEntity* (*Server_GetEntityByIndex)(int index);
- // clang-format off
- OFFSET_STRUCT(CBasePlayer)
- {
- FIELD(0x58, uint32_t m_nPlayerIndex)
+// clang-format off
+OFFSET_STRUCT(CBasePlayer)
+{
+ FIELD(0x58, uint32_t m_nPlayerIndex)
- FIELD(0x23E8, bool m_grappleActive)
- FIELD(0x1D08, uint32_t m_platformUserId)
- FIELD(0x1D10, int32_t m_classModsActive)
- FIELD(0x1D8C, int32_t m_posClassModsActive)
- FIELD(0x1DCC, bool m_passives)
- FIELD(0x4948, int32_t m_selectedOffhand)
- FIELD(0x1358, int32_t m_selectedOffhandPendingHybridAction)
- FIELD(0x1E88, int32_t m_playerFlags)
- FIELD(0x26A8, int32_t m_lastUCmdSimulationTicks)
- FIELD(0x26AC, float m_lastUCmdSimulationRemainderTime)
- FIELD(0x1F04, int32_t m_remoteTurret)
- FIELD(0x414, int32_t m_hGroundEntity)
- FIELD(0x13B8, int32_t m_titanSoul)
- FIELD(0x2054, int32_t m_petTitan)
- FIELD(0x4D4, int32_t m_iHealth)
- FIELD(0x4D0, int32_t m_iMaxHealth)
- FIELD(0x4F1, int32_t m_lifeState)
- FIELD(0x50C, float m_flMaxspeed)
- FIELD(0x298, int32_t m_fFlags)
- FIELD(0x1F64, int32_t m_iObserverMode)
- FIELD(0x1F6C, int32_t m_hObserverTarget)
- FIELD(0x2098, int32_t m_hViewModel)
- FIELD(0x27E4, int32_t m_ubEFNointerpParity)
- FIELD(0x1FA4, int32_t m_activeBurnCardIndex)
- FIELD(0x1B68, int32_t m_hColorCorrectionCtrl)
- FIELD(0x19E0, int32_t m_PlayerFog__m_hCtrl)
- FIELD(0x26BC, bool m_bShouldDrawPlayerWhileUsingViewEntity)
- FIELD(0x2848, char m_title[32])
- FIELD(0x2964, bool m_useCredit)
- FIELD(0x1F40, float m_damageImpulseNoDecelEndTime)
- FIELD(0x1E8C, bool m_hasMic)
- FIELD(0x1E8D, bool m_inPartyChat)
- FIELD(0x1E90, float m_playerMoveSpeedScale)
- FIELD(0x1F58, float m_flDeathTime)
- FIELD(0x25A8, bool m_iSpawnParity)
- FIELD(0x102284, Vector3 m_upDir)
- FIELD(0x259C, float m_lastDodgeTime)
- FIELD(0x22E0, bool m_wallHanging)
- FIELD(0x22EC, int32_t m_traversalType)
- FIELD(0x22F0, int32_t m_traversalState)
- FIELD(0x2328, Vector3 m_traversalRefPos)
- FIELD(0x231C, Vector3 m_traversalForwardDir)
- FIELD(0x2354, float m_traversalYawDelta)
- FIELD(0x2358, int32_t m_traversalYawPoseParameter)
- FIELD(0x2050, int32_t m_grappleHook)
- FIELD(0x27C0, int32_t m_autoSprintForced)
- FIELD(0x27C4, bool m_fIsSprinting)
- FIELD(0x27CC, float m_sprintStartedTime)
- FIELD(0x27D0, float m_sprintStartedFrac)
- FIELD(0x27D4, float m_sprintEndedTime)
- FIELD(0x27D8, float m_sprintEndedFrac)
- FIELD(0x27DC, float m_stickySprintStartTime)
- FIELD(0x2998, float m_smartAmmoPreviousHighestLockOnMeFractionValue)
- FIELD(0x23FC, int32_t m_activeZipline)
- FIELD(0x2400, bool m_ziplineReverse)
- FIELD(0x2410, int32_t m_ziplineState)
- FIELD(0x2250, int32_t m_duckState)
- FIELD(0x2254, Vector3 m_StandHullMin)
- FIELD(0x2260, Vector3 m_StandHullMax)
- FIELD(0x226C, Vector3 m_DuckHullMin)
- FIELD(0x2278, Vector3 m_DuckHullMax)
- FIELD(0x205C, int32_t m_xp)
- FIELD(0x2060, int32_t m_generation)
- FIELD(0x2064, int32_t m_rank)
- FIELD(0x2068, int32_t m_serverForceIncreasePlayerListGenerationParity)
- FIELD(0x206C, bool m_isPlayingRanked)
- FIELD(0x2070, float m_skill_mu)
- FIELD(0x1E80, int32_t m_titanSoulBeingRodeoed)
- FIELD(0x1E84, int32_t m_entitySyncingWithMe)
- FIELD(0x2078, float m_nextTitanRespawnAvailable)
- FIELD(0x1C90, bool m_hasBadReputation)
- FIELD(0x1C91, char m_communityName[64])
- FIELD(0x1CD1, char m_communityClanTag[16])
- FIELD(0x1CE1, char m_factionName[16])
- FIELD(0x1CF1, char m_hardwareIcon[16])
- FIELD(0x1D01, bool m_happyHourActive)
- FIELD(0x1EF4, int32_t m_gestureAutoKillBitfield)
- FIELD(0x2EA8, int32_t m_pilotClassIndex)
- FIELD(0x100490, Vector3 m_vecAbsOrigin)
- FIELD(0x25BE, bool m_isPerformingBoostAction)
- FIELD(0x240C, bool m_ziplineValid3pWeaponLayerAnim)
- FIELD(0x345C, int32_t m_playerScriptNetDataGlobal)
- FIELD(0x1598, int32_t m_bZooming)
- FIELD(0x1599, bool m_zoomToggleOn)
- FIELD(0x159C, float m_zoomBaseFrac)
- FIELD(0x15A0, float m_zoomBaseTime)
- FIELD(0x15A4, float m_zoomFullStartTime)
- FIELD(0xA04, int32_t m_camoIndex)
- FIELD(0xA08, int32_t m_decalIndex)
- };
- // clang-format on
+ FIELD(0x23E8, bool m_grappleActive)
+ FIELD(0x1D08, uint32_t m_platformUserId)
+ FIELD(0x1D10, int32_t m_classModsActive)
+ FIELD(0x1D8C, int32_t m_posClassModsActive)
+ FIELD(0x1DCC, bool m_passives)
+ FIELD(0x4948, int32_t m_selectedOffhand)
+ FIELD(0x1358, int32_t m_selectedOffhandPendingHybridAction)
+ FIELD(0x1E88, int32_t m_playerFlags)
+ FIELD(0x26A8, int32_t m_lastUCmdSimulationTicks)
+ FIELD(0x26AC, float m_lastUCmdSimulationRemainderTime)
+ FIELD(0x1F04, int32_t m_remoteTurret)
+ FIELD(0x414, int32_t m_hGroundEntity)
+ FIELD(0x13B8, int32_t m_titanSoul)
+ FIELD(0x2054, int32_t m_petTitan)
+ FIELD(0x4D4, int32_t m_iHealth)
+ FIELD(0x4D0, int32_t m_iMaxHealth)
+ FIELD(0x4F1, int32_t m_lifeState)
+ FIELD(0x50C, float m_flMaxspeed)
+ FIELD(0x298, int32_t m_fFlags)
+ FIELD(0x1F64, int32_t m_iObserverMode)
+ FIELD(0x1F6C, int32_t m_hObserverTarget)
+ FIELD(0x2098, int32_t m_hViewModel)
+ FIELD(0x27E4, int32_t m_ubEFNointerpParity)
+ FIELD(0x1FA4, int32_t m_activeBurnCardIndex)
+ FIELD(0x1B68, int32_t m_hColorCorrectionCtrl)
+ FIELD(0x19E0, int32_t m_PlayerFog__m_hCtrl)
+ FIELD(0x26BC, bool m_bShouldDrawPlayerWhileUsingViewEntity)
+ FIELD(0x2848, char m_title[32])
+ FIELD(0x2964, bool m_useCredit)
+ FIELD(0x1F40, float m_damageImpulseNoDecelEndTime)
+ FIELD(0x1E8C, bool m_hasMic)
+ FIELD(0x1E8D, bool m_inPartyChat)
+ FIELD(0x1E90, float m_playerMoveSpeedScale)
+ FIELD(0x1F58, float m_flDeathTime)
+ FIELD(0x25A8, bool m_iSpawnParity)
+ FIELD(0x102284, Vector3 m_upDir)
+ FIELD(0x259C, float m_lastDodgeTime)
+ FIELD(0x22E0, bool m_wallHanging)
+ FIELD(0x22EC, int32_t m_traversalType)
+ FIELD(0x22F0, int32_t m_traversalState)
+ FIELD(0x2328, Vector3 m_traversalRefPos)
+ FIELD(0x231C, Vector3 m_traversalForwardDir)
+ FIELD(0x2354, float m_traversalYawDelta)
+ FIELD(0x2358, int32_t m_traversalYawPoseParameter)
+ FIELD(0x2050, int32_t m_grappleHook)
+ FIELD(0x27C0, int32_t m_autoSprintForced)
+ FIELD(0x27C4, bool m_fIsSprinting)
+ FIELD(0x27CC, float m_sprintStartedTime)
+ FIELD(0x27D0, float m_sprintStartedFrac)
+ FIELD(0x27D4, float m_sprintEndedTime)
+ FIELD(0x27D8, float m_sprintEndedFrac)
+ FIELD(0x27DC, float m_stickySprintStartTime)
+ FIELD(0x2998, float m_smartAmmoPreviousHighestLockOnMeFractionValue)
+ FIELD(0x23FC, int32_t m_activeZipline)
+ FIELD(0x2400, bool m_ziplineReverse)
+ FIELD(0x2410, int32_t m_ziplineState)
+ FIELD(0x2250, int32_t m_duckState)
+ FIELD(0x2254, Vector3 m_StandHullMin)
+ FIELD(0x2260, Vector3 m_StandHullMax)
+ FIELD(0x226C, Vector3 m_DuckHullMin)
+ FIELD(0x2278, Vector3 m_DuckHullMax)
+ FIELD(0x205C, int32_t m_xp)
+ FIELD(0x2060, int32_t m_generation)
+ FIELD(0x2064, int32_t m_rank)
+ FIELD(0x2068, int32_t m_serverForceIncreasePlayerListGenerationParity)
+ FIELD(0x206C, bool m_isPlayingRanked)
+ FIELD(0x2070, float m_skill_mu)
+ FIELD(0x1E80, int32_t m_titanSoulBeingRodeoed)
+ FIELD(0x1E84, int32_t m_entitySyncingWithMe)
+ FIELD(0x2078, float m_nextTitanRespawnAvailable)
+ FIELD(0x1C90, bool m_hasBadReputation)
+ FIELD(0x1C91, char m_communityName[64])
+ FIELD(0x1CD1, char m_communityClanTag[16])
+ FIELD(0x1CE1, char m_factionName[16])
+ FIELD(0x1CF1, char m_hardwareIcon[16])
+ FIELD(0x1D01, bool m_happyHourActive)
+ FIELD(0x1EF4, int32_t m_gestureAutoKillBitfield)
+ FIELD(0x2EA8, int32_t m_pilotClassIndex)
+ FIELD(0x100490, Vector3 m_vecAbsOrigin)
+ FIELD(0x25BE, bool m_isPerformingBoostAction)
+ FIELD(0x240C, bool m_ziplineValid3pWeaponLayerAnim)
+ FIELD(0x345C, int32_t m_playerScriptNetDataGlobal)
+ FIELD(0x1598, int32_t m_bZooming)
+ FIELD(0x1599, bool m_zoomToggleOn)
+ FIELD(0x159C, float m_zoomBaseFrac)
+ FIELD(0x15A0, float m_zoomBaseTime)
+ FIELD(0x15A4, float m_zoomFullStartTime)
+ FIELD(0xA04, int32_t m_camoIndex)
+ FIELD(0xA08, int32_t m_decalIndex)
+};
+// clang-format on
- extern CBasePlayer*(__fastcall* UTIL_PlayerByIndex)(int playerIndex);
-} // namespace R2
+extern CBasePlayer*(__fastcall* UTIL_PlayerByIndex)(int playerIndex);
diff --git a/NorthstarDLL/server/serverchathooks.cpp b/NorthstarDLL/server/serverchathooks.cpp
index cb3af244..d3ac4776 100644
--- a/NorthstarDLL/server/serverchathooks.cpp
+++ b/NorthstarDLL/server/serverchathooks.cpp
@@ -25,7 +25,7 @@ void(__fastcall* CServerGameDLL__OnReceivedSayTextMessage)(
void(__fastcall* CRecipientFilter__Construct)(CRecipientFilter* self);
void(__fastcall* CRecipientFilter__Destruct)(CRecipientFilter* self);
void(__fastcall* CRecipientFilter__AddAllPlayers)(CRecipientFilter* self);
-void(__fastcall* CRecipientFilter__AddRecipient)(CRecipientFilter* self, const R2::CBasePlayer* player);
+void(__fastcall* CRecipientFilter__AddRecipient)(CRecipientFilter* self, const CBasePlayer* player);
void(__fastcall* CRecipientFilter__MakeReliable)(CRecipientFilter* self);
void(__fastcall* UserMessageBegin)(CRecipientFilter* filter, const char* messagename);
@@ -40,7 +40,7 @@ AUTOHOOK(_CServerGameDLL__OnReceivedSayTextMessage, server.dll + 0x1595C0,
void, __fastcall, (CServerGameDLL* self, unsigned int senderPlayerId, const char* text, bool isTeam))
// clang-format on
{
- NS::Utils::RemoveAsciiControlSequences(const_cast<char*>(text), true);
+ RemoveAsciiControlSequences(const_cast<char*>(text), true);
// MiniHook doesn't allow calling the base function outside of anywhere but the hook function.
// To allow bypassing the hook, isSkippingHook can be set.
@@ -52,7 +52,7 @@ void, __fastcall, (CServerGameDLL* self, unsigned int senderPlayerId, const char
}
// check chat ratelimits
- if (!g_pServerLimits->CheckChatLimits(&R2::g_pClientArray[senderPlayerId - 1]))
+ if (!g_pServerLimits->CheckChatLimits(&g_pClientArray[senderPlayerId - 1]))
return;
SQRESULT result = g_pSquirrel<ScriptContext::SERVER>->Call(
@@ -75,10 +75,10 @@ void ChatSendMessage(unsigned int playerIndex, const char* text, bool isTeam)
void ChatBroadcastMessage(int fromPlayerIndex, int toPlayerIndex, const char* text, bool isTeam, bool isDead, CustomMessageType messageType)
{
- R2::CBasePlayer* toPlayer = NULL;
+ CBasePlayer* toPlayer = NULL;
if (toPlayerIndex >= 0)
{
- toPlayer = R2::UTIL_PlayerByIndex(toPlayerIndex + 1);
+ toPlayer = UTIL_PlayerByIndex(toPlayerIndex + 1);
if (toPlayer == NULL)
return;
}
@@ -163,7 +163,7 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerChatHooks, ServerSquirrel, (CModule mod
CRecipientFilter__Construct = module.Offset(0x1E9440).RCast<void(__fastcall*)(CRecipientFilter*)>();
CRecipientFilter__Destruct = module.Offset(0x1E9700).RCast<void(__fastcall*)(CRecipientFilter*)>();
CRecipientFilter__AddAllPlayers = module.Offset(0x1E9940).RCast<void(__fastcall*)(CRecipientFilter*)>();
- CRecipientFilter__AddRecipient = module.Offset(0x1E9B30).RCast<void(__fastcall*)(CRecipientFilter*, const R2::CBasePlayer*)>();
+ CRecipientFilter__AddRecipient = module.Offset(0x1E9B30).RCast<void(__fastcall*)(CRecipientFilter*, const CBasePlayer*)>();
CRecipientFilter__MakeReliable = module.Offset(0x1EA4E0).RCast<void(__fastcall*)(CRecipientFilter*)>();
UserMessageBegin = module.Offset(0x15C520).RCast<void(__fastcall*)(CRecipientFilter*, const char*)>();
diff --git a/NorthstarDLL/server/servernethooks.cpp b/NorthstarDLL/server/servernethooks.cpp
index f74f2d38..148b735f 100644
--- a/NorthstarDLL/server/servernethooks.cpp
+++ b/NorthstarDLL/server/servernethooks.cpp
@@ -84,7 +84,7 @@ cleanup:
}
// v1 HMACSHA256-signed masterserver request (HMAC-SHA256(JSONData, MasterServerToken) + JSONData)
-static void ProcessAtlasConnectionlessPacketSigreq1(R2::netpacket_t* packet, bool dbg, std::string pType, std::string pData)
+static void ProcessAtlasConnectionlessPacketSigreq1(netpacket_t* packet, bool dbg, std::string pType, std::string pData)
{
if (pData.length() < HMACSHA256_LEN)
{
@@ -135,7 +135,7 @@ static void ProcessAtlasConnectionlessPacketSigreq1(R2::netpacket_t* packet, boo
return;
}
-static void ProcessAtlasConnectionlessPacket(R2::netpacket_t* packet)
+static void ProcessAtlasConnectionlessPacket(netpacket_t* packet)
{
bool dbg = Cvar_net_debug_atlas_packet->GetBool();
@@ -168,7 +168,7 @@ static void ProcessAtlasConnectionlessPacket(R2::netpacket_t* packet)
return;
}
-AUTOHOOK(ProcessConnectionlessPacket, engine.dll + 0x117800, bool, , (void* a1, R2::netpacket_t* packet))
+AUTOHOOK(ProcessConnectionlessPacket, engine.dll + 0x117800, bool, , (void* a1, netpacket_t* packet))
{
// packet->data consists of 0xFFFFFFFF (int32 -1) to indicate packets aren't split, followed by a header consisting of a single
// character, which is used to uniquely identify the packet kind. Most kinds follow this with a null-terminated string payload
diff --git a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
index 8821a40d..8064d5ac 100644
--- a/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/exploitfixes.cpp
@@ -84,7 +84,7 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10
};
auto msg = (NET_SetConVar*)pMsg;
- bool bIsServerFrame = Tier0::ThreadInServerFrameThread();
+ bool bIsServerFrame = ThreadInServerFrameThread();
std::string BLOCK_PREFIX =
std::string {"NET_SetConVar ("} + (bIsServerFrame ? "server" : "client") + "): Blocked dangerous/invalid msg: ";
@@ -118,7 +118,7 @@ bool, __fastcall, (void* pMsg)) // 48 8B D1 48 8B 49 18 48 8B 01 48 FF 60 10
if (!nameValid || !valValid)
return BLOCKED_INFO("Missing null terminators");
- ConVar* pVar = R2::g_pCVar->FindVar(entry->name);
+ ConVar* pVar = g_pCVar->FindVar(entry->name);
if (pVar)
{
@@ -263,19 +263,19 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D
{
// somewhat temp, store the modname here, since we don't have a proper ptr in engine to it rn
int iSize = strlen(pModName);
- R2::g_pModName = new char[iSize + 1];
- strcpy(R2::g_pModName, pModName);
+ g_pModName = new char[iSize + 1];
+ strcpy(g_pModName, pModName);
if (g_pVanillaCompatibility->GetVanillaCompatibility())
return false;
- return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !Tier0::CommandLine()->CheckParm("-norestrictservercommands");
+ return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !CommandLine()->CheckParm("-norestrictservercommands");
}
// ratelimit stringcmds, and prevent remote clients from calling commands that they shouldn't
// clang-format off
AUTOHOOK(CGameClient__ExecuteStringCommand, engine.dll + 0x1022E0,
-bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommandString))
+bool, __fastcall, (CBaseClient* self, uint32_t unknown, const char* pCommandString))
// clang-format on
{
if (Cvar_ns_should_log_all_clientcommands->GetBool())
@@ -283,7 +283,7 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
if (!g_pServerLimits->CheckStringCommandLimits(self))
{
- R2::CBaseClient__Disconnect(self, 1, "Sent too many stringcmd commands");
+ CBaseClient__Disconnect(self, 1, "Sent too many stringcmd commands");
return false;
}
@@ -292,10 +292,10 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
- if (!R2::CCommand__Tokenize(tempCommand, pCommandString, R2::cmd_source_t::kCommandSrcCode) || !tempCommand.ArgC())
+ if (!CCommand__Tokenize(tempCommand, pCommandString, cmd_source_t::kCommandSrcCode) || !tempCommand.ArgC())
return false;
- ConCommand* command = R2::g_pCVar->FindCommand(tempCommand.Arg(0));
+ ConCommand* command = g_pCVar->FindCommand(tempCommand.Arg(0));
// if the command doesn't exist pass it on to ExecuteStringCommand for script clientcommands and stuff
if (command && !command->IsFlagSet(FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS))
@@ -304,7 +304,7 @@ bool, __fastcall, (R2::CBaseClient* self, uint32_t unknown, const char* pCommand
if (IsDedicatedServer())
return false;
- if (strcmp(self->m_UID, R2::g_pLocalPlayerUserID))
+ if (strcmp(self->m_UID, g_pLocalPlayerUserID))
return false;
}
@@ -355,7 +355,7 @@ void, __fastcall, (void* self))
bWasWritingStringTableSuccessful = true;
CBaseClient__SendServerInfo(self);
if (!bWasWritingStringTableSuccessful)
- R2::CBaseClient__Disconnect(
+ CBaseClient__Disconnect(
self, 1, "Overflowed CNetworkStringTableContainer::WriteBaselines, try restarting your client and reconnecting");
}
@@ -457,5 +457,5 @@ ON_DLL_LOAD_RELIESON("server.dll", ServerExploitFixes, ConVar, (CModule module))
Cvar_ns_should_log_all_clientcommands =
new ConVar("ns_should_log_all_clientcommands", "0", FCVAR_NONE, "Whether to log all clientcommands");
- Cvar_sv_cheats = R2::g_pCVar->FindVar("sv_cheats");
+ Cvar_sv_cheats = g_pCVar->FindVar("sv_cheats");
}
diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
index c9085cb0..bd855ee4 100644
--- a/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
+++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.cpp
@@ -19,47 +19,47 @@ void ServerLimitsManager::RunFrame(double flCurrentTime, float flFrameTime)
if (Cvar_sv_antispeedhack_enable->GetBool())
{
// for each player, set their usercmd processing budget for the frame to the last frametime for the server
- for (int i = 0; i < R2::g_pGlobals->m_nMaxClients; i++)
+ for (int i = 0; i < g_pGlobals->m_nMaxClients; i++)
{
- R2::CBaseClient* player = &R2::g_pClientArray[i];
+ CBaseClient* player = &g_pClientArray[i];
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
{
PlayerLimitData* pLimitData = &g_pServerLimits->m_PlayerLimitData[player];
- if (pLimitData->flFrameUserCmdBudget < R2::g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
+ if (pLimitData->flFrameUserCmdBudget < g_pGlobals->m_flTickInterval * Cvar_sv_antispeedhack_maxtickbudget->GetFloat())
{
pLimitData->flFrameUserCmdBudget += g_pServerLimits->Cvar_sv_antispeedhack_budgetincreasemultiplier->GetFloat() *
- fmax(flFrameTime, R2::g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
+ fmax(flFrameTime, g_pGlobals->m_flFrameTime * CEngineServer__GetTimescale());
}
}
}
}
}
-void ServerLimitsManager::AddPlayer(R2::CBaseClient* player)
+void ServerLimitsManager::AddPlayer(CBaseClient* player)
{
PlayerLimitData limitData;
limitData.flFrameUserCmdBudget =
- R2::g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
+ g_pGlobals->m_flTickInterval * CEngineServer__GetTimescale() * Cvar_sv_antispeedhack_maxtickbudget->GetFloat();
m_PlayerLimitData.insert(std::make_pair(player, limitData));
}
-void ServerLimitsManager::RemovePlayer(R2::CBaseClient* player)
+void ServerLimitsManager::RemovePlayer(CBaseClient* player)
{
if (m_PlayerLimitData.find(player) != m_PlayerLimitData.end())
m_PlayerLimitData.erase(player);
}
-bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckStringCommandLimits(CBaseClient* player)
{
if (CVar_sv_quota_stringcmdspersecond->GetInt() != -1)
{
// note: this isn't super perfect, legit clients can trigger it in lobby if they try, mostly good enough tho imo
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastClientCommandQuotaStart >= 1.0)
{
// reset quota
- m_PlayerLimitData[player].lastClientCommandQuotaStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastClientCommandQuotaStart = Plat_FloatTime();
m_PlayerLimitData[player].numClientCommandsInQuota = 0;
}
@@ -74,11 +74,11 @@ bool ServerLimitsManager::CheckStringCommandLimits(R2::CBaseClient* player)
return true;
}
-bool ServerLimitsManager::CheckChatLimits(R2::CBaseClient* player)
+bool ServerLimitsManager::CheckChatLimits(CBaseClient* player)
{
- if (Tier0::Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
+ if (Plat_FloatTime() - m_PlayerLimitData[player].lastSayTextLimitStart >= 1.0)
{
- m_PlayerLimitData[player].lastSayTextLimitStart = Tier0::Plat_FloatTime();
+ m_PlayerLimitData[player].lastSayTextLimitStart = Plat_FloatTime();
m_PlayerLimitData[player].sayTextLimitCount = 0;
}
@@ -100,14 +100,14 @@ char, __fastcall, (void* self, void* buf))
NETCHANLIMIT_KICK
};
- double startTime = Tier0::Plat_FloatTime();
+ double startTime = Plat_FloatTime();
char ret = CNetChan__ProcessMessages(self, buf);
// check processing limits, unless we're in a level transition
- if (R2::g_pHostState->m_iCurrentState == R2::HostState_t::HS_RUN && Tier0::ThreadInServerFrameThread())
+ if (g_pHostState->m_iCurrentState == HostState_t::HS_RUN && ThreadInServerFrameThread())
{
// player that sent the message
- R2::CBaseClient* sender = *(R2::CBaseClient**)((char*)self + 368);
+ CBaseClient* sender = *(CBaseClient**)((char*)self + 368);
// if no sender, return
// relatively certain this is fine?
@@ -121,7 +121,7 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->m_PlayerLimitData[sender].lastNetChanProcessingLimitStart = startTime;
g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime = 0.0;
}
- g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Tier0::Plat_FloatTime() * 1000) - (startTime * 1000);
+ g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime += (Plat_FloatTime() * 1000) - (startTime * 1000);
if (g_pServerLimits->m_PlayerLimitData[sender].netChanProcessingLimitTime >=
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt())
@@ -133,9 +133,9 @@ char, __fastcall, (void* self, void* buf))
g_pServerLimits->Cvar_net_chan_limit_msec_per_sec->GetInt());
// never kick local player
- if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(R2::g_pLocalPlayerUserID, sender->m_UID))
+ if (g_pServerLimits->Cvar_net_chan_limit_mode->GetInt() != NETCHANLIMIT_WARN && strcmp(g_pLocalPlayerUserID, sender->m_UID))
{
- R2::CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
+ CBaseClient__Disconnect(sender, 1, "Exceeded net channel processing limit");
return false;
}
}
@@ -144,12 +144,12 @@ char, __fastcall, (void* self, void* buf))
return ret;
}
-bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packet)
+bool ServerLimitsManager::CheckConnectionlessPacketLimits(netpacket_t* packet)
{
- static const ConVar* Cvar_net_data_block_enabled = R2::g_pCVar->FindVar("net_data_block_enabled");
+ static const ConVar* Cvar_net_data_block_enabled = g_pCVar->FindVar("net_data_block_enabled");
// don't ratelimit datablock packets as long as datablock is enabled
- if (packet->adr.type == R2::NA_IP &&
+ if (packet->adr.type == NA_IP &&
(!(packet->data[4] == 'N' && Cvar_net_data_block_enabled->GetBool()) || !Cvar_net_data_block_enabled->GetBool()))
{
// bad lookup: optimise later tm
@@ -169,12 +169,12 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
memcpy(sendData->ip, packet->adr.ip, 16);
}
- if (Tier0::Plat_FloatTime() < sendData->timeoutEnd)
+ if (Plat_FloatTime() < sendData->timeoutEnd)
return false;
- if (Tier0::Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
+ if (Plat_FloatTime() - sendData->lastQuotaStart >= 1.0)
{
- sendData->lastQuotaStart = Tier0::Plat_FloatTime();
+ sendData->lastQuotaStart = Plat_FloatTime();
sendData->packetCount = 0;
}
@@ -188,7 +188,7 @@ bool ServerLimitsManager::CheckConnectionlessPacketLimits(R2::netpacket_t* packe
packet->data[4]);
// timeout for a minute
- sendData->timeoutEnd = Tier0::Plat_FloatTime() + 60.0;
+ sendData->timeoutEnd = Plat_FloatTime() + 60.0;
return false;
}
}
@@ -232,12 +232,12 @@ struct alignas(4) SV_CUserCmd
// clang-format off
AUTOHOOK(CPlayerMove__RunCommand, server.dll + 0x5B8100,
-void, __fastcall, (void* self, R2::CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
+void, __fastcall, (void* self, CBasePlayer* player, SV_CUserCmd* pUserCmd, uint64_t a4))
// clang-format on
{
if (g_pServerLimits->Cvar_sv_antispeedhack_enable->GetBool())
{
- R2::CBaseClient* pClient = &R2::g_pClientArray[player->m_nPlayerIndex - 1];
+ CBaseClient* pClient = &g_pClientArray[player->m_nPlayerIndex - 1];
if (g_pServerLimits->m_PlayerLimitData.find(pClient) != g_pServerLimits->m_PlayerLimitData.end())
{
diff --git a/NorthstarDLL/shared/exploit_fixes/ns_limits.h b/NorthstarDLL/shared/exploit_fixes/ns_limits.h
index d1f7f2ed..a2cc431f 100644
--- a/NorthstarDLL/shared/exploit_fixes/ns_limits.h
+++ b/NorthstarDLL/shared/exploit_fixes/ns_limits.h
@@ -37,16 +37,16 @@ class ServerLimitsManager
ConVar* Cvar_sv_antispeedhack_maxtickbudget;
ConVar* Cvar_sv_antispeedhack_budgetincreasemultiplier;
- std::unordered_map<R2::CBaseClient*, PlayerLimitData> m_PlayerLimitData;
+ std::unordered_map<CBaseClient*, PlayerLimitData> m_PlayerLimitData;
std::vector<UnconnectedPlayerLimitData> m_UnconnectedPlayerLimitData;
public:
void RunFrame(double flCurrentTime, float flFrameTime);
- void AddPlayer(R2::CBaseClient* player);
- void RemovePlayer(R2::CBaseClient* player);
- bool CheckStringCommandLimits(R2::CBaseClient* player);
- bool CheckChatLimits(R2::CBaseClient* player);
- bool CheckConnectionlessPacketLimits(R2::netpacket_t* packet);
+ void AddPlayer(CBaseClient* player);
+ void RemovePlayer(CBaseClient* player);
+ bool CheckStringCommandLimits(CBaseClient* player);
+ bool CheckChatLimits(CBaseClient* player);
+ bool CheckConnectionlessPacketLimits(netpacket_t* packet);
};
extern ServerLimitsManager* g_pServerLimits;
diff --git a/NorthstarDLL/shared/maxplayers.cpp b/NorthstarDLL/shared/maxplayers.cpp
index 4af8ea1c..711193d4 100644
--- a/NorthstarDLL/shared/maxplayers.cpp
+++ b/NorthstarDLL/shared/maxplayers.cpp
@@ -48,21 +48,17 @@ constexpr int Team_AddedSize = Team_PlayerArray_AddedSize;
bool MaxPlayersIncreaseEnabled()
{
- static bool bMaxPlayersIncreaseEnabled = Tier0::CommandLine()->CheckParm("-experimentalmaxplayersincrease");
+ static bool bMaxPlayersIncreaseEnabled = CommandLine()->CheckParm("-experimentalmaxplayersincrease");
return bMaxPlayersIncreaseEnabled;
}
-// should we use R2 for this? not sure
-namespace R2 // use R2 namespace for game funcs
+int GetMaxPlayers()
{
- int GetMaxPlayers()
- {
- if (MaxPlayersIncreaseEnabled())
- return NEW_MAX_PLAYERS;
+ if (MaxPlayersIncreaseEnabled())
+ return NEW_MAX_PLAYERS;
- return 32;
- }
-} // namespace R2
+ return 32;
+}
template <class T> void ChangeOffset(CMemoryAddress addr, unsigned int offset)
{
diff --git a/NorthstarDLL/shared/maxplayers.h b/NorthstarDLL/shared/maxplayers.h
index b251f6a6..40a3ac58 100644
--- a/NorthstarDLL/shared/maxplayers.h
+++ b/NorthstarDLL/shared/maxplayers.h
@@ -1,7 +1,3 @@
#pragma once
-// should we use R2 for this? not sure
-namespace R2 // use R2 namespace for game funcs
-{
- int GetMaxPlayers();
-} // namespace R2
+int GetMaxPlayers();
diff --git a/NorthstarDLL/shared/misccommands.cpp b/NorthstarDLL/shared/misccommands.cpp
index 5d9ced99..15da6767 100644
--- a/NorthstarDLL/shared/misccommands.cpp
+++ b/NorthstarDLL/shared/misccommands.cpp
@@ -15,21 +15,21 @@ void ConCommand_force_newgame(const CCommand& arg)
if (arg.ArgC() < 2)
return;
- R2::g_pHostState->m_iNextState = R2::HostState_t::HS_NEW_GAME;
- strncpy(R2::g_pHostState->m_levelName, arg.Arg(1), sizeof(R2::g_pHostState->m_levelName));
+ g_pHostState->m_iNextState = HostState_t::HS_NEW_GAME;
+ strncpy(g_pHostState->m_levelName, arg.Arg(1), sizeof(g_pHostState->m_levelName));
}
void ConCommand_ns_start_reauth_and_leave_to_lobby(const CCommand& arg)
{
// hack for special case where we're on a local server, so we erase our own newly created auth data on disconnect
g_pMasterServerManager->m_bNewgameAfterSelfAuth = true;
- g_pMasterServerManager->AuthenticateWithOwnServer(R2::g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken);
+ g_pMasterServerManager->AuthenticateWithOwnServer(g_pLocalPlayerUserID, g_pMasterServerManager->m_sOwnClientAuthToken);
}
void ConCommand_ns_end_reauth_and_leave_to_lobby(const CCommand& arg)
{
if (g_pServerAuthentication->m_RemoteAuthenticationData.size())
- R2::g_pCVar->FindVar("serverfilter")->SetValue(g_pServerAuthentication->m_RemoteAuthenticationData.begin()->first.c_str());
+ g_pCVar->FindVar("serverfilter")->SetValue(g_pServerAuthentication->m_RemoteAuthenticationData.begin()->first.c_str());
// weird way of checking, but check if client script vm is initialised, mainly just to allow players to cancel this
if (g_pSquirrel<ScriptContext::CLIENT>->m_pSQVM)
@@ -39,8 +39,8 @@ void ConCommand_ns_end_reauth_and_leave_to_lobby(const CCommand& arg)
// this won't set playlist correctly on remote clients, don't think they can set playlist until they've left which sorta
// fucks things should maybe set this in HostState_NewGame?
R2::SetCurrentPlaylist("tdm");
- strcpy(R2::g_pHostState->m_levelName, "mp_lobby");
- R2::g_pHostState->m_iNextState = R2::HostState_t::HS_NEW_GAME;
+ strcpy(g_pHostState->m_levelName, "mp_lobby");
+ g_pHostState->m_iNextState = HostState_t::HS_NEW_GAME;
}
}
@@ -52,7 +52,7 @@ void ConCommand_cvar_setdefaultvalue(const CCommand& arg)
return;
}
- ConVar* pCvar = R2::g_pCVar->FindVar(arg.Arg(1));
+ ConVar* pCvar = g_pCVar->FindVar(arg.Arg(1));
if (!pCvar)
{
spdlog::info("usage: cvar_setdefaultvalue mp_gamemode tdm");
@@ -75,7 +75,7 @@ void ConCommand_cvar_setvalueanddefaultvalue(const CCommand& arg)
return;
}
- ConVar* pCvar = R2::g_pCVar->FindVar(arg.Arg(1));
+ ConVar* pCvar = g_pCVar->FindVar(arg.Arg(1));
if (!pCvar)
{
spdlog::info("usage: cvar_setvalueanddefaultvalue mp_gamemode tdm");
@@ -99,7 +99,7 @@ void ConCommand_cvar_reset(const CCommand& arg)
return;
}
- ConVar* pCvar = R2::g_pCVar->FindVar(arg.Arg(1));
+ ConVar* pCvar = g_pCVar->FindVar(arg.Arg(1));
if (!pCvar)
{
spdlog::info("usage: cvar_reset mp_gamemode");
@@ -143,11 +143,11 @@ void AddMiscConCommands()
// fixes up various cvar flags to have more sane values
void FixupCvarFlags()
{
- if (Tier0::CommandLine()->CheckParm("-allowdevcvars"))
+ if (CommandLine()->CheckParm("-allowdevcvars"))
{
// strip hidden and devonly cvar flags
int iNumCvarsAltered = 0;
- for (auto& pair : R2::g_pCVar->DumpToMap())
+ for (auto& pair : g_pCVar->DumpToMap())
{
// strip flags
int flags = pair.second->GetFlags();
@@ -177,7 +177,7 @@ void FixupCvarFlags()
int i = 0;
do
{
- ConCommandBase* pCommand = R2::g_pCVar->FindCommandBase(ppEngineClientCommands[i]);
+ ConCommandBase* pCommand = g_pCVar->FindCommandBase(ppEngineClientCommands[i]);
if (pCommand) // not all the commands in this array actually exist in respawn source
pCommand->m_nFlags |= FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS;
} while (ppEngineClientCommands[++i]);
@@ -367,21 +367,21 @@ void FixupCvarFlags()
for (auto& fixup : CVAR_FIXUP_ADD_FLAGS)
{
- ConCommandBase* command = R2::g_pCVar->FindCommandBase(std::get<0>(fixup));
+ ConCommandBase* command = g_pCVar->FindCommandBase(std::get<0>(fixup));
if (command)
command->m_nFlags |= std::get<1>(fixup);
}
for (auto& fixup : CVAR_FIXUP_REMOVE_FLAGS)
{
- ConCommandBase* command = R2::g_pCVar->FindCommandBase(std::get<0>(fixup));
+ ConCommandBase* command = g_pCVar->FindCommandBase(std::get<0>(fixup));
if (command)
command->m_nFlags &= ~std::get<1>(fixup);
}
for (auto& fixup : CVAR_FIXUP_DEFAULT_VALUES)
{
- ConVar* cvar = R2::g_pCVar->FindVar(std::get<0>(fixup));
+ ConVar* cvar = g_pCVar->FindVar(std::get<0>(fixup));
if (cvar && !strcmp(cvar->GetString(), cvar->m_pszDefaultValue))
{
cvar->SetValue(std::get<1>(fixup));
diff --git a/NorthstarDLL/shared/playlist.cpp b/NorthstarDLL/shared/playlist.cpp
index ab7aab22..2b9ad979 100644
--- a/NorthstarDLL/shared/playlist.cpp
+++ b/NorthstarDLL/shared/playlist.cpp
@@ -26,7 +26,7 @@ char, __fastcall, (void* a1, void* a2))
{
// the private_match playlist on mp_lobby is the only situation where there should be any legitimate sending of this netmessage
if (!Cvar_ns_use_clc_SetPlaylistVarOverride->GetBool() || strcmp(R2::GetCurrentPlaylistName(), "private_match") ||
- strcmp(R2::g_pGlobals->m_pMapName, "mp_lobby"))
+ strcmp(g_pGlobals->m_pMapName, "mp_lobby"))
return 1;
return clc_SetPlaylistVarOverride__Process(a1, a2);
diff --git a/NorthstarDLL/squirrel/squirrel.cpp b/NorthstarDLL/squirrel/squirrel.cpp
index d8eff0d6..ac9a2ce9 100644
--- a/NorthstarDLL/squirrel/squirrel.cpp
+++ b/NorthstarDLL/squirrel/squirrel.cpp
@@ -504,17 +504,17 @@ void __fastcall ScriptCompileErrorHook(HSquirrelVM* sqvm, const char* error, con
}
else
{
- R2::Cbuf_AddText(
- R2::Cbuf_GetCurrentPlayer(),
+ Cbuf_AddText(
+ Cbuf_GetCurrentPlayer(),
fmt::format("disconnect \"Encountered {} script compilation error, see console for details.\"", GetContextName(realContext))
.c_str(),
- R2::cmd_source_t::kCommandSrcCode);
+ cmd_source_t::kCommandSrcCode);
// likely temp: show console so user can see any errors, as error message wont display if ui is dead
// maybe we could disable all mods other than the coremods and try a reload before doing this?
// could also maybe do some vgui bullshit to show something visually rather than console
if (realContext == ScriptContext::UI)
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "showconsole", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "showconsole", cmd_source_t::kCommandSrcCode);
}
}
@@ -638,7 +638,7 @@ template <ScriptContext context, TemplateStringLiteral funcName> SQRESULT SQ_Stu
template <ScriptContext context> void StubUnsafeSQFuncs()
{
- if (!Tier0::CommandLine()->CheckParm("-allowunsafesqfuncs"))
+ if (!CommandLine()->CheckParm("-allowunsafesqfuncs"))
{
g_pSquirrel<context>->AddFuncOverride("DevTextBufferWrite", SQ_StubbedFunc<context, "DevTextBufferWrite">);
g_pSquirrel<context>->AddFuncOverride("DevTextBufferClear", SQ_StubbedFunc<context, "DevTextBufferClear">);
diff --git a/NorthstarDLL/util/printcommands.cpp b/NorthstarDLL/util/printcommands.cpp
index 7c915318..34d56666 100644
--- a/NorthstarDLL/util/printcommands.cpp
+++ b/NorthstarDLL/util/printcommands.cpp
@@ -12,7 +12,7 @@ void PrintCommandHelpDialogue(const ConCommandBase* command, const char* name)
}
// temp because command->IsCommand does not currently work
- ConVar* cvar = R2::g_pCVar->FindVar(command->m_pszName);
+ ConVar* cvar = g_pCVar->FindVar(command->m_pszName);
// build string for flags if not FCVAR_NONE
std::string flagString;
@@ -66,7 +66,7 @@ void TryPrintCvarHelpForCommand(const char* pCommand)
}
// check if we're inputting a cvar, but not setting it at all
- ConVar* cvar = R2::g_pCVar->FindVar(pCvarStr);
+ ConVar* cvar = g_pCVar->FindVar(pCvarStr);
if (cvar)
PrintCommandHelpDialogue(&cvar->m_ConCommandBase, pCvarStr);
@@ -81,7 +81,7 @@ void ConCommand_help(const CCommand& arg)
return;
}
- PrintCommandHelpDialogue(R2::g_pCVar->FindCommandBase(arg.Arg(1)), arg.Arg(1));
+ PrintCommandHelpDialogue(g_pCVar->FindCommandBase(arg.Arg(1)), arg.Arg(1));
}
void ConCommand_find(const CCommand& arg)
@@ -96,7 +96,7 @@ void ConCommand_find(const CCommand& arg)
char pTempSearchTerm[256];
ConCommandBase* var;
- CCVarIteratorInternal* itint = R2::g_pCVar->FactoryInternalIterator();
+ CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
std::map<std::string, ConCommandBase*> sorted;
for (itint->SetFirst(); itint->IsValid(); itint->Next())
{
@@ -165,7 +165,7 @@ void ConCommand_findflags(const CCommand& arg)
}
ConCommandBase* var;
- CCVarIteratorInternal* itint = R2::g_pCVar->FactoryInternalIterator();
+ CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
std::map<std::string, ConCommandBase*> sorted;
for (itint->SetFirst(); itint->IsValid(); itint->Next())
{
@@ -189,7 +189,7 @@ void ConCommand_findflags(const CCommand& arg)
void ConCommand_list(const CCommand& arg)
{
ConCommandBase* var;
- CCVarIteratorInternal* itint = R2::g_pCVar->FactoryInternalIterator();
+ CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
std::map<std::string, ConCommandBase*> sorted;
for (itint->SetFirst(); itint->IsValid(); itint->Next())
{
@@ -210,7 +210,7 @@ void ConCommand_list(const CCommand& arg)
void ConCommand_differences(const CCommand& arg)
{
- CCVarIteratorInternal* itint = R2::g_pCVar->FactoryInternalIterator();
+ CCVarIteratorInternal* itint = g_pCVar->FactoryInternalIterator();
std::map<std::string, ConCommandBase*> sorted;
for (itint->SetFirst(); itint->IsValid(); itint->Next())
@@ -225,7 +225,7 @@ void ConCommand_differences(const CCommand& arg)
for (auto& map : sorted)
{
- ConVar* cvar = R2::g_pCVar->FindVar(map.second->m_pszName);
+ ConVar* cvar = g_pCVar->FindVar(map.second->m_pszName);
if (!cvar)
{
@@ -267,19 +267,19 @@ void InitialiseCommandPrint()
// these commands already exist, so we need to modify the preexisting command to use our func instead
// and clear the flags also
- ConCommand* helpCommand = R2::g_pCVar->FindCommand("help");
+ ConCommand* helpCommand = g_pCVar->FindCommand("help");
helpCommand->m_nFlags = FCVAR_NONE;
helpCommand->m_pCommandCallback = ConCommand_help;
- ConCommand* findCommand = R2::g_pCVar->FindCommand("convar_findByFlags");
+ ConCommand* findCommand = g_pCVar->FindCommand("convar_findByFlags");
findCommand->m_nFlags = FCVAR_NONE;
findCommand->m_pCommandCallback = ConCommand_findflags;
- ConCommand* listCommand = R2::g_pCVar->FindCommand("convar_list");
+ ConCommand* listCommand = g_pCVar->FindCommand("convar_list");
listCommand->m_nFlags = FCVAR_NONE;
listCommand->m_pCommandCallback = ConCommand_list;
- ConCommand* diffCommand = R2::g_pCVar->FindCommand("convar_differences");
+ ConCommand* diffCommand = g_pCVar->FindCommand("convar_differences");
diffCommand->m_nFlags = FCVAR_NONE;
diffCommand->m_pCommandCallback = ConCommand_differences;
}
diff --git a/NorthstarDLL/util/printmaps.cpp b/NorthstarDLL/util/printmaps.cpp
index bf9f1dec..d3253605 100644
--- a/NorthstarDLL/util/printmaps.cpp
+++ b/NorthstarDLL/util/printmaps.cpp
@@ -42,10 +42,10 @@ void RefreshMapList()
// Only update the maps list every 10 seconds max to we avoid constantly reading fs
static double fLastRefresh = -999;
- if (fLastRefresh + 10.0 > R2::g_pGlobals->m_flRealTime)
+ if (fLastRefresh + 10.0 > g_pGlobals->m_flRealTime)
return;
- fLastRefresh = R2::g_pGlobals->m_flRealTime;
+ fLastRefresh = g_pGlobals->m_flRealTime;
// Rebuild map list
vMapList.clear();
@@ -110,7 +110,7 @@ void RefreshMapList()
}
// get maps in game dir
- std::string gameDir = fmt::format("{}/maps", R2::g_pModName);
+ std::string gameDir = fmt::format("{}/maps", g_pModName);
if (!std::filesystem::exists(gameDir))
{
return;
@@ -212,7 +212,7 @@ AUTOHOOK(Host_Map_f, engine.dll + 0x15B340, void, __fastcall, (const CCommand& a
return;
}
- if (*R2::g_pServerState >= R2::server_state_t::ss_active)
+ if (*g_pServerState >= server_state_t::ss_active)
return Host_Changelevel_f(args);
else
return Host_Map_helper(args, nullptr);
@@ -222,7 +222,7 @@ void InitialiseMapsPrint()
{
AUTOHOOK_DISPATCH()
- ConCommand* mapsCommand = R2::g_pCVar->FindCommand("maps");
+ ConCommand* mapsCommand = g_pCVar->FindCommand("maps");
mapsCommand->m_pCommandCallback = ConCommand_maps;
}
diff --git a/NorthstarDLL/util/utils.cpp b/NorthstarDLL/util/utils.cpp
index 2c9dc85a..c3f90cfa 100644
--- a/NorthstarDLL/util/utils.cpp
+++ b/NorthstarDLL/util/utils.cpp
@@ -20,7 +20,7 @@ bool skip_valid_ansi_csi_sgr(char*& str)
return true;
}
-void NS::Utils::RemoveAsciiControlSequences(char* str, bool allow_color_codes)
+void RemoveAsciiControlSequences(char* str, bool allow_color_codes)
{
for (char *pc = str, c = *pc; c = *pc; pc++)
{
diff --git a/NorthstarDLL/util/utils.h b/NorthstarDLL/util/utils.h
index 97b92f18..85922692 100644
--- a/NorthstarDLL/util/utils.h
+++ b/NorthstarDLL/util/utils.h
@@ -1,6 +1,3 @@
#pragma once
-namespace NS::Utils
-{
- void RemoveAsciiControlSequences(char* str, bool allow_color_codes);
-}
+void RemoveAsciiControlSequences(char* str, bool allow_color_codes);