From 48252705b85158f07d58911a75a0c9b0f2d5c918 Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 25 Aug 2021 14:49:58 -0700 Subject: [PATCH] less elapsed time: ! and ^Z Suppress any time spent in a sub-shell or in the background when accumulating total elapsed play time. This won't help for leaving the game idle instead of saving and restoring. That's a can of worms I'd prefer to leave sealed. --- doc/fixes37.0 | 4 +++- src/cmd.c | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 1e2790bf1..cf6be7bc8 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.629 $ $NHDT-Date: 1629817676 2021/08/24 15:07:56 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.630 $ $NHDT-Date: 1629928191 2021/08/25 21:49:51 $ General Fixes and Modified Features ----------------------------------- @@ -594,6 +594,8 @@ concealed mimic could trigger sanity check warning "mimic concealed as an object despite Prot-from-shape-changers" if hidden as "strange object" cancelled shape changer would become uncancelled if saved and restored (even just leaving its level and then returning) +don't include time spent suspended in background (^Z) or in shell escape (!) + in the total elapsed time recorded to xlogfile Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/cmd.c b/src/cmd.c index bc872135d..4cd891308 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1627408993 2021/07/27 18:03:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.481 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1629928192 2021/08/25 21:49:52 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.483 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4841,8 +4841,13 @@ dosuspend_core(void) #ifdef SUSPEND /* Does current window system support suspend? */ if ((*windowprocs.win_can_suspend)()) { + time_t now = getnow(); + + urealtime.realtime += timet_delta(now, urealtime.start_timing); + urealtime.start_timing = now; /* as a safeguard against panic save */ /* NB: SYSCF SHELLERS handled in port code. */ dosuspend(); + urealtime.start_timing = getnow(); /* resume keeping track of time */ } else #endif Norep(cmdnotavail, "#suspend"); @@ -4854,8 +4859,13 @@ static int dosh_core(void) { #ifdef SHELL + time_t now = getnow(); + + urealtime.realtime += timet_delta(now, urealtime.start_timing); + urealtime.start_timing = now; /* (see dosuspend_core) */ /* access restrictions, if any, are handled in port code */ dosh(); + urealtime.start_timing = getnow(); #else Norep(cmdnotavail, "#shell"); #endif