From 244084ad32c72bc7e7023f9b16bb3e95a5986011 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sat, 13 May 2006 21:11:06 +0000 Subject: [PATCH] fixes to win32 dedicated server, fix to "-port" being parsed too soon git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2276 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/sv_main.c | 40 +++++++++++++++++++------------------- engine/server/sv_sys_win.c | 28 +++++++++++++++++++++----- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 1550951b4..29d460be9 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -3097,7 +3097,7 @@ extern void Log_Init (void); void SV_InitLocal (void) { - int i; + int i, p; extern cvar_t sv_maxvelocity; extern cvar_t sv_gravity; extern cvar_t sv_aim; @@ -3364,6 +3364,25 @@ void SV_InitLocal (void) svs.log[1].maxsize = sizeof(svs.log_buf[1]); svs.log[1].cursize = 0; svs.log[1].allowoverflow = true; + + // parse params for cvars + p = COM_CheckParm ("-port"); + if (!p) + p = COM_CheckParm ("-svport"); + if (p && p < com_argc) + { + int port = atoi(com_argv[p+1]); + if (!port) + port = PORT_SERVER; + Cvar_SetValue(&sv_port, port); +#ifdef IPPROTO_IPV6 + Cvar_SetValue(&sv_port_ipv6, port); +#endif +#ifdef USEIPX + Cvar_SetValue(&sv_port_ipx, port); +#endif + } + } @@ -3834,8 +3853,6 @@ SV_Init void SV_Demo_Init(void); void SV_Init (quakeparms_t *parms) { - int p; - #ifndef SERVERONLY if (isDedicated) #endif @@ -3863,23 +3880,6 @@ void SV_Init (quakeparms_t *parms) Mod_Init (); } - p = COM_CheckParm ("-port"); - if (!p) - p = COM_CheckParm ("-svport"); - if (p && p < com_argc) - { - int port = atoi(com_argv[p+1]); - if (!port) - port = PORT_SERVER; - Cvar_SetValue(&sv_port, port); -#ifdef IPPROTO_IPV6 - Cvar_SetValue(&sv_port_ipv6, port); -#endif -#ifdef USEIPX - Cvar_SetValue(&sv_port_ipx, port); -#endif - } - PR_Init (); SV_InitNet (); diff --git a/engine/server/sv_sys_win.c b/engine/server/sv_sys_win.c index f3c098d85..0495a1c57 100644 --- a/engine/server/sv_sys_win.c +++ b/engine/server/sv_sys_win.c @@ -289,8 +289,8 @@ void Sys_Error (const char *error, ...) va_list argptr; char text[1024]; double end; - LPWSTR *szArglist; - int nArgs; + STARTUPINFO startupinfo; + PROCESS_INFORMATION processinfo; va_start (argptr,error); vsnprintf (text,sizeof(text)-1, error,argptr); @@ -319,9 +319,12 @@ void Sys_Error (const char *error, ...) end = Sys_DoubleTime() + 10; while(Sys_DoubleTime() < end) { + Sleep(500); // don't burn up CPU with polling if (_kbhit()) Sys_Quit(); } + + Sys_Printf("\nLoading new instance of FTE...\n\n\n"); PR_Deinit(); //this takes a bit more mem Rank_Flush(); #ifndef MINGW @@ -330,9 +333,24 @@ void Sys_Error (const char *error, ...) VirtualFree (host_parms.membase, 0, MEM_RELEASE); // free(host_parms.membase); //get rid of the mem. We don't need it now. // system("dqwsv.exe"); //spawn a new server to take over. This way, if debugging, then any key will quit, otherwise the server will just spawn a new one. - GetModuleFileName(NULL, text, sizeof(text)); - szArglist = CommandLineToArgV(GetCommandLine(), &nArgs); - spawnv(P_NOWAIT|P_OVERLAY, text, text, szArglist); + + memset(&startupinfo, 0, sizeof(startupinfo)); + memset(&processinfo, 0, sizeof(processinfo)); + + CreateProcess(NULL, + GetCommandLine(), + NULL, + NULL, + false, + 0, + NULL, + NULL, + &startupinfo, + &processinfo); + + CloseHandle(processinfo.hProcess); + CloseHandle(processinfo.hThread); + Sys_Quit (); }