]> git.pond.sub.org Git - empserver/commitdiff
Store update disable flag in the game table to make it visible in
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 27 Jul 2007 05:58:40 +0000 (05:58 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 27 Jul 2007 05:58:40 +0000 (05:58 +0000)
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.

include/game.h
include/optlist.h
include/prototypes.h
src/lib/commands/disa.c
src/lib/commands/enab.c
src/lib/common/game.c
src/lib/common/wantupd.c
src/lib/global/nsc.c

index 1a5f1f3678cb5295801156f936b4fc730e566f9a..4f78585b6378600eb15443144755a2bb93472e3b 100644 (file)
@@ -40,6 +40,7 @@ struct gamestr {
     /* 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.
@@ -52,6 +53,8 @@ struct gamestr {
 #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 *);
index dcf0031482ec397e5b18fa961bc2b7cb58b50c75..0b8c396ee4a28f15efc1ebedacf3ae9074ff3c01 100644 (file)
@@ -49,7 +49,6 @@ extern char *schedulefil;
 
 extern char motdfil[];
 extern char downfil[];
-extern char disablefil[];
 extern char annfil[];
 extern char teldir[];
 extern char telfil[];
index 4a381ba053c24b1f1a2ab8ec6ab7b00d5f2265cd..44aa78431f99a19975d13d4b71e1a28c66b3981c 100644 (file)
@@ -346,7 +346,6 @@ extern int sct_typematch(char *);
 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);
 
index ca2534d5786d620116296167bc107941c75463a7..663160002c1bf42486e357efd64aeca24633c6d0 100644 (file)
 
 #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;
 }
index 2579fd9d36e7a9884bd1aff76ed26856968665f2..9dd59f8ae8bb87d142e83de01e3dc918730cff6b 100644 (file)
 
 #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;
 }
index 25dcea036ffc2b39b69ff07f91f411a7ff8e60ed..121b56c2a8c72005796148720a4fd9fb649928f7 100644 (file)
 #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.
  */
index f58fedec8c85d9f68bbaeee7d86851437f78baad..30b0e634b87a3294ae402c59324884fc9a51e77f 100644 (file)
@@ -116,14 +116,3 @@ demandupdatecheck(void)
        && 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;
-}
index 8a58a4cd955699e707f9d7ffb9e271e6972907aa..eb68eae930f5f61442c53b32d8ed5407c56b5145 100644 (file)
@@ -546,6 +546,9 @@ struct castr realm_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, NSC_DEITY, 0, offsetof(struct gamestr, game_tick), "tick",
      EF_BAD},