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

@ -24,33 +24,33 @@ without prior permission by the authors of Eressea.
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);
sqlite3 *db = (sqlite3 *)tolua_tousertype(L, 1, 0);
db_update_factions(db, tolua_toboolean(L, 2, 0), game_id());
return 0;
}
extern int db_update_scores(sqlite3 * db, bool force);
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));
return 0;
}
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);
int res = sqlite3_exec(db, sql, 0, 0, 0);
tolua_pushnumber(L, (LUA_NUMBER) res);
tolua_pushnumber(L, (LUA_NUMBER)res);
return 1;
}
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);
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

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@ -208,7 +208,8 @@ int HelpMask(void)
tok = strtok(NULL, " ");
}
free(sstr);
} else {
}
else {
rule = HELP_ALL;
}
}
@ -290,23 +291,23 @@ race_t old_race(const struct race * rc)
}
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.
@ -746,7 +747,7 @@ static int ally_mode(const ally * sf, int mode)
int
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)
sf = sf->next;
@ -770,7 +771,7 @@ alliedgroup(const struct plane *pl, const struct faction *f,
int
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);
}
@ -807,7 +808,7 @@ int alliedunit(const unit * u, const faction * f2, int mode)
if (fval(u, UFL_GROUP)) {
const attrib *a = a_findc(u->attribs, &at_group);
if (a != NULL)
sf = ((group *) a->data.v)->allies;
sf = ((group *)a->data.v)->allies;
}
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
cansee(const faction * f, const region * r, const unit * u, int modifier)
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
/* r kann != u->region sein, wenn es um durchreisen geht */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
{
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)) {
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 {
u = (unit *)a->data.v;
}
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;
}
}
@ -921,7 +927,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier)
bool
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 */
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
* erblickt wird */
@ -1014,7 +1020,7 @@ void update_lighthouse(building * lh)
continue;
a = a_find(r2->attribs, &at_lighthouse);
while (a && a->type == &at_lighthouse) {
building *b = (building *) a->data.v;
building *b = (building *)a->data.v;
if (b == lh)
break;
a = a->next;
@ -1035,18 +1041,20 @@ int count_faction(const faction * f, int flags)
for (u = f->units; u; u = u->nextF) {
const race *rc = u_race(u);
int x = (flags&COUNT_UNITS) ? 1 : u->number;
if (f->race!=rc) {
if (f->race != rc) {
if (!playerrace(rc)) {
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)) {
n+=x;
n += x;
}
}
} else if (flags&COUNT_DEFAULT) {
n+=x;
}
else if (flags&COUNT_DEFAULT) {
n += x;
}
}
return n;
@ -1054,7 +1062,7 @@ int count_faction(const faction * f, int flags)
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)
{
@ -1088,7 +1096,7 @@ int count_maxmigrants(const faction * f)
}
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;
@ -1155,7 +1163,7 @@ int findoption(const char *s, const struct locale *lang)
variant token;
if (findtoken(*tokens, s, &token) == E_TOK_SUCCESS) {
return (direction_t) token.i;
return (direction_t)token.i;
}
return NODIRECTION;
}
@ -1164,7 +1172,7 @@ param_t findparam(const char *s, const struct locale * lang)
{
param_t result = NOPARAM;
char buffer[64];
char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s);
char * str = transliterate(buffer, sizeof(buffer) - sizeof(int), s);
if (str && *str) {
int i;
@ -1186,7 +1194,7 @@ param_t findparam_ex(const char *s, const struct locale * lang)
{
param_t result = findparam(s, lang);
if (result==NOPARAM) {
if (result == NOPARAM) {
const building_type *btype = findbuildingtype(s, lang);
if (btype != NULL)
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)
{
if (s[0]>'@') {
param_t p = (param==P_GEBAEUDE) ? findparam_ex(s, lang) : findparam(s, lang);
return p==param;
if (s[0] > '@') {
param_t p = (param == P_GEBAEUDE) ? findparam_ex(s, lang) : findparam(s, lang);
return p == param;
}
return false;
}
@ -1509,7 +1517,7 @@ unit *createunit(region * r, faction * f, int number, const struct race * rc)
bool idle(faction * f)
{
return (bool) (f ? false : true);
return (bool)(f ? false : true);
}
int maxworkingpeasants(const struct region *r)
@ -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;
}
@ -1561,7 +1571,7 @@ bool check_leuchtturm(region * r, faction * f)
for (a = a_find(r->attribs, &at_lighthouse); a && a->type == &at_lighthouse;
a = a->next) {
building *b = (building *) a->data.v;
building *b = (building *)a->data.v;
assert(b->type == bt_find("lighthouse"));
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)
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;
}
@ -1627,7 +1639,7 @@ region *lastregion(faction * f)
if (fval(r, RF_TRAVELUNIT)) {
attrib *ru = a_find(r->attribs, &at_travelunit);
while (ru && ru->type == &at_travelunit) {
u = (unit *) ru->data.v;
u = (unit *)ru->data.v;
if (u->faction == f) {
f->last = r;
break;
@ -1697,7 +1709,7 @@ void *gc_add(void *p)
void add_translation(critbit_tree **cbp, const char *key, int i) {
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;
if (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);
cb_insert(cb, buffer, len);
} else {
}
else {
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;
assert(string_cb);
assert(maxstrings>0);
assert(maxstrings > 0);
tokens = get_translations(lang, ut);
for (i = 0; i != maxstrings; ++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)
{
assert(i<MAXPARAMS && i>=0);
assert(i < MAXPARAMS && i >= 0);
return parameters[i];
}
@ -1855,7 +1868,7 @@ const char *get_param(const struct param *p, const char *key)
if (cmp == 0) {
return p->data;
}
else if (cmp>0) {
else if (cmp > 0) {
break;
}
p = p->next;
@ -1928,7 +1941,7 @@ void set_param(struct param **p, const char *key, const char *data)
(*p)->data = _strdup(data);
return;
}
else if (cmp>0) {
else if (cmp > 0) {
break;
}
p = &(*p)->next;
@ -1993,7 +2006,7 @@ void setstatus(struct unit *u, int status)
{
assert(status >= ST_AGGRO && status <= ST_FLEE);
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 (a)
a_remove(&u->attribs, a);
} else {
}
else {
if (!a)
a = a_add(&u->attribs, a_new(&at_guard));
a->data.i = (int)flags;
@ -2028,7 +2042,7 @@ unsigned int getguard(const unit * u)
{
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");
a = a_find(u->attribs, &at_guard);
if (a) {
@ -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;
}
}
@ -2333,13 +2351,13 @@ void plagues(region * r, bool ismagic)
* Modifikation für Städter. */
static const int wagetable[7][4] = {
{10, 10, 11, -7}, /* Baustelle */
{10, 10, 11, -5}, /* Handelsposten */
{11, 11, 12, -3}, /* Befestigung */
{12, 11, 13, -1}, /* Turm */
{13, 12, 14, 0}, /* Burg */
{14, 12, 15, 1}, /* Festung */
{15, 13, 16, 2} /* Zitadelle */
{ 10, 10, 11, -7 }, /* Baustelle */
{ 10, 10, 11, -5 }, /* Handelsposten */
{ 11, 11, 12, -3 }, /* Befestigung */
{ 12, 11, 13, -1 }, /* Turm */
{ 13, 12, 14, 0 }, /* Burg */
{ 14, 12, 15, 1 }, /* Festung */
{ 15, 13, 16, 2 } /* Zitadelle */
};
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);
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;
}
}
@ -2770,7 +2796,7 @@ void attrib_init(void)
register_bordertype(&bt_illusionwall);
register_bordertype(&bt_road);
register_function((pf_generic) & minimum_wage, "minimum_wage");
register_function((pf_generic)& minimum_wage, "minimum_wage");
at_register(&at_germs);
@ -2797,13 +2823,14 @@ order *default_order(const struct locale *lang)
static int usedefault = 1;
int i = locale_index(lang);
order *result = 0;
assert(i<MAXLOCALES);
assert(i < MAXLOCALES);
result = defaults[i];
if (!result && usedefault) {
const char * str = locale_string(lang, "defaultorder");
if (str) {
result = defaults[i] = parse_order(str, lang);
} else {
}
else {
usedefault = 0;
}
}
@ -2856,7 +2883,7 @@ void free_gamedata(void)
free_regions();
free_borders();
for (i=0;i!=MAXLOCALES;++i) {
for (i = 0; i != MAXLOCALES; ++i) {
if (defaults[i]) {
free_order(defaults[i]);
defaults[i] = 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,19 +2936,22 @@ 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;
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;
}
@ -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

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
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))
/* 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
# define MAXREGIONS 524287 /* must be prime for hashing. 262139 was a little small */
#endif
@ -52,23 +52,23 @@ extern "C" {
#define PEASANTFORCE 0.75 /* Chance einer Vermehrung trotz 90% Auslastung */
#define HERBROTCHANCE 5 /* Verrottchance für Kräuter (ifdef HERBS_ROT) */
/* Gebäudegröße = Minimalbelagerer */
/* Gebäudegröße = Minimalbelagerer */
#define SIEGEFACTOR 2
/** Magic */
/** Magic */
#define MAXMAGICIANS 3
#define MAXALCHEMISTS 3
/** Plagues **/
/** Plagues **/
#define PLAGUE_CHANCE 0.1F /* Seuchenwahrscheinlichkeit (siehe plagues()) */
#define PLAGUE_VICTIMS 0.2F /* % Betroffene */
#define PLAGUE_HEALCHANCE 0.25F /* Wahrscheinlichkeit Heilung */
#define PLAGUE_HEALCOST 30 /* Heilkosten */
/* Chance of a monster attack */
/* Chance of a monster attack */
#define MONSTERATTACK 0.4F
/* Bewegungsweiten: */
/* Bewegungsweiten: */
#define BP_WALKING 4
#define BP_RIDING 6
#define BP_UNICORN 9
@ -80,7 +80,7 @@ extern "C" {
#define PERSON_WEIGHT 1000 /* weight of a "normal" human unit */
#define STAMINA_AFFECTS_HP 1<<0
/**
/**
* Hier endet der Teil von config.h, der die defines für die
* 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 STRENGTHMULTIPLIER 50 /* multiplier for trollbelt */
/* ----------------- Befehle ----------------------------------- */
/* ----------------- 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);
void init_locales(void);
@ -127,14 +122,11 @@ extern "C" {
#define fset(u, i) ((u)->flags |= (i))
#define freset(u, i) ((u)->flags &= ~(i))
extern int turn;
extern int verbosity;
/* parteinummern */
/* parteinummern */
bool faction_id_is_unused(int);
int max_magicians(const struct faction * f);
/* leuchtturm */
int max_magicians(const struct faction * f);
/* leuchtturm */
bool check_leuchtturm(struct region *r, struct faction *f);
void update_lighthouse(struct building *lh);
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);
/* special units */
/* special units */
void make_undead_unit(struct unit *);
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,
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);
@ -222,7 +215,7 @@ int max_magicians(const struct faction * f);
const char *unitname(const struct unit *u);
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);
struct building *largestbuilding(const struct region *r, cmp_building_cb,
bool imaginary);
@ -264,7 +257,7 @@ int max_magicians(const struct faction * f);
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. */
void verify_data(void);
@ -275,7 +268,7 @@ int max_magicians(const struct faction * f);
int weight(const struct unit *u);
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 *lastregion(struct faction *f);
@ -285,10 +278,10 @@ int max_magicians(const struct faction * f);
bool idle(struct faction *f);
bool unit_has_cursed_item(struct unit *u);
/* simple garbage collection: */
/* simple garbage collection: */
void *gc_add(void *p);
/* grammatik-flags: */
/* grammatik-flags: */
#define GF_NONE 0
/* singular, ohne was dran */
#define GF_PLURAL 1
@ -322,9 +315,9 @@ int max_magicians(const struct faction * f);
#define GUARD_ALL 0xFFFF
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);
/* !< setzt die guard-flags der Einheit */
/* !< setzt die guard-flags der Einheit */
unsigned int getguard(const struct unit *u);
/* liest die guard-flags der Einheit */
void guard(struct unit *u, unsigned int mask);
@ -348,7 +341,7 @@ int max_magicians(const struct faction * f);
const struct region *dest);
void add_income(struct unit *u, int type, int want, int qty);
/* movewhere error codes */
/* movewhere error codes */
enum {
E_MOVE_OK = 0, /* possible to move */
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_done(void);
extern const char *localenames[];
/* globale settings des Spieles */
/* globale settings des Spieles */
typedef struct settings {
const char *gamename;
struct attrib *attribs;
@ -386,16 +377,16 @@ int max_magicians(const struct faction * f);
struct _dictionary_ *inifile;
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);
int (*maintenance) (const struct unit * u);
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

@ -1,7 +1,7 @@
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
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
/* 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;
@ -164,7 +165,7 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
break;
if (s[0]) {
if (s[0]!='@') {
if (s[0] != '@') {
const char *stok = s;
stok = parse_token(&stok);
@ -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;
@ -305,7 +309,7 @@ int readorders(const char *filename)
b = getbuf(F, enc_gamedata);
if (!b)
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
&& p != P_GAMENAME);
break;
@ -375,7 +379,7 @@ enum {
race_t typus2race(unsigned char typus)
{
if (typus > 0 && typus <= 11)
return (race_t) (typus - 1);
return (race_t)(typus - 1);
return NORACE;
}
@ -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);
}
@ -486,7 +494,7 @@ void write_items(struct storage *store, item * ilist)
static int resolve_owner(variant id, void *address)
{
region_owner *owner = (region_owner *) address;
region_owner *owner = (region_owner *)address;
int result = 0;
faction *f = NULL;
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);
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);
}
}
@ -564,7 +576,7 @@ int current_turn(void)
static void
writeorder(struct gamedata *data, const struct order *ord,
const struct locale *lang)
const struct locale *lang)
{
char obuf[1024];
write_order(ord, obuf, sizeof(obuf));
@ -584,7 +596,7 @@ unit *read_unit(struct gamedata *data)
READ_INT(data->store, &n);
if (n <= 0) {
log_error("data contains invalid unit %d.\n", n);
assert(n>0);
assert(n > 0);
return 0;
}
u = findunit(n);
@ -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)
@ -795,14 +816,15 @@ void write_unit(struct gamedata *data, const unit * u)
write_building_reference(u->building, data->store);
write_ship_reference(u->ship, data->store);
WRITE_INT(data->store, u->status);
if (u->building && u==building_owner(u->building)) flags |= UFL_OWNER;
if (u->ship && u==ship_owner(u->ship)) 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;
WRITE_INT(data->store, flags);
WRITE_SECTION(data->store);
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;
}
@ -840,7 +863,7 @@ void write_unit(struct gamedata *data, const unit * u)
WRITE_SECTION(data->store);
if (u->hp == 0) {
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_SECTION(data->store);
@ -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);
@ -890,12 +915,13 @@ static region *readregion(struct gamedata *data, int x, int y)
if (data->version < TERRAIN_VERSION) {
int ter;
READ_INT(data->store, &ter);
terrain = newterrain((terrain_t) ter);
terrain = newterrain((terrain_t)ter);
if (terrain == NULL) {
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;
@ -1146,9 +1175,10 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
if (i < 0)
break;
if (bookp) {
sp = find_spellbyid((unsigned int) i);
sp = find_spellbyid((unsigned int)i);
}
} else {
}
else {
READ_TOK(store, spname, sizeof(spname));
if (strcmp(spname, "end") == 0)
break;
@ -1164,7 +1194,7 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
}
if (sp) {
spellbook * sb = *bookp;
if (level<=0 && get_level) {
if (level <= 0 && get_level) {
level = get_level(sp, cbdata);
}
if (!sb) {
@ -1185,7 +1215,7 @@ void write_spellbook(const struct spellbook *book, struct storage *store)
if (book) {
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_INT(store, sbe->level);
}
@ -1207,9 +1237,10 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &n);
f = findfaction(n);
if (f == NULL) {
f = (faction *) calloc(1, sizeof(faction));
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 */
}
}
@ -1279,8 +1312,8 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &f->flags);
if (data->version < INTFLAGS_VERSION) {
if (f->no==0 || f->no==666) {
f->flags = FFL_NPC|FFL_NOTIMEOUT|FFL_NOIDLEOUT;
if (f->no == 0 || f->no == 666) {
f->flags = FFL_NPC | FFL_NOTIMEOUT | FFL_NOIDLEOUT;
}
}
assert((f->flags&FFL_SAVEMASK) == f->flags);
@ -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,15 +1547,17 @@ 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));
watcher *w = (watcher *)malloc(sizeof(watcher));
ur_add(fno, &w->faction, resolve_faction);
READ_INT(&store, &n);
w->mode = (unsigned char)n;
@ -1585,7 +1624,7 @@ int readgame(const char *filename, int backup)
while (--p >= 0) {
b = (building *) calloc(1, sizeof(building));
b = (building *)calloc(1, sizeof(building));
READ_INT(&store, &b->no);
*bp = b;
bp = &b->next;
@ -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);
}
@ -1613,7 +1653,7 @@ int readgame(const char *filename, int backup)
shp = &r->ships;
while (--p >= 0) {
ship *sh = (ship *) calloc(1, sizeof(ship));
ship *sh = (ship *)calloc(1, sizeof(ship));
sh->region = r;
READ_INT(&store, &sh->no);
*shp = sh;
@ -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,19 +1827,14 @@ 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);
WRITE_SECTION(&store);
WRITE_INT(&store, turn);
WRITE_INT(&store, 0 /*max_unique_id */ );
WRITE_INT(&store, 0 /*max_unique_id */);
WRITE_INT(&store, nextborder);
/* Write planes */

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));