From 8d736d74241f427e27476a695cc790eecbbc4ed0 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 7 Nov 2002 16:43:05 +0000 Subject: [PATCH] uptime (via status) for qw-server and map time and auto map start for nq-server --- NEWS | 3 +++ nq/source/host.c | 11 +++++++++-- nq/source/host_cmd.c | 19 ++++++++++++++++++- qw/source/sv_ccmds.c | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 2f65c8c47..873ec421d 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ Changes from 0.5.2 * sv_maxrate changes now take effect immediately rather than when clients (re)connect or change their rate * segfault when using "snd_output null" fixed + * qw server "status" command now gives the server's uptime + * "map" will display the amount of time the current map has been active + * nq-server will now auto-load the start map if none is specified o qfcc enhancements. * @argc and @argv deprecated in favor of @args.count and @args.list diff --git a/nq/source/host.c b/nq/source/host.c index d6ef9a009..d71788990 100644 --- a/nq/source/host.c +++ b/nq/source/host.c @@ -993,10 +993,17 @@ Host_Init (void) Con_Printf ("\nVersion %s (build %04d)\n\n", VERSION, build_number ()); - Con_Printf ("\x80\x81\x81\x82 %s Initialized\x80\x81\x81\x82\n", PROGRAM); + Con_Printf ("\x80\x81\x81\x82 %s initialized\x80\x81\x81\x82\n", PROGRAM); CL_UpdateScreen (cl.time); - Con_NewMap (); + if (isDedicated) { + if (!sv.active) + Cmd_ExecuteString ("map start", src_command); + if (!sv.active) + Sys_Error ("Could not initialize server"); + } else { + Con_NewMap (); + } CL_UpdateScreen (cl.time); } diff --git a/nq/source/host_cmd.c b/nq/source/host_cmd.c index afb801d9e..3c1bf7b10 100644 --- a/nq/source/host_cmd.c +++ b/nq/source/host_cmd.c @@ -231,6 +231,23 @@ Host_Ping_f (void) // SERVER TRANSITIONS ========================================================= +static const char * +nice_time (float time) +{ + int t = time + 0.5; + + if (t < 60) { + return va ("%ds", t); + } else if (t < 3600) { + return va ("%dm%02ds", t / 60, t % 60); + } else if (t < 86400) { + return va ("%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60); + } else { + return va ("%dd%02dh%02dm%02ds", + t / 86400, (t / 3600) % 24, (t / 60) % 60, t % 60); + } +} + /* Host_Map_f @@ -254,7 +271,7 @@ Host_Map_f (void) return; } if (Cmd_Argc () == 1) { - Con_Printf ("map is %s\n", sv.name); + Con_Printf ("map is %s (%s)\n", sv.name, nice_time (sv.time)); return; } diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index 55a541688..e635aea23 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -474,6 +474,7 @@ SV_Status_f (void) pak = (float) svs.stats.latched_packets / STATFRAMES; SV_Printf ("net address : %s\n", NET_AdrToString (net_local_adr)); + SV_Printf ("uptime : %s\n", nice_time (Sys_DoubleTime ())); SV_Printf ("cpu utilization : %3i%% (%3i%%)\n", (int) cpu, (int)demo); SV_Printf ("avg response time: %i ms\n", (int) avg); SV_Printf ("packets/frame : %5.2f\n", pak);