Store game down flag in the game table
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.
This commit is contained in:
parent
f1d89514a5
commit
fe9f02ccfb
5 changed files with 36 additions and 2 deletions
|
@ -44,6 +44,7 @@ struct gamestr {
|
||||||
time_t game_timestamp;
|
time_t game_timestamp;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
char game_upd_disable; /* updates disabled? */
|
char game_upd_disable; /* updates disabled? */
|
||||||
|
char game_down; /* playing disabled? */
|
||||||
/*
|
/*
|
||||||
* The Empire clock.
|
* The Empire clock.
|
||||||
* Access it through game_tick_tick(), or else it'll be late.
|
* Access it through game_tick_tick(), or else it'll be late.
|
||||||
|
@ -58,6 +59,8 @@ struct gamestr {
|
||||||
|
|
||||||
extern void game_ctrl_update(int);
|
extern void game_ctrl_update(int);
|
||||||
extern int updates_disabled(void);
|
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_note_bsanct(void);
|
||||||
extern void game_record_update(time_t);
|
extern void game_record_update(time_t);
|
||||||
extern struct gamestr *game_tick_tick(void);
|
extern struct gamestr *game_tick_tick(void);
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "game.h"
|
||||||
#include "tel.h"
|
#include "tel.h"
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "optlist.h"
|
||||||
|
@ -64,6 +65,7 @@ turn(void)
|
||||||
logerror("Could not remove no-login file (%s).\n", downfil);
|
logerror("Could not remove no-login file (%s).\n", downfil);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
game_ctrl_play(1);
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
} else {
|
} else {
|
||||||
msgfilepath = motdfil;
|
msgfilepath = motdfil;
|
||||||
|
@ -122,5 +124,6 @@ turn(void)
|
||||||
|
|
||||||
pr("\n");
|
pr("\n");
|
||||||
|
|
||||||
|
game_ctrl_play(0);
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disable updates
|
* Enable / disable updates
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
game_ctrl_update(int enable)
|
game_ctrl_update(int enable)
|
||||||
|
@ -71,6 +71,27 @@ updates_disabled(void)
|
||||||
return getgamep()->game_upd_disable;
|
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.
|
* Notice that a player broke sanctuary.
|
||||||
* This starts the Empire clock if it hasn't been started yet.
|
* This starts the Empire clock if it hasn't been started yet.
|
||||||
|
|
|
@ -619,6 +619,7 @@ struct castr game_ca[] = {
|
||||||
EF_BAD, NSC_EXTRA},
|
EF_BAD, NSC_EXTRA},
|
||||||
{"upd_disable", fldoff(game_upd_disable), NSC_CHAR, 0, NULL,
|
{"upd_disable", fldoff(game_upd_disable), NSC_CHAR, 0, NULL,
|
||||||
EF_BAD, 0},
|
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},
|
{"turn", fldoff(game_turn), NSC_SHORT, 0, NULL, EF_BAD, 0},
|
||||||
{"tick", fldoff(game_tick), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
|
{"tick", fldoff(game_tick), NSC_SHORT, 0, NULL, EF_BAD, NSC_DEITY},
|
||||||
{"rt", fldoff(game_rt), NSC_TIME, 0, NULL, EF_BAD, NSC_DEITY},
|
{"rt", fldoff(game_rt), NSC_TIME, 0, NULL, EF_BAD, NSC_DEITY},
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "com.h"
|
#include "com.h"
|
||||||
#include "empio.h"
|
#include "empio.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
|
#include "game.h"
|
||||||
#include "match.h"
|
#include "match.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
|
@ -187,8 +188,13 @@ gamedown(int suppress_deity_message)
|
||||||
struct telstr tgm;
|
struct telstr tgm;
|
||||||
char buf[MAXTELSIZE + 1]; /* UTF-8 */
|
char buf[MAXTELSIZE + 1]; /* UTF-8 */
|
||||||
|
|
||||||
if ((down_fp = fopen(downfil, "rb")) == NULL)
|
if (!game_play_disabled())
|
||||||
return 0;
|
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) {
|
if (fread(&tgm, sizeof(tgm), 1, down_fp) != 1) {
|
||||||
logerror("bad header on login message (downfil)");
|
logerror("bad header on login message (downfil)");
|
||||||
fclose(down_fp);
|
fclose(down_fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue