forked from github/server
save game id in the data file, not name of XML file
This commit is contained in:
parent
51207167c8
commit
2bec7e2bbe
|
@ -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>
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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"/>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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"/>
|
||||||
|
|
|
@ -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
|
|
@ -25,7 +25,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1040,12 +1046,14 @@ int count_faction(const faction * f, int flags)
|
||||||
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) {
|
}
|
||||||
|
else if (flags&COUNT_DEFAULT) {
|
||||||
n += x;
|
n += x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2803,7 +2829,8 @@ order *default_order(const struct locale *lang)
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,14 +2936,17 @@ 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;
|
||||||
|
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,12 +100,7 @@ extern "C" {
|
||||||
|
|
||||||
/* ----------------- 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);
|
||||||
|
@ -127,9 +122,6 @@ 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;
|
|
||||||
extern int verbosity;
|
|
||||||
|
|
||||||
/* parteinummern */
|
/* parteinummern */
|
||||||
bool faction_id_is_unused(int);
|
bool faction_id_is_unused(int);
|
||||||
|
|
||||||
|
@ -180,6 +172,8 @@ int max_magicians(const struct faction * f);
|
||||||
bool seefaction(const struct faction *f, const struct region *r,
|
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);
|
||||||
|
|
||||||
|
@ -370,8 +363,6 @@ 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;
|
||||||
|
@ -391,11 +382,11 @@ int max_magicians(const struct faction * f);
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
|
@ -802,7 +823,8 @@ void write_unit(struct gamedata *data, const unit * u)
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
@ -895,7 +920,8 @@ static region *readregion(struct gamedata *data, int x, int y)
|
||||||
log_error("while reading datafile from pre-TERRAIN_VERSION, could not find terrain #%d.\n", ter);
|
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;
|
||||||
|
@ -1148,7 +1177,8 @@ void read_spellbook(spellbook **bookp, struct storage *store, int(*get_level)(co
|
||||||
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;
|
||||||
|
@ -1209,7 +1239,8 @@ faction *readfaction(struct gamedata * data)
|
||||||
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 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,12 +1547,14 @@ 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));
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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,12 +1827,7 @@ 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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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 */
|
||||||
|
|
15
src/main.c
15
src/main.c
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
||||||
|
|
Loading…
Reference in New Issue