From 3c0ad2ca71122e0acfa67fd32643b808cbf84910 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sun, 11 Jul 2021 08:18:02 +0900 Subject: [PATCH] [qw] Fix some server status output issues The uptime display had not been updated for the offset Sys_DoubleTime, so add Sys_DoubleTimeBase to make it easy to use Sys_DoubleTime as uptime. Line up the layout of the client list was not consistent for drop and qport. --- include/QF/sys.h | 1 + libs/util/sys.c | 6 ++++++ qw/source/sv_ccmds.c | 7 ++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/QF/sys.h b/include/QF/sys.h index e1ed1a057..00dc40a92 100644 --- a/include/QF/sys.h +++ b/include/QF/sys.h @@ -80,6 +80,7 @@ void Sys_Shutdown (void); void Sys_RegisterShutdown (void (*func) (void *), void *data); int64_t Sys_LongTime (void); double Sys_DoubleTime (void); +double Sys_DoubleTimeBase (void); void Sys_TimeOfDay(date_t *date); void Sys_MaskPrintf (int mask, const char *fmt, ...) __attribute__((format(PRINTF,2,3))); diff --git a/libs/util/sys.c b/libs/util/sys.c index 87241a8c1..c0619bfdc 100644 --- a/libs/util/sys.c +++ b/libs/util/sys.c @@ -412,6 +412,12 @@ Sys_DoubleTime (void) return (__INT64_C (4294967296000000) + Sys_LongTime ()) / 1e6; } +VISIBLE double +Sys_DoubleTimeBase (void) +{ + return __INT64_C (4294967296000000) / 1e6; +} + VISIBLE void Sys_TimeOfDay (date_t *date) { diff --git a/qw/source/sv_ccmds.c b/qw/source/sv_ccmds.c index 22604df69..4297bf9cc 100644 --- a/qw/source/sv_ccmds.c +++ b/qw/source/sv_ccmds.c @@ -390,7 +390,7 @@ SV_Current_Map (void) } static const char * -nice_time (float time) +nice_time (double time) { int t = time + 0.5; @@ -529,7 +529,8 @@ 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 ("uptime : %s\n", + nice_time (Sys_DoubleTime () - Sys_DoubleTimeBase ())); 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); @@ -602,7 +603,7 @@ SV_Status_f (void) SV_Printf ("SERVER %d\n", cl->ping); continue; } - SV_Printf ("%4i %4i %3.1f %4i", + SV_Printf ("%4i %4i %4.1f%% %5i", (int) (1000 * cl->netchan.frame_rate), (int) SV_CalcPing (cl), 100.0 * cl->netchan.drop_count /