From 94acb826cb19cf3fb3dc79d2f619dd3586ea396d Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 14 Nov 2023 22:24:57 +0800 Subject: [PATCH] [server] Update main --- server/main.cpp | 33 ++++++++++++++++++++++++++++++++- server/main.h | 3 +++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/server/main.cpp b/server/main.cpp index 3b7b9d5..699ce72 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -5,7 +5,9 @@ CNetGame *pNetGame = NULL; CConsole *pConsole = NULL; CPlugins *pPlugins = NULL; -FILE *pLogFile; +FILE *pLogFile; +bool bQuitApp = false; +BOOL bGameModeFinished=FALSE; bool bLogQueries; int iMaxNpc = 0; @@ -260,6 +262,35 @@ int main (int argc, char** argv) pNetGame = new CNetGame(); pNetGame->Init(true); + // Start the rcon server + PCHAR szBindAddress = pConsole->GetStringVariable("rcon_bind"); + if (!szBindAddress || szBindAddress[0] == 0) + szBindAddress = pConsole->GetStringVariable("bind"); + if (!szBindAddress || szBindAddress[0] == 0) + szBindAddress = NULL; + + // While the app is running... + while (!bQuitApp) + { + pNetGame->Process(); + + if(TRUE == bGameModeFinished) { + pNetGame->ShutdownForGameModeRestart(); + bGameModeFinished = FALSE; + } + + if(sub_44E9D0() - unnamed_4 > iConnSeedTime) + { + unnamed_3 = rand(); + unnamed_4 = sub_44E9D0(); + } + + SLEEP(iSleep); + } + + delete pNetGame; + + delete pPlugins; delete pConsole; diff --git a/server/main.h b/server/main.h index d5630af..d73fccd 100644 --- a/server/main.h +++ b/server/main.h @@ -19,10 +19,13 @@ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN + #define SLEEP(x) { Sleep(x); } #include #include #else + #define SLEEP(x) { usleep(x * 1000); } + #ifndef stricmp #define stricmp strcasecmp #endif