save game id in the data file, not name of XML file

This commit is contained in:
Enno Rehling 2014-07-23 11:54:51 +02:00
parent 51207167c8
commit 2bec7e2bbe
18 changed files with 3573 additions and 3464 deletions

View File

@ -6,11 +6,11 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
rewritePrefix="../server/core/res/" />
rewritePrefix="../../core/res/" />
<rewriteURI
uriStartString="config:///game/"
rewritePrefix="../server/res/eressea/" />
rewritePrefix="../../res/eressea/" />
<rewriteURI
uriStartString="config:///default/"
rewritePrefix="../server/res/" />
rewritePrefix="../../res/" />
</catalog>

View File

@ -97,6 +97,8 @@
<param name="rules.check_overload" value="0"/>
<param name="rules.limit.faction" value="2500"/>
<param name="rules.maxskills.magic" value="5"/>
<param name="game.id" value="2"/>
<param name="game.name" value="Eressea"/>
</game>
<strings>
<string name="mailto">

View File

@ -6,11 +6,11 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
rewritePrefix="../server/core/res/" />
rewritePrefix="../../core/res/" />
<rewriteURI
uriStartString="config:///game/"
rewritePrefix="../server/res/e3a/" />
rewritePrefix="../../res/e3a/" />
<rewriteURI
uriStartString="config:///default/"
rewritePrefix="../server/res/" />
rewritePrefix="../../res/" />
</catalog>

View File

@ -158,6 +158,8 @@
<param name="movement.shipspeed.skillbonus" value="6"/>
<param name="alliance.auto" value="fight"/>
<param name="alliance.restricted" value="fight"/>
<param name="game.id" value="3"/>
<param name="game.name" value="E3"/>
</game>
<rules>
<function name="wage" value="minimum_wage"/>

View File

@ -6,11 +6,11 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
rewritePrefix="../server/core/res/" />
rewritePrefix="../../core/res/" />
<rewriteURI
uriStartString="config:///game/"
rewritePrefix="../server/res/e3a/" />
rewritePrefix="../../res/e3a/" />
<rewriteURI
uriStartString="config:///default/"
rewritePrefix="../server/res/" />
rewritePrefix="../../res/" />
</catalog>

View File

@ -159,6 +159,8 @@
<param name="movement.shipspeed.skillbonus" value="6"/>
<param name="alliance.auto" value="fight"/>
<param name="alliance.restricted" value="fight"/>
<param name="game.id" value="4"/>
<param name="game.name" value="Deveron"/>
</game>
<rules>
<function name="wage" value="minimum_wage"/>

15
conf/eressea.ini Normal file
View File

@ -0,0 +1,15 @@
[eressea]
base = .
report = reports
verbose = 0
lomem = 0
debug = 0
memcheck = 0
locales = de,en
[config]
source_dir = ../server
maxnmrs = 20
[editor]
color = 1

View File

@ -25,7 +25,7 @@ extern int db_update_factions(sqlite3 * db, bool force, int game);
static int tolua_db_update_factions(lua_State * L)
{
sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0);
db_update_factions(db, tolua_toboolean(L, 2, 0), global.game_id);
db_update_factions(db, tolua_toboolean(L, 2, 0), game_id());
return 0;
}

View File

@ -1490,7 +1490,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
fprintf(F, "\"%s\";locale\n", locale_name(f->locale));
fprintf(F, "%d;noskillpoints\n", 1);
fprintf(F, "%ld;date\n", ctx->report_time);
fprintf(F, "\"%s\";Spiel\n", global.gamename);
fprintf(F, "\"%s\";Spiel\n", game_name());
fprintf(F, "\"%s\";Konfiguration\n", "Standard");
fprintf(F, "\"%s\";Koordinaten\n", "Hex");
fprintf(F, "%d;Basis\n", 36);

View File

