]> git.pond.sub.org Git - empserver/commitdiff
New Empire table game, to be used for global stuff:
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jul 2007 14:49:58 +0000 (14:49 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 14 Jul 2007 14:49:58 +0000 (14:49 +0000)
(gamestr, EF_GAME, game_ca): New.
(empfile): Declare the table.
(ef_open_srv, ef_close_srv): Open and close it.
(main): Create it.
(empobj_storage): New member game.

(EF_DYNMAX): New.
(EF_IS_GAME_STATE): Use it.

include/empobj.h
include/file.h
include/game.h [new file with mode: 0644]
include/nsc.h
include/types.h
src/lib/global/file.c
src/lib/global/nsc.c
src/lib/subs/fileinit.c
src/util/files.c

index d84da0c6348ed66ea82d4d1614c5806555f4da4a..785926ed4322019c17041e5ae64d88ab31590096 100644 (file)
@@ -36,6 +36,7 @@
 #define EMPOBJ_H
 
 #include "commodity.h"
 #define EMPOBJ_H
 
 #include "commodity.h"
+#include "game.h"
 #include "land.h"
 #include "loan.h"
 #include "lost.h"
 #include "land.h"
 #include "loan.h"
 #include "lost.h"
@@ -70,6 +71,7 @@ union empobj_storage {
     short ef_type;
     struct empobj gen;
     struct comstr comm;
     short ef_type;
     struct empobj gen;
     struct comstr comm;
+    struct gamestr game;
     struct lndstr land;
     struct lonstr loan;
     struct loststr lost;
     struct lndstr land;
     struct lonstr loan;
     struct loststr lost;
index 7e9b362c8c2c3a614e9ee12cc6cc3983d29e6547..3011a13f87443d42b7f2271b37f37df824135f74 100644 (file)
@@ -116,6 +116,8 @@ enum {
     EF_COMM,
     EF_LOST,
     EF_REALM,
     EF_COMM,
     EF_LOST,
     EF_REALM,
+    EF_GAME,
+    EF_DYNMAX = EF_GAME,
     /* Static game data (configuration) */
     /* Order is relevant; see read_builtin_tables() */
     EF_ITEM,
     /* Static game data (configuration) */
     /* Order is relevant; see read_builtin_tables() */
     EF_ITEM,
@@ -157,7 +159,7 @@ enum {
     EF_MAX
 };
 
     EF_MAX
 };
 
-#define EF_IS_GAME_STATE(type) (EF_SECTOR <= (type) && (type) <= EF_REALM)
+#define EF_IS_GAME_STATE(type) (EF_SECTOR <= (type) && (type) <= EF_DYNMAX)
 #define EF_IS_VIEW(type) (EF_COUNTRY <= (type) && (type) < EF_MAX)
 
 extern struct castr *ef_cadef(int);
 #define EF_IS_VIEW(type) (EF_COUNTRY <= (type) && (type) < EF_MAX)
 
 extern struct castr *ef_cadef(int);
diff --git a/include/game.h b/include/game.h
new file mode 100644 (file)
index 0000000..c49258e
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  Empire - A multi-player, client/server Internet based war game.
+ *  Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                           Ken Stevens, Steve McClure
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  ---
+ *
+ *  See files README, COPYING and CREDITS in the root of the source
+ *  tree for related information and legal notices.  It is expected
+ *  that future projects/authors will amend these files as needed.
+ *
+ *  ---
+ *
+ *  game.h: The game file
+ * 
+ *  Known contributors to this file:
+ *       Markus Armbruster, 2007
+ */
+
+#ifndef GAME_H
+#define GAME_H
+
+struct gamestr {
+    /* initial part must match struct empobj */
+    short ef_type;
+    /* end of part matching struct empobj */
+};
+
+#define putgame() ef_write(EF_GAME, 0, ef_ptr(EF_GAME, 0))
+#define getgamep() ((struct gamestr *)ef_ptr(EF_GAME, 0))
+
+#endif
index c666f27f7917b71c2338cb65ac5249ac4941828a..5ba06a9bba7cae971ec27c8ae9efa91f58dd992d 100644 (file)
@@ -216,6 +216,7 @@ extern struct castr trade_ca[];
 extern struct castr nat_ca[];
 extern struct castr cou_ca[];
 extern struct castr realm_ca[];
 extern struct castr nat_ca[];
 extern struct castr cou_ca[];
 extern struct castr realm_ca[];
+extern struct castr game_ca[];
 extern struct castr intrchr_ca[];
 extern struct castr rpt_ca[];
 extern struct castr empfile_ca[];
 extern struct castr intrchr_ca[];
 extern struct castr rpt_ca[];
 extern struct castr empfile_ca[];
index b76e75ab8b178f996d66af7eae33c6a562f0c476..04d6f5b855c802e1e9702a6489bc7df1c918822b 100644 (file)
@@ -40,6 +40,7 @@ typedef short coord;
 struct bp;
 struct emp_qelem;
 struct empobj;
 struct bp;
 struct emp_qelem;
 struct empobj;
+struct gamestr;
 struct lndstr;
 struct lndstr;
 struct lonstr;
 struct lndstr;
 struct lndstr;
 struct lonstr;
index 530fbff2d0d43361e1cba870093093aa7ecc4dd7..9f91ebb7b40b0b19a0c14a10491cca803a6b5a1c 100644 (file)
@@ -36,6 +36,7 @@
 #include <stddef.h>
 #include "commodity.h"
 #include "file.h"
 #include <stddef.h>
 #include "commodity.h"
 #include "file.h"
+#include "game.h"
 #include "land.h"
 #include "loan.h"
 #include "lost.h"
 #include "land.h"
 #include "loan.h"
 #include "lost.h"
@@ -139,6 +140,8 @@ struct empfile empfile[] = {
      UNMAPPED_CACHE(struct loststr, EFF_OWNER)},
     {EF_REALM, "realm", "realms", realm_ca,
      UNMAPPED_CACHE(struct realmstr, EFF_OWNER)},
      UNMAPPED_CACHE(struct loststr, EFF_OWNER)},
     {EF_REALM, "realm", "realms", realm_ca,
      UNMAPPED_CACHE(struct realmstr, EFF_OWNER)},
+    {EF_GAME, "game", "game", game_ca,
+     UNMAPPED_CACHE(struct gamestr, 0)},
 
     /* Static game data (configuration) */
     {EF_ITEM, "item", "item.config", ichr_ca,
 
     /* Static game data (configuration) */
     {EF_ITEM, "item", "item.config", ichr_ca,
index 9382d571b5d26daa61a28e90e49a6df5594175f7..a1acdacf5fcb8141187a102f3c21909b71c9f657 100644 (file)
@@ -544,6 +544,10 @@ struct castr realm_ca[] = {
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
     {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
 };
 
+struct castr game_ca[] = {
+    {NSC_NOTYPE, 0, 0, 0, NULL, EF_BAD}
+};
+
 struct castr intrchr_ca[] = {
     /* no need for uid as long as it's not referenced from other tables */
     {NSC_STRING, NSC_CONST, 0, offsetof(struct sctintrins, in_name), "name",
 struct castr intrchr_ca[] = {
     /* no need for uid as long as it's not referenced from other tables */
     {NSC_STRING, NSC_CONST, 0, offsetof(struct sctintrins, in_name), "name",
index 0778d6bb7bc16fa94cd8f0c12043c1ba3cd5d6db..aac64c527d612207ea675f5b2f167dc253bf057e 100644 (file)
@@ -104,6 +104,7 @@ ef_open_srv(void)
     failed |= !ef_open(EF_SHIP, EFF_MEM);
     failed |= !ef_open(EF_PLANE, EFF_MEM);
     failed |= !ef_open(EF_LAND, EFF_MEM);
     failed |= !ef_open(EF_SHIP, EFF_MEM);
     failed |= !ef_open(EF_PLANE, EFF_MEM);
     failed |= !ef_open(EF_LAND, EFF_MEM);
+    failed |= !ef_open(EF_GAME, EFF_MEM);
     failed |= !ef_open(EF_NEWS, 0);
     failed |= !ef_open(EF_LOAN, 0);
     failed |= !ef_open(EF_TREATY, 0);
     failed |= !ef_open(EF_NEWS, 0);
     failed |= !ef_open(EF_LOAN, 0);
     failed |= !ef_open(EF_TREATY, 0);
@@ -132,6 +133,7 @@ ef_close_srv(void)
     ef_close(EF_SHIP);
     ef_close(EF_PLANE);
     ef_close(EF_LAND);
     ef_close(EF_SHIP);
     ef_close(EF_PLANE);
     ef_close(EF_LAND);
+    ef_close(EF_GAME);
     ef_close(EF_NEWS);
     ef_close(EF_LOAN);
     ef_close(EF_TREATY);
     ef_close(EF_NEWS);
     ef_close(EF_LOAN);
     ef_close(EF_TREATY);
index 9da0132b39d059ca3be2586bc4f376cbdae4005a..01a44b151581d5f94715c404ae367328e9b107af 100644 (file)
@@ -47,6 +47,7 @@
 #endif
 
 #include "file.h"
 #endif
 
 #include "file.h"
+#include "game.h"
 #include "land.h"
 #include "misc.h"
 #include "nat.h"
 #include "land.h"
 #include "misc.h"
 #include "nat.h"
@@ -82,6 +83,7 @@ main(int argc, char *argv[])
     char buf[255];
     char *filename;
     int x, y;
     char buf[255];
     char *filename;
     int x, y;
+    struct gamestr *game;
     struct natstr nat;
     struct realmstr realm;
     struct sctstr sct;
     struct natstr nat;
     struct realmstr realm;
     struct sctstr sct;
@@ -143,6 +145,10 @@ main(int argc, char *argv[])
            exit(1);
        }
     }
            exit(1);
        }
     }
+    game = getgamep();
+    memset(game, 0, sizeof(*game));
+    game->ef_type = EF_GAME;
+    putgame();
     memset(&nat, 0, sizeof(nat));
     nat.ef_type = EF_NATION;
     strcpy(nat.nat_cnam, "POGO");
     memset(&nat, 0, sizeof(nat));
     nat.ef_type = EF_NATION;
     strcpy(nat.nat_cnam, "POGO");