aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/playlist.cpp
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-24 21:52:00 +0000
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-12-24 21:52:00 +0000
commit352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7 (patch)
tree8f0b6bcac5ac2ec4e07a879f2e57f8d847e8f25c /NorthstarDedicatedTest/playlist.cpp
parent3dcd9f6b6da1c3f277b27a296f58bca3cbc3a775 (diff)
downloadNorthstarLauncher-352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7.tar.gz
NorthstarLauncher-352952bd8b12ef0a5d66fa2dc5341a4d5777f9b7.zip
prevent playlist var names over 64 characters and send maxplayers on map change
Diffstat (limited to 'NorthstarDedicatedTest/playlist.cpp')
-rw-r--r--NorthstarDedicatedTest/playlist.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/playlist.cpp b/NorthstarDedicatedTest/playlist.cpp
index 6339d3ba..3de5b8c8 100644
--- a/NorthstarDedicatedTest/playlist.cpp
+++ b/NorthstarDedicatedTest/playlist.cpp
@@ -8,6 +8,8 @@
typedef char(*Onclc_SetPlaylistVarOverrideType)(void* a1, void* a2);
Onclc_SetPlaylistVarOverrideType Onclc_SetPlaylistVarOverride;
+// function type defined in gameutils.h
+SetPlaylistVarOverrideType SetPlaylistVarOverrideOriginal;
ConVar* Cvar_ns_use_clc_SetPlaylistVarOverride;
@@ -29,6 +31,14 @@ char Onclc_SetPlaylistVarOverrideHook(void* a1, void* a2)
return Onclc_SetPlaylistVarOverride(a1, a2);
}
+void SetPlaylistVarOverrideHook(const char* varName, const char* value)
+{
+ if (strlen(value) >= 64)
+ return;
+
+ SetPlaylistVarOverrideOriginal(varName, value);
+}
+
void InitialisePlaylistHooks(HMODULE baseAddress)
{
RegisterConCommand("setplaylist", SetPlaylistCommand, "Sets the current playlist", FCVAR_NONE);
@@ -39,6 +49,7 @@ void InitialisePlaylistHooks(HMODULE baseAddress)
HookEnabler hook;
ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x222180, &Onclc_SetPlaylistVarOverrideHook, reinterpret_cast<LPVOID*>(&Onclc_SetPlaylistVarOverride));
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0x18ED17, &SetPlaylistVarOverrideHook, reinterpret_cast<LPVOID*>(&SetPlaylistVarOverrideOriginal));
// patch to prevent clc_SetPlaylistVarOverride from being able to crash servers if we reach max overrides due to a call to Error (why is this possible respawn, wtf)
// todo: add a warning for this