aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobTheBob <for.oliver.kirkham@gmail.com>2023-03-07 11:26:33 +0000
committerBobTheBob <for.oliver.kirkham@gmail.com>2023-03-07 11:26:33 +0000
commitddf4448a5cef7c06845d65815602fb6290c460fa (patch)
tree2a9def502a9602ea8b7e0a434971fd7d763ca81b
parentf7e833f62b8db14a9c884729bd1531ba3988da60 (diff)
parentecb83ef17e10fc21eaaab6f568adb17b74d4a3bd (diff)
downloadNorthstarLauncher-ddf4448a5cef7c06845d65815602fb6290c460fa.tar.gz
NorthstarLauncher-ddf4448a5cef7c06845d65815602fb6290c460fa.zip
Merge remote-tracking branch 'origin/main' into modloading-rewrite-pr
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj2
-rw-r--r--NorthstarDLL/NorthstarDLL.vcxproj.filters8
-rw-r--r--NorthstarDLL/core/hooks.h2
-rw-r--r--NorthstarDLL/dedicated/dedicated.cpp4
-rw-r--r--NorthstarDLL/dedicated/dedicatedlogtoclient.cpp49
-rw-r--r--NorthstarDLL/dedicated/dedicatedlogtoclient.h11
-rw-r--r--NorthstarDLL/scripts/scripthttprequesthandler.cpp54
-rw-r--r--NorthstarDLL/server/r2server.h84
-rw-r--r--NorthstarDLL/shared/playlist.cpp8
-rw-r--r--NorthstarDLL/shared/playlist.h8
10 files changed, 192 insertions, 38 deletions
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj b/NorthstarDLL/NorthstarDLL.vcxproj
index 3826c232..3ed99d25 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj
+++ b/NorthstarDLL/NorthstarDLL.vcxproj
@@ -413,6 +413,7 @@
<ClInclude Include="core\structs.h" />
<ClInclude Include="core\tier0.h" />
<ClInclude Include="dedicated\dedicated.h" />
+ <ClInclude Include="dedicated\dedicatedlogtoclient.h" />
<ClInclude Include="dllmain.h" />
<ClInclude Include="engine\hoststate.h" />
<ClInclude Include="engine\r2engine.h" />
@@ -483,6 +484,7 @@
<ClCompile Include="core\sourceinterface.cpp" />
<ClCompile Include="core\tier0.cpp" />
<ClCompile Include="dedicated\dedicated.cpp" />
+ <ClCompile Include="dedicated\dedicatedlogtoclient.cpp" />
<ClCompile Include="dedicated\dedicatedmaterialsystem.cpp" />
<ClCompile Include="dllmain.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Use</PrecompiledHeader>
diff --git a/NorthstarDLL/NorthstarDLL.vcxproj.filters b/NorthstarDLL/NorthstarDLL.vcxproj.filters
index 8baef399..10f6d796 100644
--- a/NorthstarDLL/NorthstarDLL.vcxproj.filters
+++ b/NorthstarDLL/NorthstarDLL.vcxproj.filters
@@ -1182,6 +1182,9 @@
<ClInclude Include="util\utils.h">
<Filter>Header Files\util</Filter>
</ClInclude>
+ <ClInclude Include="dedicated\dedicatedlogtoclient.h">
+ <Filter>Header Files\dedicated</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\include\spdlog\fmt\bundled\LICENSE.rst">
@@ -1429,6 +1432,9 @@
<ClCompile Include="util\utils.cpp">
<Filter>Source Files\util</Filter>
</ClCompile>
+ <ClCompile Include="dedicated\dedicatedlogtoclient.cpp">
+ <Filter>Source Files\dedicated</Filter>
+ </ClCompile>
<ClCompile Include="mods\reload\reloadmodweapons.cpp">
<Filter>Source Files\mods\reload</Filter>
</ClCompile>
@@ -1438,7 +1444,7 @@
</ItemGroup>
<ItemGroup>
<MASM Include="audio_asm.asm">
- <Filter>Source Files</Filter>
+ <Filter>Source Files\client</Filter>
</MASM>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/NorthstarDLL/core/hooks.h b/NorthstarDLL/core/hooks.h
index 205b6079..0144712f 100644
--- a/NorthstarDLL/core/hooks.h
+++ b/NorthstarDLL/core/hooks.h
@@ -324,7 +324,7 @@ class __autovar
// int* g_pSomeInt;
// DEFINED_VAR_AT(engine.dll + 0x5005, g_pSomeInt)
-#define DEFINED_VAR_AT(addrString, name) \
+#define DEFINED_VAR_AT(addrString, name) \
namespace \
{ \
__autovar CONCAT2(__autovar, __LINE__)(&__FILEAUTOHOOK, __STR(addrString), (void**)&name); \
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<DedicatedServerLogToClientSink>());
+
// 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<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++)
+ {
+ 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<void (*)(R2::CBaseClient*, const char*, ...)>();
+}
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;
+};
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 <ScriptContext context> int HttpRequestHandler::MakeHttpRequest(const H
return handle;
}
-template <ScriptContext context> void HttpRequestHandler::RegisterSQFuncs()
-{
- g_pSquirrel<context>->AddFuncRegistration(
- "int",
- "NS_InternalMakeHttpRequest",
- "int method, string baseUrl, table<string, array<string> > headers, table<string, array<string> > 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<context>);
-
- g_pSquirrel<context>->AddFuncRegistration(
- "bool",
- "NSIsHttpEnabled",
- "",
- "Whether or not HTTP requests are enabled. You can opt-out by starting the game with -disablehttprequests.",
- SQ_IsHttpEnabled<context>);
-
- g_pSquirrel<context>->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<context>);
-}
-
// int NS_InternalMakeHttpRequest(int method, string baseUrl, table<string, string> headers, table<string, string> queryParams,
// string contentType, string body, int timeout, string userAgent)
template <ScriptContext context> SQRESULT SQ_InternalMakeHttpRequest(HSquirrelVM* sqvm)
@@ -567,6 +540,33 @@ template <ScriptContext context> SQRESULT SQ_IsLocalHttpAllowed(HSquirrelVM* sqv
return SQRESULT_NOTNULL;
}
+template <ScriptContext context> void HttpRequestHandler::RegisterSQFuncs()
+{
+ g_pSquirrel<context>->AddFuncRegistration(
+ "int",
+ "NS_InternalMakeHttpRequest",
+ "int method, string baseUrl, table<string, array<string> > headers, table<string, array<string> > 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<context>);
+
+ g_pSquirrel<context>->AddFuncRegistration(
+ "bool",
+ "NSIsHttpEnabled",
+ "",
+ "Whether or not HTTP requests are enabled. You can opt-out by starting the game with -disablehttprequests.",
+ SQ_IsHttpEnabled<context>);
+
+ g_pSquirrel<context>->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<context>);
+}
+
ON_DLL_LOAD_RELIESON("client.dll", HttpRequestHandler_ClientInit, ClientSquirrel, (CModule module))
{
g_httpRequestHandler->RegisterSQFuncs<ScriptContext::CLIENT>();
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
diff --git a/NorthstarDLL/shared/playlist.cpp b/NorthstarDLL/shared/playlist.cpp
index f19f32bb..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
{
- FUNCTION_AT(engine.dll + 0x18C640, const char*, , GetCurrentPlaylistName, ());
- FUNCTION_AT(engine.dll + 0x18EB20, void, , SetCurrentPlaylist, (const char* pPlaylistName));
- FUNCTION_AT(engine.dll + 0x18ED00, void, , SetPlaylistVarOverride, (const char* pVarName, const char* pValue));
- FUNCTION_AT(engine.dll + 0x18C680, 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;
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