(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.
#define EMPOBJ_H
#include "commodity.h"
+#include "game.h"
#include "land.h"
#include "loan.h"
#include "lost.h"
short ef_type;
struct empobj gen;
struct comstr comm;
+ struct gamestr game;
struct lndstr land;
struct lonstr loan;
struct loststr lost;
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,
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);
--- /dev/null
+/*
+ * 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
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[];
struct bp;
struct emp_qelem;
struct empobj;
+struct gamestr;
struct lndstr;
struct lndstr;
struct lonstr;
#include <stddef.h>
#include "commodity.h"
#include "file.h"
+#include "game.h"
#include "land.h"
#include "loan.h"
#include "lost.h"
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,
{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",
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);
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);
#endif
#include "file.h"
+#include "game.h"
#include "land.h"
#include "misc.h"
#include "nat.h"
char buf[255];
char *filename;
int x, y;
+ struct gamestr *game;
struct natstr nat;
struct realmstr realm;
struct sctstr sct;
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");