2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * fileinit.c: Initialize Empire tables for full server operations.
29 * Known contributors to this file:
30 * Ron Koenderink, 2005
31 * Markus Armbruster, 2005-2008
39 #include "prototypes.h"
44 void (*oninit)(void *);
45 void (*postread)(int, void *);
46 void (*prewrite)(int, void *, void *);
47 void (*onresize)(int);
50 static struct fileinit fileinit[] = {
51 {EF_SECTOR, NULL, sct_postread, sct_prewrite, NULL},
52 {EF_SHIP, NULL, shp_postread, shp_prewrite, unit_onresize},
53 {EF_PLANE, pln_oninit, pln_postread, pln_prewrite, unit_onresize},
54 {EF_LAND, lnd_oninit, lnd_postread, lnd_prewrite, unit_onresize},
55 {EF_NUKE, nuk_oninit, nuk_postread, nuk_prewrite, unit_onresize}
58 static void ef_open_srv(void);
59 static void ef_close_srv(void);
62 * Initialize empfile for full server operations.
69 for (i = 0; i < sizeof(fileinit) / sizeof(fileinit[0]); i++) {
70 empfile[fileinit[i].ef_type].oninit = fileinit[i].oninit;
71 empfile[fileinit[i].ef_type].postread = fileinit[i].postread;
72 empfile[fileinit[i].ef_type].prewrite = fileinit[i].prewrite;
73 empfile[fileinit[i].ef_type].onresize = fileinit[i].onresize;
95 failed |= !ef_open(EF_NATION, EFF_MEM, MAXNOC);
96 failed |= !ef_open(EF_SECTOR, EFF_MEM, WORLD_SZ());
97 failed |= !ef_open(EF_SHIP, EFF_MEM, -1);
98 failed |= !ef_open(EF_PLANE, EFF_MEM, -1);
99 failed |= !ef_open(EF_LAND, EFF_MEM, -1);
100 failed |= !ef_open(EF_GAME, EFF_MEM, 1);
101 failed |= !ef_open(EF_NEWS, 0, -1);
102 failed |= !ef_open(EF_LOAN, 0, -1);
103 failed |= !ef_open(EF_TREATY, 0, -1);
104 failed |= !ef_open(EF_NUKE, EFF_MEM, -1);
105 failed |= !ef_open(EF_POWER, 0, -1);
106 failed |= !ef_open(EF_TRADE, 0, -1);
107 failed |= !ef_open(EF_MAP, EFF_MEM, MAXNOC);
108 failed |= !ef_open(EF_BMAP, EFF_MEM, MAXNOC);
109 failed |= !ef_open(EF_COMM, 0, -1);
110 failed |= !ef_open(EF_LOST, 0, -1);
111 failed |= !ef_open(EF_REALM, EFF_MEM, MAXNOC * MAXNOR);
113 failed |= ef_open_view(EF_COUNTRY, EF_NATION);
115 logerror("Missing files, giving up");
123 ef_close(EF_COUNTRY);