This avoids the silly opening of downfil all the time.
For what it's worth, it also makes the information visible in xdump,
as new game selector down.
time_t game_timestamp;
/* end of part matching struct empobj */
char game_upd_disable; /* updates disabled? */
+ char game_down; /* playing disabled? */
/*
* The Empire clock.
* Access it through game_tick_tick(), or else it'll be late.
extern void game_ctrl_update(int);
extern int updates_disabled(void);
+extern void game_ctrl_play(int);
+extern int game_play_disabled(void);
extern void game_note_bsanct(void);
extern void game_record_update(time_t);
extern struct gamestr *game_tick_tick(void);
#include <errno.h>
#include <unistd.h>
+#include "game.h"
#include "tel.h"
#include "commands.h"
#include "optlist.h"
logerror("Could not remove no-login file (%s).\n", downfil);
return RET_FAIL;
}
+ game_ctrl_play(1);
return RET_OK;
} else {
msgfilepath = motdfil;
pr("\n");
+ game_ctrl_play(0);
return RET_OK;
}
#include "server.h"
/*
- * Disable updates
+ * Enable / disable updates
*/
void
game_ctrl_update(int enable)
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.
EF_BAD, NSC_EXTRA},
{"upd_disable", fldoff(game_upd_disable), NSC_CHAR, 0, NULL,
EF_BAD, 0},
+ {"down", fldoff(game_down), NSC_CHAR, 0, NULL, EF_BAD, 0},
{"turn", fldoff(game_turn), NSC_SHORT, 0, NULL, EF_BAD, 0},
{"tick", fldoff(game_tick), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
{"rt", fldoff(game_rt), NSC_TIME, 0, NULL, EF_BAD, NSC_DEITY},
#include "com.h"
#include "empio.h"
#include "file.h"
+#include "game.h"
#include "match.h"
#include "misc.h"
#include "nat.h"
struct telstr tgm;
char buf[MAXTELSIZE + 1]; /* UTF-8 */
- if ((down_fp = fopen(downfil, "rb")) == NULL)
+ if (!game_play_disabled())
return 0;
+
+ if ((down_fp = fopen(downfil, "rb")) == NULL) {
+ logerror("Could not open downfil.\n");
+ return 1;
+ }
if (fread(&tgm, sizeof(tgm), 1, down_fp) != 1) {
logerror("bad header on login message (downfil)");
fclose(down_fp);