@ -208,7 +208,8 @@ int HelpMask(void)
tok = strtok(NULL, " ");
}
free(sstr);
} else {
}
else {
rule = HELP_ALL;
}
}
@ -834,14 +835,17 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
if (u->faction == f || omniscient(f)) {
return true;
} else if (fval(u_race(u), RCF_INVISIBLE)) {
}
else if (fval(u_race(u), RCF_INVISIBLE)) {
return false;
} else if (u->number == 0) {
}
else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator);
if (a) { /* u is an empty temporary unit. In this special case
we look at the creating unit. */
u = (unit *)a->data.v;
} else {
}
else {
return false;
}
}
@ -870,7 +874,8 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
if (observation >= stealth) {
return true;
}
} else {
}
else {
return true;
}
}
@ -912,7 +917,8 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
if (o >= n) {
return true;
}
} else {
}
else {
return true;
}
}
@ -1040,12 +1046,14 @@ int count_faction(const faction * f, int flags)
if (flags&COUNT_MONSTERS) {
n += x;
}
} else if (flags&COUNT_MIGRANTS) {
}
else if (flags&COUNT_MIGRANTS) {
if (!is_cursed(u->attribs, C_SLAVE, 0)) {
n += x;
}
}
} else if (flags&COUNT_DEFAULT) {
}
else if (flags&COUNT_DEFAULT) {
n += x;
}
}
@ -1541,10 +1549,12 @@ int lighthouse_range(const building * b, const faction * f)
if (d == maxd)
break;
}
} else if (c)
}
else if (c)
break; /* first unit that's no longer in the house ends the search */
}
} else {
}
else {
/* E3A rule: no perception req'd */
return maxd;
}
@ -1586,10 +1596,12 @@ bool check_leuchtturm(region * r, faction * f)
if (eff_skill(u, SK_PERCEPTION, r) >= d * 3)
return true;
}
} else if (c)
}
else if (c)
break; /* first unit that's no longer in the house ends the search */
}
} else {
}
else {
/* E3A rule: no perception req'd */
return maxd;
}
@ -1706,7 +1718,8 @@ void add_translation(critbit_tree **cbp, const char *key, int i) {
}
len = cb_new_kv(str, len, &i, sizeof(int), buffer);
cb_insert(cb, buffer, len);
} else {
}
else {
log_error("could not transliterate '%s'\n", key);
}
}
@ -2017,7 +2030,8 @@ void setguard(unit * u, unsigned int flags)
if ((int)flags == guard_flags(u)) {
if (a)
a_remove(&u->attribs, a);
} else {
}
else {
if (!a)
a = a_add(&u->attribs, a_new(&at_guard));
a->data.i = (int)flags;
@ -2074,7 +2088,8 @@ void remove_empty_factions(void)
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
} else
}
else
sfp = &(*sfp)->next;
}
for (g = f3->groups; g; g = g->next) {
@ -2084,7 +2099,8 @@ void remove_empty_factions(void)
if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next;
free(sf);
} else
}
else
sfp = &(*sfp)->next;
}
}
@ -2094,7 +2110,8 @@ void remove_empty_factions(void)
funhash(f);
free_faction(f);
free(f);
} else
}
else
fp = &(*fp)->next;
}
}
@ -2268,7 +2285,8 @@ bool hunger(int number, unit * u)
int dam = dice_rand(rcdamage ? rcdamage : damage);
if (dam >= hp) {
++dead;
} else {
}
else {
hpsub += dam;
}
}
@ -2373,7 +2391,8 @@ int cmp_taxes(const building * b, const building * a)
unit *u = building_owner(b);
if (!u) {
return -1;
} else if (a) {
}
else if (a) {
int newsize = buildingeffsize(b, false);
double newtaxes = b->type->taxes(b, newsize);
int oldsize = buildingeffsize(a, false);
@ -2395,7 +2414,8 @@ int cmp_taxes(const building * b, const building * a)
return 1;
}
}
} else {
}
else {
return 1;
}
}
@ -2422,7 +2442,8 @@ int cmp_current_owner(const building * b, const building * a)
if (newsize != oldsize)
return newsize - oldsize;
return (b->size - a->size);
} else {
}
else {
return 1;
}
}
@ -2545,14 +2566,18 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
index = 1;
}
wage = wagetable[esize][index];
} else {
}
else {
if (is_mourning(r, in_turn)) {
wage = 10;
} else if (fval(r->terrain, SEA_REGION)) {
}
else if (fval(r->terrain, SEA_REGION)) {
wage = 11;
} else if (fval(r, RF_ORCIFIED)) {
}
else if (fval(r, RF_ORCIFIED)) {
wage = wagetable[esize][1];
} else {
}
else {
wage = wagetable[esize][2];
}
if (rule_blessed_harvest() == HARVEST_WORK) {
@ -2722,7 +2747,8 @@ bool has_limited_skills(const struct unit * u)
has_skill(u, SK_TACTICS) || has_skill(u, SK_HERBALISM) ||
has_skill(u, SK_SPY)) {
return true;
} else {
}
else {
return false;
}
}
@ -2803,7 +2829,8 @@ order *default_order(const struct locale *lang)
const char * str = locale_string(lang, "defaultorder");
if (str) {
result = defaults[i] = parse_order(str, lang);
} else {
}
else {
usedefault = 0;
}
}
@ -2890,6 +2917,15 @@ void free_gamedata(void)
init_resources();
}
const char * game_name(void) {
const char * param = get_param(global.parameters, "game.name");
return param ? param : global.gamename;
}
int game_id(void) {
return get_param_int(global.parameters, "game.id", global.game_id);
}
void load_inifile(dictionary * d)
{
const char *reportdir = reportpath();
@ -2900,14 +2936,17 @@ void load_inifile(dictionary * d)
assert(d);
str = iniparser_getstring(d, "eressea:base", basedir);
if (str != basedir)
if (str != basedir) {
set_basepath(str);
}
str = iniparser_getstring(d, "eressea:report", reportdir);
if (str != reportdir)
if (str != reportdir) {
set_reportpath(str);
}
str = iniparser_getstring(d, "eressea:data", datadir);
if (str != datadir)
if (str != datadir) {
set_datapath(str);
}
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
@ -2924,5 +2963,7 @@ void load_inifile(dictionary * d)
/* excerpt from [config] (the rest is used in bindings.c) */
global.game_id = iniparser_getint(d, "config:game_id", 0);
if (global.inifile) iniparser_free(global.inifile);
global.inifile = d;
}

