aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-09-27 00:25:36 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-09-27 00:25:36 +0100
commit26d090e4ae6153d1f7b49f8776c2923345dd810f (patch)
treec1abdb12fe6b891819597c8bbf376d76b12fed86 /NorthstarDedicatedTest
parentda212ca9b7d2ab97f8baa531d31a91fd40d9c085 (diff)
downloadNorthstarLauncher-26d090e4ae6153d1f7b49f8776c2923345dd810f.tar.gz
NorthstarLauncher-26d090e4ae6153d1f7b49f8776c2923345dd810f.zip
read cmdline args from file, disable origin on dedi
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp28
-rw-r--r--NorthstarDedicatedTest/dedicated.h3
-rw-r--r--NorthstarDedicatedTest/dllmain.cpp1
-rw-r--r--NorthstarDedicatedTest/gameutils.h10
4 files changed, 32 insertions, 10 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp
index bcf2acc8..42ddb5e4 100644
--- a/NorthstarDedicatedTest/dedicated.cpp
+++ b/NorthstarDedicatedTest/dedicated.cpp
@@ -15,6 +15,7 @@ struct CDedicatedExports; // forward declare
typedef void (*DedicatedSys_PrintfType)(CDedicatedExports* dedicated, char* msg);
typedef void (*DedicatedRunServerType)(CDedicatedExports* dedicated);
+// would've liked to just do this as a class but have not been able to get it to work
struct CDedicatedExports
{
void* vtable; // because it's easier, we just set this to &this, since CDedicatedExports has no props we care about other than funcs
@@ -37,22 +38,21 @@ void RunServer(CDedicatedExports* dedicated)
{
Sys_Printf(dedicated, (char*)"CDedicatedExports::RunServer(): starting");
- HMODULE engine = GetModuleHandleA("engine.dll");
- CEngine__FrameType CEngine__Frame = (CEngine__FrameType)((char*)engine + 0x1C8650);
- CHostState__InitType CHostState__Init = (CHostState__InitType)((char*)engine + 0x16E110);
-
// init hoststate, if we don't do this, we get a crash later on
+ CHostState__InitType CHostState__Init = (CHostState__InitType)((char*)GetModuleHandleA("engine.dll") + 0x16E110);
CHostState__Init(g_pHostState);
// set host state to allow us to enter CHostState::FrameUpdate, with the state HS_NEW_GAME
g_pHostState->m_iNextState = HostState_t::HS_NEW_GAME;
strncpy(g_pHostState->m_levelName, CommandLine()->ParmValue("+map", "mp_lobby"), sizeof(g_pHostState->m_levelName)); // set map to load into
- while (true)
+ spdlog::info(CommandLine()->GetCmdLine());
+
+ while (g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING)
{
- CEngine__Frame(g_pEngine);
+ g_pEngine->Frame();
- spdlog::info("CEngine::Frame() on map {} took {}ms", g_pHostState->m_levelName, g_pEngine->m_flFrameTime);
+ spdlog::info("g_pEngine->Frame() on map {} took {}ms", g_pHostState->m_levelName, g_pEngine->GetFrameTime());
Sleep(50);
}
}
@@ -233,4 +233,18 @@ void InitialiseDedicated(HMODULE engineAddress)
CommandLine()->AppendParm("-nomenuvid", 0);
CommandLine()->AppendParm("-nosound", 0);
CommandLine()->AppendParm("+host_preload_shaders", "0");
+}
+
+typedef void(*Tier0_InitOriginType)();
+Tier0_InitOriginType Tier0_InitOrigin;
+void Tier0_InitOriginHook()
+{
+ if (!IsDedicated())
+ Tier0_InitOrigin();
+}
+
+void InitialiseDedicatedOrigin(HMODULE baseAddress)
+{
+ HookEnabler hook;
+ ENABLER_CREATEHOOK(hook, GetProcAddress(GetModuleHandleA("tier0.dll"), "Tier0_InitOrigin"), &Tier0_InitOriginHook, reinterpret_cast<LPVOID*>(&Tier0_InitOrigin));
} \ No newline at end of file
diff --git a/NorthstarDedicatedTest/dedicated.h b/NorthstarDedicatedTest/dedicated.h
index 96bb96c4..ded6af70 100644
--- a/NorthstarDedicatedTest/dedicated.h
+++ b/NorthstarDedicatedTest/dedicated.h
@@ -2,4 +2,5 @@
bool IsDedicated();
-void InitialiseDedicated(HMODULE moduleAddress); \ No newline at end of file
+void InitialiseDedicated(HMODULE moduleAddress);
+void InitialiseDedicatedOrigin(HMODULE baseAddress); \ No newline at end of file
diff --git a/NorthstarDedicatedTest/dllmain.cpp b/NorthstarDedicatedTest/dllmain.cpp
index b801b281..33b8c920 100644
--- a/NorthstarDedicatedTest/dllmain.cpp
+++ b/NorthstarDedicatedTest/dllmain.cpp
@@ -68,6 +68,7 @@ void InitialiseNorthstar()
// dedi patches
{
AddDllLoadCallback("engine.dll", InitialiseDedicated);
+ AddDllLoadCallback("launcher.dll", InitialiseDedicatedOrigin);
AddDllLoadCallback("materialsystem_dx11.dll", InitialiseDedicatedMaterialSystem);
}
diff --git a/NorthstarDedicatedTest/gameutils.h b/NorthstarDedicatedTest/gameutils.h
index 786c5e99..f63d4c81 100644
--- a/NorthstarDedicatedTest/gameutils.h
+++ b/NorthstarDedicatedTest/gameutils.h
@@ -144,10 +144,16 @@ enum EngineState_t
DLL_PAUSED, // engine is paused, can become active from this state
};
-struct CEngine
+class CEngine
{
public:
- void* vtable;
+ virtual bool Load(bool dedicated, const char* baseDir) {}
+ virtual void Unload() {}
+ virtual void SetNextState(EngineState_t iNextState) {}
+ virtual EngineState_t GetState() {}
+ virtual void Frame() {}
+ virtual float GetFrameTime() {}
+ virtual float GetCurTime() {}
EngineQuitState m_nQuitting;
EngineState_t m_nDllState;