aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKawe Mazidjatari <48657826+Mauler125@users.noreply.github.com>2022-04-21 20:14:09 +0200
committerGitHub <noreply@github.com>2022-04-21 20:14:09 +0200
commit367a40f9c6a9310ec7cc8784943e85b8ab72f02e (patch)
treef2a4b4f30c682baf8bbbf3c442f1edefead9898a
parent981e93818bf0c6011bf2b1a803e0a9bc3e1f63d9 (diff)
parentc2f9dd4695824a75e930db5eaea96f5df2f4ea27 (diff)
downloadNorthstarLauncher-367a40f9c6a9310ec7cc8784943e85b8ab72f02e.tar.gz
NorthstarLauncher-367a40f9c6a9310ec7cc8784943e85b8ab72f02e.zip
Merge branch 'main' into NetCon
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj2
-rw-r--r--NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters6
-rw-r--r--NorthstarDedicatedTest/debugoverlay.cpp159
-rw-r--r--NorthstarDedicatedTest/debugoverlay.h3
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp4
5 files changed, 173 insertions, 1 deletions
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
index 4f7c0a9a..b8860040 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj
@@ -118,6 +118,7 @@
<ClInclude Include="cl_rcon.pb.h" />
<ClInclude Include="host_state.h" />
<ClInclude Include="igameserverdata.h" />
+ <ClInclude Include="debugoverlay.h" />
<ClInclude Include="clientruihooks.h" />
<ClInclude Include="clientvideooverrides.h" />
<ClInclude Include="localchatwriter.h" />
@@ -596,6 +597,7 @@
<ClCompile Include="context.cpp" />
<ClCompile Include="convar.cpp" />
<ClCompile Include="cvar.cpp" />
+ <ClCompile Include="debugoverlay.cpp" />
<ClCompile Include="dedicated.cpp" />
<ClCompile Include="dedicatedmaterialsystem.cpp" />
<ClCompile Include="dllmain.cpp" />
diff --git a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
index bf8424e3..22865847 100644
--- a/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
+++ b/NorthstarDedicatedTest/NorthstarDedicatedTest.vcxproj.filters
@@ -1521,6 +1521,9 @@
<ClInclude Include="host_state.h">
<Filter>Header Files\Shared</Filter>
</ClInclude>
+ <ClInclude Include="debugoverlay.h">
+ <Filter>Header Files\Client</Filter>
+ </ClInclude>
<ClInclude Include="clientvideooverrides.h">
<Filter>Header Files\Client</Filter>
</ClInclude>
@@ -1721,6 +1724,9 @@
<ClCompile Include="host_state.cpp">
<Filter>Source Files\Shared</Filter>
</ClCompile>
+ <ClCompile Include="debugoverlay.cpp">
+ <Filter>Source Files\Client</Filter>
+ </ClCompile>
<ClCompile Include="clientvideooverrides.cpp">
<Filter>Source Files\Client</Filter>
</ClCompile>
diff --git a/NorthstarDedicatedTest/debugoverlay.cpp b/NorthstarDedicatedTest/debugoverlay.cpp
new file mode 100644
index 00000000..9620609f
--- /dev/null
+++ b/NorthstarDedicatedTest/debugoverlay.cpp
@@ -0,0 +1,159 @@
+#include "pch.h"
+#include "debugoverlay.h"
+#include "dedicated.h"
+#include "cvar.h"
+
+struct Vector3
+{
+ float x, y, z;
+};
+
+struct QAngle
+{
+ float x, y, z, w;
+};
+
+enum OverlayType_t
+{
+ OVERLAY_BOX = 0,
+ OVERLAY_SPHERE,
+ OVERLAY_LINE,
+ OVERLAY_TRIANGLE,
+ OVERLAY_SWEPT_BOX,
+ OVERLAY_BOX2,
+ OVERLAY_CAPSULE
+};
+
+struct OverlayBase_t
+{
+ OverlayBase_t()
+ {
+ m_Type = OVERLAY_BOX;
+ m_nServerCount = -1;
+ m_nCreationTick = -1;
+ m_flEndTime = 0.0f;
+ m_pNextOverlay = NULL;
+ }
+
+ OverlayType_t m_Type; // What type of overlay is it?
+ int m_nCreationTick; // Duration -1 means go away after this frame #
+ int m_nServerCount; // Latch server count, too
+ float m_flEndTime; // When does this box go away
+ OverlayBase_t* m_pNextOverlay;
+ __int64 m_pUnk;
+};
+
+struct OverlayLine_t : public OverlayBase_t
+{
+ OverlayLine_t() { m_Type = OVERLAY_LINE; }
+
+ Vector3 origin;
+ Vector3 dest;
+ int r;
+ int g;
+ int b;
+ int a;
+ bool noDepthTest;
+};
+
+struct OverlayBox_t : public OverlayBase_t
+{
+ OverlayBox_t() { m_Type = OVERLAY_BOX; }
+
+ Vector3 origin;
+ Vector3 mins;
+ Vector3 maxs;
+ QAngle angles;
+ int r;
+ int g;
+ int b;
+ int a;
+};
+
+// this is in cvar.h, don't need it here
+/*class Color
+{
+ public:
+ Color(int r, int g, int b, int a)
+ {
+ _color[0] = (unsigned char)r;
+ _color[1] = (unsigned char)g;
+ _color[2] = (unsigned char)b;
+ _color[3] = (unsigned char)a;
+ }
+
+ private:
+ unsigned char _color[4];
+};*/
+
+static HMODULE sEngineModule;
+
+typedef void (*DrawOverlayType)(OverlayBase_t* a1);
+DrawOverlayType DrawOverlay;
+
+typedef void (*RenderLineType)(Vector3 v1, Vector3 v2, Color c, bool bZBuffer);
+static RenderLineType RenderLine;
+
+typedef void (*RenderBoxType)(Vector3 vOrigin, QAngle angles, Vector3 vMins, Vector3 vMaxs, Color c, bool bZBuffer, bool bInsideOut);
+static RenderBoxType RenderBox;
+
+static RenderBoxType RenderWireframeBox;
+
+// engine.dll+0xABCB0
+void __fastcall DrawOverlayHook(OverlayBase_t* pOverlay)
+{
+ EnterCriticalSection((LPCRITICAL_SECTION)((char*)sEngineModule + 0x10DB0A38)); // s_OverlayMutex
+
+ void* pMaterialSystem = *(void**)((char*)sEngineModule + 0x14C675B0);
+
+ switch (pOverlay->m_Type)
+ {
+ case OVERLAY_LINE:
+ {
+ OverlayLine_t* pLine = static_cast<OverlayLine_t*>(pOverlay);
+ RenderLine(pLine->origin, pLine->dest, Color(pLine->r, pLine->g, pLine->b, pLine->a), pLine->noDepthTest);
+ }
+ break;
+ case OVERLAY_BOX:
+ {
+ OverlayBox_t* pCurrBox = static_cast<OverlayBox_t*>(pOverlay);
+ if (pCurrBox->a > 0)
+ {
+ RenderBox(
+ pCurrBox->origin, pCurrBox->angles, pCurrBox->mins, pCurrBox->maxs,
+ Color(pCurrBox->r, pCurrBox->g, pCurrBox->b, pCurrBox->a), false, false);
+ }
+ if (pCurrBox->a < 255)
+ {
+ RenderWireframeBox(
+ pCurrBox->origin, pCurrBox->angles, pCurrBox->mins, pCurrBox->maxs, Color(pCurrBox->r, pCurrBox->g, pCurrBox->b, 255),
+ false, false);
+ }
+ }
+ break;
+ }
+ LeaveCriticalSection((LPCRITICAL_SECTION)((char*)sEngineModule + 0x10DB0A38));
+}
+
+void InitialiseDebugOverlay(HMODULE baseAddress)
+{
+ if (IsDedicated())
+ return;
+
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0xABCB0, &DrawOverlayHook, reinterpret_cast<LPVOID*>(&DrawOverlay));
+
+ RenderLine = reinterpret_cast<RenderLineType>((char*)baseAddress + 0x192A70);
+
+ RenderBox = reinterpret_cast<RenderBoxType>((char*)baseAddress + 0x192520);
+
+ RenderWireframeBox = reinterpret_cast<RenderBoxType>((char*)baseAddress + 0x193DA0);
+
+ sEngineModule = baseAddress;
+
+ // not in g_pCVar->FindVar by this point for whatever reason, so have to get from memory
+ ConVar* Cvar_enable_debug_overlays = (ConVar*)((char*)baseAddress + 0x10DB0990);
+ Cvar_enable_debug_overlays->SetValue(false);
+ Cvar_enable_debug_overlays->m_pszDefaultValue = (char*)"0";
+ Cvar_enable_debug_overlays->AddFlags(FCVAR_CHEAT);
+} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/debugoverlay.h b/NorthstarDedicatedTest/debugoverlay.h
new file mode 100644
index 00000000..a300018c
--- /dev/null
+++ b/NorthstarDedicatedTest/debugoverlay.h
@@ -0,0 +1,3 @@
+#pragma once
+
+void InitialiseDebugOverlay(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index 04dfe85a..76293a89 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -41,6 +41,7 @@
#include "plugins.h"
#include "host_state.h"
#include "rcon_shared.h"
+#include "debugoverlay.h"
#include "clientvideooverrides.h"
#include "clientruihooks.h"
#include "rapidjson/document.h"
@@ -227,6 +228,7 @@ bool InitialiseNorthstar()
// client-exclusive patches
{
+
AddDllLoadCallbackForClient("tier0.dll", InitialiseTier0LanguageHooks);
AddDllLoadCallbackForClient("client.dll", InitialiseClientSquirrel);
AddDllLoadCallbackForClient("client.dll", InitialiseSourceConsole);
@@ -246,7 +248,7 @@ bool InitialiseNorthstar()
AddDllLoadCallbackForClient("client.dll", InitialiseScriptServerToClientStringCommands);
AddDllLoadCallbackForClient("client.dll", InitialiseClientVideoOverrides);
AddDllLoadCallbackForClient("engine.dll", InitialiseEngineClientRUIHooks);
-
+ AddDllLoadCallbackForClient("engine.dll", InitialiseDebugOverlay);
// audio hooks
AddDllLoadCallbackForClient("client.dll", InitialiseMilesAudioHooks);
}