aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest
diff options
context:
space:
mode:
authorHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2021-12-28 12:56:08 +0300
committerHappyDOGE <28511119+HappyDOGE@users.noreply.github.com>2021-12-28 12:56:08 +0300
commitbb93442db8b1e450adf08a8305335020c436d358 (patch)
tree1b214ce4a3b77939b44cc91d223bb91f8502b793 /NorthstarDedicatedTest
parent1c1b18e1b7887a76eb56bd33fd983fdcfd171a08 (diff)
downloadNorthstarLauncher-bb93442db8b1e450adf08a8305335020c436d358.tar.gz
NorthstarLauncher-bb93442db8b1e450adf08a8305335020c436d358.zip
dedicated console command input
Diffstat (limited to 'NorthstarDedicatedTest')
-rw-r--r--NorthstarDedicatedTest/dedicated.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/NorthstarDedicatedTest/dedicated.cpp b/NorthstarDedicatedTest/dedicated.cpp
index 83a9950a..26dcc9ae 100644
--- a/NorthstarDedicatedTest/dedicated.cpp
+++ b/NorthstarDedicatedTest/dedicated.cpp
@@ -76,6 +76,32 @@ bool IsGameActiveWindowHook()
return true;
}
+HANDLE consoleInputThreadHandle = NULL;
+
+DWORD WINAPI ConsoleInputThread(PVOID pThreadParameter)
+{
+ while (!g_pEngine || !g_pHostState || g_pHostState->m_iCurrentState != HostState_t::HS_RUN)
+ Sleep(1000);
+
+ // Bind stdin to receive console input.
+ FILE* fp = nullptr;
+ freopen_s(&fp, "CONIN$", "r", stdin);
+
+ spdlog::info("Ready to receive console commands.");
+
+ {
+ // Process console input
+ std::string input;
+ while (g_pEngine && g_pEngine->m_nQuitting == EngineQuitState::QUIT_NOTQUITTING && std::getline(std::cin, input))
+ {
+ input += "\n";
+ Cbuf_AddText(Cbuf_GetCurrentPlayer(), input.c_str(), cmd_source_t::kCommandSrcCode);
+ }
+ }
+
+ return 0;
+}
+
void InitialiseDedicated(HMODULE engineAddress)
{
if (!IsDedicated())
@@ -380,6 +406,9 @@ void InitialiseDedicated(HMODULE engineAddress)
CommandLine()->AppendParm("+host_preload_shaders", "0");
CommandLine()->AppendParm("+net_usesocketsforloopback", "1");
CommandLine()->AppendParm("+exec", "autoexec_ns_server");
+
+ // create console input thread
+ consoleInputThreadHandle = CreateThread(0, 0, ConsoleInputThread, 0, 0, NULL);
}
typedef void(*Tier0_InitOriginType)();