]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host.c
you can now (try to) play in maps you don't have, and models you don't have are shown...
[xonotic/darkplaces.git] / host.c
diff --git a/host.c b/host.c
index 28ff3f1d1bff7bcd16d0ccc91571789f31de4c73..2816a121cf18b9039defe75d8b7dabda50eec4c8 100644 (file)
--- a/host.c
+++ b/host.c
@@ -19,8 +19,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 // host.c -- coordinates spawning and killing of local servers
 
-#include "quakedef.h"
 #include <time.h>
+#include "quakedef.h"
+#include "cl_video.h"
 
 /*
 
@@ -33,8 +34,6 @@ Memory is cleared / released when a server or client begins, not when they end.
 
 */
 
-quakeparms_t host_parms;
-
 qboolean       host_initialized;               // true if into command execution
 qboolean       host_loopactive = false;        // LordHavoc: used to turn Host_Error into Sys_Error if starting up or shutting down
 qboolean       host_shuttingdown = false;      // LordHavoc: set when quit is executed
@@ -57,6 +56,8 @@ cvar_t        slowmo = {0, "slowmo", "1.0"};                                  // LordHavoc: framerate independent sl
 cvar_t host_minfps = {CVAR_SAVE, "host_minfps", "10"};         // LordHavoc: game logic lower cap on framerate (if framerate is below this is, it pretends it is this, so game logic will run normally)
 cvar_t host_maxfps = {CVAR_SAVE, "host_maxfps", "1000"};               // LordHavoc: framerate upper cap
 
+cvar_t sv_echobprint = {CVAR_SAVE, "sv_echobprint", "1"};      // print broadcast messages in dedicated mode
+
 cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
 cvar_t serverprofile = {0, "serverprofile","0"};
 
@@ -142,14 +143,14 @@ void Host_Error (char *error, ...)
                Sys_Error ("Host_Error: recursively entered (original error was: %s    new error is: %s)", hosterrorstring, string);
        }
        inerror = true;
-       
-       SCR_EndLoadingPlaque ();                // reenable screen updates
 
        va_start (argptr,error);
        vsprintf (hosterrorstring,error,argptr);
        va_end (argptr);
        Con_Printf ("Host_Error: %s\n",hosterrorstring);
-       
+
+       PR_Crash();
+
        if (sv.active)
                Host_ShutdownServer (false);
 
@@ -202,8 +203,8 @@ void        Host_FindMaxClients (void)
                        svs.maxclients = 8;
        }
 
-       // BloodBath doesn't support single player games
-       if (gamemode == GAME_BLOODBATH && svs.maxclients < 4)
+       // Transfusion doesn't support single player games
+       if (gamemode == GAME_TRANSFUSION && svs.maxclients < 4)
                svs.maxclients = 4;
 
        if (svs.maxclients < 1)
@@ -242,6 +243,8 @@ void Host_InitLocal (void)
        Cvar_RegisterVariable (&host_minfps);
        Cvar_RegisterVariable (&host_maxfps);
 
+       Cvar_RegisterVariable (&sv_echobprint);
+
        Cvar_RegisterVariable (&sys_ticrate);
        Cvar_RegisterVariable (&serverprofile);
 
@@ -342,6 +345,9 @@ void SV_BroadcastPrintf (char *fmt, ...)
                        MSG_WriteByte (&svs.clients[i].message, svc_print);
                        MSG_WriteString (&svs.clients[i].message, string);
                }
+
+       if (sv_echobprint.integer && cls.state == ca_dedicated)
+               Sys_Printf ("%s", string);
 }
 
 /*
@@ -359,7 +365,7 @@ void Host_ClientCommands (char *fmt, ...)
        va_start (argptr,fmt);
        vsprintf (string, fmt,argptr);
        va_end (argptr);
-       
+
        MSG_WriteByte (&host_client->message, svc_stufftext);
        MSG_WriteString (&host_client->message, string);
 }
@@ -445,6 +451,9 @@ void Host_ShutdownServer(qboolean crash)
        if (!sv.active)
                return;
 
+       // print out where the crash happened, if it was caused by QC
+       PR_Crash();
+
        sv.active = false;
 
 // stop all client sounds immediately
@@ -549,8 +558,9 @@ qboolean Host_FilterTime (double time)
        }
        else if (!cls.timedemo)
        {
+               // default to sys_ticrate (server framerate - presumably low) unless we're the active window and either connected to a server or playing a video
                timecap = sys_ticrate.value;
-               if (cls.state == ca_connected)
+               if (vid_activewindow && (cls.state == ca_connected || cl_videoplaying))
                        timecap = 1.0 / host_maxfps.value;
 
                if ((realtime - oldrealtime) < timecap)
@@ -571,11 +581,7 @@ qboolean Host_FilterTime (double time)
        if (host_framerate.value > 0)
                host_frametime = host_framerate.value;
        else if (cl_avidemo.value >= 0.1f)
-       {
-               // don't allow really short frames
-               //if (host_frametime > (1.0 / cl_avidemo.value))
-                       host_frametime = (1.0 / cl_avidemo.value);
-       }
+               host_frametime = (1.0 / cl_avidemo.value);
        else
        {
                // don't allow really short frames
@@ -624,13 +630,12 @@ void Host_ServerFrame (void)
        if (cls.state != ca_dedicated && svs.maxclients > 1 && ((realtime - lastservertime) < sys_ticrate.value))
                return;
 // run the world state
-       if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
+       if (!sv.paused && (svs.maxclients > 1 || (key_dest == key_game && !key_consoleactive)))
                sv.frametime = pr_global_struct->frametime = frametimetotal;
        else
                sv.frametime = 0;
        frametimetotal = 0;
        lastservertime = realtime;
-//     pr_global_struct->frametime = host_frametime;
 
 // set the time and clear the general datagram
        SV_ClearDatagram ();
@@ -643,7 +648,7 @@ void Host_ServerFrame (void)
 
 // move things around and think
 // always pause in single player if in console or menus
-       if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
+       if (sv.frametime)
                SV_Physics ();
 
 // send all messages to the clients
@@ -723,6 +728,8 @@ void _Host_Frame (float time)
 
        ui_update();
 
+       CL_VideoFrame();
+
 // update video
        if (host_speeds.integer)
                time1 = Sys_DoubleTime ();
@@ -810,8 +817,6 @@ void Host_Init (void)
        // LordHavoc: quake never seeded the random number generator before... heh
        srand(time(NULL));
 
-       com_argc = host_parms.argc;
-       com_argv = host_parms.argv;
        // FIXME: this is evil, but possibly temporary
        if (COM_CheckParm("-developer"))
        {
@@ -820,7 +825,6 @@ void Host_Init (void)
                developer.value = 1;
        }
 
-       Memory_Init ();
        Cmd_Init ();
        Memory_Init_Commands();
        R_Modules_Init();
@@ -839,7 +843,7 @@ void Host_Init (void)
        NET_Init ();
        SV_Init ();
 
-       Con_Printf ("Exe: "__TIME__" "__DATE__"\n");
+       Con_Printf ("Builddate: %s\n", buildstring);
 
        if (cls.state != ca_dedicated)
        {
@@ -891,9 +895,6 @@ void Host_Shutdown(void)
        }
        isdown = true;
 
-// keep Con_Printf from trying to update the screen
-//     scr_disabled_for_loading = true;
-
        Host_WriteConfiguration (); 
 
        CDAudio_Shutdown ();