From 8468f509d4ede30e0c457db4448c83909464e83c Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Wed, 22 Feb 2023 22:26:56 +0000
Subject: Add additional properties to `CBasePlayer` (#329)
* add additional properties to CBasePlayer
* fixup names
* use hex offsets
---
NorthstarDLL/server/r2server.h | 84 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 83 insertions(+), 1 deletion(-)
diff --git a/NorthstarDLL/server/r2server.h b/NorthstarDLL/server/r2server.h
index 313284be..8fde7b9d 100644
--- a/NorthstarDLL/server/r2server.h
+++ b/NorthstarDLL/server/r2server.h
@@ -12,15 +12,97 @@ namespace R2
// clang-format off
OFFSET_STRUCT(CBasePlayer)
{
- STRUCT_SIZE(0x1D02);
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
--
cgit v1.2.3
From 6aaac4cd452878acc59d9748bcd2d0e072d2a432 Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Wed, 22 Feb 2023 23:08:44 +0000
Subject: Implement `dedi_sendPrintsToClient` (#418)
* add CGlobals class and g_pGlobals, and update scripts to support
* don't automatically enable antispeedhack (oops)
* add dedicated.cpp
* format
* bad push oops
* reformat again
* implement dedi_sendPrintsToClient
* update formatting
---
NorthstarDLL/NorthstarDLL.vcxproj | 8 ++--
NorthstarDLL/NorthstarDLL.vcxproj.filters | 14 +++++--
NorthstarDLL/dedicated/dedicated.cpp | 4 ++
NorthstarDLL/dedicated/dedicatedlogtoclient.cpp | 49 +++++++++++++++++++++++++
NorthstarDLL/dedicated/dedicatedlogtoclient.h | 11 ++++++
5 files changed, 79 insertions(+), 7 deletions(-)
create mode 100644 NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
create mode 100644 NorthstarDLL/dedicated/dedicatedlogtoclient.h
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj
index bb28d575..7aa68841 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj
+++ b/NorthstarDLL/NorthstarDLL.vcxproj
@@ -413,6 +413,7 @@
+
@@ -449,7 +450,7 @@
-
+
@@ -483,6 +484,7 @@
+
Use
@@ -540,7 +542,7 @@
-
+
@@ -549,4 +551,4 @@
-
+
\ No newline at end of file
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters
index d8437ba5..bb880580 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj.filters
+++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters
@@ -1173,12 +1173,15 @@
Header Files\core
-
- Header Files
+
+ Header Files
Header Files\util
+
+ Header Files\dedicated
+
@@ -1429,10 +1432,13 @@
Source Files\util
+
+ Source Files\dedicated
+
- Source Files
+ Source Files\client
-
+
\ No newline at end of file
diff --git a/NorthstarDLL/dedicated/dedicated.cpp b/NorthstarDLL/dedicated/dedicated.cpp
index 267fbe92..1aff0f34 100644
--- a/NorthstarDLL/dedicated/dedicated.cpp
+++ b/NorthstarDLL/dedicated/dedicated.cpp
@@ -1,4 +1,5 @@
#include "dedicated.h"
+#include "dedicatedlogtoclient.h"
#include "core/tier0.h"
#include "playlist.h"
#include "engine/r2engine.h"
@@ -226,6 +227,9 @@ ON_DLL_LOAD_DEDI_RELIESON("engine.dll", DedicatedServer, ServerPresence, (CModul
DedicatedConsoleServerPresence* presenceReporter = new DedicatedConsoleServerPresence;
g_pServerPresence->AddPresenceReporter(presenceReporter);
+ // setup dedicated printing to client
+ RegisterCustomSink(std::make_shared());
+
// Disable Quick Edit mode to reduce chance of user unintentionally hanging their server by selecting something.
if (!Tier0::CommandLine()->CheckParm("-bringbackquickedit"))
{
diff --git a/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
new file mode 100644
index 00000000..bb62cb36
--- /dev/null
+++ b/NorthstarDLL/dedicated/dedicatedlogtoclient.cpp
@@ -0,0 +1,49 @@
+#include "pch.h"
+#include "dedicatedlogtoclient.h"
+#include "engine/r2engine.h"
+
+void (*CGameClient__ClientPrintf)(R2::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)
+ return;
+
+ enum class eSendPrintsToClient
+ {
+ NONE = -1,
+ FIRST,
+ ALL
+ };
+
+ static const ConVar* Cvar_dedi_sendPrintsToClient = R2::g_pCVar->FindVar("dedi_sendPrintsToClient");
+ eSendPrintsToClient eSendPrints = static_cast(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++)
+ {
+ R2::CBaseClient* pClient = &R2::g_pClientArray[i];
+
+ if (pClient->m_Signon >= R2::eSignonState::CONNECTED)
+ {
+ CGameClient__ClientPrintf(pClient, sLogMessage.c_str());
+
+ if (eSendPrints == eSendPrintsToClient::FIRST)
+ break;
+ }
+ }
+}
+
+void DedicatedServerLogToClientSink::sink_it_(const spdlog::details::log_msg& msg)
+{
+ throw std::runtime_error("sink_it_ called on DedicatedServerLogToClientSink with pure log_msg. This is an error!");
+}
+
+void DedicatedServerLogToClientSink::flush_() {}
+
+ON_DLL_LOAD_DEDI("engine.dll", DedicatedServerLogToClient, (CModule module))
+{
+ CGameClient__ClientPrintf = module.Offset(0x1016A0).As();
+}
diff --git a/NorthstarDLL/dedicated/dedicatedlogtoclient.h b/NorthstarDLL/dedicated/dedicatedlogtoclient.h
new file mode 100644
index 00000000..16f1e584
--- /dev/null
+++ b/NorthstarDLL/dedicated/dedicatedlogtoclient.h
@@ -0,0 +1,11 @@
+#pragma once
+#include "logging/logging.h"
+#include "core/convar/convar.h"
+
+class DedicatedServerLogToClientSink : public CustomSink
+{
+ protected:
+ void custom_sink_it_(const custom_log_msg& msg);
+ void sink_it_(const spdlog::details::log_msg& msg) override;
+ void flush_() override;
+};
--
cgit v1.2.3
From 32165afe41c4cf4d3b261ee7a9c69c369253cc13 Mon Sep 17 00:00:00 2001
From: BobTheBob <32057864+BobTheBob9@users.noreply.github.com>
Date: Thu, 23 Feb 2023 00:19:48 +0000
Subject: Add `FUNCTION_AT` and `VAR_AT` macros (#416)
* add FUNCTION_AT and VAR_AT macros
* fix build issues oops
* fix formatting
* add PREDEFINED_VAR_AT
* change func name
* fixup formatting
* update to use DEFINED_VAR_AT
---
NorthstarDLL/core/convar/concommand.cpp | 2 -
NorthstarDLL/core/hooks.cpp | 39 +++++++++++++++
NorthstarDLL/core/hooks.h | 86 ++++++++++++++++++++-------------
NorthstarDLL/engine/host.cpp | 3 ++
NorthstarDLL/engine/hoststate.cpp | 7 +--
NorthstarDLL/shared/playlist.cpp | 13 ++---
NorthstarDLL/shared/playlist.h | 8 +--
7 files changed, 105 insertions(+), 53 deletions(-)
diff --git a/NorthstarDLL/core/convar/concommand.cpp b/NorthstarDLL/core/convar/concommand.cpp
index 88bd8825..67c867f8 100644
--- a/NorthstarDLL/core/convar/concommand.cpp
+++ b/NorthstarDLL/core/convar/concommand.cpp
@@ -4,8 +4,6 @@
#include
-bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, R2::cmd_source_t commandSource);
-
//-----------------------------------------------------------------------------
// Purpose: Returns true if this is a command
// Output : bool
diff --git a/NorthstarDLL/core/hooks.cpp b/NorthstarDLL/core/hooks.cpp
index 34b48d1d..7c70b0a5 100644
--- a/NorthstarDLL/core/hooks.cpp
+++ b/NorthstarDLL/core/hooks.cpp
@@ -65,6 +65,9 @@ __dllLoadCallback::__dllLoadCallback(
void __fileAutohook::Dispatch()
{
+ for (__autovar* var : vars)
+ var->Dispatch();
+
for (__autohook* hook : hooks)
hook->Dispatch();
}
@@ -114,6 +117,42 @@ bool ManualHook::Dispatch(LPVOID addr, LPVOID* orig)
return false;
}
+uintptr_t ParseDLLOffsetString(const char* pAddrString)
+{
+ // in the format server.dll + 0xDEADBEEF
+ int iDllNameEnd = 0;
+ for (; !isspace(pAddrString[iDllNameEnd]) && pAddrString[iDllNameEnd] != '+'; iDllNameEnd++)
+ ;
+
+ char* pModuleName = new char[iDllNameEnd + 1];
+ memcpy(pModuleName, pAddrString, iDllNameEnd);
+ pModuleName[iDllNameEnd] = '\0';
+
+ // get the module address
+ const HMODULE pModuleAddr = GetModuleHandleA(pModuleName);
+
+ if (!pModuleAddr)
+ return 0;
+
+ // get the offset string
+ uintptr_t iOffset = 0;
+
+ int iOffsetBegin = iDllNameEnd;
+ int iOffsetEnd = strlen(pAddrString);
+
+ // seek until we hit the start of the number offset
+ for (; !(pAddrString[iOffsetBegin] >= '0' && pAddrString[iOffsetBegin] <= '9') && pAddrString[iOffsetBegin]; iOffsetBegin++)
+ ;
+
+ bool bIsHex = pAddrString[iOffsetBegin] == '0' && (pAddrString[iOffsetBegin + 1] == 'X' || pAddrString[iOffsetBegin + 1] == 'x');
+ if (bIsHex)
+ iOffset = std::stoi(pAddrString + iOffsetBegin + 2, 0, 16);
+ else
+ iOffset = std::stoi(pAddrString + iOffsetBegin);
+
+ return ((uintptr_t)pModuleAddr + iOffset);
+}
+
// dll load callback stuff
// this allows for code to register callbacks to be run as soon as a dll is loaded, mainly to allow for patches to be made on dll load
struct DllLoadCallback
diff --git a/NorthstarDLL/core/hooks.h b/NorthstarDLL/core/hooks.h
index f47791fb..0144712f 100644
--- a/NorthstarDLL/core/hooks.h
+++ b/NorthstarDLL/core/hooks.h
@@ -63,16 +63,20 @@ class __dllLoadCallback
// new macro hook stuff
class __autohook;
+class __autovar;
class __fileAutohook
{
public:
std::vector<__autohook*> hooks;
+ std::vector<__autovar*> vars;
void Dispatch();
void DispatchForModule(const char* pModuleName);
};
+uintptr_t ParseDLLOffsetString(const char* pAddrString);
+
// initialise autohooks for this file
#define AUTOHOOK_INIT() \
namespace \
@@ -187,39 +191,7 @@ class __autohook
case OFFSET_STRING:
{
- // in the format server.dll + 0xDEADBEEF
- int iDllNameEnd = 0;
- for (; !isspace(pAddrString[iDllNameEnd]) && pAddrString[iDllNameEnd] != '+'; iDllNameEnd++)
- ;
-
- char* pModuleName = new char[iDllNameEnd + 1];
- memcpy(pModuleName, pAddrString, iDllNameEnd);
- pModuleName[iDllNameEnd] = '\0';
-
- // get the module address
- const HMODULE pModuleAddr = GetModuleHandleA(pModuleName);
-
- if (!pModuleAddr)
- break;
-
- // get the offset string
- uintptr_t iOffset = 0;
-
- int iOffsetBegin = iDllNameEnd;
- int iOffsetEnd = strlen(pAddrString);
-
- // seek until we hit the start of the number offset
- for (; !(pAddrString[iOffsetBegin] >= '0' && pAddrString[iOffsetBegin] <= '9') && pAddrString[iOffsetBegin]; iOffsetBegin++)
- ;
-
- bool bIsHex =
- pAddrString[iOffsetBegin] == '0' && (pAddrString[iOffsetBegin + 1] == 'X' || pAddrString[iOffsetBegin + 1] == 'x');
- if (bIsHex)
- iOffset = std::stoi(pAddrString + iOffsetBegin + 2, 0, 16);
- else
- iOffset = std::stoi(pAddrString + iOffsetBegin);
-
- targetAddr = (LPVOID)((uintptr_t)pModuleAddr + iOffset);
+ targetAddr = (LPVOID)ParseDLLOffsetString(pAddrString);
break;
}
@@ -309,3 +281,51 @@ class ManualHook
void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFuncName = "");
#define MAKEHOOK(pTarget, pDetour, ppOriginal) MakeHook(pTarget, pDetour, ppOriginal, __STR(pDetour))
+
+class __autovar
+{
+ public:
+ char* m_pAddrString;
+ void** m_pTarget;
+
+ public:
+ __autovar(__fileAutohook* pAutohook, const char* pAddrString, void** pTarget)
+ {
+ m_pTarget = pTarget;
+
+ const int iAddrStrlen = strlen(pAddrString) + 1;
+ m_pAddrString = new char[iAddrStrlen];
+ memcpy(m_pAddrString, pAddrString, iAddrStrlen);
+
+ pAutohook->vars.push_back(this);
+ }
+
+ void Dispatch()
+ {
+ *m_pTarget = (void*)ParseDLLOffsetString(m_pAddrString);
+ }
+};
+
+// VAR_AT(engine.dll+0x404, ConVar*, Cvar_host_timescale)
+#define VAR_AT(addrString, type, name) \
+ type name; \
+ namespace \
+ { \
+ __autovar CONCAT2(__autovar, __LINE__)(&__FILEAUTOHOOK, __STR(addrString), (void**)&name); \
+ }
+
+// FUNCTION_AT(engine.dll + 0xDEADBEEF, void, __fastcall, SomeFunc, (void* a1))
+#define FUNCTION_AT(addrString, type, callingConvention, name, args) \
+ type(*callingConvention name) args; \
+ namespace \
+ { \
+ __autovar CONCAT2(__autovar, __LINE__)(&__FILEAUTOHOOK, __STR(addrString), (void**)&name); \
+ }
+
+// int* g_pSomeInt;
+// DEFINED_VAR_AT(engine.dll + 0x5005, g_pSomeInt)
+#define DEFINED_VAR_AT(addrString, name) \
+ namespace \
+ { \
+ __autovar CONCAT2(__autovar, __LINE__)(&__FILEAUTOHOOK, __STR(addrString), (void**)&name); \
+ }
diff --git a/NorthstarDLL/engine/host.cpp b/NorthstarDLL/engine/host.cpp
index 436a169d..49cc3663 100644
--- a/NorthstarDLL/engine/host.cpp
+++ b/NorthstarDLL/engine/host.cpp
@@ -5,7 +5,9 @@
#include "shared/misccommands.h"
#include "r2engine.h"
#include "core/tier0.h"
+
AUTOHOOK_INIT()
+
// clang-format off
AUTOHOOK(Host_Init, engine.dll + 0x155EA0,
void, __fastcall, (bool bDedicated))
@@ -24,6 +26,7 @@ void, __fastcall, (bool bDedicated))
else
R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", R2::cmd_source_t::kCommandSrcCode);
}
+
ON_DLL_LOAD("engine.dll", Host_Init, (CModule module))
{
AUTOHOOK_DISPATCH()
diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp
index 5a295425..44a66113 100644
--- a/NorthstarDLL/engine/hoststate.cpp
+++ b/NorthstarDLL/engine/hoststate.cpp
@@ -18,10 +18,10 @@ namespace R2
CHostState* g_pHostState;
} // namespace R2
-ConVar* Cvar_hostport;
std::string sLastMode;
-void (*_fastcall _Cmd_Exec_f)(const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists);
+VAR_AT(engine.dll + 0x13FA6070, ConVar*, Cvar_hostport);
+FUNCTION_AT(engine.dll + 0x1232C0, void, __fastcall, _Cmd_Exec_f, (const CCommand& arg, bool bOnlyIfExists, bool bUseWhitelists));
void ServerStartingOrChangingMap()
{
@@ -194,7 +194,4 @@ ON_DLL_LOAD_RELIESON("engine.dll", HostState, ConVar, (CModule module))
AUTOHOOK_DISPATCH()
g_pHostState = module.Offset(0x7CF180).As();
- Cvar_hostport = module.Offset(0x13FA6070).As();
-
- _Cmd_Exec_f = module.Offset(0x1232C0).As();
}
diff --git a/NorthstarDLL/shared/playlist.cpp b/NorthstarDLL/shared/playlist.cpp
index 018b2a9b..ab7aab22 100644
--- a/NorthstarDLL/shared/playlist.cpp
+++ b/NorthstarDLL/shared/playlist.cpp
@@ -11,10 +11,10 @@ AUTOHOOK_INIT()
// use the R2 namespace for game funcs
namespace R2
{
- const char* (*GetCurrentPlaylistName)();
- void (*SetCurrentPlaylist)(const char* pPlaylistName);
- void (*SetPlaylistVarOverride)(const char* pVarName, const char* pValue);
- const char* (*GetCurrentPlaylistVar)(const char* pVarName, bool bUseOverrides);
+ DEFINED_VAR_AT(engine.dll + 0x18C640, GetCurrentPlaylistName);
+ DEFINED_VAR_AT(engine.dll + 0x18EB20, SetCurrentPlaylist);
+ DEFINED_VAR_AT(engine.dll + 0x18ED00, SetPlaylistVarOverride);
+ DEFINED_VAR_AT(engine.dll + 0x18C680, GetCurrentPlaylistVar);
} // namespace R2
ConVar* Cvar_ns_use_clc_SetPlaylistVarOverride;
@@ -104,11 +104,6 @@ ON_DLL_LOAD_RELIESON("engine.dll", PlaylistHooks, (ConCommand, ConVar), (CModule
{
AUTOHOOK_DISPATCH()
- R2::GetCurrentPlaylistName = module.Offset(0x18C640).As();
- R2::SetCurrentPlaylist = module.Offset(0x18EB20).As();
- R2::SetPlaylistVarOverride = module.Offset(0x18ED00).As();
- R2::GetCurrentPlaylistVar = module.Offset(0x18C680).As();
-
// playlist is the name of the command on respawn servers, but we already use setplaylist so can't get rid of it
RegisterConCommand("playlist", ConCommand_playlist, "Sets the current playlist", FCVAR_NONE);
RegisterConCommand("setplaylist", ConCommand_playlist, "Sets the current playlist", FCVAR_NONE);
diff --git a/NorthstarDLL/shared/playlist.h b/NorthstarDLL/shared/playlist.h
index c77b37d9..e56fdf96 100644
--- a/NorthstarDLL/shared/playlist.h
+++ b/NorthstarDLL/shared/playlist.h
@@ -3,8 +3,8 @@
// use the R2 namespace for game funcs
namespace R2
{
- extern const char* (*GetCurrentPlaylistName)();
- extern void (*SetCurrentPlaylist)(const char* pPlaylistName);
- extern void (*SetPlaylistVarOverride)(const char* pVarName, const char* pValue);
- extern const char* (*GetCurrentPlaylistVar)(const char* pVarName, bool bUseOverrides);
+ inline const char* (*GetCurrentPlaylistName)();
+ inline void (*SetCurrentPlaylist)(const char* pPlaylistName);
+ inline void (*SetPlaylistVarOverride)(const char* pVarName, const char* pValue);
+ inline const char* (*GetCurrentPlaylistVar)(const char* pVarName, bool bUseOverrides);
} // namespace R2
--
cgit v1.2.3
From ecb83ef17e10fc21eaaab6f568adb17b74d4a3bd Mon Sep 17 00:00:00 2001
From: pg9182 <96569817+pg9182@users.noreply.github.com>
Date: Sun, 5 Mar 2023 10:55:29 -0500
Subject: Fix build errors due to declaration order in scripthttprequesthandler
(#430)
---
NorthstarDLL/scripts/scripthttprequesthandler.cpp | 54 +++++++++++------------
1 file changed, 27 insertions(+), 27 deletions(-)
diff --git a/NorthstarDLL/scripts/scripthttprequesthandler.cpp b/NorthstarDLL/scripts/scripthttprequesthandler.cpp
index 8a6f70fc..813bd50e 100644
--- a/NorthstarDLL/scripts/scripthttprequesthandler.cpp
+++ b/NorthstarDLL/scripts/scripthttprequesthandler.cpp
@@ -448,33 +448,6 @@ template int HttpRequestHandler::MakeHttpRequest(const H
return handle;
}
-template void HttpRequestHandler::RegisterSQFuncs()
-{
- g_pSquirrel->AddFuncRegistration(
- "int",
- "NS_InternalMakeHttpRequest",
- "int method, string baseUrl, table > headers, table > queryParams, string contentType, "
- "string body, "
- "int timeout, string userAgent",
- "[Internal use only] Passes the HttpRequest struct fields to be reconstructed in native and used for an http request",
- SQ_InternalMakeHttpRequest);
-
- g_pSquirrel->AddFuncRegistration(
- "bool",
- "NSIsHttpEnabled",
- "",
- "Whether or not HTTP requests are enabled. You can opt-out by starting the game with -disablehttprequests.",
- SQ_IsHttpEnabled);
-
- g_pSquirrel->AddFuncRegistration(
- "bool",
- "NSIsLocalHttpAllowed",
- "",
- "Whether or not HTTP requests can be made to a private network address. You can enable this by starting the game with "
- "-allowlocalhttp.",
- SQ_IsLocalHttpAllowed);
-}
-
// int NS_InternalMakeHttpRequest(int method, string baseUrl, table headers, table queryParams,
// string contentType, string body, int timeout, string userAgent)
template SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM* sqvm)
@@ -567,6 +540,33 @@ template SQRESULT SQ_IsLocalHttpAllowed(HSquirrelVM* sqv
return SQRESULT_NOTNULL;
}
+template void HttpRequestHandler::RegisterSQFuncs()
+{
+ g_pSquirrel->AddFuncRegistration(
+ "int",
+ "NS_InternalMakeHttpRequest",
+ "int method, string baseUrl, table > headers, table > queryParams, string contentType, "
+ "string body, "
+ "int timeout, string userAgent",
+ "[Internal use only] Passes the HttpRequest struct fields to be reconstructed in native and used for an http request",
+ SQ_InternalMakeHttpRequest);
+
+ g_pSquirrel->AddFuncRegistration(
+ "bool",
+ "NSIsHttpEnabled",
+ "",
+ "Whether or not HTTP requests are enabled. You can opt-out by starting the game with -disablehttprequests.",
+ SQ_IsHttpEnabled);
+
+ g_pSquirrel->AddFuncRegistration(
+ "bool",
+ "NSIsLocalHttpAllowed",
+ "",
+ "Whether or not HTTP requests can be made to a private network address. You can enable this by starting the game with "
+ "-allowlocalhttp.",
+ SQ_IsLocalHttpAllowed);
+}
+
ON_DLL_LOAD_RELIESON("client.dll", HttpRequestHandler_ClientInit, ClientSquirrel, (CModule module))
{
g_httpRequestHandler->RegisterSQFuncs();
--
cgit v1.2.3