X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=host.c;h=61c9bb0b05502c65d42cd7a612f1b2bb95805f90;hb=d2878a072b9a0399379741b3e19536b7327cb388;hp=89e5dab93e4f1ba2296262eb3a8d4b68850623e0;hpb=4edd84910ac8f236228591507525868ee22aa7e1;p=xonotic%2Fdarkplaces.git diff --git a/host.c b/host.c index 89e5dab9..61c9bb0b 100644 --- a/host.c +++ b/host.c @@ -109,7 +109,7 @@ void Host_EndGame (const char *format, ...) va_start (argptr,format); vsprintf (string,format,argptr); va_end (argptr); - Con_DPrintf ("Host_EndGame: %s\n",string); + Con_DPrintf("Host_EndGame: %s\n",string); if (sv.active) Host_ShutdownServer (false); @@ -144,7 +144,7 @@ void Host_Error (const char *error, ...) vsprintf (hosterrorstring1,error,argptr); va_end (argptr); - Con_Printf ("Host_Error: %s\n", hosterrorstring1); + Con_Printf("Host_Error: %s\n", hosterrorstring1); // LordHavoc: if first frame has not been shown, or currently shutting // down, do Sys_Error instead @@ -312,7 +312,7 @@ void Host_SaveConfig_f(void) f = FS_Open ("config.cfg", "w", false); if (!f) { - Con_Printf ("Couldn't write config.cfg.\n"); + Con_Print("Couldn't write config.cfg.\n"); return; } @@ -324,6 +324,20 @@ void Host_SaveConfig_f(void) } +/* +================= +SV_ClientPrint + +Sends text across to be displayed +FIXME: make this just a stuffed echo? +================= +*/ +void SV_ClientPrint(const char *msg) +{ + MSG_WriteByte(&host_client->message, svc_print); + MSG_WriteString(&host_client->message, msg); +} + /* ================= SV_ClientPrintf @@ -335,45 +349,57 @@ FIXME: make this just a stuffed echo? void SV_ClientPrintf(const char *fmt, ...) { va_list argptr; - char string[1024]; + char msg[4096]; - va_start (argptr,fmt); - vsprintf (string, fmt,argptr); - va_end (argptr); + va_start(argptr,fmt); + vsnprintf(msg,sizeof(msg),fmt,argptr); + va_end(argptr); - MSG_WriteByte (&host_client->message, svc_print); - MSG_WriteString (&host_client->message, string); + SV_ClientPrint(msg); } /* ================= -SV_BroadcastPrintf +SV_BroadcastPrint Sends text to all active clients ================= */ -void SV_BroadcastPrintf(const char *fmt, ...) +void SV_BroadcastPrint(const char *msg) { - va_list argptr; - char string[4096]; int i; client_t *client; - va_start(argptr,fmt); - vsnprintf(string, sizeof(string), fmt,argptr); - va_end(argptr); - for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++) { if (client->spawned) { MSG_WriteByte(&client->message, svc_print); - MSG_WriteString(&client->message, string); + MSG_WriteString(&client->message, msg); } } if (sv_echobprint.integer && cls.state == ca_dedicated) - Sys_Printf("%s", string); + Sys_Print(msg); +} + +/* +================= +SV_BroadcastPrintf + +Sends text to all active clients +================= +*/ +void SV_BroadcastPrintf(const char *fmt, ...) +{ + va_list argptr; + char msg[4096]; + + va_start(argptr,fmt); + vsnprintf(msg,sizeof(msg),fmt,argptr); + va_end(argptr); + + SV_BroadcastPrint(msg); } /* @@ -525,7 +551,7 @@ not reinitialize anything. */ void Host_ClearMemory (void) { - Con_DPrintf ("Clearing memory\n"); + Con_DPrint("Clearing memory\n"); Mod_ClearAll (); cls.signon = 0; @@ -564,17 +590,20 @@ qboolean Host_FilterTime (double time) // default to sys_ticrate (server framerate - presumably low) unless we // have a good reason to run faster timecap = sys_ticrate.value; - if (cl_avidemo.value >= 0.1f) - timecap = 1.0 / (double)cl_avidemo.value; - else if (vid_activewindow) - timecap = 1.0 / host_maxfps.value; + if (cls.state != ca_dedicated) + { + if (cl_avidemo.value >= 0.1f) + timecap = 1.0 / (double)cl_avidemo.value; + else if (vid_activewindow) + timecap = 1.0 / host_maxfps.value; + } timeleft = oldrealtime + timecap - realtime; if (timeleft > 0) { // don't totally hog the CPU if (timeleft >= 0.02) - Sys_Sleep(); + Sys_Sleep((int)(timeleft * 1000) - 5); return false; } } @@ -754,6 +783,7 @@ void _Host_Frame (float time) if (host_speeds.integer) time1 = Sys_DoubleTime(); + R_UpdateWorld(); CL_UpdateScreen(); if (host_speeds.integer) @@ -820,7 +850,7 @@ void Host_Frame (float time) c++; } - Con_Printf ("serverprofile: %2i clients %2i msec\n", c, m); + Con_Printf("serverprofile: %2i clients %2i msec\n", c, m); } //============================================================================ @@ -834,6 +864,8 @@ Host_Init */ void Host_Init (void) { + int i; + // LordHavoc: quake never seeded the random number generator before... heh srand(time(NULL)); @@ -860,7 +892,7 @@ void Host_Init (void) NetConn_Init(); SV_Init(); - Con_Printf ("Builddate: %s\n", buildstring); + Con_Printf("Builddate: %s\n", buildstring); if (cls.state != ca_dedicated) { @@ -875,12 +907,15 @@ void Host_Init (void) } // only cvars are executed when host_initialized == false - Cbuf_InsertText("exec quake.rc\n"); + if (gamemode == GAME_TEU) + Cbuf_InsertText("exec teu.rc\n"); + else + Cbuf_InsertText("exec quake.rc\n"); Cbuf_Execute(); host_initialized = true; - Con_DPrintf ("========Initialized=========\n"); + Con_DPrint("========Initialized=========\n"); if (cls.state != ca_dedicated) { @@ -891,7 +926,16 @@ void Host_Init (void) // stuff it again so the first host frame will execute it again, this time // in its entirety - Cbuf_InsertText("exec quake.rc\n"); + if (gamemode == GAME_TEU) + Cbuf_InsertText("exec teu.rc\n"); + else + Cbuf_InsertText("exec quake.rc\n"); + + // check for special benchmark mode + i = COM_CheckParm("-benchmark"); + if (i && i + 1 < com_argc) + Cbuf_InsertText(va("timedemo %s\n", com_argv[i + 1])); + Cbuf_Execute(); } @@ -910,7 +954,7 @@ void Host_Shutdown(void) if (isdown) { - Con_Printf ("recursive shutdown\n"); + Con_Print("recursive shutdown\n"); return; } isdown = true;