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
This commit is contained in:
TimeServ 2006-05-13 21:11:06 +00:00
parent 75af125d79
commit 244084ad32
2 changed files with 43 additions and 25 deletions

View File

@ -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 ();

View File

@ -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 ();
}