]> git.pond.sub.org Git - empserver/commitdiff
Start the Empire clock on first break or update
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 10 May 2008 19:52:19 +0000 (21:52 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 10 May 2008 19:52:19 +0000 (21:52 +0200)
Before, the Empire clock started at the epoch, which effectively made
it not tick before the first update.

include/game.h
src/lib/common/game.c
src/lib/subs/bsanct.c

index 8a52509c5313f4a848b2d1ab84149d523fd06c18..b89bac4afbbce8a5541c28f012ab77d6794f14eb 100644 (file)
@@ -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 *);
index 3c0695f1ed5ec72037fae01c4cb771f84efa7f2c..8bb24761e6d56bff8807f90a15a1a6322cae2f1f 100644 (file)
@@ -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)
index d56b20832e3f7bd93da217253dcdecce59d47d86..a6bbf33e5dc4dc5a72b1d6896633337d5b220d9b 100644 (file)
@@ -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);
+    }
 }