From bb7c8665e4d6d6cf533f98337fdd3b39c1c29279 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 10 May 2008 21:52:19 +0200 Subject: [PATCH] Start the Empire clock on first break or update Before, the Empire clock started at the epoch, which effectively made it not tick before the first update. --- include/game.h | 1 + src/lib/common/game.c | 20 ++++++++++++++++++-- src/lib/subs/bsanct.c | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/include/game.h b/include/game.h index 8a52509c..b89bac4a 100644 --- a/include/game.h +++ b/include/game.h @@ -57,6 +57,7 @@ struct gamestr { extern void game_ctrl_update(int); extern int updates_disabled(void); +extern void game_note_bsanct(void); extern void game_record_update(time_t); extern struct gamestr *game_tick_tick(void); extern int game_tick_to_now(short *); diff --git a/src/lib/common/game.c b/src/lib/common/game.c index 3c0695f1..8bb24761 100644 --- a/src/lib/common/game.c +++ b/src/lib/common/game.c @@ -71,8 +71,24 @@ updates_disabled(void) return getgamep()->game_upd_disable; } +/* + * Notice that a player broke sanctuary. + * This starts the Empire clock if it hasn't been started yet. + */ +void +game_note_bsanct(void) +{ + struct gamestr *game = getgamep(); + + if (game->game_rt == 0) { + game->game_rt = time(NULL); + putgame(); + } +} + /* * Record an update in the game file, the current time is NOW. + * This starts the Empire clock if it hasn't been started yet. */ void game_record_update(time_t now) @@ -94,8 +110,8 @@ secs_per_etu(struct gamestr *game) { double secs; - if (!update_time[0]) - return HUGE_VAL; /* no update scheduled */ + if (!game->game_rt || !update_time[0]) + return HUGE_VAL; /* not started or no update scheduled */ secs = update_time[0] - game->game_rt; if (secs < 0) diff --git a/src/lib/subs/bsanct.c b/src/lib/subs/bsanct.c index d56b2083..a6bbf33e 100644 --- a/src/lib/subs/bsanct.c +++ b/src/lib/subs/bsanct.c @@ -69,6 +69,8 @@ bsanct(void) (void)putsect(&s); count++; } - if (count > 0) + if (count > 0) { + game_note_bsanct(); nreport(player->cnum, N_BROKE_SANCT, 0, 1); + } }