git-svn-id: http://bladebattles.com/kurok/SVN@11 20cd92bb-ff49-0410-b73e-96a06e42c3b9
[kurok.git] / host.c
bloba7397e9bf9440d6a722741b14a0028ddae025be7
1 /*
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
22 #include "quakedef.h"
23 #include "r_local.h"
24 #include "psp/module.h"
28 A server can allways be started, even if the system started out as a client
29 to a remote system.
31 A client can NOT be started if the system started as a dedicated server.
33 Memory is cleared / released when a server or client begins, not when they end.
37 quakeparms_t host_parms;
39 qboolean host_initialized; // true if into command execution
41 double host_frametime;
42 double host_time;
43 double realtime; // without any filtering or bounding
44 double oldrealtime; // last frame run
45 int host_framecount;
46 int fps_count;
48 int host_hunklevel;
50 int minimum_memory;
52 client_t *host_client; // current client
54 jmp_buf host_abortserver;
56 byte *host_basepal;
57 byte *host_colormap;
59 cvar_t show_fps = {"show_fps","0", true}; // set for running times - muff
60 cvar_t max_fps = {"max_fps", "65", true}; // MrG - max_fps
61 cvar_t host_framerate = {"host_framerate","0"}; // set for slow motion
62 cvar_t host_speeds = {"host_speeds","0"}; // set for running times
64 cvar_t sys_ticrate = {"sys_ticrate","0.05"};
65 cvar_t serverprofile = {"serverprofile","0"};
67 cvar_t fraglimit = {"fraglimit","15",false,true};
68 cvar_t timelimit = {"timelimit","15",false,true};
69 cvar_t teamplay = {"teamplay","0",false,true};
71 cvar_t samelevel = {"samelevel","0"};
72 cvar_t noexit = {"noexit","0",false,true};
74 #ifdef QUAKE2
75 cvar_t developer = {"developer","1"}; // should be 0 for release!
76 #else
77 cvar_t developer = {"developer","0"};
78 #endif
80 cvar_t skill = {"skill","1"}; // 0 - 3
81 cvar_t deathmatch = {"deathmatch","0"}; // 0, 1, or 2
82 cvar_t coop = {"coop","0"}; // 0 or 1
84 cvar_t pausable = {"pausable","1"};
86 cvar_t temp1 = {"temp1","0"};
88 qboolean bmg_type_changed = false;
92 ================
93 Host_EndGame
94 ================
96 void Host_EndGame (char *message, ...)
98 va_list argptr;
99 char string[1024];
101 va_start (argptr,message);
102 vsprintf (string,message,argptr);
103 va_end (argptr);
104 Con_DPrintf ("Host_EndGame: %s\n",string);
106 if (sv.active)
107 Host_ShutdownServer (false);
109 if (cls.state == ca_dedicated)
110 Sys_Error ("Host_EndGame: %s\n",string); // dedicated servers exit
112 if (cls.demonum != -1)
113 CL_NextDemo ();
114 else
115 CL_Disconnect ();
117 longjmp (host_abortserver, 1);
121 ================
122 Host_Error
124 This shuts down both the client and server
125 ================
127 void Host_Error (char *error, ...)
129 va_list argptr;
130 char string[1024];
131 static qboolean inerror = false;
133 if (inerror)
134 Sys_Error ("Host_Error: recursively entered");
135 inerror = true;
137 SCR_EndLoadingPlaque (); // reenable screen updates
139 va_start (argptr,error);
140 vsprintf (string,error,argptr);
141 va_end (argptr);
142 Con_Printf ("Host_Error: %s\n",string);
144 if (sv.active)
145 Host_ShutdownServer (false);
147 if (cls.state == ca_dedicated)
148 Sys_Error ("Host_Error: %s\n",string); // dedicated servers exit
150 CL_Disconnect ();
151 cls.demonum = -1;
153 inerror = false;
155 longjmp (host_abortserver, 1);
159 ================
160 Host_FindMaxClients
161 ================
163 void Host_FindMaxClients (void)
165 int i;
167 svs.maxclients = 1;
169 i = COM_CheckParm ("-dedicated");
170 if (i)
172 cls.state = ca_dedicated;
173 if (i != (com_argc - 1))
175 svs.maxclients = Q_atoi (com_argv[i+1]);
177 else
178 svs.maxclients = 8;
180 else
181 cls.state = ca_disconnected;
183 i = COM_CheckParm ("-listen");
184 if (i)
186 if (cls.state == ca_dedicated)
187 Sys_Error ("Only one of -dedicated or -listen can be specified");
188 if (i != (com_argc - 1))
189 svs.maxclients = Q_atoi (com_argv[i+1]);
190 else
191 svs.maxclients = 8;
193 if (svs.maxclients < 1)
194 svs.maxclients = 8;
195 else if (svs.maxclients > MAX_SCOREBOARD)
196 svs.maxclients = MAX_SCOREBOARD;
198 svs.maxclientslimit = svs.maxclients;
199 if (svs.maxclientslimit < 4)
200 svs.maxclientslimit = 4;
201 svs.clients = Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients");
203 if (svs.maxclients > 1)
205 if (deathmatch.value > 1)
206 Cvar_SetValue ("deathmatch", deathmatch.value);
207 else
208 Cvar_SetValue ("deathmatch", 1.0);
210 else
211 Cvar_SetValue ("deathmatch", 0.0);
216 =======================
217 Host_InitLocal
218 ======================
220 void Host_InitLocal (void)
222 Host_InitCommands ();
224 Cvar_RegisterVariable (&show_fps); // muff
225 Cvar_RegisterVariable (&max_fps); // MrG - max_fps
226 Cvar_RegisterVariable (&host_framerate);
227 Cvar_RegisterVariable (&host_speeds);
229 Cvar_RegisterVariable (&sys_ticrate);
230 Cvar_RegisterVariable (&serverprofile);
232 Cvar_RegisterVariable (&fraglimit);
233 Cvar_RegisterVariable (&timelimit);
234 Cvar_RegisterVariable (&teamplay);
235 Cvar_RegisterVariable (&samelevel);
236 Cvar_RegisterVariable (&noexit);
237 Cvar_RegisterVariable (&skill);
238 Cvar_RegisterVariable (&developer);
239 Cvar_RegisterVariable (&deathmatch);
240 Cvar_RegisterVariable (&coop);
242 Cvar_RegisterVariable (&pausable);
244 Cvar_RegisterVariable (&temp1);
246 Host_FindMaxClients ();
248 host_time = 1.0; // so a think at time 0 won't get called
253 ===============
254 Host_WriteConfiguration
256 Writes key bindings and archived cvars to config.cfg
257 ===============
259 void Host_WriteConfiguration (void)
261 FILE *f;
263 // dedicated servers initialize the host but don't parse and set the
264 // config.cfg cvars
265 if (host_initialized & !isDedicated)
267 f = fopen (va("%s/config.cfg",com_gamedir), "w");
268 if (!f)
270 Con_Printf ("Couldn't write config.cfg.\n");
271 return;
274 Key_WriteBindings (f);
275 Cvar_WriteVariables (f);
277 fclose (f);
283 =================
284 SV_ClientPrintf
286 Sends text across to be displayed
287 FIXME: make this just a stuffed echo?
288 =================
290 void SV_ClientPrintf (char *fmt, ...)
292 va_list argptr;
293 char string[1024];
295 va_start (argptr,fmt);
296 vsprintf (string, fmt,argptr);
297 va_end (argptr);
299 MSG_WriteByte (&host_client->message, svc_print);
300 MSG_WriteString (&host_client->message, string);
304 =================
305 SV_BroadcastPrintf
307 Sends text to all active clients
308 =================
310 void SV_BroadcastPrintf (char *fmt, ...)
312 va_list argptr;
313 char string[1024];
314 int i;
316 va_start (argptr,fmt);
317 vsprintf (string, fmt,argptr);
318 va_end (argptr);
320 for (i=0 ; i<svs.maxclients ; i++)
321 if (svs.clients[i].active && svs.clients[i].spawned)
323 MSG_WriteByte (&svs.clients[i].message, svc_print);
324 MSG_WriteString (&svs.clients[i].message, string);
329 =================
330 Host_ClientCommands
332 Send text over to the client to be executed
333 =================
335 void Host_ClientCommands (char *fmt, ...)
337 va_list argptr;
338 char string[1024];
340 va_start (argptr,fmt);
341 vsprintf (string, fmt,argptr);
342 va_end (argptr);
344 MSG_WriteByte (&host_client->message, svc_stufftext);
345 MSG_WriteString (&host_client->message, string);
349 =====================
350 SV_DropClient
352 Called when the player is getting totally kicked off the host
353 if (crash = true), don't bother sending signofs
354 =====================
356 void SV_DropClient (qboolean crash)
358 int saveSelf;
359 int i;
360 client_t *client;
362 if (!crash)
364 // send any final messages (don't check for errors)
365 if (NET_CanSendMessage (host_client->netconnection))
367 MSG_WriteByte (&host_client->message, svc_disconnect);
368 NET_SendMessage (host_client->netconnection, &host_client->message);
371 if (host_client->edict && host_client->spawned)
373 // call the prog function for removing a client
374 // this will set the body to a dead frame, among other things
375 saveSelf = pr_global_struct->self;
376 pr_global_struct->self = EDICT_TO_PROG(host_client->edict);
377 PR_ExecuteProgram (pr_global_struct->ClientDisconnect);
378 pr_global_struct->self = saveSelf;
381 Sys_Printf ("Client %s removed\n",host_client->name);
384 // break the net connection
385 NET_Close (host_client->netconnection);
386 host_client->netconnection = NULL;
388 // free the client (the body stays around)
389 host_client->active = false;
390 host_client->name[0] = 0;
391 host_client->old_frags = -999999;
392 net_activeconnections--;
394 // send notification to all clients
395 for (i=0, client = svs.clients ; i<svs.maxclients ; i++, client++)
397 if (!client->active)
398 continue;
399 MSG_WriteByte (&client->message, svc_updatename);
400 MSG_WriteByte (&client->message, host_client - svs.clients);
401 MSG_WriteString (&client->message, "");
402 MSG_WriteByte (&client->message, svc_updatefrags);
403 MSG_WriteByte (&client->message, host_client - svs.clients);
404 MSG_WriteShort (&client->message, 0);
405 MSG_WriteByte (&client->message, svc_updatecolors);
406 MSG_WriteByte (&client->message, host_client - svs.clients);
407 MSG_WriteByte (&client->message, 0);
412 ==================
413 Host_ShutdownServer
415 This only happens at the end of a game, not between levels
416 ==================
418 void Host_ShutdownServer(qboolean crash)
420 int i;
421 int count;
422 sizebuf_t buf;
423 char message[4];
424 double start;
426 if (!sv.active)
427 return;
429 sv.active = false;
431 // stop all client sounds immediately
432 if (cls.state == ca_connected)
433 CL_Disconnect ();
435 // flush any pending messages - like the score!!!
436 start = Sys_FloatTime();
439 count = 0;
440 for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
442 if (host_client->active && host_client->message.cursize)
444 if (NET_CanSendMessage (host_client->netconnection))
446 NET_SendMessage(host_client->netconnection, &host_client->message);
447 SZ_Clear (&host_client->message);
449 else
451 NET_GetMessage(host_client->netconnection);
452 count++;
456 if ((Sys_FloatTime() - start) > 3.0)
457 break;
459 while (count);
461 // make sure all the clients know we're disconnecting
462 buf.data = message;
463 buf.maxsize = 4;
464 buf.cursize = 0;
465 MSG_WriteByte(&buf, svc_disconnect);
466 count = NET_SendToAll(&buf, 5);
467 if (count)
468 Con_Printf("Host_ShutdownServer: NET_SendToAll failed for %u clients\n", count);
470 for (i=0, host_client = svs.clients ; i<svs.maxclients ; i++, host_client++)
471 if (host_client->active)
472 SV_DropClient(crash);
475 // clear structures
477 memset (&sv, 0, sizeof(sv));
478 memset (svs.clients, 0, svs.maxclientslimit*sizeof(client_t));
483 ================
484 Host_ClearMemory
486 This clears all the memory used by both the client and server, but does
487 not reinitialize anything.
488 ================
490 void Host_ClearMemory (void)
492 Con_DPrintf ("Clearing memory\n");
493 D_FlushCaches ();
494 Mod_ClearAll ();
495 if (host_hunklevel)
496 Hunk_FreeToLowMark (host_hunklevel);
498 cls.signon = 0;
499 memset (&sv, 0, sizeof(sv));
500 memset (&cl, 0, sizeof(cl));
504 //============================================================================
508 ===================
509 Host_FilterTime
511 Returns false if the time is too short to run a frame
512 ===================
514 qboolean Host_FilterTime (float time)
516 realtime += time;
518 // MrG - max_fps
520 if (max_fps.value < 1) Cvar_SetValue("max_fps", 65);
521 if (!cls.timedemo && realtime - oldrealtime < 1.0/max_fps.value)
522 return false; // framerate is too high
524 host_frametime = realtime - oldrealtime;
525 oldrealtime = realtime;
527 if (host_framerate.value > 0)
528 host_frametime = host_framerate.value;
529 else
530 { // don't allow really long or short frames
531 if (host_frametime > 0.1)
532 host_frametime = 0.1;
533 if (host_frametime < 0.001)
534 host_frametime = 0.001;
537 return true;
542 ===================
543 Host_GetConsoleCommands
545 Add them exactly as if they had been typed at the console
546 ===================
548 void Host_GetConsoleCommands (void)
550 char *cmd;
552 while (1)
554 cmd = Sys_ConsoleInput ();
555 if (!cmd)
556 break;
557 Cbuf_AddText (cmd);
563 ==================
564 Host_ServerFrame
566 ==================
568 #ifdef FPS_20
570 void _Host_ServerFrame (void)
572 // run the world state
573 pr_global_struct->frametime = host_frametime;
575 // read client messages
576 SV_RunClients ();
578 // move things around and think
579 // always pause in single player if in console or menus
580 if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
582 SV_Physics ();
584 if(kurok)
586 Cvar_Set("bgmtype","cd");
587 bmg_type_changed = true;
590 else
592 if(kurok)
594 Cvar_Set("bgmtype","none");
595 bmg_type_changed = true;
600 void Host_ServerFrame (void)
602 float save_host_frametime;
603 float temp_host_frametime;
605 // run the world state
606 pr_global_struct->frametime = host_frametime;
608 // set the time and clear the general datagram
609 SV_ClearDatagram ();
611 // check for new clients
612 SV_CheckForNewClients ();
614 temp_host_frametime = save_host_frametime = host_frametime;
615 while(temp_host_frametime > (1.0/72.0))
617 if (temp_host_frametime > 0.05)
618 host_frametime = 0.05;
619 else
620 host_frametime = temp_host_frametime;
621 temp_host_frametime -= host_frametime;
622 _Host_ServerFrame ();
624 host_frametime = save_host_frametime;
626 // send all messages to the clients
627 SV_SendClientMessages ();
630 #else
632 void Host_ServerFrame (void)
634 // run the world state
635 pr_global_struct->frametime = host_frametime;
637 // set the time and clear the general datagram
638 SV_ClearDatagram ();
640 // check for new clients
641 SV_CheckForNewClients ();
643 // read client messages
644 SV_RunClients ();
646 // move things around and think
647 // always pause in single player if in console or menus
648 if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game) )
649 SV_Physics ();
651 // send all messages to the clients
652 SV_SendClientMessages ();
655 #endif
659 ==================
660 Host_Frame
662 Runs all active servers
663 ==================
665 void _Host_Frame (float time)
667 static double time1 = 0;
668 static double time2 = 0;
669 static double time3 = 0;
670 int pass1, pass2, pass3;
672 if (setjmp (host_abortserver) )
673 return; // something bad happened, or the server disconnected
675 // keep the random time dependent
676 rand ();
678 // decide the simulation time
679 if (!Host_FilterTime (time))
680 return; // don't run too fast, or packets will flood out
682 // get new key events
683 Sys_SendKeyEvents ();
685 // allow mice or other external controllers to add commands
686 IN_Commands ();
688 // process console commands
689 Cbuf_Execute ();
691 NET_Poll();
693 // if running the server locally, make intentions now
694 if (sv.active)
695 CL_SendCmd ();
697 //-------------------
699 // server operations
701 //-------------------
703 // check for commands typed to the host
704 Host_GetConsoleCommands ();
706 if (sv.active)
707 Host_ServerFrame ();
709 //-------------------
711 // client operations
713 //-------------------
715 // if running the server remotely, send intentions now after
716 // the incoming messages have been read
717 if (!sv.active)
718 CL_SendCmd ();
720 host_time += host_frametime;
722 // fetch results from server
723 if (cls.state == ca_connected)
725 CL_ReadFromServer ();
728 // update video
729 if (host_speeds.value)
730 time1 = Sys_FloatTime ();
732 SCR_UpdateScreen ();
734 if (host_speeds.value)
735 time2 = Sys_FloatTime ();
737 // update audio
738 if (cls.signon == SIGNONS)
740 S_Update (r_origin, vpn, vright, vup);
741 CL_DecayLights ();
743 else
744 S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
746 if (bmg_type_changed == true) {
747 CDAudio_Update();
748 bmg_type_changed = false;
751 if (host_speeds.value)
753 pass1 = (time1 - time3)*1000;
754 time3 = Sys_FloatTime ();
755 pass2 = (time2 - time1)*1000;
756 pass3 = (time3 - time2)*1000;
757 Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
758 pass1+pass2+pass3, pass1, pass2, pass3);
761 host_framecount++;
762 //frame speed counter
763 fps_count++;//muff
766 void Host_Frame (float time)
768 double time1, time2;
769 static double timetotal;
770 static int timecount;
771 int i, c, m;
773 if (!serverprofile.value)
775 _Host_Frame (time);
776 return;
779 time1 = Sys_FloatTime ();
780 _Host_Frame (time);
781 time2 = Sys_FloatTime ();
783 timetotal += time2 - time1;
784 timecount++;
786 if (timecount < 1000)
787 return;
789 m = timetotal*1000/timecount;
790 timecount = 0;
791 timetotal = 0;
792 c = 0;
793 for (i=0 ; i<svs.maxclients ; i++)
795 if (svs.clients[i].active)
796 c++;
799 Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m);
802 //============================================================================
805 extern int vcrFile;
806 #define VCR_SIGNATURE 0x56435231
807 // "VCR1"
809 void Host_InitVCR (quakeparms_t *parms)
811 int i, len, n;
812 char *p;
814 if (COM_CheckParm("-playback"))
816 if (com_argc != 2)
817 Sys_Error("No other parameters allowed with -playback\n");
819 Sys_FileOpenRead("quake.vcr", &vcrFile);
820 if (vcrFile == -1)
821 Sys_Error("playback file not found\n");
823 Sys_FileRead (vcrFile, &i, sizeof(int));
824 if (i != VCR_SIGNATURE)
825 Sys_Error("Invalid signature in vcr file\n");
827 Sys_FileRead (vcrFile, &com_argc, sizeof(int));
828 com_argv = malloc(com_argc * sizeof(char *));
829 com_argv[0] = parms->argv[0];
830 for (i = 0; i < com_argc; i++)
832 Sys_FileRead (vcrFile, &len, sizeof(int));
833 p = malloc(len);
834 Sys_FileRead (vcrFile, p, len);
835 com_argv[i+1] = p;
837 com_argc++; /* add one for arg[0] */
838 parms->argc = com_argc;
839 parms->argv = com_argv;
842 if ( (n = COM_CheckParm("-record")) != 0)
844 vcrFile = Sys_FileOpenWrite("quake.vcr");
846 i = VCR_SIGNATURE;
847 Sys_FileWrite(vcrFile, &i, sizeof(int));
848 i = com_argc - 1;
849 Sys_FileWrite(vcrFile, &i, sizeof(int));
850 for (i = 1; i < com_argc; i++)
852 if (i == n)
854 len = 10;
855 Sys_FileWrite(vcrFile, &len, sizeof(int));
856 Sys_FileWrite(vcrFile, "-playback", len);
857 continue;
859 len = Q_strlen(com_argv[i]) + 1;
860 Sys_FileWrite(vcrFile, &len, sizeof(int));
861 Sys_FileWrite(vcrFile, com_argv[i], len);
868 ====================
869 Host_Init
870 ====================
872 void Host_Init (quakeparms_t *parms)
874 scr_disabled_for_loading = true;
876 if (standard_quake)
877 minimum_memory = MINIMUM_MEMORY;
878 else
879 minimum_memory = MINIMUM_MEMORY_LEVELPAK;
881 if (COM_CheckParm ("-minmemory"))
882 parms->memsize = minimum_memory;
884 host_parms = *parms;
886 if (parms->memsize < minimum_memory)
887 Sys_Error ("Only %4.1f megs of memory available, can't execute game", parms->memsize / (float)0x100000);
889 com_argc = parms->argc;
890 com_argv = parms->argv;
892 Memory_Init (parms->membase, parms->memsize);
893 Cbuf_Init ();
894 Cmd_Init ();
895 V_Init ();
896 Chase_Init ();
897 Host_InitVCR (parms);
898 COM_Init (parms->basedir);
899 Host_InitLocal ();
900 W_LoadWadFile ("gfx.wad");
901 Key_Init ();
902 Con_Init ();
903 M_Init ();
904 PR_Init ();
905 Mod_Init ();
906 NET_Init ();
907 SV_Init ();
909 Con_Printf ("PSP Kurok Engine v 0.4\n"); //(EBOOT: "__TIME__" "__DATE__")\n");
911 int currentCPU = scePowerGetCpuClockFrequency();
912 int currentVRAM = sceGeEdramGetSize();
913 int currentVRAMADD = sceGeEdramGetAddr();
915 #ifdef NORMAL_MODEL
916 Con_Printf ("PSP Normal 32MB RAM Mode \n");
917 #endif
918 #ifdef SLIM_MODEL
919 Con_Printf ("PSP Slim 64MB RAM Mode \n");
920 #endif
922 Con_Printf ("%4.1f megabyte heap \n",parms->memsize/ (1024*1024.0));
923 Con_Printf ("%4.1f PSP application heap \n",1.0f*PSP_HEAP_SIZE_MB);
924 Con_Printf ("%d VRAM \n",currentVRAM);
925 Con_Printf ("%d VRAM Address \n",currentVRAMADD);
927 Con_Printf ("CPU Speed %d MHz\n", currentCPU);
929 R_InitTextures (); // needed even for dedicated servers
931 if (cls.state != ca_dedicated)
933 host_basepal = (byte *)COM_LoadHunkFile ("gfx/palette.lmp");
934 if (!host_basepal)
935 Sys_Error ("Couldn't load gfx/palette.lmp");
936 host_colormap = (byte *)COM_LoadHunkFile ("gfx/colormap.lmp");
937 if (!host_colormap)
938 Sys_Error ("Couldn't load gfx/colormap.lmp");
940 #ifndef WIN32 // on non win32, mouse comes before video for security reasons
941 IN_Init ();
942 #endif
943 VID_Init (host_basepal);
945 Draw_Init ();
946 SCR_Init ();
947 R_Init ();
949 #ifndef WIN32
950 // on Win32, sound initialization has to come before video initialization, so we
951 // can put up a popup if the sound hardware is in use
952 S_Init ();
953 #else
955 #ifdef GLQUAKE
956 // FIXME: doesn't use the new one-window approach yet
957 S_Init ();
958 #endif
960 #endif // WIN32
961 CDAudio_Init ();
962 Sbar_Init ();
963 CL_Init ();
964 #ifdef WIN32 // on non win32, mouse comes before video for security reasons
965 IN_Init ();
966 #endif
969 Cbuf_InsertText ("exec quake.rc\n");
971 Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
972 host_hunklevel = Hunk_LowMark ();
974 host_initialized = true;
976 scr_disabled_for_loading = false;
978 Con_Printf ("Loading ... Please wait ...\n");
980 Sys_Printf ("================ Kurok Initialized ===============\n");
985 ===============
986 Host_Shutdown
988 FIXME: this is a callback from Sys_Quit and Sys_Error. It would be better
989 to run quit through here before the final handoff to the sys code.
990 ===============
992 void Host_Shutdown(void)
994 static qboolean isdown = false;
996 if (isdown)
998 printf ("recursive shutdown\n");
999 return;
1001 isdown = true;
1003 // keep Con_Printf from trying to update the screen
1004 scr_disabled_for_loading = true;
1006 Host_WriteConfiguration ();
1008 CDAudio_Shutdown ();
1009 NET_Shutdown ();
1010 S_Shutdown();
1011 IN_Shutdown ();
1013 if (cls.state != ca_dedicated)
1015 VID_Shutdown();