2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Merge pull request #409 from dreamstalker/fixes201703192

Make cycle more close to original.
This commit is contained in:
Lev 2017-03-19 22:41:16 +05:00 committed by GitHub
commit e92df0e3f4
2 changed files with 42 additions and 47 deletions

View File

@ -80,19 +80,21 @@ char *UTIL_GetBaseDir()
int RunServer() int RunServer()
{ {
#ifdef _WIN32 #ifdef _WIN32
// TODO: finish me! if (g_bVGui)
/*if (g_bVGui)
{ {
vgui::ivgui()->SetSleep(0); // TODO: finish VGUI
}*/ //vgui::ivgui()->SetSleep(0);
}
#endif #endif
int iret = 0;
while (true) while (true)
{ {
if (gbAppHasBeenTerminated) if (gbAppHasBeenTerminated)
break; return iret;
CreateInterfaceFn engineFactory = Sys_GetFactory(g_pEngineModule); CreateInterfaceFn engineFactory = Sys_GetFactory(g_pEngineModule);
RunVGUIFrame(); RunVGUIFrame();
if (engineFactory) if (engineFactory)
@ -113,21 +115,22 @@ int RunServer()
} }
#endif #endif
} }
RunVGUIFrame(); RunVGUIFrame();
if (!engineAPI) if (!engineAPI)
return -1; return -1;
if (!engineAPI->Init(UTIL_GetBaseDir(), (char *)CommandLine()->GetCmdLine(), Sys_GetFactoryThis(), g_FilesystemFactoryFn)) { if (!engineAPI->Init(UTIL_GetBaseDir(), (char *)CommandLine()->GetCmdLine(), Sys_GetFactoryThis(), g_FilesystemFactoryFn))
return -1; return -1;
}
RunVGUIFrame(); RunVGUIFrame();
#ifdef _WIN32 #ifdef _WIN32
// TODO: finish me! if (g_bVGui)
/*if (g_bVGui)
{ {
g_pFileSystemInterface->AddSearchPath("platform", "PLATFORM"); // TODO: finish VGUI
/*g_pFileSystemInterface->AddSearchPath("platform", "PLATFORM");
// find our configuration directory // find our configuration directory
char szConfigDir[512]; char szConfigDir[512];
@ -141,56 +144,57 @@ int RunServer()
{ {
// we're not running steam, so just put the config dir under the platform // we're not running steam, so just put the config dir under the platform
strncpy(szConfigDir, "platform/config", sizeof(szConfigDir)); strncpy(szConfigDir, "platform/config", sizeof(szConfigDir));
} }*/
}*/ }
#endif // _WIN32 #endif // _WIN32
RunVGUIFrame(); RunVGUIFrame();
if (gpszCvars) { if (gpszCvars)
engineAPI->AddConsoleText(gpszCvars); engineAPI->AddConsoleText(gpszCvars);
}
VGUIFinishedConfig(); VGUIFinishedConfig();
RunVGUIFrame(); RunVGUIFrame();
bool bDone = false; while (true)
while (!bDone)
{ {
#ifdef _WIN32
if (g_bVGui)
RunVGUIFrame();
#endif // _WIN32
// Running really fast, yield some time to other apps // Running really fast, yield some time to other apps
sys->Sleep(1); sys->Sleep(1);
#ifdef _WIN32 #ifdef _WIN32
MSG msg; if (!g_bVGui)
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{ {
if (!GetMessage(&msg, NULL, 0, 0)) bool bDone = false;
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{ {
bDone = true; if (!GetMessage(&msg, NULL, 0, 0))
break; {
bDone = true;
break;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
} }
TranslateMessage(&msg); if (gbAppHasBeenTerminated || bDone)
DispatchMessage(&msg); break;
} }
if (gbAppHasBeenTerminated) if (!g_bVGui)
break;
if (g_bVGui)
{
RunVGUIFrame();
}
else
#endif // _WIN32 #endif // _WIN32
{ {
ProcessConsoleInput(); ProcessConsoleInput();
} }
if (!engineAPI->RunFrame()) if (!engineAPI->RunFrame())
{ break;
bDone = true;
}
sys->UpdateStatus(0 /* don't force */); sys->UpdateStatus(0 /* don't force */);
} }
@ -206,13 +210,11 @@ int RunServer()
console.ShutDown(); console.ShutDown();
} }
auto iret = engineAPI->Shutdown(); iret = engineAPI->Shutdown();
Sys_UnloadModule(g_pEngineModule); Sys_UnloadModule(g_pEngineModule);
VGUIFinishedConfig(); VGUIFinishedConfig();
if (iret == DLL_CLOSE) if (iret == DLL_CLOSE)
return iret; return iret;
} }
return 0;
} }

View File

@ -61,14 +61,7 @@ void Sleep_Select(int msec)
void Sleep_Net(int msec) void Sleep_Net(int msec)
{ {
if (NET_Sleep_Timeout) NET_Sleep_Timeout();
{
NET_Sleep_Timeout();
return;
}
// NET_Sleep_Timeout isn't hooked yet, fallback to the old method
Sleep_Old(msec);
} }
// linux runs on a 100Hz scheduling clock, so the minimum latency from // linux runs on a 100Hz scheduling clock, so the minimum latency from
@ -275,11 +268,11 @@ int main(int argc, char *argv[])
Sys_Sleep = Sleep_Select; Sys_Sleep = Sleep_Select;
break; break;
case 3: case 3:
Sys_Sleep = Sleep_Net;
// we Sys_GetProcAddress NET_Sleep() from // we Sys_GetProcAddress NET_Sleep() from
//engine_i486.so later in this function //engine_i486.so later in this function
NET_Sleep_Timeout = (NET_Sleep_t)Sys_GetProcAddress(g_pEngineModule, "NET_Sleep_Timeout"); NET_Sleep_Timeout = (NET_Sleep_t)Sys_GetProcAddress(g_pEngineModule, "NET_Sleep_Timeout");
if (NET_Sleep_Timeout != nullptr)
Sys_Sleep = Sleep_Net;
break; break;
// just in case // just in case
default: default: