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"> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI <rewriteURI
uriStartString="config:///core/" uriStartString="config:///core/"
rewritePrefix="../server/core/res/" /> rewritePrefix="../../core/res/" />
<rewriteURI <rewriteURI
uriStartString="config:///game/" uriStartString="config:///game/"
rewritePrefix="../server/res/eressea/" /> rewritePrefix="../../res/eressea/" />
<rewriteURI <rewriteURI
uriStartString="config:///default/" uriStartString="config:///default/"
rewritePrefix="../server/res/" /> rewritePrefix="../../res/" />
</catalog> </catalog>

View File

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

View File

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

View File

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

View File

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

View File

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

@ -24,33 +24,33 @@ without prior permission by the authors of Eressea.
extern int db_update_factions(sqlite3 * db, bool force, int game); extern int db_update_factions(sqlite3 * db, bool force, int game);
static int tolua_db_update_factions(lua_State * L) static int tolua_db_update_factions(lua_State * L)
{ {
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0); 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; return 0;
} }
extern int db_update_scores(sqlite3 * db, bool force); extern int db_update_scores(sqlite3 * db, bool force);
static int tolua_db_update_scores(lua_State * L) static int tolua_db_update_scores(lua_State * L)
{ {
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0); sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0);
db_update_scores(db, tolua_toboolean(L, 2, 0)); db_update_scores(db, tolua_toboolean(L, 2, 0));
return 0; return 0;
} }
static int tolua_db_execute(lua_State * L) static int tolua_db_execute(lua_State * L)
{ {
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0); sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0);
const char *sql = tolua_tostring(L, 2, 0); const char *sql = tolua_tostring(L, 2, 0);
int res = sqlite3_exec(db, sql, 0, 0, 0); int res = sqlite3_exec(db, sql, 0, 0, 0);
tolua_pushnumber(L, (LUA_NUMBER) res); tolua_pushnumber(L, (LUA_NUMBER)res);
return 1; return 1;
} }
static int tolua_db_close(lua_State * L) static int tolua_db_close(lua_State * L)
{ {
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0); sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0);
sqlite3_close(db); sqlite3_close(db);
return 0; 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, "\"%s\";locale\n", locale_name(f->locale));
fprintf(F, "%d;noskillpoints\n", 1); fprintf(F, "%d;noskillpoints\n", 1);
fprintf(F, "%ld;date\n", ctx->report_time); 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\";Konfiguration\n", "Standard");
fprintf(F, "\"%s\";Koordinaten\n", "Hex"); fprintf(F, "\"%s\";Koordinaten\n", "Hex");
fprintf(F, "%d;Basis\n", 36); fprintf(F, "%d;Basis\n", 36);

View File

@ -1,7 +1,7 @@
/* /*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de> Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de> Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -208,7 +208,8 @@ int HelpMask(void)
tok = strtok(NULL, " "); tok = strtok(NULL, " ");
} }
free(sstr); free(sstr);
} else { }
else {
rule = HELP_ALL; rule = HELP_ALL;
} }
} }
@ -290,23 +291,23 @@ race_t old_race(const struct race * rc)
} }
helpmode helpmodes[] = { helpmode helpmodes[] = {
{"all", HELP_ALL} { "all", HELP_ALL }
, ,
{"money", HELP_MONEY} { "money", HELP_MONEY }
, ,
{"fight", HELP_FIGHT} { "fight", HELP_FIGHT }
, ,
{"observe", HELP_OBSERVE} { "observe", HELP_OBSERVE }
, ,
{"give", HELP_GIVE} { "give", HELP_GIVE }
, ,
{"guard", HELP_GUARD} { "guard", HELP_GUARD }
, ,
{"stealth", HELP_FSTEALTH} { "stealth", HELP_FSTEALTH }
, ,
{"travel", HELP_TRAVEL} { "travel", HELP_TRAVEL }
, ,
{NULL, 0} { NULL, 0 }
}; };
/** Returns the English name of the race, which is what the database uses. /** Returns the English name of the race, which is what the database uses.
@ -746,7 +747,7 @@ static int ally_mode(const ally * sf, int mode)
int int
alliedgroup(const struct plane *pl, const struct faction *f, alliedgroup(const struct plane *pl, const struct faction *f,
const struct faction *f2, const struct ally *sf, int mode) const struct faction *f2, const struct ally *sf, int mode)
{ {
while (sf && sf->faction != f2) while (sf && sf->faction != f2)
sf = sf->next; sf = sf->next;
@ -770,7 +771,7 @@ alliedgroup(const struct plane *pl, const struct faction *f,
int int
alliedfaction(const struct plane *pl, const struct faction *f, alliedfaction(const struct plane *pl, const struct faction *f,
const struct faction *f2, int mode) const struct faction *f2, int mode)
{ {
return alliedgroup(pl, f, f2, f->allies, mode); return alliedgroup(pl, f, f2, f->allies, mode);
} }
@ -807,7 +808,7 @@ int alliedunit(const unit * u, const faction * f2, int mode)
if (fval(u, UFL_GROUP)) { if (fval(u, UFL_GROUP)) {
const attrib *a = a_findc(u->attribs, &at_group); const attrib *a = a_findc(u->attribs, &at_group);
if (a != NULL) if (a != NULL)
sf = ((group *) a->data.v)->allies; sf = ((group *)a->data.v)->allies;
} }
return alliedgroup(pl, u->faction, f2, sf, mode); return alliedgroup(pl, u->faction, f2, sf, mode);
} }
@ -825,8 +826,8 @@ seefaction(const faction * f, const region * r, const unit * u, int modifier)
bool bool
cansee(const faction * f, const region * r, const unit * u, int modifier) cansee(const faction * f, const region * r, const unit * u, int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */ /* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm /* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */ * erblickt wird */
{ {
int stealth, rings; int stealth, rings;
@ -834,14 +835,17 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
if (u->faction == f || omniscient(f)) { if (u->faction == f || omniscient(f)) {
return true; return true;
} else if (fval(u_race(u), RCF_INVISIBLE)) { }
else if (fval(u_race(u), RCF_INVISIBLE)) {
return false; return false;
} else if (u->number == 0) { }
else if (u->number == 0) {
attrib *a = a_find(u->attribs, &at_creator); attrib *a = a_find(u->attribs, &at_creator);
if (a) { /* u is an empty temporary unit. In this special case if (a) { /* u is an empty temporary unit. In this special case
we look at the creating unit. */ we look at the creating unit. */
u = (unit *) a->data.v; u = (unit *)a->data.v;
} else { }
else {
return false; return false;
} }
} }
@ -870,7 +874,8 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
if (observation >= stealth) { if (observation >= stealth) {
return true; return true;
} }
} else { }
else {
return true; return true;
} }
} }
@ -912,7 +917,8 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
if (o >= n) { if (o >= n) {
return true; return true;
} }
} else { }
else {
return true; return true;
} }
} }
@ -921,7 +927,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
bool bool
cansee_durchgezogen(const faction * f, const region * r, const unit * u, cansee_durchgezogen(const faction * f, const region * r, const unit * u,
int modifier) int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */ /* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm /* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */ * erblickt wird */
@ -1014,7 +1020,7 @@ void update_lighthouse(building * lh)
continue; continue;
a = a_find(r2->attribs, &at_lighthouse); a = a_find(r2->attribs, &at_lighthouse);
while (a && a->type == &at_lighthouse) { while (a && a->type == &at_lighthouse) {
building *b = (building *) a->data.v; building *b = (building *)a->data.v;
if (b == lh) if (b == lh)
break; break;
a = a->next; a = a->next;
@ -1035,18 +1041,20 @@ int count_faction(const faction * f, int flags)
for (u = f->units; u; u = u->nextF) { for (u = f->units; u; u = u->nextF) {
const race *rc = u_race(u); const race *rc = u_race(u);
int x = (flags&COUNT_UNITS) ? 1 : u->number; int x = (flags&COUNT_UNITS) ? 1 : u->number;
if (f->race!=rc) { if (f->race != rc) {
if (!playerrace(rc)) { if (!playerrace(rc)) {
if (flags&COUNT_MONSTERS) { if (flags&COUNT_MONSTERS) {
n+=x; n += x;
} }
} else if (flags&COUNT_MIGRANTS) { }
else if (flags&COUNT_MIGRANTS) {
if (!is_cursed(u->attribs, C_SLAVE, 0)) { if (!is_cursed(u->attribs, C_SLAVE, 0)) {
n+=x; n += x;
} }
} }
} else if (flags&COUNT_DEFAULT) { }
n+=x; else if (flags&COUNT_DEFAULT) {
n += x;
} }
} }
return n; return n;
@ -1054,7 +1062,7 @@ int count_faction(const faction * f, int flags)
int count_units(const faction * f) int count_units(const faction * f)
{ {
return count_faction(f, COUNT_ALL|COUNT_UNITS); return count_faction(f, COUNT_ALL | COUNT_UNITS);
} }
int count_all(const faction * f) int count_all(const faction * f)
{ {
@ -1088,7 +1096,7 @@ int count_maxmigrants(const faction * f)
} }
void void
parse(keyword_t kword, int (*dofun) (unit *, struct order *), bool thisorder) parse(keyword_t kword, int(*dofun) (unit *, struct order *), bool thisorder)
{ {
region *r; region *r;
@ -1155,7 +1163,7 @@ int findoption(const char *s, const struct locale *lang)
variant token; variant token;
if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) { if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
return (direction_t) token.i; return (direction_t)token.i;
} }
return NODIRECTION; return NODIRECTION;
} }
@ -1164,7 +1172,7 @@ param_t findparam(const char *s, const struct locale * lang)
{ {
param_t result = NOPARAM; param_t result = NOPARAM;
char buffer[64]; char buffer[64];
char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s); char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), s);
if (str && *str) { if (str && *str) {
int i; int i;
@ -1186,7 +1194,7 @@ param_t findparam_ex(const char *s, const struct locale * lang)
{ {
param_t result = findparam(s, lang); param_t result = findparam(s, lang);
if (result==NOPARAM) { if (result == NOPARAM) {
const building_type *btype = findbuildingtype(s, lang); const building_type *btype = findbuildingtype(s, lang);
if (btype != NULL) if (btype != NULL)
return P_GEBAEUDE; return P_GEBAEUDE;
@ -1196,9 +1204,9 @@ param_t findparam_ex(const char *s, const struct locale * lang)
bool isparam(const char *s, const struct locale * lang, param_t param) bool isparam(const char *s, const struct locale * lang, param_t param)
{ {
if (s[0]>'@') { if (s[0] > '@') {
param_t p = (param==P_GEBAEUDE) ? findparam_ex(s, lang) : findparam(s, lang); param_t p = (param == P_GEBAEUDE) ? findparam_ex(s, lang) : findparam(s, lang);
return p==param; return p == param;
} }
return false; return false;
} }
@ -1509,7 +1517,7 @@ unit *createunit(region * r, faction * f, int number, const struct race * rc)
bool idle(faction * f) bool idle(faction * f)
{ {
return (bool) (f ? false : true); return (bool)(f ? false : true);
} }
int maxworkingpeasants(const struct region *r) int maxworkingpeasants(const struct region *r)
@ -1541,10 +1549,12 @@ int lighthouse_range(const building * b, const faction * f)
if (d == maxd) if (d == maxd)
break; break;
} }
} else if (c) }
else if (c)
break; /* first unit that's no longer in the house ends the search */ break; /* first unit that's no longer in the house ends the search */
} }
} else { }
else {
/* E3A rule: no perception req'd */ /* E3A rule: no perception req'd */
return maxd; return maxd;
} }
@ -1561,7 +1571,7 @@ bool check_leuchtturm(region * r, faction * f)
for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse; for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse;
a = a->next) { a = a->next) {
building *b = (building *) a->data.v; building *b = (building *)a->data.v;
assert(b->type == bt_find("lighthouse")); assert(b->type == bt_find("lighthouse"));
if (fval(b, BLD_WORKING) && b->size >= 10) { if (fval(b, BLD_WORKING) && b->size >= 10) {
@ -1586,10 +1596,12 @@ bool check_leuchtturm(region * r, faction * f)
if (eff_skill(u, SK_PERCEPTION, r) >= d * 3) if (eff_skill(u, SK_PERCEPTION, r) >= d * 3)
return true; return true;
} }
} else if (c) }
else if (c)
break; /* first unit that's no longer in the house ends the search */ break; /* first unit that's no longer in the house ends the search */
} }
} else { }
else {
/* E3A rule: no perception req'd */ /* E3A rule: no perception req'd */
return maxd; return maxd;
} }
@ -1627,7 +1639,7 @@ region *lastregion(faction * f)
if (fval(r, RF_TRAVELUNIT)) { if (fval(r, RF_TRAVELUNIT)) {
attrib *ru = a_find(r->attribs, &at_travelunit); attrib *ru = a_find(r->attribs, &at_travelunit);
while (ru && ru->type == &at_travelunit) { while (ru && ru->type == &at_travelunit) {
u = (unit *) ru->data.v; u = (unit *)ru->data.v;
if (u->faction == f) { if (u->faction == f) {
f->last = r; f->last = r;
break; break;
@ -1697,7 +1709,7 @@ void *gc_add(void *p)
void add_translation(critbit_tree **cbp, const char *key, int i) { void add_translation(critbit_tree **cbp, const char *key, int i) {
char buffer[256]; char buffer[256];
char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), key); char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), key);
critbit_tree * cb = *cbp; critbit_tree * cb = *cbp;
if (str) { if (str) {
size_t len = strlen(str); size_t len = strlen(str);
@ -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); len = cb_new_kv(str, len, &i, sizeof(int), buffer);
cb_insert(cb, buffer, len); cb_insert(cb, buffer, len);
} else { }
else {
log_error("could not transliterate '%s'\n", key); log_error("could not transliterate '%s'\n", key);
} }
} }
@ -1717,7 +1730,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
int i; int i;
assert(string_cb); assert(string_cb);
assert(maxstrings>0); assert(maxstrings > 0);
tokens = get_translations(lang, ut); tokens = get_translations(lang, ut);
for (i = 0; i != maxstrings; ++i) { for (i = 0; i != maxstrings; ++i) {
const char * s = string_cb(i); const char * s = string_cb(i);
@ -1732,7 +1745,7 @@ void init_translations(const struct locale *lang, int ut, const char * (*string_
static const char * parameter_key(int i) static const char * parameter_key(int i)
{ {
assert(i<MAXPARAMS && i>=0); assert(i < MAXPARAMS && i >= 0);
return parameters[i]; return parameters[i];
} }
@ -1855,7 +1868,7 @@ const char *get_param(const struct param *p, const char *key)
if (cmp == 0) { if (cmp == 0) {
return p->data; return p->data;
} }
else if (cmp>0) { else if (cmp > 0) {
break; break;
} }
p = p->next; p = p->next;
@ -1928,7 +1941,7 @@ void set_param(struct param **p, const char *key, const char *data)
(*p)->data = _strdup(data); (*p)->data = _strdup(data);
return; return;
} }
else if (cmp>0) { else if (cmp > 0) {
break; break;
} }
p = &(*p)->next; p = &(*p)->next;
@ -1993,7 +2006,7 @@ void setstatus(struct unit *u, int status)
{ {
assert(status >= ST_AGGRO && status <= ST_FLEE); assert(status >= ST_AGGRO && status <= ST_FLEE);
if (u->status != status) { if (u->status != status) {
u->status = (status_t) status; u->status = (status_t)status;
} }
} }
@ -2017,7 +2030,8 @@ void setguard(unit * u, unsigned int flags)
if ((int)flags == guard_flags(u)) { if ((int)flags == guard_flags(u)) {
if (a) if (a)
a_remove(&u->attribs, a); a_remove(&u->attribs, a);
} else { }
else {
if (!a) if (!a)
a = a_add(&u->attribs, a_new(&at_guard)); a = a_add(&u->attribs, a_new(&at_guard));
a->data.i = (int)flags; a->data.i = (int)flags;
@ -2028,7 +2042,7 @@ unsigned int getguard(const unit * u)
{ {
attrib *a; attrib *a;
assert(fval(u, UFL_GUARD) || (u->building && u==building_owner(u->building)) assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building))
|| !"you're doing it wrong! check is_guard first"); || !"you're doing it wrong! check is_guard first");
a = a_find(u->attribs, &at_guard); a = a_find(u->attribs, &at_guard);
if (a) { if (a) {
@ -2074,7 +2088,8 @@ void remove_empty_factions(void)
if (sf->faction == f || sf->faction == NULL) { if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next; *sfp = sf->next;
free(sf); free(sf);
} else }
else
sfp = &(*sfp)->next; sfp = &(*sfp)->next;
} }
for (g = f3->groups; g; g = g->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) { if (sf->faction == f || sf->faction == NULL) {
*sfp = sf->next; *sfp = sf->next;
free(sf); free(sf);
} else }
else
sfp = &(*sfp)->next; sfp = &(*sfp)->next;
} }
} }
@ -2094,7 +2110,8 @@ void remove_empty_factions(void)
funhash(f); funhash(f);
free_faction(f); free_faction(f);
free(f); free(f);
} else }
else
fp = &(*fp)->next; fp = &(*fp)->next;
} }
} }
@ -2268,7 +2285,8 @@ bool hunger(int number, unit * u)
int dam = dice_rand(rcdamage ? rcdamage : damage); int dam = dice_rand(rcdamage ? rcdamage : damage);
if (dam >= hp) { if (dam >= hp) {
++dead; ++dead;
} else { }
else {
hpsub += dam; hpsub += dam;
} }
} }
@ -2333,13 +2351,13 @@ void plagues(region * r, bool ismagic)
* Modifikation für Städter. */ * Modifikation für Städter. */
static const int wagetable[7][4] = { static const int wagetable[7][4] = {
{10, 10, 11, -7}, /* Baustelle */ { 10, 10, 11, -7 }, /* Baustelle */
{10, 10, 11, -5}, /* Handelsposten */ { 10, 10, 11, -5 }, /* Handelsposten */
{11, 11, 12, -3}, /* Befestigung */ { 11, 11, 12, -3 }, /* Befestigung */
{12, 11, 13, -1}, /* Turm */ { 12, 11, 13, -1 }, /* Turm */
{13, 12, 14, 0}, /* Burg */ { 13, 12, 14, 0 }, /* Burg */
{14, 12, 15, 1}, /* Festung */ { 14, 12, 15, 1 }, /* Festung */
{15, 13, 16, 2} /* Zitadelle */ { 15, 13, 16, 2 } /* Zitadelle */
}; };
int cmp_wage(const struct building *b, const building * a) int cmp_wage(const struct building *b, const building * a)
@ -2373,7 +2391,8 @@ int cmp_taxes(const building * b, const building * a)
unit *u = building_owner(b); unit *u = building_owner(b);
if (!u) { if (!u) {
return -1; return -1;
} else if (a) { }
else if (a) {
int newsize = buildingeffsize(b, false); int newsize = buildingeffsize(b, false);
double newtaxes = b->type->taxes(b, newsize); double newtaxes = b->type->taxes(b, newsize);
int oldsize = buildingeffsize(a, false); int oldsize = buildingeffsize(a, false);
@ -2395,7 +2414,8 @@ int cmp_taxes(const building * b, const building * a)
return 1; return 1;
} }
} }
} else { }
else {
return 1; return 1;
} }
} }
@ -2422,7 +2442,8 @@ int cmp_current_owner(const building * b, const building * a)
if (newsize != oldsize) if (newsize != oldsize)
return newsize - oldsize; return newsize - oldsize;
return (b->size - a->size); return (b->size - a->size);
} else { }
else {
return 1; return 1;
} }
} }
@ -2545,14 +2566,18 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
index = 1; index = 1;
} }
wage = wagetable[esize][index]; wage = wagetable[esize][index];
} else { }
else {
if (is_mourning(r, in_turn)) { if (is_mourning(r, in_turn)) {
wage = 10; wage = 10;
} else if (fval(r->terrain, SEA_REGION)) { }
else if (fval(r->terrain, SEA_REGION)) {
wage = 11; wage = 11;
} else if (fval(r, RF_ORCIFIED)) { }
else if (fval(r, RF_ORCIFIED)) {
wage = wagetable[esize][1]; wage = wagetable[esize][1];
} else { }
else {
wage = wagetable[esize][2]; wage = wagetable[esize][2];
} }
if (rule_blessed_harvest() == HARVEST_WORK) { 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_TACTICS) || has_skill(u, SK_HERBALISM) ||
has_skill(u, SK_SPY)) { has_skill(u, SK_SPY)) {
return true; return true;
} else { }
else {
return false; return false;
} }
} }
@ -2770,7 +2796,7 @@ void attrib_init(void)
register_bordertype(&bt_illusionwall); register_bordertype(&bt_illusionwall);
register_bordertype(&bt_road); register_bordertype(&bt_road);
register_function((pf_generic) & minimum_wage, "minimum_wage"); register_function((pf_generic)& minimum_wage, "minimum_wage");
at_register(&at_germs); at_register(&at_germs);
@ -2797,13 +2823,14 @@ order *default_order(const struct locale *lang)
static int usedefault = 1; static int usedefault = 1;
int i = locale_index(lang); int i = locale_index(lang);
order *result = 0; order *result = 0;
assert(i<MAXLOCALES); assert(i < MAXLOCALES);
result = defaults[i]; result = defaults[i];
if (!result && usedefault) { if (!result && usedefault) {
const char * str = locale_string(lang, "defaultorder"); const char * str = locale_string(lang, "defaultorder");
if (str) { if (str) {
result = defaults[i] = parse_order(str, lang); result = defaults[i] = parse_order(str, lang);
} else { }
else {
usedefault = 0; usedefault = 0;
} }
} }
@ -2856,7 +2883,7 @@ void free_gamedata(void)
free_regions(); free_regions();
free_borders(); free_borders();
for (i=0;i!=MAXLOCALES;++i) { for (i = 0; i != MAXLOCALES; ++i) {
if (defaults[i]) { if (defaults[i]) {
free_order(defaults[i]); free_order(defaults[i]);
defaults[i] = 0; defaults[i] = 0;
@ -2890,6 +2917,15 @@ void free_gamedata(void)
init_resources(); 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) void load_inifile(dictionary * d)
{ {
const char *reportdir = reportpath(); const char *reportdir = reportpath();
@ -2900,19 +2936,22 @@ void load_inifile(dictionary * d)
assert(d); assert(d);
str = iniparser_getstring(d, "eressea:base", basedir); str = iniparser_getstring(d, "eressea:base", basedir);
if (str != basedir) if (str != basedir) {
set_basepath(str); set_basepath(str);
}
str = iniparser_getstring(d, "eressea:report", reportdir); str = iniparser_getstring(d, "eressea:report", reportdir);
if (str != reportdir) if (str != reportdir) {
set_reportpath(str); set_reportpath(str);
}
str = iniparser_getstring(d, "eressea:data", datadir); str = iniparser_getstring(d, "eressea:data", datadir);
if (str != datadir) if (str != datadir) {
set_datapath(str); set_datapath(str);
}
lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0;
str = iniparser_getstring(d, "eressea:encoding", NULL); str = iniparser_getstring(d, "eressea:encoding", NULL);
if (str && (_strcmpl(str, "utf8")==0 || _strcmpl(str, "utf-8")==0)) { if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) {
enc_gamedata = ENCODING_UTF8; enc_gamedata = ENCODING_UTF8;
} }
@ -2924,5 +2963,7 @@ void load_inifile(dictionary * d)
/* excerpt from [config] (the rest is used in bindings.c) */ /* excerpt from [config] (the rest is used in bindings.c) */
global.game_id = iniparser_getint(d, "config:game_id", 0); global.game_id = iniparser_getint(d, "config:game_id", 0);
if (global.inifile) iniparser_free(global.inifile);
global.inifile = d; global.inifile = d;
} }

View File

@ -1,7 +1,7 @@
/* /*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de> Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de> Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -38,7 +38,7 @@ extern "C" {
#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance)) #define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))
/* for some good prime numbers, check http://www.math.niu.edu/~rusin/known-math/98/pi_x */ /* for some good prime numbers, check http://www.math.niu.edu/~rusin/known-math/98/pi_x */
#ifndef MAXREGIONS #ifndef MAXREGIONS
# define MAXREGIONS 524287 /* must be prime for hashing. 262139 was a little small */ # define MAXREGIONS 524287 /* must be prime for hashing. 262139 was a little small */
#endif #endif
@ -52,23 +52,23 @@ extern "C" {
#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */ #define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
#define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */ #define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */
/* Gebäudegröße = Minimalbelagerer */ /* Gebäudegröße = Minimalbelagerer */
#define SIEGEFACTOR 2 #define SIEGEFACTOR 2
/** Magic */ /** Magic */
#define MAXMAGICIANS 3 #define MAXMAGICIANS 3
#define MAXALCHEMISTS 3 #define MAXALCHEMISTS 3
/** Plagues **/ /** Plagues **/
#define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */ #define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */
#define PLAGUE_VICTIMS 0.2F /* % Betroffene */ #define PLAGUE_VICTIMS 0.2F /* % Betroffene */
#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */ #define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */ #define PLAGUE_HEALCOST 30 /* Heilkosten */
/* Chance of a monster attack */ /* Chance of a monster attack */
#define MONSTERATTACK 0.4F #define MONSTERATTACK 0.4F
/* Bewegungsweiten: */ /* Bewegungsweiten: */
#define BP_WALKING 4 #define BP_WALKING 4
#define BP_RIDING 6 #define BP_RIDING 6
#define BP_UNICORN 9 #define BP_UNICORN 9
@ -80,7 +80,7 @@ extern "C" {
#define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */ #define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */
#define STAMINA_AFFECTS_HP 1<<0 #define STAMINA_AFFECTS_HP 1<<0
/** /**
* Hier endet der Teil von config.h, der die defines für die * Hier endet der Teil von config.h, der die defines für die
* Spielwelt Eressea enthält, und beginnen die allgemeinen Routinen * Spielwelt Eressea enthält, und beginnen die allgemeinen Routinen
*/ */
@ -98,15 +98,10 @@ extern "C" {
#define STRENGTHCAPACITY 50000 /* zusätzliche Tragkraft beim Kraftzauber (deprecated) */ #define STRENGTHCAPACITY 50000 /* zusätzliche Tragkraft beim Kraftzauber (deprecated) */
#define STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */ #define STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */
/* ----------------- Befehle ----------------------------------- */ /* ----------------- Befehle ----------------------------------- */
extern const char *parameters[MAXPARAMS];
/** report options **/
#define want(option) (1<<option) #define want(option) (1<<option)
extern const char *options[MAXOPTIONS]; /* ------------------------------------------------------------- */
/* ------------------------------------------------------------- */
void add_translation(struct critbit_tree **cb, const char *str, int i); 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); void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings);
void init_locales(void); void init_locales(void);
@ -127,14 +122,11 @@ extern "C" {
#define fset(u, i) ((u)->flags |= (i)) #define fset(u, i) ((u)->flags |= (i))
#define freset(u, i) ((u)->flags &= ~(i)) #define freset(u, i) ((u)->flags &= ~(i))
extern int turn; /* parteinummern */
extern int verbosity;
/* parteinummern */
bool faction_id_is_unused(int); bool faction_id_is_unused(int);
int max_magicians(const struct faction * f); int max_magicians(const struct faction * f);
/* leuchtturm */ /* leuchtturm */
bool check_leuchtturm(struct region *r, struct faction *f); bool check_leuchtturm(struct region *r, struct faction *f);
void update_lighthouse(struct building *lh); void update_lighthouse(struct building *lh);
int lighthouse_range(const struct building *b, int lighthouse_range(const struct building *b,
@ -142,7 +134,7 @@ int max_magicians(const struct faction * f);
int findoption(const char *s, const struct locale *lang); int findoption(const char *s, const struct locale *lang);
/* special units */ /* special units */
void make_undead_unit(struct unit *); void make_undead_unit(struct unit *);
void addstrlist(strlist ** SP, const char *s); void addstrlist(strlist ** SP, const char *s);
@ -180,6 +172,8 @@ int max_magicians(const struct faction * f);
bool seefaction(const struct faction *f, const struct region *r, bool seefaction(const struct faction *f, const struct region *r,
const struct unit *u, int modifier); const struct unit *u, int modifier);
const char * game_name(void);
int game_id(void);
int lovar(double xpct_x2); int lovar(double xpct_x2);
/* returns a value between [0..xpct_2], generated with two dice */ /* 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, struct unit *createunit(struct region *r, struct faction *f,
int number, const struct race *rc); int number, const struct race *rc);
void create_unitid(struct unit *u, int id); void create_unitid(struct unit *u, int id);
extern bool getunitpeasants;
struct unit *getunitg(const struct region *r, const struct faction *f); struct unit *getunitg(const struct region *r, const struct faction *f);
struct unit *getunit(const struct region *r, const struct faction *f); struct unit *getunit(const struct region *r, const struct faction *f);
@ -222,7 +215,7 @@ int max_magicians(const struct faction * f);
const char *unitname(const struct unit *u); const char *unitname(const struct unit *u);
char *write_unitname(const struct unit *u, char *buffer, size_t size); char *write_unitname(const struct unit *u, char *buffer, size_t size);
typedef int (*cmp_building_cb) (const struct building * b, typedef int(*cmp_building_cb) (const struct building * b,
const struct building * a); const struct building * a);
struct building *largestbuilding(const struct region *r, cmp_building_cb, struct building *largestbuilding(const struct region *r, cmp_building_cb,
bool imaginary); bool imaginary);
@ -264,7 +257,7 @@ int max_magicians(const struct faction * f);
int check_option(struct faction *f, int option); int check_option(struct faction *f, int option);
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine, /* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */ * sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
void verify_data(void); void verify_data(void);
@ -275,7 +268,7 @@ int max_magicians(const struct faction * f);
int weight(const struct unit *u); int weight(const struct unit *u);
void changeblockchaos(void); void changeblockchaos(void);
/* intervall, in dem die regionen der partei zu finden sind */ /* intervall, in dem die regionen der partei zu finden sind */
struct region *firstregion(struct faction *f); struct region *firstregion(struct faction *f);
struct region *lastregion(struct faction *f); struct region *lastregion(struct faction *f);
@ -285,10 +278,10 @@ int max_magicians(const struct faction * f);
bool idle(struct faction *f); bool idle(struct faction *f);
bool unit_has_cursed_item(struct unit *u); bool unit_has_cursed_item(struct unit *u);
/* simple garbage collection: */ /* simple garbage collection: */
void *gc_add(void *p); void *gc_add(void *p);
/* grammatik-flags: */ /* grammatik-flags: */
#define GF_NONE 0 #define GF_NONE 0
/* singular, ohne was dran */ /* singular, ohne was dran */
#define GF_PLURAL 1 #define GF_PLURAL 1
@ -322,9 +315,9 @@ int max_magicians(const struct faction * f);
#define GUARD_ALL 0xFFFF #define GUARD_ALL 0xFFFF
void setstatus(struct unit *u, int status); void setstatus(struct unit *u, int status);
/* !< sets combatstatus of a unit */ /* !< sets combatstatus of a unit */
void setguard(struct unit *u, unsigned int flags); void setguard(struct unit *u, unsigned int flags);
/* !< setzt die guard-flags der Einheit */ /* !< setzt die guard-flags der Einheit */
unsigned int getguard(const struct unit *u); unsigned int getguard(const struct unit *u);
/* liest die guard-flags der Einheit */ /* liest die guard-flags der Einheit */
void guard(struct unit *u, unsigned int mask); void guard(struct unit *u, unsigned int mask);
@ -348,7 +341,7 @@ int max_magicians(const struct faction * f);
const struct region *dest); const struct region *dest);
void add_income(struct unit *u, int type, int want, int qty); void add_income(struct unit *u, int type, int want, int qty);
/* movewhere error codes */ /* movewhere error codes */
enum { enum {
E_MOVE_OK = 0, /* possible to move */ E_MOVE_OK = 0, /* possible to move */
E_MOVE_NOREGION, /* no region exists in this direction */ E_MOVE_NOREGION, /* no region exists in this direction */
@ -370,9 +363,7 @@ int max_magicians(const struct faction * f);
void kernel_init(void); void kernel_init(void);
void kernel_done(void); void kernel_done(void);
extern const char *localenames[]; /* globale settings des Spieles */
/* globale settings des Spieles */
typedef struct settings { typedef struct settings {
const char *gamename; const char *gamename;
struct attrib *attribs; struct attrib *attribs;
@ -386,16 +377,16 @@ int max_magicians(const struct faction * f);
struct _dictionary_ *inifile; struct _dictionary_ *inifile;
struct global_functions { struct global_functions {
int (*wage) (const struct region * r, const struct faction * f, int(*wage) (const struct region * r, const struct faction * f,
const struct race * rc, int in_turn); const struct race * rc, int in_turn);
int (*maintenance) (const struct unit * u); int(*maintenance) (const struct unit * u);
} functions; } functions;
} settings; } settings;
extern settings global;
extern bool battledebug; typedef struct helpmode {
extern bool sqlpatch; const char *name;
extern bool lomem; /* save memory */ int status;
} helpmode;
const char *dbrace(const struct race *rc); const char *dbrace(const struct race *rc);
@ -416,12 +407,7 @@ int max_magicians(const struct faction * f);
int entertainmoney(const struct region *r); int entertainmoney(const struct region *r);
void plagues(struct region *r, bool ismagic); void plagues(struct region *r, bool ismagic);
typedef struct helpmode { void free_gamedata(void);
const char *name;
int status;
} helpmode;
extern struct helpmode helpmodes[];
#define GIVE_SELF 1 #define GIVE_SELF 1
#define GIVE_PEASANTS 2 #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) #define GIVE_DEFAULT (GIVE_SELF|GIVE_PEASANTS|GIVE_LUXURIES|GIVE_HERBS|GIVE_GOODS)
extern struct attrib_type at_guard; 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 #ifdef __cplusplus
} }

View File

@ -1,7 +1,7 @@
/* /*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de> Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de> Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above purpose with or without fee is hereby granted, provided that the above
@ -87,7 +87,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define MAXPERSISTENT 128 #define MAXPERSISTENT 128
/* exported symbols symbols */ /* exported symbols symbols */
const char *game_name = "eressea";
int firstx = 0, firsty = 0; int firstx = 0, firsty = 0;
int enc_gamedata = ENCODING_UTF8; int enc_gamedata = ENCODING_UTF8;
@ -142,11 +141,13 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL; ord->next = NULL;
free_order(ord); free_order(ord);
} else { }
else {
ordp = &ord->next; ordp = &ord->next;
} }
} }
} else { }
else {
free_orders(&u->orders); free_orders(&u->orders);
} }
u->orders = 0; u->orders = 0;
@ -164,7 +165,7 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
break; break;
if (s[0]) { if (s[0]) {
if (s[0]!='@') { if (s[0] != '@') {
const char *stok = s; const char *stok = s;
stok = parse_token(&stok); stok = parse_token(&stok);
@ -183,7 +184,8 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
if (strlen(stok) >= 3) { if (strlen(stok) >= 3) {
quit = true; quit = true;
break; break;
} else { }
else {
quit = false; quit = false;
} }
break; break;
@ -204,7 +206,8 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
} }
} }
} else { }
else {
/* cmistake(?, buf, 160, MSG_EVENT); */ /* cmistake(?, buf, 160, MSG_EVENT); */
return NULL; return NULL;
} }
@ -234,7 +237,8 @@ static faction *factionorders(void)
* incrementiert wird. */ * incrementiert wird. */
f->lastorders = global.data_turn + 1; f->lastorders = global.data_turn + 1;
} else { }
else {
log_warning("orders for invalid faction %s\n", itoa36(fid)); log_warning("orders for invalid faction %s\n", itoa36(fid));
} }
return f; return f;
@ -305,7 +309,7 @@ int readorders(const char *filename)
b = getbuf(F, enc_gamedata); b = getbuf(F, enc_gamedata);
if (!b) if (!b)
break; break;
p = (b[0]=='@') ? NOPARAM : igetparam(b, lang); p = (b[0] == '@') ? NOPARAM : igetparam(b, lang);
} while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT } while ((p != P_UNIT || !f) && p != P_FACTION && p != P_NEXT
&& p != P_GAMENAME); && p != P_GAMENAME);
break; break;
@ -375,7 +379,7 @@ enum {
race_t typus2race(unsigned char typus) race_t typus2race(unsigned char typus)
{ {
if (typus > 0 && typus <= 11) if (typus > 0 && typus <= 11)
return (race_t) (typus - 1); return (race_t)(typus - 1);
return NORACE; return NORACE;
} }
@ -409,10 +413,12 @@ void read_items(struct storage *store, item ** ilist)
READ_INT(store, &i); READ_INT(store, &i);
if (i <= 0) { if (i <= 0) {
log_error("data contains an entry with %d %s\n", i, rtype->_name[1]); log_error("data contains an entry with %d %s\n", i, rtype->_name[1]);
} else { }
else {
if (rtype && rtype->itype) { if (rtype && rtype->itype) {
i_change(ilist, rtype->itype, i); i_change(ilist, rtype->itype, i);
} else { }
else {
log_error("data contains unknown item type %s.\n", ibuf); log_error("data contains unknown item type %s.\n", ibuf);
} }
assert(rtype && rtype->itype); assert(rtype && rtype->itype);
@ -432,7 +438,8 @@ static void read_alliances(struct storage *store)
terminator = atoi36("end"); terminator = atoi36("end");
READ_STR(store, pbuf, sizeof(pbuf)); READ_STR(store, pbuf, sizeof(pbuf));
id = atoi36(pbuf); id = atoi36(pbuf);
} else { }
else {
READ_INT(store, &id); READ_INT(store, &id);
} }
while (id != terminator) { while (id != terminator) {
@ -447,7 +454,8 @@ static void read_alliances(struct storage *store)
read_reference(&al->_leader, store, read_faction_reference, read_reference(&al->_leader, store, read_faction_reference,
resolve_faction); resolve_faction);
READ_INT(store, &id); READ_INT(store, &id);
} else { }
else {
READ_STR(store, pbuf, sizeof(pbuf)); READ_STR(store, pbuf, sizeof(pbuf));
id = atoi36(pbuf); id = atoi36(pbuf);
} }
@ -486,7 +494,7 @@ void write_items(struct storage *store, item * ilist)
static int resolve_owner(variant id, void *address) static int resolve_owner(variant id, void *address)
{ {
region_owner *owner = (region_owner *) address; region_owner *owner = (region_owner *)address;
int result = 0; int result = 0;
faction *f = NULL; faction *f = NULL;
if (id.i != 0) { if (id.i != 0) {
@ -514,19 +522,22 @@ static void read_owner(struct gamedata *data, region_owner ** powner)
READ_INT(data->store, &owner->morale_turn); READ_INT(data->store, &owner->morale_turn);
if (data->version >= MOURNING_VERSION) { if (data->version >= MOURNING_VERSION) {
READ_INT(data->store, &owner->flags); READ_INT(data->store, &owner->flags);
} else { }
else {
owner->flags = 0; owner->flags = 0;
} }
if (data->version >= OWNER_2_VERSION) { if (data->version >= OWNER_2_VERSION) {
int id; int id;
READ_INT(data->store, &id); READ_INT(data->store, &id);
owner->alliance = id ? findalliance(id) : NULL; owner->alliance = id ? findalliance(id) : NULL;
} else { }
else {
owner->alliance = NULL; owner->alliance = NULL;
} }
read_reference(owner, data->store, &read_faction_reference, &resolve_owner); read_reference(owner, data->store, &read_faction_reference, &resolve_owner);
*powner = owner; *powner = owner;
} else { }
else {
*powner = 0; *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->flags);
WRITE_INT(data->store, owner->alliance ? owner->alliance->id : 0); WRITE_INT(data->store, owner->alliance ? owner->alliance->id : 0);
write_faction_reference(owner->owner, data->store); write_faction_reference(owner->owner, data->store);
} else { }
else {
WRITE_INT(data->store, -1); WRITE_INT(data->store, -1);
} }
} }
@ -564,7 +576,7 @@ int current_turn(void)
static void static void
writeorder(struct gamedata *data, const struct order *ord, writeorder(struct gamedata *data, const struct order *ord,
const struct locale *lang) const struct locale *lang)
{ {
char obuf[1024]; char obuf[1024];
write_order(ord, obuf, sizeof(obuf)); write_order(ord, obuf, sizeof(obuf));
@ -584,7 +596,7 @@ unit *read_unit(struct gamedata *data)
READ_INT(data->store, &n); READ_INT(data->store, &n);
if (n <= 0) { if (n <= 0) {
log_error("data contains invalid unit %d.\n", n); log_error("data contains invalid unit %d.\n", n);
assert(n>0); assert(n > 0);
return 0; return 0;
} }
u = findunit(n); u = findunit(n);
@ -600,7 +612,8 @@ unit *read_unit(struct gamedata *data)
u->skills = 0; u->skills = 0;
u->skill_size = 0; u->skill_size = 0;
u_setfaction(u, NULL); u_setfaction(u, NULL);
} else { }
else {
u = calloc(sizeof(unit), 1); u = calloc(sizeof(unit), 1);
u->no = n; u->no = n;
uhash(u); uhash(u);
@ -613,7 +626,8 @@ unit *read_unit(struct gamedata *data)
} }
if (u->faction) { if (u->faction) {
++u->faction->no_units; ++u->faction->no_units;
} else { }
else {
log_error("unit %s has faction == NULL\n", unitname(u)); log_error("unit %s has faction == NULL\n", unitname(u));
assert(u->faction); assert(u->faction);
return 0; return 0;
@ -623,7 +637,8 @@ unit *read_unit(struct gamedata *data)
u->name = _strdup(obuf); u->name = _strdup(obuf);
if (lomem) { if (lomem) {
READ_STR(data->store, NULL, 0); READ_STR(data->store, NULL, 0);
} else { }
else {
READ_STR(data->store, obuf, sizeof(obuf)); READ_STR(data->store, obuf, sizeof(obuf));
u->display = _strdup(obuf); u->display = _strdup(obuf);
} }
@ -654,14 +669,16 @@ unit *read_unit(struct gamedata *data)
} while (*inc); } while (*inc);
*outc = 0; *outc = 0;
} }
} else { }
else {
READ_TOK(data->store, rname, sizeof(rname)); READ_TOK(data->store, rname, sizeof(rname));
} }
u_setrace(u, rc_find(rname)); u_setrace(u, rc_find(rname));
if (data->version < STORAGE_VERSION) { if (data->version < STORAGE_VERSION) {
READ_STR(data->store, rname, sizeof(rname)); READ_STR(data->store, rname, sizeof(rname));
} else { }
else {
READ_TOK(data->store, rname, sizeof(rname)); READ_TOK(data->store, rname, sizeof(rname));
} }
if (rname[0] && skill_enabled(SK_STEALTH)) if (rname[0] && skill_enabled(SK_STEALTH))
@ -688,7 +705,8 @@ unit *read_unit(struct gamedata *data)
if (fval(u, UFL_OWNER)) { if (fval(u, UFL_OWNER)) {
building_set_owner(u); building_set_owner(u);
} }
} else { }
else {
log_error("read_unit: unit in unkown building '%s'\n", itoa36(n)); 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)) { if (fval(u, UFL_OWNER)) {
ship_set_owner(u); ship_set_owner(u);
} }
} else { }
else {
log_error("read_unit: unit in unkown ship '%s'\n", itoa36(n)); 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;
orderp = &ord->next; orderp = &ord->next;
ord = NULL; ord = NULL;
} else if (p == MAXPERSISTENT) { }
else if (p == MAXPERSISTENT) {
log_warning("%s had %d or more persistent orders\n", unitname(u), 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); log_warning("%s had %d or more orders\n", unitname(u), MAXORDERS);
} }
if (ord != NULL) if (ord != NULL)
@ -795,14 +816,15 @@ void write_unit(struct gamedata *data, const unit * u)
write_building_reference(u->building, data->store); write_building_reference(u->building, data->store);
write_ship_reference(u->ship, data->store); write_ship_reference(u->ship, data->store);
WRITE_INT(data->store, u->status); WRITE_INT(data->store, u->status);
if (u->building && u==building_owner(u->building)) flags |= UFL_OWNER; if (u->building && u == building_owner(u->building)) flags |= UFL_OWNER;
if (u->ship && u==ship_owner(u->ship)) flags |= UFL_OWNER; if (u->ship && u == ship_owner(u->ship)) flags |= UFL_OWNER;
WRITE_INT(data->store, flags); WRITE_INT(data->store, flags);
WRITE_SECTION(data->store); WRITE_SECTION(data->store);
for (ord = u->old_orders; ord; ord = ord->next) { for (ord = u->old_orders; ord; ord = ord->next) {
if (++p < MAXPERSISTENT) { if (++p < MAXPERSISTENT) {
writeorder(data, ord, u->faction->locale); writeorder(data, ord, u->faction->locale);
} else { }
else {
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
break; break;
} }
@ -813,7 +835,8 @@ void write_unit(struct gamedata *data, const unit * u)
if (is_persistent(ord)) { if (is_persistent(ord)) {
if (++p < MAXPERSISTENT) { if (++p < MAXPERSISTENT) {
writeorder(data, ord, u->faction->locale); writeorder(data, ord, u->faction->locale);
} else { }
else {
log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT); log_warning("%s had %d or more persistent orders\n", unitname(u), MAXPERSISTENT);
break; break;
} }
@ -840,7 +863,7 @@ void write_unit(struct gamedata *data, const unit * u)
WRITE_SECTION(data->store); WRITE_SECTION(data->store);
if (u->hp == 0) { if (u->hp == 0) {
log_error("unit %s has 0 hitpoints, adjusting.\n", itoa36(u->no)); log_error("unit %s has 0 hitpoints, adjusting.\n", itoa36(u->no));
((unit *) u)->hp = u->number; ((unit *)u)->hp = u->number;
} }
WRITE_INT(data->store, u->hp); WRITE_INT(data->store, u->hp);
WRITE_SECTION(data->store); WRITE_SECTION(data->store);
@ -863,7 +886,8 @@ static region *readregion(struct gamedata *data, int x, int y)
if (r == NULL) { if (r == NULL) {
plane *pl = findplane(x, y); plane *pl = findplane(x, y);
r = new_region(x, y, pl, uid); r = new_region(x, y, pl, uid);
} else { }
else {
assert(uid == 0 || r->uid == uid); assert(uid == 0 || r->uid == uid);
current_region = r; current_region = r;
while (r->attribs) while (r->attribs)
@ -881,7 +905,8 @@ static region *readregion(struct gamedata *data, int x, int y)
} }
if (lomem) { if (lomem) {
READ_STR(data->store, NULL, 0); READ_STR(data->store, NULL, 0);
} else { }
else {
char info[DISPLAYSIZE]; char info[DISPLAYSIZE];
READ_STR(data->store, info, sizeof(info)); READ_STR(data->store, info, sizeof(info));
region_setinfo(r, info); region_setinfo(r, info);
@ -890,12 +915,13 @@ static region *readregion(struct gamedata *data, int x, int y)
if (data->version < TERRAIN_VERSION) { if (data->version < TERRAIN_VERSION) {
int ter; int ter;
READ_INT(data->store, &ter); READ_INT(data->store, &ter);
terrain = newterrain((terrain_t) ter); terrain = newterrain((terrain_t)ter);
if (terrain == NULL) { if (terrain == NULL) {
log_error("while reading datafile from pre-TERRAIN_VERSION, could not find terrain #%d.\n", ter); log_error("while reading datafile from pre-TERRAIN_VERSION, could not find terrain #%d.\n", ter);
terrain = newterrain(T_PLAIN); terrain = newterrain(T_PLAIN);
} }
} else { }
else {
char name[64]; char name[64];
READ_STR(data->store, name, sizeof(name)); READ_STR(data->store, name, sizeof(name));
terrain = get_terrain(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); const resource_type *rtype = rt_find(token);
assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB)); assert(rtype && rtype->itype && fval(rtype->itype, ITF_HERB));
rsetherbtype(r, rtype->itype); rsetherbtype(r, rtype->itype);
} else { }
else {
rsetherbtype(r, NULL); rsetherbtype(r, NULL);
} }
READ_INT(data->store, &n); READ_INT(data->store, &n);
@ -1054,7 +1081,8 @@ void writeregion(struct gamedata *data, const region * r)
rht = rherbtype(r); rht = rherbtype(r);
if (rht) { if (rht) {
WRITE_TOK(data->store, resourcename(rht->rtype, 0)); WRITE_TOK(data->store, resourcename(rht->rtype, 0));
} else { }
else {
WRITE_TOK(data->store, "noherb"); WRITE_TOK(data->store, "noherb");
} }
WRITE_INT(data->store, rherbs(r)); 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); sbe = spellbook_get(common, sp);
if (sbe) { if (sbe) {
return sbe->level; return sbe->level;
} else { }
else {
log_error("read_spellbook: faction '%s' has a spell with unknown level: '%s'", factionname(f), sp->sname); log_error("read_spellbook: faction '%s' has a spell with unknown level: '%s'", factionname(f), sp->sname);
} }
return 0; return 0;
@ -1146,9 +1175,10 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
if (i < 0) if (i < 0)
break; break;
if (bookp) { if (bookp) {
sp = find_spellbyid((unsigned int) i); sp = find_spellbyid((unsigned int)i);
} }
} else { }
else {
READ_TOK(store, spname, sizeof(spname)); READ_TOK(store, spname, sizeof(spname));
if (strcmp(spname, "end") == 0) if (strcmp(spname, "end") == 0)
break; break;
@ -1164,7 +1194,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
} }
if (sp) { if (sp) {
spellbook * sb = *bookp; spellbook * sb = *bookp;
if (level<=0 && get_level) { if (level <= 0 && get_level) {
level = get_level(sp, cbdata); level = get_level(sp, cbdata);
} }
if (!sb) { if (!sb) {
@ -1185,7 +1215,7 @@ void write_spellbook(const struct spellbook *book, struct storage *store)
if (book) { if (book) {
for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) { for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry *sbe = (spellbook_entry *) ql_get(ql, qi); spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi);
WRITE_TOK(store, sbe->sp->sname); WRITE_TOK(store, sbe->sp->sname);
WRITE_INT(store, sbe->level); WRITE_INT(store, sbe->level);
} }
@ -1207,9 +1237,10 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &n); READ_INT(data->store, &n);
f = findfaction(n); f = findfaction(n);
if (f == NULL) { if (f == NULL) {
f = (faction *) calloc(1, sizeof(faction)); f = (faction *)calloc(1, sizeof(faction));
f->no = n; f->no = n;
} else { }
else {
f->allies = NULL; /* mem leak */ f->allies = NULL; /* mem leak */
while (f->attribs) while (f->attribs)
a_remove(&f->attribs, 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"); || !"non-allied dummy-alliance has more than one member");
} }
ql_push(&al->members, f); ql_push(&al->members, f);
} else if (rule_region_owners()) { }
else if (rule_region_owners()) {
/* compat fix for non-allied factions */ /* compat fix for non-allied factions */
alliance *al = makealliance(0, NULL); alliance *al = makealliance(0, NULL);
setalliance(f, al); setalliance(f, al);
} }
if (data->version >= OWNER_2_VERSION) { if (data->version >= OWNER_2_VERSION) {
READ_INT(data->store, &f->alliance_joindate); READ_INT(data->store, &f->alliance_joindate);
} else { }
else {
f->alliance_joindate = turn - 10; /* we're guessing something safe here */ f->alliance_joindate = turn - 10; /* we're guessing something safe here */
} }
} }
@ -1279,8 +1312,8 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &f->flags); READ_INT(data->store, &f->flags);
if (data->version < INTFLAGS_VERSION) { if (data->version < INTFLAGS_VERSION) {
if (f->no==0 || f->no==666) { if (f->no == 0 || f->no == 666) {
f->flags = FFL_NPC|FFL_NOTIMEOUT|FFL_NOIDLEOUT; f->flags = FFL_NPC | FFL_NOTIMEOUT | FFL_NOIDLEOUT;
} }
} }
assert((f->flags&FFL_SAVEMASK) == f->flags); assert((f->flags&FFL_SAVEMASK) == f->flags);
@ -1323,7 +1356,8 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &state); READ_INT(data->store, &state);
sfp = addally(f, sfp, aid, state); sfp = addally(f, sfp, aid, state);
} }
} else { }
else {
for (;;) { for (;;) {
int aid = 0; int aid = 0;
if (data->version < STORAGE_VERSION) { if (data->version < STORAGE_VERSION) {
@ -1331,14 +1365,16 @@ faction *readfaction(struct gamedata * data)
if (strcmp(name, "end") != 0) { if (strcmp(name, "end") != 0) {
aid = atoi36(name); aid = atoi36(name);
} }
} else { }
else {
READ_INT(data->store, &aid); READ_INT(data->store, &aid);
} }
if (aid > 0) { if (aid > 0) {
int state; int state;
READ_INT(data->store, &state); READ_INT(data->store, &state);
sfp = addally(f, sfp, aid, state); sfp = addally(f, sfp, aid, state);
} else { }
else {
break; break;
} }
} }
@ -1364,7 +1400,8 @@ void writefaction(struct gamedata *data, const faction * f)
assert(f == f->alliance->_leader assert(f == f->alliance->_leader
|| !"non-allied faction is not leader of its own dummy-alliance."); || !"non-allied faction is not leader of its own dummy-alliance.");
} }
} else { }
else {
WRITE_INT(data->store, 0); WRITE_INT(data->store, 0);
} }
WRITE_INT(data->store, f->alliance_joindate); WRITE_INT(data->store, f->alliance_joindate);
@ -1453,20 +1490,19 @@ int readgame(const char *filename, int backup)
gdata.store = &store; gdata.store = &store;
global.data_version = gdata.version; /* HACK: attribute::read does not have access to gamedata, only storage */ global.data_version = gdata.version; /* HACK: attribute::read does not have access to gamedata, only storage */
if (gdata.version >= SAVEXMLNAME_VERSION) { if (gdata.version >= SAVEGAMEID_VERSION) {
char basefile[1024]; int gameid;
READ_STR(&store, basefile, sizeof(basefile)); READ_INT(&store, &gameid);
if (strcmp(game_name, basefile) != 0) { if (gameid != game_id()) {
char buffer[64]; log_warning("game mismatch: datafile contains game %d, but config is for %d\n", gameid, game_id());
strlcpy(buffer, game_name, sizeof(buffer)); printf("WARNING: invalid game id. any key to continue, Ctrl-C to stop\n");
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");
getchar(); getchar();
} }
} }
else if (gdata.version >= SAVEXMLNAME_VERSION) {
char basefile[32];
READ_STR(&store, basefile, sizeof(basefile));
} }
a_read(&store, &global.attribs, NULL); a_read(&store, &global.attribs, NULL);
READ_INT(&store, &turn); READ_INT(&store, &turn);
@ -1490,7 +1526,8 @@ int readgame(const char *filename, int backup)
if (pl == NULL) { if (pl == NULL) {
pl = calloc(1, sizeof(plane)); pl = calloc(1, sizeof(plane));
} else { }
else {
log_warning("the plane with id=%d already exists.\n", id); log_warning("the plane with id=%d already exists.\n", id);
} }
pl->id = id; pl->id = id;
@ -1510,15 +1547,17 @@ int readgame(const char *filename, int backup)
READ_TOK(&store, rname, sizeof(rname)); READ_TOK(&store, rname, sizeof(rname));
if (strcmp(rname, "end") == 0) { if (strcmp(rname, "end") == 0) {
break; /* this is most likely the end of the list */ break; /* this is most likely the end of the list */
} else { }
else {
log_error( log_error(
("This datafile contains watchers, but we are unable to read them\n")); ("This datafile contains watchers, but we are unable to read them\n"));
} }
} }
} else { }
else {
fno = read_faction_reference(&store); fno = read_faction_reference(&store);
while (fno.i) { while (fno.i) {
watcher *w = (watcher *) malloc(sizeof(watcher)); watcher *w = (watcher *)malloc(sizeof(watcher));
ur_add(fno, &w->faction, resolve_faction); ur_add(fno, &w->faction, resolve_faction);
READ_INT(&store, &n); READ_INT(&store, &n);
w->mode = (unsigned char)n; w->mode = (unsigned char)n;
@ -1585,7 +1624,7 @@ int readgame(const char *filename, int backup)
while (--p >= 0) { while (--p >= 0) {
b = (building *) calloc(1, sizeof(building)); b = (building *)calloc(1, sizeof(building));
READ_INT(&store, &b->no); READ_INT(&store, &b->no);
*bp = b; *bp = b;
bp = &b->next; bp = &b->next;
@ -1594,7 +1633,8 @@ int readgame(const char *filename, int backup)
b->name = _strdup(name); b->name = _strdup(name);
if (lomem) { if (lomem) {
READ_STR(gdata.store, NULL, 0); READ_STR(gdata.store, NULL, 0);
} else { }
else {
READ_STR(&store, name, sizeof(name)); READ_STR(&store, name, sizeof(name));
b->display = _strdup(name); b->display = _strdup(name);
} }
@ -1613,7 +1653,7 @@ int readgame(const char *filename, int backup)
shp = &r->ships; shp = &r->ships;
while (--p >= 0) { while (--p >= 0) {
ship *sh = (ship *) calloc(1, sizeof(ship)); ship *sh = (ship *)calloc(1, sizeof(ship));
sh->region = r; sh->region = r;
READ_INT(&store, &sh->no); READ_INT(&store, &sh->no);
*shp = sh; *shp = sh;
@ -1623,7 +1663,8 @@ int readgame(const char *filename, int backup)
sh->name = _strdup(name); sh->name = _strdup(name);
if (lomem) { if (lomem) {
READ_STR(&store, NULL, 0); READ_STR(&store, NULL, 0);
} else { }
else {
READ_STR(&store, name, sizeof(name)); READ_STR(&store, name, sizeof(name));
sh->display = _strdup(name); sh->display = _strdup(name);
} }
@ -1713,7 +1754,8 @@ int readgame(const char *filename, int backup)
log_warning("renum(monsters, %d)\n", no); log_warning("renum(monsters, %d)\n", no);
renumber_faction(f, no); renumber_faction(f, no);
} }
} else { }
else {
for (u = f->units; u; u = u->nextF) { for (u = f->units; u; u = u->nextF) {
if (u->number > 0) { if (u->number > 0) {
f->alive = 1; f->alive = 1;
@ -1742,7 +1784,6 @@ static void clear_monster_orders(void)
int writegame(const char *filename) int writegame(const char *filename)
{ {
char *base;
int n; int n;
faction *f; faction *f;
region *r; region *r;
@ -1786,19 +1827,14 @@ int writegame(const char *filename)
/* globale Variablen */ /* globale Variablen */
base = strrchr(game_name, '/'); WRITE_INT(&store, game_id());
if (base) {
WRITE_STR(&store, base + 1);
} else {
WRITE_STR(&store, game_name);
}
WRITE_SECTION(&store); WRITE_SECTION(&store);
a_write(&store, global.attribs, NULL); a_write(&store, global.attribs, NULL);
WRITE_SECTION(&store); WRITE_SECTION(&store);
WRITE_INT(&store, turn); WRITE_INT(&store, turn);
WRITE_INT(&store, 0 /*max_unique_id */ ); WRITE_INT(&store, 0 /*max_unique_id */);
WRITE_INT(&store, nextborder); WRITE_INT(&store, nextborder);
/* Write planes */ /* Write planes */

View File

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

View File

@ -71,8 +71,9 @@
#define SPELLBOOK_VERSION 340 /* turn 775, full spellbooks are stored for factions */ #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 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 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 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 */ #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 */ /* only one value in the [editor] section */
force_color = iniparser_getint(d, "editor:color", force_color); force_color = iniparser_getint(d, "editor:color", force_color);
#endif #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) 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" printf("\n%s PBEM host\n"
"Copyright (C) 1996-2005 C. Schlittchen, K. Zedel, E. Rehling, H. Peters.\n\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", "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 #ifdef USE_CURSES
} }
else if (strcmp(argv[i] + 2, "color") == 0) { else if (strcmp(argv[i] + 2, "color") == 0) {
@ -261,12 +255,13 @@ int main(int argc, char **argv)
return err; return err;
} }
/* ini file sets defaults for arguments*/ /* ini file sets defaults for arguments*/
if (confpath) { parse_config(inifile);
if (!global.inifile && confpath) {
_snprintf(inipath, sizeof(inipath), "%s/%s", confpath, inifile); _snprintf(inipath, sizeof(inipath), "%s/%s", confpath, inifile);
parse_config(inipath); parse_config(inipath);
} }
else { if (!global.inifile) {
parse_config(inifile); log_error("could not open ini configuration %s\n", inifile);
} }
/* parse arguments again, to override ini file */ /* parse arguments again, to override ini file */
parse_args(argc, argv, &err); 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)); 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); nr_render(m, f->locale, buf, sizeof(buf), f);
msg_release(m); msg_release(m);
centre(F, buf, true); centre(F, buf, true);

View File

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

View File

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