View File

@ -100,12 +100,7 @@ extern "C" {
/* ----------------- Befehle ----------------------------------- */
extern const char *parameters[MAXPARAMS];
/** report options **/
#define want(option) (1<<option)
extern const char *options[MAXOPTIONS];
/* ------------------------------------------------------------- */
void add_translation(struct critbit_tree **cb, const char *str, int i);
void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
@ -127,9 +122,6 @@ extern "C" {
#define fset(u, i) ((u)->flags |= (i))
#define freset(u, i) ((u)->flags &= ~(i))
extern int turn;
extern int verbosity;
/* parteinummern */
bool faction_id_is_unused(int);
@ -180,6 +172,8 @@ int max_magicians(const struct faction * f);
bool seefaction(const struct faction *f, const struct region *r,
const struct unit *u, int modifier);
const char * game_name(void);
int game_id(void);
int lovar(double xpct_x2);
/* returns a value between [0..xpct_2], generated with two dice */
@ -193,7 +187,6 @@ int max_magicians(const struct faction * f);
struct unit *createunit(struct region *r, struct faction *f,
int number, const struct race *rc);
void create_unitid(struct unit *u, int id);
extern bool getunitpeasants;
struct unit *getunitg(const struct region *r, const struct faction *f);
struct unit *getunit(const struct region *r, const struct faction *f);
@ -370,8 +363,6 @@ int max_magicians(const struct faction * f);
void kernel_init(void);
void kernel_done(void);
extern const char *localenames[];
/* globale settings des Spieles */
typedef struct settings {
const char *gamename;
@ -391,11 +382,11 @@ int max_magicians(const struct faction * f);
int(*maintenance) (const struct unit * u);
} functions;
} settings;
extern settings global;
extern bool battledebug;
extern bool sqlpatch;
extern bool lomem; /* save memory */
typedef struct helpmode {
const char *name;
int status;
} helpmode;
const char *dbrace(const struct race *rc);
@ -416,12 +407,7 @@ int max_magicians(const struct faction * f);
int entertainmoney(const struct region *r);
void plagues(struct region *r, bool ismagic);
typedef struct helpmode {
const char *name;
int status;
} helpmode;
extern struct helpmode helpmodes[];
void free_gamedata(void);
#define GIVE_SELF 1
#define GIVE_PEASANTS 2
@ -433,7 +419,37 @@ int max_magicians(const struct faction * f);
#define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
extern struct attrib_type at_guard;
void free_gamedata(void);
extern struct helpmode helpmodes[];
extern const char *parameters[];
extern const char *localenames[];
extern settings global;
extern bool battledebug;
extern bool sqlpatch;
extern bool lomem; /* save memory */
extern int turn;
extern int verbosity;
extern bool getunitpeasants;
/** report options **/
extern const char *options[MAXOPTIONS];
extern struct helpmode helpmodes[];
extern const char *parameters[];
extern const char *localenames[];
extern settings global;
extern bool battledebug;
extern bool sqlpatch;
extern bool lomem; /* save memory */
extern int turn;
extern int verbosity;
extern bool getunitpeasants;
/** report options **/
extern const char *options[MAXOPTIONS];
#ifdef __cplusplus
}

