/*
-A server can allways be started, even if the system started out as a client
+A server can always be started, even if the system started out as a client
to a remote system.
A client can NOT be started if the system started as a dedicated server.
quakeparms_t host_parms;
qboolean host_initialized; // true if into command execution
+qboolean hostloopactive = 0; // LordHavoc: used to turn Host_Error into Sys_Error if Host_Frame has not yet run
double host_frametime;
double host_realframetime; // LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
This shuts down both the client and server
================
*/
-char hosterrorstring[1024];
+char hosterrorstring[4096];
+extern qboolean hostloopactive;
void Host_Error (char *error, ...)
{
va_list argptr;
static qboolean inerror = false;
-
+
+ // LordHavoc: if host_frame loop has not been run yet, do a Sys_Error instead
+ if (!hostloopactive)
+ {
+ char string[4096];
+ va_start (argptr,error);
+ vsprintf (string,error,argptr);
+ va_end (argptr);
+ Sys_Error ("%s", string);
+ }
+
if (inerror)
{
- char string[1024];
+ char string[4096];
va_start (argptr,error);
vsprintf (string,error,argptr);
va_end (argptr);
// this will set the body to a dead frame, among other things
saveSelf = pr_global_struct->self;
pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
- PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
+ PR_ExecuteProgram (pr_global_struct->ClientDisconnect, "QC function ClientDisconnect is missing");
pr_global_struct->self = saveSelf;
}
}
host_frametime *= slowmo.value;
+ cl.frametime = host_frametime;
return true;
}
==================
*/
-double frametimetotal = 0, lastservertime = 0;
void Host_ServerFrame (void)
{
+ static double frametimetotal = 0, lastservertime = 0;
frametimetotal += host_frametime;
// LordHavoc: cap server at sys_ticrate in listen games
if (!isDedicated && svs.maxclients > 1 && ((realtime - lastservertime) < sys_ticrate.value))
return;
// run the world state
- sv_frametime = pr_global_struct->frametime = frametimetotal;
+ sv.frametime = pr_global_struct->frametime = frametimetotal;
frametimetotal = 0;
+ lastservertime = realtime;
// pr_global_struct->frametime = host_frametime;
// set the time and clear the general datagram
if (setjmp (host_abortserver) )
return; // something bad happened, or the server disconnected
+ hostloopactive = 1;
// keep the random time dependent
rand ();
// fetch results from server
if (cls.state == ca_connected)
- {
CL_ReadFromServer ();
- }
// update video
if (host_speeds.value)
if (host_speeds.value)
{
- pass1 = (time1 - time3)*1000;
+ pass1 = (time1 - time3)*1000000;
time3 = Sys_FloatTime ();
- pass2 = (time2 - time1)*1000;
- pass3 = (time3 - time2)*1000;
- Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
+ pass2 = (time2 - time1)*1000000;
+ pass3 = (time3 - time2)*1000000;
+ Con_Printf ("%6ius total %6ius server %6ius gfx %6ius snd\n",
pass1+pass2+pass3, pass1, pass2, pass3);
}
*/
void Host_Init ()
{
+ int i;
/*
if (standard_quake)
minimum_memory = MINIMUM_MEMORY;
Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms.memsize / (float)0x100000);
*/
+ host_parms.memsize = DEFAULTMEM * 1024 * 1024;
+
+ i = COM_CheckParm("-mem");
+ if (i)
+ host_parms.memsize = (int) (atof(com_argv[i+1]) * 1024 * 1024);
+
+ i = COM_CheckParm("-winmem");
+ if (i)
+ host_parms.memsize = (int) (atof(com_argv[i+1]) * 1024 * 1024);
+
+ i = COM_CheckParm("-heapsize");
+ if (i)
+ host_parms.memsize = (int) (atof(com_argv[i+1]) * 1024);
+
+ host_parms.membase = qmalloc(host_parms.memsize);
+ if (!host_parms.membase)
+ Sys_Error("Not enough memory free, close some programs and try again, or free disk space\n");
+
com_argc = host_parms.argc;
com_argv = host_parms.argv;
if (cls.state != ca_dedicated)
{
- R_ShutdownModules();
+ R_Modules_Shutdown();
VID_Shutdown();
}
}