aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/engine
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2023-12-20 13:24:07 +0000
committerGitHub <noreply@github.com>2023-12-20 14:24:07 +0100
commit0438b5c8cfa99ac01c7e142d959aa40f88f1cc70 (patch)
treebbfdded20f8686cf188dba148db4b6c1b1211872 /NorthstarDLL/engine
parent210dab2b0e5c686829bafdc857d2910f6b216b85 (diff)
downloadNorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.tar.gz
NorthstarLauncher-0438b5c8cfa99ac01c7e142d959aa40f88f1cc70.zip
Cherry pick "remove unnecessary namespaces" from primedev (#618)v1.21.2-rc2
Cherry-picks the removal of unnecessary namespaces from `primedev` https://github.com/F1F7Y/NorthstarPrime/ Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'NorthstarDLL/engine')
-rw-r--r--NorthstarDLL/engine/host.cpp4
-rw-r--r--NorthstarDLL/engine/hoststate.cpp33
-rw-r--r--NorthstarDLL/engine/hoststate.h70
-rw-r--r--NorthstarDLL/engine/r2engine.cpp30
-rw-r--r--NorthstarDLL/engine/r2engine.h486
-rw-r--r--NorthstarDLL/engine/runframe.cpp2
6 files changed, 302 insertions, 323 deletions
diff --git a/NorthstarDLL/engine/host.cpp b/NorthstarDLL/engine/host.cpp
index 49cc3663..dacb8fc1 100644
--- a/NorthstarDLL/engine/host.cpp
+++ b/NorthstarDLL/engine/host.cpp
@@ -22,9 +22,9 @@ void, __fastcall, (bool bDedicated))
// client/server autoexecs on necessary platforms
// dedi needs autoexec_ns_server on boot, while non-dedi will run it on on listen server start
if (bDedicated)
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_server", cmd_source_t::kCommandSrcCode);
else
- R2::Cbuf_AddText(R2::Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", R2::cmd_source_t::kCommandSrcCode);
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), "exec autoexec_ns_client", cmd_source_t::kCommandSrcCode);
}
ON_DLL_LOAD("engine.dll", Host_Init, (CModule module))
diff --git a/NorthstarDLL/engine/hoststate.cpp b/NorthstarDLL/engine/hoststate.cpp
index 1734a1c3..ec728afb 100644
--- a/NorthstarDLL/engine/hoststate.cpp
+++ b/NorthstarDLL/engine/hoststate.cpp
@@ -12,13 +12,7 @@
AUTOHOOK_INIT()
-using namespace R2;
-
-// use the R2 namespace for game funcs
-namespace R2
-{
- CHostState* g_pHostState;
-} // namespace R2
+CHostState* g_pHostState;
std::string sLastMode;
@@ -35,15 +29,14 @@ void ServerStartingOrChangingMap()
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
if (sLastMode.length() &&
- CCommand__Tokenize(
- tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), R2::cmd_source_t::kCommandSrcCode))
+ CCommand__Tokenize(tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), cmd_source_t::kCommandSrcCode))
_Cmd_Exec_f(tempCommand, false, false);
memset(commandBuf, 0, sizeof(commandBuf));
if (CCommand__Tokenize(
tempCommand,
fmt::format("exec server/setup_gamemode_{}", sLastMode = Cvar_mp_gamemode->GetString()).c_str(),
- R2::cmd_source_t::kCommandSrcCode))
+ cmd_source_t::kCommandSrcCode))
{
_Cmd_Exec_f(tempCommand, false, false);
}
@@ -73,18 +66,18 @@ void, __fastcall, (CHostState* self))
// need to do this to ensure we don't go to private match
if (g_pServerAuthentication->m_bNeedLocalAuthForNewgame)
- SetCurrentPlaylist("tdm");
+ R2::SetCurrentPlaylist("tdm");
ServerStartingOrChangingMap();
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_NewGame(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
// setup server presence
g_pServerPresence->CreatePresence();
g_pServerPresence->SetMap(g_pHostState->m_levelName, true);
- g_pServerPresence->SetPlaylist(GetCurrentPlaylistName());
+ g_pServerPresence->SetPlaylist(R2::GetCurrentPlaylistName());
g_pServerPresence->SetPort(Cvar_hostport->GetInt());
g_pServerAuthentication->m_bNeedLocalAuthForNewgame = false;
@@ -107,9 +100,9 @@ void, __fastcall, (CHostState* self))
g_pCVar->FindVar("net_data_block_enabled")->SetValue(true);
g_pServerAuthentication->m_bStartingLocalSPGame = true;
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_LoadGame(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
// no server presence, can't do it because no map name in hoststate
// and also not super important for sp saves really
@@ -126,9 +119,9 @@ void, __fastcall, (CHostState* self))
ServerStartingOrChangingMap();
- double dStartTime = Tier0::Plat_FloatTime();
+ double dStartTime = Plat_FloatTime();
CHostState__State_ChangeLevelMP(self);
- spdlog::info("loading took {}s", Tier0::Plat_FloatTime() - dStartTime);
+ spdlog::info("loading took {}s", Plat_FloatTime() - dStartTime);
g_pServerPresence->SetMap(g_pHostState->m_levelName);
}
@@ -151,7 +144,7 @@ void, __fastcall, (CHostState* self))
memset(commandBuf, 0, sizeof(commandBuf));
CCommand tempCommand = *(CCommand*)&commandBuf;
if (CCommand__Tokenize(
- tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), R2::cmd_source_t::kCommandSrcCode))
+ tempCommand, fmt::format("exec server/cleanup_gamemode_{}", sLastMode).c_str(), cmd_source_t::kCommandSrcCode))
{
_Cmd_Exec_f(tempCommand, false, false);
Cbuf_Execute();
@@ -168,7 +161,7 @@ void, __fastcall, (CHostState* self, double flCurrentTime, float flFrameTime))
{
CHostState__FrameUpdate(self, flCurrentTime, flFrameTime);
- if (*R2::g_pServerState == R2::server_state_t::ss_active)
+ if (*g_pServerState == server_state_t::ss_active)
{
// update server presence
g_pServerPresence->RunFrame(flCurrentTime);
diff --git a/NorthstarDLL/engine/hoststate.h b/NorthstarDLL/engine/hoststate.h
index a77385ef..0536e91c 100644
--- a/NorthstarDLL/engine/hoststate.h
+++ b/NorthstarDLL/engine/hoststate.h
@@ -1,45 +1,41 @@
#pragma once
-// use the R2 namespace for game funxcs
-namespace R2
+enum class HostState_t
{
- enum class HostState_t
- {
- HS_NEW_GAME = 0,
- HS_LOAD_GAME,
- HS_CHANGE_LEVEL_SP,
- HS_CHANGE_LEVEL_MP,
- HS_RUN,
- HS_GAME_SHUTDOWN,
- HS_SHUTDOWN,
- HS_RESTART,
- };
+ HS_NEW_GAME = 0,
+ HS_LOAD_GAME,
+ HS_CHANGE_LEVEL_SP,
+ HS_CHANGE_LEVEL_MP,
+ HS_RUN,
+ HS_GAME_SHUTDOWN,
+ HS_SHUTDOWN,
+ HS_RESTART,
+};
- struct CHostState
- {
- public:
- HostState_t m_iCurrentState;
- HostState_t m_iNextState;
+struct CHostState
+{
+ public:
+ HostState_t m_iCurrentState;
+ HostState_t m_iNextState;
- float m_vecLocation[3];
- float m_angLocation[3];
+ float m_vecLocation[3];
+ float m_angLocation[3];
- char m_levelName[32];
- char m_mapGroupName[32];
- char m_landmarkName[32];
- char m_saveName[32];
- float m_flShortFrameTime; // run a few one-tick frames to avoid large timesteps while loading assets
+ char m_levelName[32];
+ char m_mapGroupName[32];
+ char m_landmarkName[32];
+ char m_saveName[32];
+ float m_flShortFrameTime; // run a few one-tick frames to avoid large timesteps while loading assets
- bool m_activeGame;
- bool m_bRememberLocation;
- bool m_bBackgroundLevel;
- bool m_bWaitingForConnection;
- bool m_bLetToolsOverrideLoadGameEnts; // During a load game, this tells Foundry to override ents that are selected in Hammer.
- bool m_bSplitScreenConnect;
- bool m_bGameHasShutDownAndFlushedMemory; // This is false once we load a map into memory, and set to true once the map is unloaded
- // and all memory flushed
- bool m_bWorkshopMapDownloadPending;
- };
+ bool m_activeGame;
+ bool m_bRememberLocation;
+ bool m_bBackgroundLevel;
+ bool m_bWaitingForConnection;
+ bool m_bLetToolsOverrideLoadGameEnts; // During a load game, this tells Foundry to override ents that are selected in Hammer.
+ bool m_bSplitScreenConnect;
+ bool m_bGameHasShutDownAndFlushedMemory; // This is false once we load a map into memory, and set to true once the map is unloaded
+ // and all memory flushed
+ bool m_bWorkshopMapDownloadPending;
+};
- extern CHostState* g_pHostState;
-} // namespace R2
+extern CHostState* g_pHostState;
diff --git a/NorthstarDLL/engine/r2engine.cpp b/NorthstarDLL/engine/r2engine.cpp
index 67a628fd..88500376 100644
--- a/NorthstarDLL/engine/r2engine.cpp
+++ b/NorthstarDLL/engine/r2engine.cpp
@@ -1,28 +1,22 @@
#include "r2engine.h"
-using namespace R2;
+Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
+Cbuf_AddTextType Cbuf_AddText;
+Cbuf_ExecuteType Cbuf_Execute;
-// use the R2 namespace for game funcs
-namespace R2
-{
- Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
- Cbuf_AddTextType Cbuf_AddText;
- Cbuf_ExecuteType Cbuf_Execute;
-
- bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, R2::cmd_source_t commandSource);
+bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, cmd_source_t commandSource);
- CEngine* g_pEngine;
+CEngine* g_pEngine;
- void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
- CBaseClient* g_pClientArray;
+void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
+CBaseClient* g_pClientArray;
- server_state_t* g_pServerState;
+server_state_t* g_pServerState;
- char* g_pModName =
- nullptr; // we cant set this up here atm since we dont have an offset to it in engine, instead we store it in IsRespawnMod
+char* g_pModName =
+ nullptr; // we cant set this up here atm since we dont have an offset to it in engine, instead we store it in IsRespawnMod
- CGlobalVars* g_pGlobals;
-} // namespace R2
+CGlobalVars* g_pGlobals;
ON_DLL_LOAD("engine.dll", R2Engine, (CModule module))
{
@@ -30,7 +24,7 @@ ON_DLL_LOAD("engine.dll", R2Engine, (CModule module))
Cbuf_AddText = module.Offset(0x1203B0).RCast<Cbuf_AddTextType>();
Cbuf_Execute = module.Offset(0x1204B0).RCast<Cbuf_ExecuteType>();
- CCommand__Tokenize = module.Offset(0x418380).RCast<bool (*)(CCommand&, const char*, R2::cmd_source_t)>();
+ CCommand__Tokenize = module.Offset(0x418380).RCast<bool (*)(CCommand&, const char*, cmd_source_t)>();
g_pEngine = module.Offset(0x7D70C8).Deref().RCast<CEngine*>();
diff --git a/NorthstarDLL/engine/r2engine.h b/NorthstarDLL/engine/r2engine.h
index df0cda74..91676b6b 100644
--- a/NorthstarDLL/engine/r2engine.h
+++ b/NorthstarDLL/engine/r2engine.h
@@ -1,264 +1,260 @@
#pragma once
#include "shared/keyvalues.h"
-// use the R2 namespace for game funcs
-namespace R2
+// Cbuf
+enum class ECommandTarget_t
{
- // Cbuf
- enum class ECommandTarget_t
- {
- CBUF_FIRST_PLAYER = 0,
- CBUF_LAST_PLAYER = 1, // MAX_SPLITSCREEN_CLIENTS - 1, MAX_SPLITSCREEN_CLIENTS = 2
- CBUF_SERVER = CBUF_LAST_PLAYER + 1,
-
- CBUF_COUNT,
- };
-
- enum class cmd_source_t
- {
- // Added to the console buffer by gameplay code. Generally unrestricted.
- kCommandSrcCode,
-
- // Sent from code via engine->ClientCmd, which is restricted to commands visible
- // via FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS.
- kCommandSrcClientCmd,
-
- // Typed in at the console or via a user key-bind. Generally unrestricted, although
- // the client will throttle commands sent to the server this way to 16 per second.
- kCommandSrcUserInput,
-
- // Came in over a net connection as a clc_stringcmd
- // host_client will be valid during this state.
- //
- // Restricted to FCVAR_GAMEDLL commands (but not convars) and special non-ConCommand
- // server commands hardcoded into gameplay code (e.g. "joingame")
- kCommandSrcNetClient,
+ CBUF_FIRST_PLAYER = 0,
+ CBUF_LAST_PLAYER = 1, // MAX_SPLITSCREEN_CLIENTS - 1, MAX_SPLITSCREEN_CLIENTS = 2
+ CBUF_SERVER = CBUF_LAST_PLAYER + 1,
- // Received from the server as the client
- //
- // Restricted to commands with FCVAR_SERVER_CAN_EXECUTE
- kCommandSrcNetServer,
+ CBUF_COUNT,
+};
- // Being played back from a demo file
- //
- // Not currently restricted by convar flag, but some commands manually ignore calls
- // from this source. FIXME: Should be heavily restricted as demo commands can come
- // from untrusted sources.
- kCommandSrcDemoFile,
-
- // Invalid value used when cleared
- kCommandSrcInvalid = -1
- };
-
- typedef ECommandTarget_t (*Cbuf_GetCurrentPlayerType)();
- extern Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
-
- typedef void (*Cbuf_AddTextType)(ECommandTarget_t eTarget, const char* text, cmd_source_t source);
- extern Cbuf_AddTextType Cbuf_AddText;
-
- typedef void (*Cbuf_ExecuteType)();
- extern Cbuf_ExecuteType Cbuf_Execute;
-
- extern bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, R2::cmd_source_t commandSource);
-
- // CEngine
-
- enum EngineQuitState
- {
- QUIT_NOTQUITTING = 0,
- QUIT_TODESKTOP,
- QUIT_RESTART
- };
-
- enum class EngineState_t
- {
- DLL_INACTIVE = 0, // no dll
- DLL_ACTIVE, // engine is focused
- DLL_CLOSE, // closing down dll
- DLL_RESTART, // engine is shutting down but will restart right away
- DLL_PAUSED, // engine is paused, can become active from this state
- };
-
- class CEngine
- {
- public:
- virtual void unknown() = 0; // unsure if this is where
- virtual bool Load(bool dedicated, const char* baseDir) = 0;
- virtual void Unload() = 0;
- virtual void SetNextState(EngineState_t iNextState) = 0;
- virtual EngineState_t GetState() = 0;
- virtual void Frame() = 0;
- virtual double GetFrameTime() = 0;
- virtual float GetCurTime() = 0;
-
- EngineQuitState m_nQuitting;
- EngineState_t m_nDllState;
- EngineState_t m_nNextDllState;
- double m_flCurrentTime;
- float m_flFrameTime;
- double m_flPreviousTime;
- float m_flFilteredTime;
- float m_flMinFrameTime; // Expected duration of a frame, or zero if it is unlimited.
- };
+enum class cmd_source_t
+{
+ // Added to the console buffer by gameplay code. Generally unrestricted.
+ kCommandSrcCode,
+
+ // Sent from code via engine->ClientCmd, which is restricted to commands visible
+ // via FCVAR_GAMEDLL_FOR_REMOTE_CLIENTS.
+ kCommandSrcClientCmd,
+
+ // Typed in at the console or via a user key-bind. Generally unrestricted, although
+ // the client will throttle commands sent to the server this way to 16 per second.
+ kCommandSrcUserInput,
+
+ // Came in over a net connection as a clc_stringcmd
+ // host_client will be valid during this state.
+ //
+ // Restricted to FCVAR_GAMEDLL commands (but not convars) and special non-ConCommand
+ // server commands hardcoded into gameplay code (e.g. "joingame")
+ kCommandSrcNetClient,
+
+ // Received from the server as the client
+ //
+ // Restricted to commands with FCVAR_SERVER_CAN_EXECUTE
+ kCommandSrcNetServer,
+
+ // Being played back from a demo file
+ //
+ // Not currently restricted by convar flag, but some commands manually ignore calls
+ // from this source. FIXME: Should be heavily restricted as demo commands can come
+ // from untrusted sources.
+ kCommandSrcDemoFile,
+
+ // Invalid value used when cleared
+ kCommandSrcInvalid = -1
+};
- extern CEngine* g_pEngine;
+typedef ECommandTarget_t (*Cbuf_GetCurrentPlayerType)();
+extern Cbuf_GetCurrentPlayerType Cbuf_GetCurrentPlayer;
- extern void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
+typedef void (*Cbuf_AddTextType)(ECommandTarget_t eTarget, const char* text, cmd_source_t source);
+extern Cbuf_AddTextType Cbuf_AddText;
+
+typedef void (*Cbuf_ExecuteType)();
+extern Cbuf_ExecuteType Cbuf_Execute;
+
+extern bool (*CCommand__Tokenize)(CCommand& self, const char* pCommandString, cmd_source_t commandSource);
+
+// CEngine
+
+enum EngineQuitState
+{
+ QUIT_NOTQUITTING = 0,
+ QUIT_TODESKTOP,
+ QUIT_RESTART
+};
+
+enum class EngineState_t
+{
+ DLL_INACTIVE = 0, // no dll
+ DLL_ACTIVE, // engine is focused
+ DLL_CLOSE, // closing down dll
+ DLL_RESTART, // engine is shutting down but will restart right away
+ DLL_PAUSED, // engine is paused, can become active from this state
+};
+
+class CEngine
+{
+ public:
+ virtual void unknown() = 0; // unsure if this is where
+ virtual bool Load(bool dedicated, const char* baseDir) = 0;
+ virtual void Unload() = 0;
+ virtual void SetNextState(EngineState_t iNextState) = 0;
+ virtual EngineState_t GetState() = 0;
+ virtual void Frame() = 0;
+ virtual double GetFrameTime() = 0;
+ virtual float GetCurTime() = 0;
+
+ EngineQuitState m_nQuitting;
+ EngineState_t m_nDllState;
+ EngineState_t m_nNextDllState;
+ double m_flCurrentTime;
+ float m_flFrameTime;
+ double m_flPreviousTime;
+ float m_flFilteredTime;
+ float m_flMinFrameTime; // Expected duration of a frame, or zero if it is unlimited.
+};
+
+extern CEngine* g_pEngine;
+
+extern void (*CBaseClient__Disconnect)(void* self, uint32_t unknownButAlways1, const char* reason, ...);
#pragma once
- typedef enum
- {
- NA_NULL = 0,
- NA_LOOPBACK,
- NA_IP,
- } netadrtype_t;
+typedef enum
+{
+ NA_NULL = 0,
+ NA_LOOPBACK,
+ NA_IP,
+} netadrtype_t;
#pragma pack(push, 1)
- typedef struct netadr_s
- {
- netadrtype_t type;
- unsigned char ip[16]; // IPv6
- // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
- // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
- unsigned short port;
- } netadr_t;
+typedef struct netadr_s
+{
+ netadrtype_t type;
+ unsigned char ip[16]; // IPv6
+ // IPv4's 127.0.0.1 is [::ffff:127.0.0.1], that is:
+ // 00 00 00 00 00 00 00 00 00 00 FF FF 7F 00 00 01
+ unsigned short port;
+} netadr_t;
#pragma pack(pop)
#pragma pack(push, 1)
- typedef struct netpacket_s
- {
- netadr_t adr; // sender address
- // int source; // received source
- char unk[10];
- double received_time;
- unsigned char* data; // pointer to raw packet data
- void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- char unk2[16];
- int size;
-
- // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
- // int size; // size in bytes
- // int wiresize; // size in bytes before decompression
- // bool stream; // was send as stream
- // struct netpacket_s* pNext; // for internal use, should be NULL in public
- } netpacket_t;
+typedef struct netpacket_s
+{
+ netadr_t adr; // sender address
+ // int source; // received source
+ char unk[10];
+ double received_time;
+ unsigned char* data; // pointer to raw packet data
+ void* message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ char unk2[16];
+ int size;
+
+ // bf_read message; // easy bitbuf data access // 'inpacket.message' etc etc (pointer)
+ // int size; // size in bytes
+ // int wiresize; // size in bytes before decompression
+ // bool stream; // was send as stream
+ // struct netpacket_s* pNext; // for internal use, should be NULL in public
+} netpacket_t;
#pragma pack(pop)
- // #56169 $DB69 PData size
- // #512 $200 Trailing data
- // #100 $64 Safety buffer
- const int PERSISTENCE_MAX_SIZE = 0xDDCD;
-
- // note: NOT_READY and READY are the only entries we have here that are defined by the vanilla game
- // entries after this are custom and used to determine the source of persistence, e.g. whether it is local or remote
- enum class ePersistenceReady : char
- {
- NOT_READY,
- READY = 3,
- READY_INSECURE = 3,
- READY_REMOTE
- };
-
- enum class eSignonState : int
- {
- NONE = 0, // no state yet; about to connect
- CHALLENGE = 1, // client challenging server; all OOB packets
- CONNECTED = 2, // client is connected to server; netchans ready
- NEW = 3, // just got serverinfo and string tables
- PRESPAWN = 4, // received signon buffers
- GETTINGDATA = 5, // respawn-defined signonstate, assumedly this is for persistence
- SPAWN = 6, // ready to receive entity packets
- FIRSTSNAP = 7, // another respawn-defined one
- FULL = 8, // we are fully connected; first non-delta packet received
- CHANGELEVEL = 9, // server is changing level; please wait
- };
-
- // clang-format off
- OFFSET_STRUCT(CBaseClient)
- {
- STRUCT_SIZE(0x2D728)
- FIELD(0x16, char m_Name[64])
- FIELD(0x258, KeyValues* m_ConVars)
- FIELD(0x2A0, eSignonState m_Signon)
- FIELD(0x358, char m_ClanTag[16])
- FIELD(0x484, bool m_bFakePlayer)
- FIELD(0x4A0, ePersistenceReady m_iPersistenceReady)
- FIELD(0x4FA, char m_PersistenceBuffer[PERSISTENCE_MAX_SIZE])
- FIELD(0xF500, char m_UID[32])
- };
- // clang-format on
-
- extern CBaseClient* g_pClientArray;
-
- enum server_state_t
- {
- ss_dead = 0, // Dead
- ss_loading, // Spawning
- ss_active, // Running
- ss_paused, // Running, but paused
- };
-
- extern server_state_t* g_pServerState;
-
- extern char* g_pModName;
-
- // clang-format off
- OFFSET_STRUCT(CGlobalVars)
- {
- FIELD(0x0,
- // Absolute time (per frame still - Use Plat_FloatTime() for a high precision real time
- // perf clock, but not that it doesn't obey host_timescale/host_framerate)
- double m_flRealTime);
-
- FIELDS(0x8,
- // Absolute frame counter - continues to increase even if game is paused
- int m_nFrameCount;
+// #56169 $DB69 PData size
+// #512 $200 Trailing data
+// #100 $64 Safety buffer
+const int PERSISTENCE_MAX_SIZE = 0xDDCD;
+
+// note: NOT_READY and READY are the only entries we have here that are defined by the vanilla game
+// entries after this are custom and used to determine the source of persistence, e.g. whether it is local or remote
+enum class ePersistenceReady : char
+{
+ NOT_READY,
+ READY = 3,
+ READY_INSECURE = 3,
+ READY_REMOTE
+};
+
+enum class eSignonState : int
+{
+ NONE = 0, // no state yet; about to connect
+ CHALLENGE = 1, // client challenging server; all OOB packets
+ CONNECTED = 2, // client is connected to server; netchans ready
+ NEW = 3, // just got serverinfo and string tables
+ PRESPAWN = 4, // received signon buffers
+ GETTINGDATA = 5, // respawn-defined signonstate, assumedly this is for persistence
+ SPAWN = 6, // ready to receive entity packets
+ FIRSTSNAP = 7, // another respawn-defined one
+ FULL = 8, // we are fully connected; first non-delta packet received
+ CHANGELEVEL = 9, // server is changing level; please wait
+};
+
+// clang-format off
+OFFSET_STRUCT(CBaseClient)
+{
+ STRUCT_SIZE(0x2D728)
+ FIELD(0x16, char m_Name[64])
+ FIELD(0x258, KeyValues* m_ConVars)
+ FIELD(0x2A0, eSignonState m_Signon)
+ FIELD(0x358, char m_ClanTag[16])
+ FIELD(0x484, bool m_bFakePlayer)
+ FIELD(0x4A0, ePersistenceReady m_iPersistenceReady)
+ FIELD(0x4FA, char m_PersistenceBuffer[PERSISTENCE_MAX_SIZE])
+ FIELD(0xF500, char m_UID[32])
+};
+// clang-format on
+
+extern CBaseClient* g_pClientArray;
+
+enum server_state_t
+{
+ ss_dead = 0, // Dead
+ ss_loading, // Spawning
+ ss_active, // Running
+ ss_paused, // Running, but paused
+};
+
+extern server_state_t* g_pServerState;
+
+extern char* g_pModName;
+
+// clang-format off
+OFFSET_STRUCT(CGlobalVars)
+{
+ FIELD(0x0,
+ // Absolute time (per frame still - Use Plat_FloatTime() for a high precision real time
+ // perf clock, but not that it doesn't obey host_timescale/host_framerate)
+ double m_flRealTime);
+
+ FIELDS(0x8,
+ // Absolute frame counter - continues to increase even if game is paused
+ int m_nFrameCount;
- // Non-paused frametime
- float m_flAbsoluteFrameTime;
+ // Non-paused frametime
+ float m_flAbsoluteFrameTime;
- // Current time
- //
- // On the client, this (along with tickcount) takes a different meaning based on what
- // piece of code you're in:
- //
- // - While receiving network packets (like in PreDataUpdate/PostDataUpdate and proxies),
- // this is set to the SERVER TICKCOUNT for that packet. There is no interval between
- // the server ticks.
- // [server_current_Tick * tick_interval]
- //
- // - While rendering, this is the exact client clock
- // [client_current_tick * tick_interval + interpolation_amount]
- //
- // - During prediction, this is based on the client's current tick:
- // [client_current_tick * tick_interval]
- float m_flCurTime;
- )
-
- FIELDS(0x30,
- // Time spent on last server or client frame (has nothing to do with think intervals)
- float m_flFrameTime;
-
- // current maxplayers setting
- int m_nMaxClients;
- )
-
- FIELDS(0x3C,
- // Simulation ticks - does not increase when game is paused
- uint32_t m_nTickCount; // this is weird and doesn't seem to increase once per frame?
-
- // Simulation tick interval
- float m_flTickInterval;
- )
-
- FIELDS(0x60,
- const char* m_pMapName;
- int m_nMapVersion;
- )
-
- //FIELD(0x98, double m_flRealTime); // again?
- };
- // clang-format on
-
- extern CGlobalVars* g_pGlobals;
-} // namespace R2
+ // Current time
+ //
+ // On the client, this (along with tickcount) takes a different meaning based on what
+ // piece of code you're in:
+ //
+ // - While receiving network packets (like in PreDataUpdate/PostDataUpdate and proxies),
+ // this is set to the SERVER TICKCOUNT for that packet. There is no interval between
+ // the server ticks.
+ // [server_current_Tick * tick_interval]
+ //
+ // - While rendering, this is the exact client clock
+ // [client_current_tick * tick_interval + interpolation_amount]
+ //
+ // - During prediction, this is based on the client's current tick:
+ // [client_current_tick * tick_interval]
+ float m_flCurTime;
+ )
+
+ FIELDS(0x30,
+ // Time spent on last server or client frame (has nothing to do with think intervals)
+ float m_flFrameTime;
+
+ // current maxplayers setting
+ int m_nMaxClients;
+ )
+
+ FIELDS(0x3C,
+ // Simulation ticks - does not increase when game is paused
+ uint32_t m_nTickCount; // this is weird and doesn't seem to increase once per frame?
+
+ // Simulation tick interval
+ float m_flTickInterval;
+ )
+
+ FIELDS(0x60,
+ const char* m_pMapName;
+ int m_nMapVersion;
+ )
+
+ //FIELD(0x98, double m_flRealTime); // again?
+};
+// clang-format on
+
+extern CGlobalVars* g_pGlobals;
diff --git a/NorthstarDLL/engine/runframe.cpp b/NorthstarDLL/engine/runframe.cpp
index 40a619bb..ddfd9253 100644
--- a/NorthstarDLL/engine/runframe.cpp
+++ b/NorthstarDLL/engine/runframe.cpp
@@ -7,7 +7,7 @@ AUTOHOOK_INIT()
// clang-format off
AUTOHOOK(CEngine__Frame, engine.dll + 0x1C8650,
-void, __fastcall, (R2::CEngine* self))
+void, __fastcall, (CEngine* self))
// clang-format on
{
CEngine__Frame(self);