]> git.pond.sub.org Git - empserver/blobdiff - src/lib/common/game.c
Update known contributors comments
[empserver] / src / lib / common / game.c
index 25dcea036ffc2b39b69ff07f91f411a7ff8e60ed..5a4f4c11382d0e52c524f4899446478553327b84 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -26,9 +26,9 @@
  *  ---
  *
  *  game.c: Game file access
- * 
+ *
  *  Known contributors to this file:
- *     Markus Armbruster, 2007
+ *     Markus Armbruster, 2007-2009
  */
 
 /*
 #include "prototypes.h"
 #include "server.h"
 
+/*
+ * Enable / disable updates
+ */
+void
+game_ctrl_update(int enable)
+{
+    struct gamestr *game = getgamep();
+
+    game->game_upd_disable = !enable;
+    putgame();
+}
+
+/*
+ * Are updates disabled?
+ */
+int
+updates_disabled(void)
+{
+    return getgamep()->game_upd_disable;
+}
+
+/*
+ * Enable / disable play
+ */
+void
+game_ctrl_play(int enable)
+{
+    struct gamestr *game = getgamep();
+
+    game->game_down = !enable;
+    putgame();
+}
+
+/*
+ * Is playing enabled?
+ */
+int
+game_play_disabled(void)
+{
+    return getgamep()->game_down;
+}
+
+/*
+ * 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)
@@ -73,8 +131,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)