/* initial part must match struct empobj */
short ef_type;
/* end of part matching struct empobj */
+ char game_upd_disable; /* updates disabled? */
/*
* The Empire clock.
* Access it through game_tick_tick(), or else it'll be late.
#define putgame() ef_write(EF_GAME, 0, 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 struct gamestr *game_tick_tick(void);
extern int game_tick_to_now(short *);
extern char motdfil[];
extern char downfil[];
-extern char disablefil[];
extern char annfil[];
extern char teldir[];
extern char telfil[];
extern int demand_update_want(int *, int *, int);
extern int demand_check(void);
extern int demandupdatecheck(void);
-extern int updates_disabled(void);
/* xundump.c */
extern int xundump(FILE *, char *, int);
#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 "optlist.h"
+#include "game.h"
int
disa(void)
{
- int fd;
-
- if ((fd = open(disablefil, O_RDWR | O_CREAT | O_TRUNC, S_IRWUG)) < 0)
- return RET_FAIL;
- close(fd);
+ game_ctrl_update(0);
pr("Updates are disabled\n");
return RET_OK;
}
#include <config.h>
-#if !defined(_WIN32)
-#include <unistd.h>
-#elif defined(__GNUC__)
-#include <io.h>
-#endif
#include "commands.h"
-#include "optlist.h"
+#include "game.h"
int
enab(void)
{
- (void)unlink(disablefil);
+ game_ctrl_update(1);
pr("Updates are enabled\n");
return RET_OK;
}
#include "prototypes.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.
*/
&& demand_update_time(&now)
&& demand_check();
}
-
-int
-updates_disabled(void)
-{
- int fd;
-
- if ((fd = open(disablefil, O_RDONLY, 0)) < 0)
- return 0;
- close(fd);
- return 1;
-}
};
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, NSC_DEITY, 0, offsetof(struct gamestr, game_tick), "tick",
EF_BAD},