2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // host.c -- coordinates spawning and killing of local servers
30 A server can always be started, even if the system started out as a client
33 A client can NOT be started if the system started as a dedicated server.
35 Memory is cleared / released when a server or client begins, not when they end.
39 // how many frames have occurred
40 // (checked by Host_Error and Host_SaveConfig_f)
42 // LordHavoc: set when quit is executed
43 qboolean host_shuttingdown = false;
45 double host_frametime;
46 // LordHavoc: the real frametime, before slowmo and clamping are applied (used for console scrolling)
47 double host_realframetime;
48 // the real time, without any slowmo or clamping
50 // realtime from previous frame
53 // used for -developer commandline parameter, hacky hacky
57 client_t *host_client;
59 jmp_buf host_abortframe;
61 // pretend frames take this amount of time (in seconds), 0 = realtime
62 cvar_t host_framerate = {0, "host_framerate","0"};
63 // shows time used by certain subsystems
64 cvar_t host_speeds = {0, "host_speeds","0"};
65 // LordHavoc: framerate independent slowmo
66 cvar_t slowmo = {0, "slowmo", "1.0"};
67 // LordHavoc: framerate upper cap
68 cvar_t cl_maxfps = {CVAR_SAVE, "cl_maxfps", "1000"};
70 // print broadcast messages in dedicated mode
71 cvar_t sv_echobprint = {CVAR_SAVE, "sv_echobprint", "1"};
73 cvar_t sys_ticrate = {CVAR_SAVE, "sys_ticrate","0.05"};
74 cvar_t serverprofile = {0, "serverprofile","0"};
76 cvar_t fraglimit = {CVAR_NOTIFY, "fraglimit","0"};
77 cvar_t timelimit = {CVAR_NOTIFY, "timelimit","0"};
78 cvar_t teamplay = {CVAR_NOTIFY, "teamplay","0"};
80 cvar_t samelevel = {0, "samelevel","0"};
81 cvar_t noexit = {CVAR_NOTIFY, "noexit","0"};
83 cvar_t developer = {0, "developer","0"};
85 cvar_t skill = {0, "skill","1"};
86 cvar_t deathmatch = {0, "deathmatch","0"};
87 cvar_t coop = {0, "coop","0"};
89 cvar_t pausable = {0, "pausable","1"};
91 cvar_t temp1 = {0, "temp1","0"};
93 cvar_t timestamps = {CVAR_SAVE, "timestamps", "0"};
94 cvar_t timeformat = {CVAR_SAVE, "timeformat", "[%b %e %X] "};
98 Host_AbortCurrentFrame
100 aborts the current host frame and goes on with the next one
103 void Host_AbortCurrentFrame(void)
105 longjmp (host_abortframe, 1);
112 This shuts down both the client and server
115 void Host_Error (const char *error, ...)
117 static char hosterrorstring1[4096];
118 static char hosterrorstring2[4096];
119 static qboolean hosterror = false;
122 va_start (argptr,error);
123 dpvsnprintf (hosterrorstring1,sizeof(hosterrorstring1),error,argptr);
126 Con_Printf("Host_Error: %s\n", hosterrorstring1);
128 // LordHavoc: if crashing very early, or currently shutting down, do
130 if (host_framecount < 3 || host_shuttingdown)
131 Sys_Error ("Host_Error: %s", hosterrorstring1);
134 Sys_Error ("Host_Error: recursively entered (original error was: %s new error is: %s)", hosterrorstring2, hosterrorstring1);
137 strcpy(hosterrorstring2, hosterrorstring1);
139 CL_Parse_DumpPacket();
143 // print out where the crash happened, if it was caused by QC (and do a cleanup)
147 Host_ShutdownServer (false);
149 if (cls.state == ca_dedicated)
150 Sys_Error ("Host_Error: %s\n",hosterrorstring2); // dedicated servers exit
157 Host_AbortCurrentFrame();
160 void Host_ServerOptions (void)
167 // COMMANDLINEOPTION: Server: -dedicated [playerlimit] starts a dedicated server (with a command console), default playerlimit is 8
168 // COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8
169 // if no client is in the executable or -dedicated is specified on
170 // commandline, start a dedicated server
171 i = COM_CheckParm ("-dedicated");
172 if (i || !cl_available)
174 cls.state = ca_dedicated;
175 // check for -dedicated specifying how many players
176 if (i && i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
177 svs.maxclients = atoi (com_argv[i+1]);
178 if (COM_CheckParm ("-listen"))
179 Con_Printf ("Only one of -dedicated or -listen can be specified");
180 // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users)
181 Cvar_SetValue("sv_public", 1);
183 else if (cl_available)
185 // client exists and not dedicated, check if -listen is specified
186 cls.state = ca_disconnected;
187 i = COM_CheckParm ("-listen");
190 // default players unless specified
191 if (i + 1 < com_argc && atoi (com_argv[i+1]) >= 1)
192 svs.maxclients = atoi (com_argv[i+1]);
196 // default players in some games, singleplayer in most
197 if (gamemode != GAME_GOODVSBAD2 && gamemode != GAME_NEXUIZ && gamemode != GAME_BATTLEMECH)
202 svs.maxclients = bound(1, svs.maxclients, MAX_SCOREBOARD);
204 svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients);
206 if (svs.maxclients > 1 && !deathmatch.integer)
207 Cvar_SetValueQuick(&deathmatch, 1);
211 =======================
213 ======================
215 void Host_SaveConfig_f(void);
216 void Host_InitLocal (void)
218 Cmd_AddCommand("saveconfig", Host_SaveConfig_f);
220 Cvar_RegisterVariable (&host_framerate);
221 Cvar_RegisterVariable (&host_speeds);
222 Cvar_RegisterVariable (&slowmo);
223 Cvar_RegisterVariable (&cl_maxfps);
225 Cvar_RegisterVariable (&sv_echobprint);
227 Cvar_RegisterVariable (&sys_ticrate);
228 Cvar_RegisterVariable (&serverprofile);
230 Cvar_RegisterVariable (&fraglimit);
231 Cvar_RegisterVariable (&timelimit);
232 Cvar_RegisterVariable (&teamplay);
233 Cvar_RegisterVariable (&samelevel);
234 Cvar_RegisterVariable (&noexit);
235 Cvar_RegisterVariable (&skill);
236 Cvar_RegisterVariable (&developer);
237 if (forcedeveloper) // make it real now that the cvar is registered
238 Cvar_SetValue("developer", 1);
239 Cvar_RegisterVariable (&deathmatch);
240 Cvar_RegisterVariable (&coop);
242 Cvar_RegisterVariable (&pausable);
244 Cvar_RegisterVariable (&temp1);
246 Cvar_RegisterVariable (×tamps);
247 Cvar_RegisterVariable (&timeformat);
255 Writes key bindings and archived cvars to config.cfg
258 void Host_SaveConfig_f(void)
262 // dedicated servers initialize the host but don't parse and set the
264 // LordHavoc: don't save a config if it crashed in startup
265 if (host_framecount >= 3 && cls.state != ca_dedicated)
267 f = FS_Open ("config.cfg", "wb", false, false);
270 Con_Print("Couldn't write config.cfg.\n");
274 Key_WriteBindings (f);
275 Cvar_WriteVariables (f);
286 Sends text across to be displayed
287 FIXME: make this just a stuffed echo?
290 void SV_ClientPrint(const char *msg)
292 MSG_WriteByte(&host_client->message, svc_print);
293 MSG_WriteString(&host_client->message, msg);
300 Sends text across to be displayed
301 FIXME: make this just a stuffed echo?
304 void SV_ClientPrintf(const char *fmt, ...)
309 va_start(argptr,fmt);
310 dpvsnprintf(msg,sizeof(msg),fmt,argptr);
320 Sends text to all active clients
323 void SV_BroadcastPrint(const char *msg)
328 for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
332 MSG_WriteByte(&client->message, svc_print);
333 MSG_WriteString(&client->message, msg);
337 if (sv_echobprint.integer && cls.state == ca_dedicated)
345 Sends text to all active clients
348 void SV_BroadcastPrintf(const char *fmt, ...)
353 va_start(argptr,fmt);
354 dpvsnprintf(msg,sizeof(msg),fmt,argptr);
357 SV_BroadcastPrint(msg);
364 Send text over to the client to be executed
367 void Host_ClientCommands(const char *fmt, ...)
372 va_start(argptr,fmt);
373 dpvsnprintf(string, sizeof(string), fmt, argptr);
376 MSG_WriteByte(&host_client->message, svc_stufftext);
377 MSG_WriteString(&host_client->message, string);
381 =====================
384 Called when the player is getting totally kicked off the host
385 if (crash = true), don't bother sending signofs
386 =====================
388 void SV_DropClient(qboolean crash)
391 Con_Printf("Client \"%s\" dropped\n", host_client->name);
393 // make sure edict is not corrupt (from a level change for example)
394 host_client->edict = PRVM_EDICT_NUM(host_client - svs.clients + 1);
396 if (host_client->netconnection)
398 // free the client (the body stays around)
401 // LordHavoc: no opportunity for resending, so use unreliable 3 times
402 MSG_WriteByte(&host_client->message, svc_disconnect);
403 NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
404 NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
405 NetConn_SendUnreliableMessage(host_client->netconnection, &host_client->message);
407 // break the net connection
408 NetConn_Close(host_client->netconnection);
409 host_client->netconnection = NULL;
412 // call qc ClientDisconnect function
413 // LordHavoc: don't call QC if server is dead (avoids recursive
414 // Host_Error in some mods when they run out of edicts)
415 if (host_client->clientconnectcalled && sv.active && host_client->edict)
417 // call the prog function for removing a client
418 // this will set the body to a dead frame, among other things
419 int saveSelf = prog->globals.server->self;
420 host_client->clientconnectcalled = false;
421 prog->globals.server->self = PRVM_EDICT_TO_PROG(host_client->edict);
422 PRVM_ExecuteProgram(prog->globals.server->ClientDisconnect, "QC function ClientDisconnect is missing");
423 prog->globals.server->self = saveSelf;
426 // remove leaving player from scoreboard
427 //host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
428 //if ((val = PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_clientcolors)))
430 //host_client->edict->fields.server->frags = 0;
431 host_client->name[0] = 0;
432 host_client->colors = 0;
433 host_client->frags = 0;
434 // send notification to all clients
435 // get number of client manually just to make sure we get it right...
436 i = host_client - svs.clients;
437 MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
438 MSG_WriteByte (&sv.reliable_datagram, i);
439 MSG_WriteString (&sv.reliable_datagram, host_client->name);
440 MSG_WriteByte (&sv.reliable_datagram, svc_updatecolors);
441 MSG_WriteByte (&sv.reliable_datagram, i);
442 MSG_WriteByte (&sv.reliable_datagram, host_client->colors);
443 MSG_WriteByte (&sv.reliable_datagram, svc_updatefrags);
444 MSG_WriteByte (&sv.reliable_datagram, i);
445 MSG_WriteShort (&sv.reliable_datagram, host_client->frags);
447 // free the client now
448 if (host_client->entitydatabase)
449 EntityFrame_FreeDatabase(host_client->entitydatabase);
450 if (host_client->entitydatabase4)
451 EntityFrame4_FreeDatabase(host_client->entitydatabase4);
452 if (host_client->entitydatabase5)
453 EntityFrame5_FreeDatabase(host_client->entitydatabase5);
457 // clear a fields that matter to DP_SV_CLIENTNAME and DP_SV_CLIENTCOLORS, and also frags
458 PRVM_ED_ClearEdict(host_client->edict);
461 // clear the client struct (this sets active to false)
462 memset(host_client, 0, sizeof(*host_client));
464 // update server listing on the master because player count changed
465 // (which the master uses for filtering empty/full servers)
466 NetConn_Heartbeat(1);
473 This only happens at the end of a game, not between levels
476 void Host_ShutdownServer(qboolean crash)
482 Con_DPrintf("Host_ShutdownServer\n");
489 NetConn_Heartbeat(2);
490 NetConn_Heartbeat(2);
492 // make sure all the clients know we're disconnecting
496 MSG_WriteByte(&buf, svc_disconnect);
497 count = NetConn_SendToAll(&buf, 5);
499 Con_Printf("Host_ShutdownServer: NetConn_SendToAll failed for %u clients\n", count);
501 for (i = 0, host_client = svs.clients;i < svs.maxclients;i++, host_client++)
502 if (host_client->active) {
503 SV_DropClient(crash); // server shutdown
506 NetConn_CloseServerPorts();
512 memset(&sv, 0, sizeof(sv));
513 memset(svs.clients, 0, svs.maxclients*sizeof(client_t));
523 This clears all the memory used by both the client and server, but does
524 not reinitialize anything.
527 void Host_ClearMemory (void)
529 Con_DPrint("Clearing memory\n");
533 memset (&sv, 0, sizeof(sv));
534 memset (&cl, 0, sizeof(cl));
538 //============================================================================
544 Returns false if the time is too short to run a frame
547 extern qboolean cl_capturevideo_active;
548 extern double cl_capturevideo_framerate;
549 extern qfile_t *cl_capturevideo_soundfile;
550 qboolean Host_FilterTime (double time)
552 double timecap, timeleft;
555 if (sys_ticrate.value < 0.00999 || sys_ticrate.value > 0.10001)
556 Cvar_SetValue("sys_ticrate", bound(0.01, sys_ticrate.value, 0.1));
557 if (slowmo.value < 0)
558 Cvar_SetValue("slowmo", 0);
559 if (host_framerate.value < 0.00001 && host_framerate.value != 0)
560 Cvar_SetValue("host_framerate", 0);
561 if (cl_maxfps.value < 1)
562 Cvar_SetValue("cl_maxfps", 1);
566 // disable time effects during timedemo
567 cl.frametime = host_realframetime = host_frametime = realtime - oldrealtime;
568 oldrealtime = realtime;
572 // check if framerate is too high
573 // default to sys_ticrate (server framerate - presumably low) unless we
574 // have a good reason to run faster
575 timecap = host_framerate.value;
577 timecap = sys_ticrate.value;
578 if (cls.state != ca_dedicated)
580 if (cl_capturevideo_active)
581 timecap = 1.0 / cl_capturevideo_framerate;
582 else if (vid_activewindow)
583 timecap = 1.0 / cl_maxfps.value;
586 timeleft = timecap - (realtime - oldrealtime);
590 // don't totally hog the CPU
591 if (cls.state == ca_dedicated)
593 // if dedicated, try to use as little cpu as possible by waiting
594 // just a little longer than necessary
595 // (yes this means it doesn't quite keep up with the framerate)
596 msleft = (int)ceil(timeleft * 1000);
600 // if not dedicated, try to hit exactly a steady framerate by not
601 // sleeping the full amount
602 msleft = (int)floor(timeleft * 1000);
609 // LordHavoc: copy into host_realframetime as well
610 host_realframetime = host_frametime = realtime - oldrealtime;
611 oldrealtime = realtime;
613 if (cl_capturevideo_active && !cl_capturevideo_soundfile)
614 host_frametime = timecap;
616 // apply slowmo scaling
617 host_frametime *= slowmo.value;
619 // host_framerate overrides all else
620 if (host_framerate.value)
621 host_frametime = host_framerate.value;
623 // never run a frame longer than 1 second
624 if (host_frametime > 1)
627 cl.frametime = host_frametime;
635 Host_GetConsoleCommands
637 Add them exactly as if they had been typed at the console
640 void Host_GetConsoleCommands (void)
646 cmd = Sys_ConsoleInput ();
659 void Host_ServerFrame (void)
661 // never run more than 5 frames at a time as a sanity limit
662 int framecount, framelimit = 5;
669 sv.timer += host_realframetime;
672 // run the world state
673 // don't allow simulation to run too fast or too slow or logic glitches can occur
674 for (framecount = 0;framecount < framelimit && sv.timer > 0;framecount++)
676 // setup the VM frame
680 advancetime = min(sv.timer, sys_ticrate.value);
682 advancetime = sys_ticrate.value;
683 sv.timer -= advancetime;
685 // only advance time if not paused
686 // the game also pauses in singleplayer when menu or console is used
687 sv.frametime = advancetime * slowmo.value;
688 if (host_framerate.value)
689 sv.frametime = host_framerate.value;
690 if (sv.paused || (cl.islocalgame && (key_dest != key_game || key_consoleactive)))
693 // set the time and clear the general datagram
696 // check for network packets to the server each world step incase they
697 // come in midframe (particularly if host is running really slow)
698 NetConn_ServerFrame();
700 // move things around and think unless paused
704 // send all messages to the clients
705 SV_SendClientMessages();
707 // send an heartbeat if enough time has passed since the last one
708 NetConn_Heartbeat(0);
710 // end the server VM frame
715 // if we fell behind too many frames just don't worry about it
725 Runs all active servers
728 void _Host_Frame (float time)
730 static double time1 = 0;
731 static double time2 = 0;
732 static double time3 = 0;
733 int pass1, pass2, pass3;
735 if (setjmp(host_abortframe))
736 return; // something bad happened, or the server disconnected
738 // decide the simulation time
739 if (!Host_FilterTime(time))
742 // keep the random time dependent
745 cl.islocalgame = NetConn_IsLocalGame();
747 // get new key events
750 // Collect input into cmd
753 // process console commands
756 // if running the server locally, make intentions now
757 if (cls.state == ca_connected && sv.active)
760 //-------------------
764 //-------------------
766 // check for commands typed to the host
767 Host_GetConsoleCommands();
772 //-------------------
776 //-------------------
778 cl.oldtime = cl.time;
779 cl.time += cl.frametime;
781 NetConn_ClientFrame();
783 if (cls.state == ca_connected)
785 // if running the server remotely, send intentions now after
786 // the incoming messages have been read
797 if (host_speeds.integer)
798 time1 = Sys_DoubleTime();
802 if (host_speeds.integer)
803 time2 = Sys_DoubleTime();
806 S_Update(&r_refdef.viewentitymatrix);
810 if (host_speeds.integer)
812 pass1 = (time1 - time3)*1000000;
813 time3 = Sys_DoubleTime();
814 pass2 = (time2 - time1)*1000000;
815 pass3 = (time3 - time2)*1000000;
816 Con_Printf("%6ius total %6ius server %6ius gfx %6ius snd\n",
817 pass1+pass2+pass3, pass1, pass2, pass3);
823 void Host_Frame (float time)
826 static double timetotal;
827 static int timecount;
830 if (!serverprofile.integer)
836 time1 = Sys_DoubleTime ();
838 time2 = Sys_DoubleTime ();
840 timetotal += time2 - time1;
843 if (timecount < 1000)
846 m = timetotal*1000/timecount;
850 for (i=0 ; i<svs.maxclients ; i++)
852 if (svs.clients[i].active)
856 Con_Printf("serverprofile: %2i clients %2i msec\n", c, m);
859 //============================================================================
861 qboolean vid_opened = false;
862 void Host_StartVideo(void)
864 if (!vid_opened && cls.state != ca_dedicated)
872 char engineversion[128];
874 qboolean sys_nostdout = false;
876 extern void Render_Init(void);
877 extern void Mathlib_Init(void);
878 extern void FS_Init(void);
879 extern void FS_Shutdown(void);
880 extern void PR_Cmd_Init(void);
881 extern void COM_Init_Commands(void);
882 extern void FS_Init_Commands(void);
883 extern void COM_CheckRegistered(void);
884 extern qboolean host_stuffcmdsrun;
891 void Host_Init (void)
896 // LordHavoc: quake never seeded the random number generator before... heh
899 // used by everything
902 // initialize console and logging
905 // initialize console command/cvar/alias/command execution systems
911 // initialize console window (only used by sys_win.c)
914 // detect gamemode from commandline options or executable name
917 // construct a version string for the corner of the console
918 #if defined(__linux__)
922 #elif defined(__FreeBSD__)
924 #elif defined(__NetBSD__)
926 #elif defined(__OpenBSD__)
928 #elif defined(MACOSX)
933 dpsnprintf (engineversion, sizeof (engineversion), "%s %s %s", gamename, os, buildstring);
935 // COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from
936 if (COM_CheckParm("-nostdout"))
939 Con_Printf("%s\n", engineversion);
941 // FIXME: this is evil, but possibly temporary
942 // COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers)
943 if (COM_CheckParm("-developer"))
945 forcedeveloper = true;
946 developer.integer = 1;
950 // initialize filesystem (including fs_basedir, fs_gamedir, -path, -game, scr_screenshot_name)
953 // initialize various cvars that could not be initialized earlier
954 Memory_Init_Commands();
960 COM_CheckRegistered();
962 // initialize ixtable
973 Host_ServerOptions();
975 if (cls.state != ca_dedicated)
977 Con_Printf("Initializing client\n");
992 // set up the default startmap_sp and startmap_dm aliases (mods can
993 // override these) and then execute the quake.rc startup script
994 if (gamemode == GAME_NEHAHRA)
995 Cbuf_AddText("alias startmap_sp \"map nehstart\"\nalias startmap_dm \"map nehstart\"\nexec quake.rc\n");
996 else if (gamemode == GAME_TRANSFUSION)
997 Cbuf_AddText("alias startmap_sp \"map e1m1\"\n""alias startmap_dm \"map bb1\"\nexec quake.rc\n");
998 else if (gamemode == GAME_NEXUIZ)
999 Cbuf_AddText("alias startmap_sp \"map nexdm01\"\nalias startmap_dm \"map nexdm01\"\nexec quake.rc\n");
1000 else if (gamemode == GAME_TEU)
1001 Cbuf_AddText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec teu.rc\n");
1003 Cbuf_AddText("alias startmap_sp \"map start\"\nalias startmap_dm \"map start\"\nexec quake.rc\n");
1006 // if stuffcmds wasn't run, then quake.rc is probably missing, use default
1007 if (!host_stuffcmdsrun)
1009 Cbuf_AddText("exec default.cfg\nexec config.cfg\nexec autoexec.cfg\nstuffcmds\n");
1013 // save console log up to this point to log_file if it was set by configs
1016 // FIXME: put this into some neat design, but the menu should be allowed to crash
1017 // without crashing the whole game, so this should just be a short-time solution
1020 // here comes the not so critical stuff
1021 if (setjmp(host_abortframe)) {
1025 if (cls.state != ca_dedicated)
1030 // check for special benchmark mode
1031 // COMMANDLINEOPTION: Client: -benchmark <demoname> runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log)
1032 i = COM_CheckParm("-benchmark");
1033 if (i && i + 1 < com_argc)
1034 if (!sv.active && !cls.demoplayback && !cls.connect_trying)
1036 Cbuf_AddText(va("timedemo %s\n", com_argv[i + 1]));
1040 // check for special demo mode
1041 // COMMANDLINEOPTION: Client: -demo <demoname> runs a playdemo and quits
1042 i = COM_CheckParm("-demo");
1043 if (i && i + 1 < com_argc)
1044 if (!sv.active && !cls.demoplayback && !cls.connect_trying)
1046 Cbuf_AddText(va("playdemo %s\n", com_argv[i + 1]));
1050 // check for special demolooponly mode
1051 // COMMANDLINEOPTION: Client: -demolooponly <demoname> runs a playdemo and quits
1052 i = COM_CheckParm("-demolooponly");
1053 if (i && i + 1 < com_argc)
1054 if (!sv.active && !cls.demoplayback && !cls.connect_trying)
1056 Cbuf_AddText(va("playdemo %s\n", com_argv[i + 1]));
1060 if (cls.state == ca_dedicated || COM_CheckParm("-listen"))
1061 if (!sv.active && !cls.demoplayback && !cls.connect_trying)
1063 Cbuf_AddText("startmap_dm\n");
1067 if (!sv.active && !cls.demoplayback && !cls.connect_trying)
1069 if (gamemode == GAME_NEXUIZ)
1070 Cbuf_AddText("togglemenu\nplayvideo logo\ncd loop 1\n");
1072 Cbuf_AddText("togglemenu\n");
1076 Con_DPrint("========Initialized=========\n");
1086 FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better
1087 to run quit through here before the final handoff to the sys code.
1090 void Host_Shutdown(void)
1092 static qboolean isdown = false;
1096 Con_Print("recursive shutdown\n");
1101 // be quiet while shutting down
1104 // disconnect client from server if active
1107 // shut down local server if active
1108 Host_ShutdownServer (false);
1115 // AK hmm, no PRVM_Shutdown(); yet
1117 CL_Video_Shutdown();
1119 Host_SaveConfig_f();
1121 CDAudio_Shutdown ();
1123 NetConn_Shutdown ();
1126 if (cls.state != ca_dedicated)
1128 R_Modules_Shutdown();