aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2023-03-08 00:55:12 +0000
committerGitHub <noreply@github.com>2023-03-08 01:55:12 +0100
commit7720e514934fd933502876fab2666a3c4a4516a3 (patch)
tree9e66f75b02134af74705c5921cc86807b25339f8
parent06221fab6b8ce6d922963b464854c3c4d6731995 (diff)
downloadNorthstarLauncher-7720e514934fd933502876fab2666a3c4a4516a3.tar.gz
NorthstarLauncher-7720e514934fd933502876fab2666a3c4a4516a3.zip
Fix `sv_alltalk 1` (broken originally by respawn changes) (#291)
* fix sv_alltalk 1 (broken originally by respawn changes) * nvm i forgor to commit literally the main file * fix formatting * unsure why this was buidling but it shouldn't've been? fix build errors regardless * remove duplicate alltalk.cpp * add (experimental) potentially less jank patch * (now working) better patch for checking if alltalk is enabled * oops put a z in it boo womp * fixup formatting
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj1
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj.filters3
-rw-r--r--NorthstarDLL/server/alltalk.cpp28
3 files changed, 32 insertions, 0 deletions
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj
index 7aa68841..12867b4b 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj
+++ b/NorthstarDLL/NorthstarDLL.vcxproj
@@ -522,6 +522,7 @@
<ClCompile Include="scripts\server\miscserverfixes.cpp" />
<ClCompile Include="scripts\server\miscserverscript.cpp" />
<ClCompile Include="scripts\server\scriptuserinfo.cpp" />
+ <ClCompile Include="server\alltalk.cpp" />
<ClCompile Include="server\auth\bansystem.cpp" />
<ClCompile Include="server\auth\serverauthentication.cpp" />
<ClCompile Include="server\buildainfile.cpp" />
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters
index bb880580..2526c50a 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj.filters
+++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters
@@ -1435,6 +1435,9 @@
<ClCompile Include="dedicated\dedicatedlogtoclient.cpp">
<Filter>Source Files\dedicated</Filter>
</ClCompile>
+ <ClCompile Include="server\alltalk.cpp">
+ <Filter>Source Files\server</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<MASM Include="audio_asm.asm">
diff --git a/NorthstarDLL/server/alltalk.cpp b/NorthstarDLL/server/alltalk.cpp
new file mode 100644
index 00000000..6283a1a2
--- /dev/null
+++ b/NorthstarDLL/server/alltalk.cpp
@@ -0,0 +1,28 @@
+#include "core/convar/convar.h"
+#include "engine/r2engine.h"
+
+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");
+ 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");
+}
+
+ON_DLL_LOAD_RELIESON("engine.dll", ServerAllTalk, ConVar, (CModule module))
+{
+ // replace strcmp function called in CClient::ProcessVoiceData with our own code that calls ShouldAllowAllTalk
+ MemoryAddress base = module.Offset(0x1085FA);
+
+ base.Patch("48 B8"); // mov rax, 64 bit int
+ // (uint8_t*)&ShouldAllowAlltalk doesn't work for some reason? need to make it a uint64 first
+ uint64_t pShouldAllowAllTalk = reinterpret_cast<uint64_t>(ShouldAllowAlltalk);
+ base.Offset(0x2).Patch((uint8_t*)&pShouldAllowAllTalk, 8);
+ base.Offset(0xA).Patch("FF D0"); // call rax
+
+ // nop until compare (test eax, eax)
+ base.Offset(0xC).NOP(0x7);
+}