/*
* 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
* ---
*
* 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)
{
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)