View File

@ -87,7 +87,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define MAXPERSISTENT 128
/* exported symbols symbols */
const char *game_name = "eressea";
int firstx = 0, firsty = 0;
int enc_gamedata = ENCODING_UTF8;
@ -142,11 +141,13 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
*ordp = ord->next;
ord->next = NULL;
free_order(ord);
} else {
}
else {
ordp = &ord->next;
}
}
} else {
}
else {
free_orders(&u->orders);
}
u->orders = 0;
@ -183,7 +184,8 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
if (strlen(stok) >= 3) {
quit = true;
break;
} else {
}
else {
quit = false;
}
break;
@ -204,7 +206,8 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
}
}
} else {
}
else {
/* cmistake(?, buf, 160, MSG_EVENT); */
return NULL;
}
@ -234,7 +237,8 @@ static faction *factionorders(void)
* incrementiert wird. */
f->lastorders = global.data_turn + 1;
} else {
}
else {
log_warning("orders for invalid faction %s\n", itoa36(fid));
}
return f;
@ -409,10 +413,12 @@ void read_items(struct storage *store, item ** ilist)
READ_INT(store, &i);
if (i <= 0) {
log_error("data contains an entry with %d %s\n", i, rtype->_name[1]);
} else {
}
else {
if (rtype && rtype->itype) {
i_change(ilist, rtype->itype, i);
} else {
}
else {
log_error("data contains unknown item type %s.\n", ibuf);
}
assert(rtype && rtype->itype);
@ -432,7 +438,8 @@ static void read_alliances(struct storage *store)
terminator = atoi36("end");
READ_STR(store, pbuf, sizeof(pbuf));
id = atoi36(pbuf);
} else {
}
else {
READ_INT(store, &id);
}
while (id != terminator) {
@ -447,7 +454,8 @@ static void read_alliances(struct storage *store)
read_reference(&al->_leader, store, read_faction_reference,
resolve_faction);
READ_INT(store, &id);
} else {
}
else {
READ_STR(store, pbuf, sizeof(pbuf));
id = atoi36(pbuf);
}
@ -514,19 +522,22 @@ static void read_owner(struct gamedata *data, region_owner ** powner)
READ_INT(data->store, &owner->morale_turn);
if (data->version >= MOURNING_VERSION) {
READ_INT(data->store, &owner->flags);
} else {
}
else {
owner->flags = 0;
}
if (data->version >= OWNER_2_VERSION) {
int id;
READ_INT(data->store, &id);
owner->alliance = id ? findalliance(id) : NULL;
} else {
}
else {
owner->alliance = NULL;
}
read_reference(owner, data->store, &read_faction_reference, &resolve_owner);
*powner = owner;
} else {
}
else {
*powner = 0;
}
}
@ -539,7 +550,8 @@ static void write_owner(struct gamedata *data, region_owner * owner)
WRITE_INT(data->store, owner->flags);
WRITE_INT(data->store, owner->alliance ? owner->alliance->id : 0);
write_faction_reference(owner->owner, data->store);
} else {
}
else {
WRITE_INT(data->store, -1);
}
}
@ -600,7 +612,8 @@ unit *read_unit(struct gamedata *data)
u->skills = 0;
u->skill_size = 0;
u_setfaction(u, NULL);
} else {
}
else {
u = calloc(sizeof(unit), 1);
u->no = n;
uhash(u);
@ -613,7 +626,8 @@ unit *read_unit(struct gamedata *data)
}
if (u->faction) {
++u->faction->no_units;
} else {
}
else {
log_error("unit %s has faction == NULL\n", unitname(u));
assert(u->faction);
return 0;
@ -623,7 +637,8 @@ unit *read_unit(struct gamedata *data)
u->name = _strdup(obuf);
if (lomem) {
READ_STR(data->store, NULL, 0);
} else {
}
else {
READ_STR(data->store, obuf, sizeof(obuf));
u->display = _strdup(obuf);
}
@ -654,14 +669,16 @@ unit *read_unit(struct gamedata *data)
} while (*inc);
*outc = 0;
}
} else {
}
else {
READ_TOK(data->store, rname, sizeof(rname));
}
u_setrace(u, rc_find(rname));
if (data->version < STORAGE_VERSION) {
READ_STR(data->store, rname, sizeof(rname));
} else {
}
else {
READ_TOK(data->store, rname, sizeof(rname));
}
if (rname[0] && skill_enabled(SK_STEALTH))
@ -688,7 +705,8 @@ unit *read_unit(struct gamedata *data)
if (fval(u, UFL_OWNER)) {
building_set_owner(u);
}
} else {
}
else {
log_error("read_unit: unit in unkown building '%s'\n", itoa36(n));
}
}
@ -701,7 +719,8 @@ unit *read_unit(struct gamedata *data)
if (fval(u, UFL_OWNER)) {
ship_set_owner(u);
}
} else {
}
else {
log_error("read_unit: unit in unkown ship '%s'\n", itoa36(n));
}
}
@ -729,10 +748,12 @@ unit *read_unit(struct gamedata *data)
*orderp = ord;
orderp = &ord->next;
ord = NULL;
} else if (p == MAXPERSISTENT) {
}
else if (p == MAXPERSISTENT) {
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
}
} else if (n == MAXORDERS) {
}
else if (n == MAXORDERS) {
log_warning("%s had %d or more orders\n", unitname(u), MAXORDERS);
}
if (ord != NULL)
@ -802,7 +823,8 @@ void write_unit(struct gamedata *data, const unit * u)
for (ord = u->old_orders; ord; ord = ord->next) {
if (++p < MAXPERSISTENT) {
writeorder(data, ord, u->faction->locale);
} else {
}
else {
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
break;
}
@ -813,7 +835,8 @@ void write_unit(struct gamedata *data, const unit * u)
if (is_persistent(ord)) {
if (++p < MAXPERSISTENT) {
writeorder(data, ord, u->faction->locale);
} else {
}
else {
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
break;
}
@ -863,7 +886,8 @@ static region *readregion(struct gamedata *data, int x, int y)
if (r == NULL) {
plane *pl = findplane(x, y);
r = new_region(x, y, pl, uid);
} else {
}
else {
assert(uid == 0 || r->uid == uid);
current_region = r;
while (r->attribs)
@ -881,7 +905,8 @@ static region *readregion(struct gamedata *data, int x, int y)
}
if (lomem) {
READ_STR(data->store, NULL, 0);
} else {
}
else {
char info[DISPLAYSIZE];
READ_STR(data->store, info, sizeof(info));
region_setinfo(r, info);
@ -895,7 +920,8 @@ static region *readregion(struct gamedata *data, int x, int y)
log_error("while reading datafile from pre-TERRAIN_VERSION, could not find terrain #%d.\n", ter);
terrain = newterrain(T_PLAIN);
}
} else {
}
else {
char name[64];
READ_STR(data->store, name, sizeof(name));
terrain = get_terrain(name);
@ -975,7 +1001,8 @@ static region *readregion(struct gamedata *data, int x, int y)
const resource_type *rtype = rt_find(token);
assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB));
rsetherbtype(r, rtype->itype);
} else {
}
else {
rsetherbtype(r, NULL);
}
READ_INT(data->store, &n);
@ -1054,7 +1081,8 @@ void writeregion(struct gamedata *data, const region * r)
rht = rherbtype(r);
if (rht) {
WRITE_TOK(data->store, resourcename(rht->rtype, 0));
} else {
}
else {
WRITE_TOK(data->store, "noherb");
}
WRITE_INT(data->store, rherbs(r));
@ -1127,7 +1155,8 @@ int get_spell_level_faction(const spell * sp, void * cbdata)
sbe = spellbook_get(common, sp);
if (sbe) {
return sbe->level;
} else {
}
else {
log_error("read_spellbook: faction '%s' has a spell with unknown level: '%s'", factionname(f), sp->sname);
}
return 0;
@ -1148,7 +1177,8 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
if (bookp) {
sp = find_spellbyid((unsigned int)i);
}
} else {
}
else {
READ_TOK(store, spname, sizeof(spname));
if (strcmp(spname, "end") == 0)
break;
@ -1209,7 +1239,8 @@ faction *readfaction(struct gamedata * data)
if (f == NULL) {
f = (faction *)calloc(1, sizeof(faction));
f->no = n;
} else {
}
else {
f->allies = NULL; /* mem leak */
while (f->attribs)
a_remove(&f->attribs, f->attribs);
@ -1228,14 +1259,16 @@ faction *readfaction(struct gamedata * data)
|| !"non-allied dummy-alliance has more than one member");
}
ql_push(&al->members, f);
} else if (rule_region_owners()) {
}
else if (rule_region_owners()) {
/* compat fix for non-allied factions */
alliance *al = makealliance(0, NULL);
setalliance(f, al);
}
if (data->version >= OWNER_2_VERSION) {
READ_INT(data->store, &f->alliance_joindate);
} else {
}
else {
f->alliance_joindate = turn - 10; /* we're guessing something safe here */
}
}
@ -1323,7 +1356,8 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &state);
sfp = addally(f, sfp, aid, state);
}
} else {
}
else {
for (;;) {
int aid = 0;
if (data->version < STORAGE_VERSION) {
@ -1331,14 +1365,16 @@ faction *readfaction(struct gamedata * data)
if (strcmp(name, "end") != 0) {
aid = atoi36(name);
}
} else {
}
else {
READ_INT(data->store, &aid);
}
if (aid > 0) {
int state;
READ_INT(data->store, &state);
sfp = addally(f, sfp, aid, state);
} else {
}
else {
break;
}
}
@ -1364,7 +1400,8 @@ void writefaction(struct gamedata *data, const faction * f)
assert(f == f->alliance->_leader
|| !"non-allied faction is not leader of its own dummy-alliance.");
}
} else {
}
else {
WRITE_INT(data->store, 0);
}
WRITE_INT(data->store, f->alliance_joindate);
@ -1453,20 +1490,19 @@ int readgame(const char *filename, int backup)
gdata.store = &store;
global.data_version = gdata.version; /* HACK: attribute::read does not have access to gamedata, only storage */
if (gdata.version >= SAVEXMLNAME_VERSION) {
char basefile[1024];
if (gdata.version >= SAVEGAMEID_VERSION) {
int gameid;
READ_STR(&store, basefile, sizeof(basefile));
if (strcmp(game_name, basefile) != 0) {
char buffer[64];
strlcpy(buffer, game_name, sizeof(buffer));
strlcat(buffer, ".xml", sizeof(buffer));
if (strcmp(basefile, buffer) != 0) {
log_warning("game mismatch: datafile contains %s, game is %s\n", basefile, game_name);
printf("WARNING: any key to continue, Ctrl-C to stop\n");
READ_INT(&store, &gameid);
if (gameid != game_id()) {
log_warning("game mismatch: datafile contains game %d, but config is for %d\n", gameid, game_id());
printf("WARNING: invalid game id. any key to continue, Ctrl-C to stop\n");
getchar();
}
}
else if (gdata.version >= SAVEXMLNAME_VERSION) {
char basefile[32];
READ_STR(&store, basefile, sizeof(basefile));
}
a_read(&store, &global.attribs, NULL);
READ_INT(&store, &turn);
@ -1490,7 +1526,8 @@ int readgame(const char *filename, int backup)
if (pl == NULL) {
pl = calloc(1, sizeof(plane));
} else {
}
else {
log_warning("the plane with id=%d already exists.\n", id);
}
pl->id = id;
@ -1510,12 +1547,14 @@ int readgame(const char *filename, int backup)
READ_TOK(&store, rname, sizeof(rname));
if (strcmp(rname, "end") == 0) {
break; /* this is most likely the end of the list */
} else {
}
else {
log_error(
("This datafile contains watchers, but we are unable to read them\n"));
}
}
} else {
}
else {
fno = read_faction_reference(&store);
while (fno.i) {
watcher *w = (watcher *)malloc(sizeof(watcher));
@ -1594,7 +1633,8 @@ int readgame(const char *filename, int backup)
b->name = _strdup(name);
if (lomem) {
READ_STR(gdata.store, NULL, 0);
} else {
}
else {
READ_STR(&store, name, sizeof(name));
b->display = _strdup(name);
}
@ -1623,7 +1663,8 @@ int readgame(const char *filename, int backup)
sh->name = _strdup(name);
if (lomem) {
READ_STR(&store, NULL, 0);
} else {
}
else {
READ_STR(&store, name, sizeof(name));
sh->display = _strdup(name);
}
@ -1713,7 +1754,8 @@ int readgame(const char *filename, int backup)
log_warning("renum(monsters, %d)\n", no);
renumber_faction(f, no);
}
} else {
}
else {
for (u = f->units; u; u = u->nextF) {
if (u->number > 0) {
f->alive = 1;
@ -1742,7 +1784,6 @@ static void clear_monster_orders(void)
int writegame(const char *filename)
{
char *base;
int n;
faction *f;
region *r;
@ -1786,12 +1827,7 @@ int writegame(const char *filename)
/* globale Variablen */
base = strrchr(game_name, '/');
if (base) {
WRITE_STR(&store, base + 1);
} else {
WRITE_STR(&store, game_name);
}
WRITE_INT(&store, game_id());
WRITE_SECTION(&store);
a_write(&store, global.attribs, NULL);

View File

@ -39,7 +39,6 @@ extern "C" {
/* Versionsänderungen: */
extern int data_version;
extern const char *game_name;
extern int enc_gamedata;
extern int current_turn(void);

View File

@ -71,8 +71,9 @@
#define SPELLBOOK_VERSION 340 /* turn 775, full spellbooks are stored for factions */
#define NOOVERRIDE_VERSION 341 /* turn 775, full spellbooks are stored for factions */
#define INTFLAGS_VERSION 342 /* turn 876, FFL_NPC is now bit 25, flags is an int */
#define SAVEGAMEID_VERSION 343 /* instead of XMLNAME, save the game.id parameter from the config */
#define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */
#define RELEASE_VERSION INTFLAGS_VERSION /* current datafile */
#define RELEASE_VERSION SAVEGAMEID_VERSION /* current datafile */
#define STREAM_VERSION 2 /* internal encoding of binary files */

View File

@ -59,13 +59,7 @@ static void parse_config(const char *filename)
/* only one value in the [editor] section */
force_color = iniparser_getint(d, "editor:color", force_color);
#endif
/* excerpt from [config] (the rest is used in bindings.c) */
game_name = iniparser_getstring(d, "config:game", game_name);
}
else {
log_error("could not open configuration file %s\n", filename);
}
global.inifile = d;
}
static int usage(const char *prog, const char *arg)
@ -109,7 +103,7 @@ static int parse_args(int argc, char **argv, int *exitcode)
printf("\n%s PBEM host\n"
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\n"
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %d.%d.%d\n\n",
global.gamename, VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
game_name(), VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD);
#ifdef USE_CURSES
}
else if (strcmp(argv[i] + 2, "color") == 0) {
@ -261,12 +255,13 @@ int main(int argc, char **argv)
return err;
}
/* ini file sets defaults for arguments*/
if (confpath) {
parse_config(inifile);
if (!global.inifile && confpath) {
_snprintf(inipath, sizeof(inipath), "%s/%s", confpath, inifile);
parse_config(inipath);
}
else {
parse_config(inifile);
if (!global.inifile) {
log_error("could not open ini configuration %s\n", inifile);
}
/* parse arguments again, to override ini file */
parse_args(argc, argv, &err);

View File

@ -2119,7 +2119,7 @@ report_plaintext(const char *filename, report_context * ctx,
}
strftime(pzTime, 64, "%A, %d. %B %Y, %H:%M", localtime(&ctx->report_time));
m = msg_message("nr_header_date", "game date", global.gamename, pzTime);
m = msg_message("nr_header_date", "game date", game_name(), pzTime);
nr_render(m, f->locale, buf, sizeof(buf), f);
msg_release(m);
centre(F, buf, true);

View File

@ -15,8 +15,8 @@
extern "C" {
#endif
extern void register_nr(void);
extern void report_cleanup(void);
void register_nr(void);
void report_cleanup(void);
#ifdef __cplusplus
}

View File

@ -161,7 +161,7 @@ void report_summary(summary * s, summary * o, bool full)
}
#endif
printf("Schreibe Zusammenfassung (parteien)...\n");
fprintf(F, "%s\n%s\n\n", global.gamename, gamedate2(default_locale));
fprintf(F, "%s\n%s\n\n", game_name(), gamedate2(default_locale));
fprintf(F, "Auswertung Nr: %d\n\n", turn);
fprintf(F, "Parteien: %s\n", pcomp(s->factions, o->factions));
fprintf(F, "Einheiten: %s\n", pcomp(s->nunits, o->nunits));