Store update disable flag in the game table to make it visible in
xdump: (gamestr): New member game_upd_disable. (game_ca): Update accordingly. (game_ctrl_update): New. (disa, enab): Use it. (updates_disabled): Rewrite and move to game.c (disablefil): Remove.
This commit is contained in:
parent
e7e8717e86
commit
286dda725e
8 changed files with 31 additions and 34 deletions
|
@ -40,6 +40,7 @@ struct gamestr {
|
||||||
/* initial part must match struct empobj */
|
/* initial part must match struct empobj */
|
||||||
short ef_type;
|
short ef_type;
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
|
char game_upd_disable; /* updates 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.
|
||||||
|
@ -52,6 +53,8 @@ struct gamestr {
|
||||||
#define putgame() ef_write(EF_GAME, 0, ef_ptr(EF_GAME, 0))
|
#define putgame() ef_write(EF_GAME, 0, ef_ptr(EF_GAME, 0))
|
||||||
#define getgamep() ((struct gamestr *)ef_ptr(EF_GAME, 0))
|
#define getgamep() ((struct gamestr *)ef_ptr(EF_GAME, 0))
|
||||||
|
|
||||||
|
extern void game_ctrl_update(int);
|
||||||
|
extern int updates_disabled(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);
|
||||||
extern int game_tick_to_now(short *);
|
extern int game_tick_to_now(short *);
|
||||||
|
|
|
@ -49,7 +49,6 @@ extern char *schedulefil;
|
||||||
|
|
||||||
extern char motdfil[];
|
extern char motdfil[];
|
||||||
extern char downfil[];
|
extern char downfil[];
|
||||||
extern char disablefil[];
|
|
||||||
extern char annfil[];
|
extern char annfil[];
|
||||||
extern char teldir[];
|
extern char teldir[];
|
||||||
extern char telfil[];
|
extern char telfil[];
|
||||||
|
|
|
@ -346,7 +346,6 @@ extern int sct_typematch(char *);
|
||||||
extern int demand_update_want(int *, int *, int);
|
extern int demand_update_want(int *, int *, int);
|
||||||
extern int demand_check(void);
|
extern int demand_check(void);
|
||||||
extern int demandupdatecheck(void);
|
extern int demandupdatecheck(void);
|
||||||
extern int updates_disabled(void);
|
|
||||||
/* xundump.c */
|
/* xundump.c */
|
||||||
extern int xundump(FILE *, char *, int);
|
extern int xundump(FILE *, char *, int);
|
||||||
|
|
||||||
|
|
|
@ -33,25 +33,13 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "game.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
disa(void)
|
disa(void)
|
||||||
{
|
{
|
||||||
int fd;
|
game_ctrl_update(0);
|
||||||
|
|
||||||
if ((fd = open(disablefil, O_RDWR | O_CREAT | O_TRUNC, S_IRWUG)) < 0)
|
|
||||||
return RET_FAIL;
|
|
||||||
close(fd);
|
|
||||||
pr("Updates are disabled\n");
|
pr("Updates are disabled\n");
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,13 @@
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
|
||||||
#include <unistd.h>
|
|
||||||
#elif defined(__GNUC__)
|
|
||||||
#include <io.h>
|
|
||||||
#endif
|
|
||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#include "optlist.h"
|
#include "game.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
enab(void)
|
enab(void)
|
||||||
{
|
{
|
||||||
(void)unlink(disablefil);
|
game_ctrl_update(1);
|
||||||
pr("Updates are enabled\n");
|
pr("Updates are enabled\n");
|
||||||
return RET_OK;
|
return RET_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,27 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Record an update in the game file, the current time is NOW.
|
* Record an update in the game file, the current time is NOW.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -116,14 +116,3 @@ demandupdatecheck(void)
|
||||||
&& demand_update_time(&now)
|
&& demand_update_time(&now)
|
||||||
&& demand_check();
|
&& demand_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
updates_disabled(void)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if ((fd = open(disablefil, O_RDONLY, 0)) < 0)
|
|
||||||
return 0;
|
|
||||||
close(fd);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -546,6 +546,9 @@ struct castr realm_ca[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct castr game_ca[] = {
|
struct castr game_ca[] = {
|
||||||
|
/* no need for uid */
|
||||||
|
{NSC_CHAR, 0, 0, offsetof(struct gamestr, game_upd_disable),
|
||||||
|
"upd_disable", EF_BAD},
|
||||||
{NSC_SHORT, 0, 0, offsetof(struct gamestr, game_turn), "turn", EF_BAD},
|
{NSC_SHORT, 0, 0, offsetof(struct gamestr, game_turn), "turn", EF_BAD},
|
||||||
{NSC_SHORT, NSC_DEITY, 0, offsetof(struct gamestr, game_tick), "tick",
|
{NSC_SHORT, NSC_DEITY, 0, offsetof(struct gamestr, game_tick), "tick",
|
||||||
EF_BAD},
|
EF_BAD},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue