forked from github/server
replacing read/write_default with a function that doesn't abuse layout of the union or endianness. new savefile-format
removeing some old attributes that were never used.
This commit is contained in:
parent
102a68f01e
commit
3efd05206e
|
@ -16,15 +16,16 @@
|
|||
#include "eressea.h"
|
||||
#include "iceberg.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_iceberg = {
|
||||
"iceberg_drift",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
|
|
@ -15,15 +15,16 @@
|
|||
#include <config.h>
|
||||
#include "key.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_key = {
|
||||
"key",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
};
|
||||
|
||||
attrib *
|
||||
|
|
|
@ -16,15 +16,16 @@
|
|||
#include "eressea.h"
|
||||
#include "option.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
attrib_type at_option_news = {
|
||||
"option_news",
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
|
|
@ -15,14 +15,15 @@
|
|||
#include <config.h>
|
||||
#include "orcification.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
/*
|
||||
* simple attributes that do not yet have their own file
|
||||
*/
|
||||
|
||||
attrib_type at_orcification = {
|
||||
"orcification", NULL, NULL, NULL, a_writedefault, a_readdefault, ATF_UNIQUE
|
||||
"orcification", NULL, NULL, NULL, a_writeint, a_readint, ATF_UNIQUE
|
||||
};
|
||||
|
||||
attrib *
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
#include "overrideroads.h"
|
||||
#include <kernel/save.h>
|
||||
|
||||
attrib_type at_overrideroads = {
|
||||
"roads_override", NULL, NULL, NULL, &a_writestring, &a_readstring
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
#include <eressea.h>
|
||||
#include "racename.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <config.h>
|
||||
#include <eressea.h>
|
||||
#include "raceprefix.h"
|
||||
#include <kernel/save.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#include <config.h>
|
||||
#include "reduceproduction.h"
|
||||
|
||||
#include <attrib.h>
|
||||
#include <kernel/save.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
static int
|
||||
age_reduceproduction(attrib *a)
|
||||
|
@ -31,8 +31,8 @@ attrib_type at_reduceproduction = {
|
|||
NULL,
|
||||
NULL,
|
||||
age_reduceproduction,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeshorts,
|
||||
a_readshorts,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
#include <config.h>
|
||||
#include "targetregion.h"
|
||||
|
||||
#include <eressea.h>
|
||||
#include <region.h>
|
||||
#include <kernel/eressea.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
|
||||
#include <attrib.h>
|
||||
#include <resolve.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/resolve.h>
|
||||
|
||||
static void
|
||||
write_targetregion(const attrib * a, FILE * F)
|
||||
|
@ -31,7 +33,7 @@ static int
|
|||
read_targetregion(attrib * a, FILE * F)
|
||||
{
|
||||
if (global.data_version < BASE36IDS_VERSION) {
|
||||
a_readdefault(a, F);
|
||||
a_readint(a, F);
|
||||
a->data.v = findregion(a->data.sa[0], a->data.sa[1]);
|
||||
} else {
|
||||
return read_region_reference((region**)&a->data.v, F);
|
||||
|
|
|
@ -1224,191 +1224,191 @@ randomevents(void)
|
|||
if (rand() % 100 < prob) {
|
||||
++increase;
|
||||
}
|
||||
}
|
||||
if (increase) {
|
||||
if (u->race == new_race[RC_ORC]) {
|
||||
int i;
|
||||
struct orcskills {
|
||||
skill_t skill;
|
||||
int level;
|
||||
} skills [] = {
|
||||
{ SK_MELEE, 1 }, { SK_SPEAR, 1 }, { SK_TACTICS, 0 },
|
||||
{ SK_LONGBOW, 0 }, { SK_CROSSBOW, 0 }, { SK_CATAPULT, 0 },
|
||||
{ SK_AUSDAUER, 0 }, { NOSKILL, 0 }
|
||||
};
|
||||
for (i=0;skills[i].skill!=NOSKILL;++i) {
|
||||
int k = get_level(u, skills[i].skill);
|
||||
change_skill(u, skills[i].skill, increase * max(k, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (increase) {
|
||||
if (u->race == new_race[RC_ORC]) {
|
||||
int i;
|
||||
struct orcskills {
|
||||
skill_t skill;
|
||||
int level;
|
||||
} skills [] = {
|
||||
{ SK_MELEE, 1 }, { SK_SPEAR, 1 }, { SK_TACTICS, 0 },
|
||||
{ SK_LONGBOW, 0 }, { SK_CROSSBOW, 0 }, { SK_CATAPULT, 0 },
|
||||
{ SK_AUSDAUER, 0 }, { NOSKILL, 0 }
|
||||
};
|
||||
for (i=0;skills[i].skill!=NOSKILL;++i) {
|
||||
int k = get_level(u, skills[i].skill);
|
||||
change_skill(u, skills[i].skill, increase * max(k, s));
|
||||
}
|
||||
}
|
||||
|
||||
set_number(u, u->number + increase);
|
||||
set_number(u, u->number + increase);
|
||||
|
||||
u->hp += unit_max_hp(u) * increase;
|
||||
ADDMSG(&u->faction->msgs, msg_message("orcgrowth",
|
||||
"unit amount race", u, increase, u->race));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
u->hp += unit_max_hp(u) * increase;
|
||||
ADDMSG(&u->faction->msgs, msg_message("orcgrowth",
|
||||
"unit amount race", u, increase, u->race));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
for (r = regions; r; r = r->next) {
|
||||
#if !RACE_ADJUSTMENTS
|
||||
/* Elfen generieren Wald */
|
||||
if (r->land && !fval(r, RF_MALLORN)) {
|
||||
int trees = rtrees(r, 2);
|
||||
int maxgen = (production(r) * MAXPEASANTS_PER_AREA)/8;
|
||||
for (u = r->units; u && maxgen > 0; u = u->next) {
|
||||
if (u->race == new_race[RC_ELF]) {
|
||||
for (n = u->number; n && maxgen > 0; n--) {
|
||||
if (rand() % 1000 < 15) { /* 1.5% Chance */
|
||||
trees++;
|
||||
}
|
||||
maxgen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
rsettrees(r, 2, trees);
|
||||
} /* !RACE_ADJUSTMENTS */
|
||||
/* Elfen generieren Wald */
|
||||
if (r->land && !fval(r, RF_MALLORN)) {
|
||||
int trees = rtrees(r, 2);
|
||||
int maxgen = (production(r) * MAXPEASANTS_PER_AREA)/8;
|
||||
for (u = r->units; u && maxgen > 0; u = u->next) {
|
||||
if (u->race == new_race[RC_ELF]) {
|
||||
for (n = u->number; n && maxgen > 0; n--) {
|
||||
if (rand() % 1000 < 15) { /* 1.5% Chance */
|
||||
trees++;
|
||||
}
|
||||
maxgen--;
|
||||
}
|
||||
}
|
||||
}
|
||||
rsettrees(r, 2, trees);
|
||||
} /* !RACE_ADJUSTMENTS */
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Orkifizierte Regionen mutieren und mutieren zurück */
|
||||
/* Orkifizierte Regionen mutieren und mutieren zurück */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
direction_t dir;
|
||||
double probability = 0.0;
|
||||
for (dir = 0; dir < MAXDIRECTIONS; dir++) {
|
||||
region *rc = rconnect(r, dir);
|
||||
if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED)) probability += 0.02;
|
||||
}
|
||||
if (chance(probability)) {
|
||||
ADDMSG(&r->msgs, msg_message("deorcified", "region", r));
|
||||
freset(r, RF_ORCIFIED);
|
||||
}
|
||||
} else {
|
||||
attrib *a = a_find(r->attribs, &at_orcification);
|
||||
if (a!=NULL) {
|
||||
double probability = 0.0;
|
||||
if (rpeasants(r) <= 0) continue;
|
||||
probability = a->data.i/(double)rpeasants(r);
|
||||
if (chance(probability)) {
|
||||
fset(r, RF_ORCIFIED);
|
||||
a_remove(&r->attribs, a);
|
||||
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
|
||||
} else {
|
||||
a->data.i -= max(10,a->data.i/10);
|
||||
if (a->data.i <= 0) a_remove(&r->attribs, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (fval(r, RF_ORCIFIED)) {
|
||||
direction_t dir;
|
||||
double probability = 0.0;
|
||||
for (dir = 0; dir < MAXDIRECTIONS; dir++) {
|
||||
region *rc = rconnect(r, dir);
|
||||
if (rc && rpeasants(rc) > 0 && !fval(rc, RF_ORCIFIED)) probability += 0.02;
|
||||
}
|
||||
if (chance(probability)) {
|
||||
ADDMSG(&r->msgs, msg_message("deorcified", "region", r));
|
||||
freset(r, RF_ORCIFIED);
|
||||
}
|
||||
} else {
|
||||
attrib *a = a_find(r->attribs, &at_orcification);
|
||||
if (a!=NULL) {
|
||||
double probability = 0.0;
|
||||
if (rpeasants(r) <= 0) continue;
|
||||
probability = a->data.i/(double)rpeasants(r);
|
||||
if (chance(probability)) {
|
||||
fset(r, RF_ORCIFIED);
|
||||
a_remove(&r->attribs, a);
|
||||
ADDMSG(&r->msgs, msg_message("orcified", "region", r));
|
||||
} else {
|
||||
a->data.i -= max(10,a->data.i/10);
|
||||
if (a->data.i <= 0) a_remove(&r->attribs, a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Vulkane qualmen, brechen aus ... */
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (rterrain(r)==T_VOLCANO_SMOKING && a_find(r->attribs, &at_reduceproduction)) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
} else switch(rterrain(r)) {
|
||||
case T_VOLCANO:
|
||||
if (rand()%100 < 4) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO_SMOKING);
|
||||
}
|
||||
break;
|
||||
case T_VOLCANO_SMOKING:
|
||||
if (rand()%100 < 12) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
} else if (rand()%100 < 8) {
|
||||
volcano_outbreak(r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Vulkane qualmen, brechen aus ... */
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (rterrain(r)==T_VOLCANO_SMOKING && a_find(r->attribs, &at_reduceproduction)) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
} else switch(rterrain(r)) {
|
||||
case T_VOLCANO:
|
||||
if (rand()%100 < 4) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostartsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO_SMOKING);
|
||||
}
|
||||
break;
|
||||
case T_VOLCANO_SMOKING:
|
||||
if (rand()%100 < 12) {
|
||||
ADDMSG(&r->msgs, msg_message("volcanostopsmoke", "region", r));
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
} else if (rand()%100 < 8) {
|
||||
volcano_outbreak(r);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Monumente zerfallen, Schiffe verfaulen */
|
||||
/* Monumente zerfallen, Schiffe verfaulen */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
for (b = rbuildings(r); b; b = b2) {
|
||||
b2 = b->next;
|
||||
if (fval(b->type, BTF_DECAY) && !buildingowner(r, b)) {
|
||||
b->size -= max(1, (b->size * 20) / 100);
|
||||
if (b->size == 0) {
|
||||
destroy_building(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (r = regions; r; r = r->next) {
|
||||
for (b = rbuildings(r); b; b = b2) {
|
||||
b2 = b->next;
|
||||
if (fval(b->type, BTF_DECAY) && !buildingowner(r, b)) {
|
||||
b->size -= max(1, (b->size * 20) / 100);
|
||||
if (b->size == 0) {
|
||||
destroy_building(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* monster-einheiten desertieren */
|
||||
for (r = regions; r; r=r->next) {
|
||||
for (u=r->units; u; u=u->next) {
|
||||
if (u->faction->no != MONSTER_FACTION
|
||||
&& (u->race->flags & RCF_DESERT)) {
|
||||
if (fval(u, UFL_ISNEW)) continue;
|
||||
if (rand()%100 < 5) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("desertion",
|
||||
"unit region", u, r));
|
||||
u_setfaction(u, findfaction(MONSTER_FACTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (r = regions; r; r=r->next) {
|
||||
for (u=r->units; u; u=u->next) {
|
||||
if (u->faction->no != MONSTER_FACTION
|
||||
&& (u->race->flags & RCF_DESERT)) {
|
||||
if (fval(u, UFL_ISNEW)) continue;
|
||||
if (rand()%100 < 5) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("desertion",
|
||||
"unit region", u, r));
|
||||
u_setfaction(u, findfaction(MONSTER_FACTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* lycanthropen werden werwölfe */
|
||||
for (f = factions; f; f=f->next) {
|
||||
int level = fspecial(f, FS_LYCANTROPE);
|
||||
if(level > 0) {
|
||||
for(u = f->units; u; u=u->nextF) {
|
||||
if(rand()%100 < 2*level) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("becomewere",
|
||||
"unit region", u, u->region));
|
||||
fset(u, UFL_WERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (f = factions; f; f=f->next) {
|
||||
int level = fspecial(f, FS_LYCANTROPE);
|
||||
if(level > 0) {
|
||||
for(u = f->units; u; u=u->nextF) {
|
||||
if(rand()%100 < 2*level) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("becomewere",
|
||||
"unit region", u, u->region));
|
||||
fset(u, UFL_WERE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Frühling, die Bäume schlagen aus. */
|
||||
/* Frühling, die Bäume schlagen aus. */
|
||||
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (fval(r, RF_CHAOTIC) ||(r->x >= -13 && r->x <= -6 && r->y >= 50 && r->y <= 57)) {
|
||||
if (woodcount(r) >= 40 && rand()%100 < 33) {
|
||||
int trees = rtrees(r,2);
|
||||
int treemen = rand()%(max(50,trees)/3);
|
||||
struct message * msg;
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (fval(r, RF_CHAOTIC) ||(r->x >= -13 && r->x <= -6 && r->y >= 50 && r->y <= 57)) {
|
||||
if (woodcount(r) >= 40 && rand()%100 < 33) {
|
||||
int trees = rtrees(r,2);
|
||||
int treemen = rand()%(max(50,trees)/3);
|
||||
struct message * msg;
|
||||
|
||||
treemen = max(25, treemen);
|
||||
woodcounts(r, -40);
|
||||
trees = max(0, trees-treemen);
|
||||
rsettrees(r, 2, trees);
|
||||
u = createunit(r, findfaction(MONSTER_FACTION),treemen, new_race[RC_TREEMAN]);
|
||||
treemen = max(25, treemen);
|
||||
woodcounts(r, -40);
|
||||
trees = max(0, trees-treemen);
|
||||
rsettrees(r, 2, trees);
|
||||
u = createunit(r, findfaction(MONSTER_FACTION),treemen, new_race[RC_TREEMAN]);
|
||||
fset(u, UFL_ISNEW|UFL_MOVED);
|
||||
|
||||
set_level(u, SK_OBSERVATION, 2);
|
||||
if (u->number == 1)
|
||||
set_string(&u->name, "Ein wütender Ent");
|
||||
else
|
||||
set_string(&u->name, "Wütende Ents");
|
||||
set_level(u, SK_OBSERVATION, 2);
|
||||
if (u->number == 1)
|
||||
set_string(&u->name, "Ein wütender Ent");
|
||||
else
|
||||
set_string(&u->name, "Wütende Ents");
|
||||
|
||||
log_printf("%d Ents in %s.\n", u->number, regionname(r, NULL));
|
||||
log_printf("%d Ents in %s.\n", u->number, regionname(r, NULL));
|
||||
|
||||
msg = msg_message("entrise", "region", r);
|
||||
add_message(&r->msgs, msg);
|
||||
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
|
||||
for (u=r->units;u;u=u->next) {
|
||||
if (fval(u->faction, FL_DH)) continue;
|
||||
fset(u->faction, FL_DH);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
}
|
||||
msg_release(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
msg = msg_message("entrise", "region", r);
|
||||
add_message(&r->msgs, msg);
|
||||
for (u=r->units;u;u=u->next) freset(u->faction, FL_DH);
|
||||
for (u=r->units;u;u=u->next) {
|
||||
if (fval(u->faction, FL_DH)) continue;
|
||||
fset(u->faction, FL_DH);
|
||||
add_message(&u->faction->msgs, msg);
|
||||
}
|
||||
msg_release(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Chaos */
|
||||
|
||||
|
@ -1435,15 +1435,12 @@ randomevents(void)
|
|||
item * itm = *itmp;
|
||||
int n = itm->number;
|
||||
double k = n*rot_chance/100.0;
|
||||
if (fval(itm->type, ITF_HERB)) {
|
||||
double nv = normalvariate(k, k/4);
|
||||
int inv = (int)nv;
|
||||
int delta = min(n, inv);
|
||||
if (inv<0) {
|
||||
nv = normalvariate(k, k/4);
|
||||
}
|
||||
i_change(itmp, itm->type, -delta);
|
||||
}
|
||||
if (fval(itm->type, ITF_HERB)) {
|
||||
double nv = normalvariate(k, k/4);
|
||||
int inv = (int)nv;
|
||||
int delta = min(n, inv);
|
||||
i_change(itmp, itm->type, -delta);
|
||||
}
|
||||
if (itm==*itmp) itmp=&itm->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <kernel/region.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/message.h>
|
||||
|
@ -49,8 +50,8 @@ static attrib_type at_peaceimmune = {
|
|||
"peaceimmune",
|
||||
NULL, NULL,
|
||||
age_peaceimmune,
|
||||
a_writedefault,
|
||||
a_readdefault
|
||||
a_writeint,
|
||||
a_readint
|
||||
};
|
||||
|
||||
static int
|
||||
|
|
|
@ -2089,17 +2089,11 @@ attack(battle *b, troop ta, const att *a, int numattack)
|
|||
ta.fighter->action_counter++;
|
||||
}
|
||||
if (td.fighter->unit->ship) {
|
||||
if(a_find(td.fighter->unit->ship->attribs, &at_nodestroy) == NULL) {
|
||||
td.fighter->unit->ship->damage += DAMAGE_SCALE * dice_rand(a->data.dice);
|
||||
}
|
||||
td.fighter->unit->ship->damage += DAMAGE_SCALE * dice_rand(a->data.dice);
|
||||
} else if (td.fighter->unit->building) {
|
||||
if(a_find(td.fighter->unit->building->attribs, &at_nodestroy) == NULL) {
|
||||
damage_building(b, td.fighter->unit->building,
|
||||
dice_rand(a->data.dice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
damage_building(b, td.fighter->unit->building, dice_rand(a->data.dice));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
#include "eressea.h"
|
||||
#include "border.h"
|
||||
|
||||
#include "unit.h"
|
||||
#include "terrain.h"
|
||||
#include "region.h"
|
||||
#include "save.h"
|
||||
#include "terrain.h"
|
||||
#include "unit.h"
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
|
@ -219,8 +220,8 @@ attrib_type at_countdown = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
a_agecountdown,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ
|
||||
a_writeint,
|
||||
a_readint
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -383,10 +383,6 @@ destroy_cmd(unit * u, struct order * ord)
|
|||
|
||||
if (u->building) {
|
||||
building *b = u->building;
|
||||
if (a_find(b->attribs, &at_nodestroy)) {
|
||||
cmistake(u, ord, 14, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(n >= b->size) {
|
||||
/* destroy completly */
|
||||
|
@ -407,10 +403,6 @@ destroy_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
} else if (u->ship) {
|
||||
sh = u->ship;
|
||||
if (a_find(sh->attribs, &at_nodestroy)) {
|
||||
cmistake(u, ord, 14, MSG_EVENT);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
cmistake(u, ord, 14, MSG_EVENT);
|
||||
|
|
|
@ -103,14 +103,6 @@ attrib_type at_building_action = {
|
|||
lc_write, lc_read
|
||||
};
|
||||
|
||||
attrib_type at_nodestroy = {
|
||||
"nodestroy",
|
||||
NULL, NULL, NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
building_typelist *buildingtypes;
|
||||
|
||||
const building_type *
|
||||
|
|
|
@ -142,7 +142,6 @@ extern struct building *findbuilding(int n);
|
|||
|
||||
extern struct unit * buildingowner(const struct region * r, const struct building * b);
|
||||
|
||||
extern attrib_type at_nodestroy;
|
||||
extern attrib_type at_building_action;
|
||||
|
||||
#ifdef WDW_PYRAMID
|
||||
|
|
|
@ -483,8 +483,8 @@ static attrib_type at_maxmagicians = {
|
|||
init_maxmagicians,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -500,8 +500,8 @@ static attrib_type at_npcfaction = {
|
|||
init_npcfaction,
|
||||
NULL,
|
||||
NULL,
|
||||
a_writedefault,
|
||||
a_readdefault,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -2398,8 +2398,8 @@ attrib_type at_germs = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeshorts,
|
||||
a_readshorts,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -2411,8 +2411,8 @@ attrib_type at_guard = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -3108,7 +3108,6 @@ attrib_init(void)
|
|||
at_register(&at_deathcount);
|
||||
at_register(&at_chaoscount);
|
||||
at_register(&at_woodcount);
|
||||
at_register(&at_road);
|
||||
|
||||
/* neue UNIT-Attribute */
|
||||
at_register(&at_siege);
|
||||
|
@ -3140,7 +3139,6 @@ attrib_init(void)
|
|||
at_register(&at_xontormiaexpress); /* required for old datafiles */
|
||||
#endif
|
||||
at_register(&at_speedup);
|
||||
at_register(&at_nodestroy);
|
||||
at_register(&at_building_action);
|
||||
}
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ struct building_type;
|
|||
#define SPELLNAME_VERSION 321 /* reference spells by name */
|
||||
#define TERRAIN_VERSION 322 /* terrains are a full type and saved by name */
|
||||
#define REGIONITEMS_VERSION 323 /* regions have items */
|
||||
#define ATTRIBREAD_VERSION 324 /* remove a_readint */
|
||||
|
||||
#define MIN_VERSION CURSETYPE_VERSION
|
||||
#define REGIONOWNERS_VERSION 400
|
||||
|
@ -180,7 +181,7 @@ struct building_type;
|
|||
#ifdef ENEMIES
|
||||
# define RELEASE_VERSION ENEMIES_VERSION
|
||||
#else
|
||||
# define RELEASE_VERSION REGIONITEMS_VERSION
|
||||
# define RELEASE_VERSION ATTRIBREAD_VERSION
|
||||
#endif
|
||||
|
||||
#if RESOURCE_CONVERSION
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
/* kernel includes */
|
||||
#include "unit.h"
|
||||
#include "save.h"
|
||||
#include "race.h"
|
||||
#include "region.h"
|
||||
#include "item.h"
|
||||
|
@ -39,7 +40,7 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
attrib_type at_faction_special = {
|
||||
"faction_special", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"faction_special", NULL, NULL, NULL, a_writeshorts, a_readshorts
|
||||
};
|
||||
|
||||
int
|
||||
|
@ -48,7 +49,7 @@ age_prayer_timeout(attrib *a) {
|
|||
}
|
||||
|
||||
attrib_type at_prayer_timeout = {
|
||||
"prayer_timeout", NULL, NULL, age_prayer_timeout, a_writedefault, a_readdefault
|
||||
"prayer_timeout", NULL, NULL, age_prayer_timeout, a_writeshorts, a_readshorts
|
||||
};
|
||||
|
||||
attrib_type at_prayer_effect = {
|
||||
|
@ -56,15 +57,15 @@ attrib_type at_prayer_effect = {
|
|||
};
|
||||
|
||||
attrib_type at_wyrm = {
|
||||
"wyrm", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"wyrm", NULL, NULL, NULL, a_writeint, a_readint
|
||||
};
|
||||
|
||||
attrib_type at_fshidden = {
|
||||
"fshidden", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"fshidden", NULL, NULL, NULL, a_writeint, a_readint
|
||||
};
|
||||
|
||||
attrib_type at_jihad = {
|
||||
"jihad", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"jihad", NULL, NULL, NULL, a_writeshorts, a_readshorts
|
||||
};
|
||||
|
||||
struct fspecialdata fspecials[MAXFACTIONSPECIALS] = {
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "race.h"
|
||||
#include "region.h"
|
||||
#include "render.h"
|
||||
#include "save.h"
|
||||
#include "ship.h"
|
||||
#include "skill.h"
|
||||
#include "terrain.h"
|
||||
|
@ -45,8 +46,9 @@
|
|||
#include "unit.h"
|
||||
|
||||
/* util includes */
|
||||
#include <util/goodies.h>
|
||||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/goodies.h>
|
||||
#include <util/language.h>
|
||||
#include <util/rand.h>
|
||||
|
||||
|
@ -76,8 +78,8 @@ static attrib_type at_traveldir = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE, /* Weil normales Aging an ungünstiger Stelle */
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ
|
||||
a_writechars,
|
||||
a_readchars
|
||||
};
|
||||
|
||||
typedef struct follower {
|
||||
|
@ -170,8 +172,8 @@ attrib_type at_speedup = {
|
|||
"speedup",
|
||||
NULL, NULL,
|
||||
age_speedup,
|
||||
a_writedefault,
|
||||
a_readdefault
|
||||
a_writeint,
|
||||
a_readint
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "plane.h"
|
||||
#include "region.h"
|
||||
#include "resources.h"
|
||||
#include "save.h"
|
||||
#include "terrain.h"
|
||||
#include "terrainid.h"
|
||||
#include "unit.h"
|
||||
|
@ -481,8 +482,8 @@ attrib_type at_chaoscount = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -494,8 +495,8 @@ attrib_type at_deathcount = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -507,8 +508,8 @@ attrib_type at_woodcount = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
@ -558,22 +559,6 @@ rlaen(const region * r)
|
|||
return a->data.i;
|
||||
}
|
||||
|
||||
/***************/
|
||||
/* at_road */
|
||||
/***************/
|
||||
attrib_type at_road = {
|
||||
"road",
|
||||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
#if RELEASE_VERSION<NEWROAD_VERSION
|
||||
DEFAULT_WRITE,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
DEFAULT_READ
|
||||
};
|
||||
|
||||
void
|
||||
rsetroad(region * r, direction_t d, short val)
|
||||
{
|
||||
|
|
|
@ -151,7 +151,6 @@ extern attrib_type at_chaoscount;
|
|||
extern attrib_type at_woodcount;
|
||||
extern attrib_type at_deathcount;
|
||||
extern attrib_type at_travelunit;
|
||||
extern attrib_type at_road;
|
||||
extern attrib_type at_laen;
|
||||
|
||||
void initrhash(void);
|
||||
|
|
|
@ -2105,3 +2105,104 @@ writegame(const char *filename, char quiet)
|
|||
printf("\nOk.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
a_readint(attrib * a, FILE * f)
|
||||
{
|
||||
/* assert(sizeof(int)==sizeof(a->data)); */
|
||||
fscanf(f, "%d", &a->data.i);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writeint(const attrib * a, FILE * f)
|
||||
{
|
||||
fprintf(f, "%d ", a->data.i);
|
||||
}
|
||||
|
||||
int
|
||||
a_readshorts(attrib * a, FILE * f)
|
||||
{
|
||||
if (global.data_version<ATTRIBREAD_VERSION) {
|
||||
return a_readint(a, f);
|
||||
}
|
||||
fscanf(f, "%hd %hd", &a->data.sa[0], &a->data.sa[1]);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writeshorts(const attrib * a, FILE * f)
|
||||
{
|
||||
fprintf(f, "%hd %hd ", a->data.sa[0], a->data.sa[1]);
|
||||
}
|
||||
|
||||
int
|
||||
a_readchars(attrib * a, FILE * f)
|
||||
{
|
||||
if (global.data_version<ATTRIBREAD_VERSION) {
|
||||
return a_readint(a, f);
|
||||
}
|
||||
fscanf(f, "%c %c %c %c",
|
||||
&a->data.ca[0], &a->data.ca[1], &a->data.ca[2], &a->data.ca[3]);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writechars(const attrib * a, FILE * f)
|
||||
{
|
||||
fprintf(f, "%c %c %c %c ",
|
||||
a->data.ca[0], a->data.ca[1], a->data.ca[2], a->data.ca[3]);
|
||||
}
|
||||
|
||||
int
|
||||
a_readvoid(attrib * a, FILE * f)
|
||||
{
|
||||
if (global.data_version<ATTRIBREAD_VERSION) {
|
||||
return a_readint(a, f);
|
||||
}
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writevoid(const attrib * a, FILE * f)
|
||||
{
|
||||
}
|
||||
|
||||
static char *
|
||||
read_quoted(FILE * f, char *c, size_t size)
|
||||
{
|
||||
char * s = c;
|
||||
do {
|
||||
*s = (char) fgetc(f);
|
||||
} while (*s!='"');
|
||||
|
||||
for (;;) {
|
||||
*s = (char) fgetc(f);
|
||||
if (*s=='"') break;
|
||||
if (s<c+size) ++s;
|
||||
}
|
||||
*s = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
a_readstring(attrib * a, FILE * f)
|
||||
{
|
||||
char zText[4096];
|
||||
read_quoted(f, zText, sizeof(zText));
|
||||
a->data.v = strdup(zText);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writestring(const attrib * a, FILE * f)
|
||||
{
|
||||
assert(a->data.v);
|
||||
fprintf(f, "\"%s\" ", (char*)a->data.v);
|
||||
}
|
||||
|
||||
void
|
||||
a_finalizestring(attrib * a)
|
||||
{
|
||||
free(a->data.v);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,18 @@ extern struct faction * readfaction(FILE * stream);
|
|||
|
||||
extern void fwriteorder(FILE * F, const struct order * ord, const struct locale * lang);
|
||||
|
||||
extern int a_readint(struct attrib * a, FILE * F);
|
||||
extern void a_writeint(const struct attrib * a, FILE * F);
|
||||
extern int a_readshorts(struct attrib * a, FILE * F);
|
||||
extern void a_writeshorts(const struct attrib * a, FILE * F);
|
||||
extern int a_readchars(struct attrib * a, FILE * F);
|
||||
extern void a_writechars(const struct attrib * a, FILE * F);
|
||||
extern int a_readvoid(struct attrib * a, FILE * F);
|
||||
extern void a_writevoid(const struct attrib * a, FILE * F);
|
||||
extern int a_readstring(struct attrib * a, FILE * F);
|
||||
extern void a_writestring(const struct attrib * a, FILE * F);
|
||||
extern void a_finalizestring(struct attrib * a);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "plane.h"
|
||||
#include "race.h"
|
||||
#include "region.h"
|
||||
#include "save.h"
|
||||
#include "ship.h"
|
||||
#include "skill.h"
|
||||
#include "terrain.h"
|
||||
|
@ -42,10 +43,10 @@
|
|||
|
||||
/* util includes */
|
||||
#include <util/base36.h>
|
||||
#include <event.h>
|
||||
#include <goodies.h>
|
||||
#include <resolve.h>
|
||||
#include <variant.h>
|
||||
#include <util/event.h>
|
||||
#include <util/goodies.h>
|
||||
#include <util/resolve.h>
|
||||
#include <util/variant.h>
|
||||
|
||||
/* libc includes */
|
||||
#include <assert.h>
|
||||
|
@ -546,7 +547,7 @@ read_unit_reference(unit ** up, FILE * F)
|
|||
}
|
||||
|
||||
attrib_type at_stealth = {
|
||||
"stealth", NULL, NULL, NULL, DEFAULT_WRITE, DEFAULT_READ
|
||||
"stealth", NULL, NULL, NULL, a_writeint, a_readint
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
#define PFL_MUSEUM PFL_NOMONSTERS | PFL_NOCOORDS | PFL_NORECRUITS | PFL_NOGIVE | PFL_NOATTACK | PFL_NOTERRAIN | PFL_NOMAGIC | PFL_NOSTEALTH | PFL_NOTEACH | PFL_NOBUILD | PFL_NOFEED
|
||||
|
||||
attrib_type at_museumexit = {
|
||||
"museumexit", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"museumexit", NULL, NULL, NULL, a_writeshorts, a_readshorts
|
||||
};
|
||||
|
||||
static void
|
||||
|
@ -90,7 +90,7 @@ attrib_type at_museumgivebackcookie = {
|
|||
};
|
||||
|
||||
attrib_type at_warden = {
|
||||
"itemwarden", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"itemwarden", NULL, NULL, NULL, a_writeint, a_readint
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <kernel/message.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/unit.h>
|
||||
|
||||
|
@ -39,8 +40,8 @@ attrib_type at_xontormiaexpress = {
|
|||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
DEFAULT_WRITE,
|
||||
DEFAULT_READ,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ extern void ct_register(const struct curse_type * ct);
|
|||
#include <kernel/pool.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/save.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/skill.h>
|
||||
#include <kernel/spell.h>
|
||||
|
@ -91,11 +92,11 @@ extern void ct_register(const struct curse_type * ct);
|
|||
static variant zero_effect = { 0 };
|
||||
|
||||
attrib_type at_unitdissolve = {
|
||||
"unitdissolve", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"unitdissolve", NULL, NULL, NULL, a_writechars, a_readchars
|
||||
};
|
||||
|
||||
attrib_type at_wdwpyramid = {
|
||||
"wdwpyramid", NULL, NULL, NULL, a_writedefault, a_readdefault
|
||||
"wdwpyramid", NULL, NULL, NULL, a_writevoid, a_readvoid
|
||||
};
|
||||
|
||||
/* ----------------------------------------------------------------------- */
|
||||
|
|
|
@ -180,59 +180,6 @@ a_new(const attrib_type * at) {
|
|||
return a;
|
||||
}
|
||||
|
||||
int
|
||||
a_readdefault(attrib * a, FILE * f)
|
||||
{
|
||||
/* assert(sizeof(int)==sizeof(a->data)); */
|
||||
fscanf(f, "%d", &a->data.i);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writedefault(const attrib * a, FILE * f)
|
||||
{
|
||||
fprintf(f, "%d ", a->data.i);
|
||||
}
|
||||
|
||||
static char *
|
||||
read_quoted(FILE * f, char *c, size_t size)
|
||||
{
|
||||
char * s = c;
|
||||
do {
|
||||
*s = (char) fgetc(f);
|
||||
} while (*s!='"');
|
||||
|
||||
for (;;) {
|
||||
*s = (char) fgetc(f);
|
||||
if (*s=='"') break;
|
||||
if (s<c+size) ++s;
|
||||
}
|
||||
*s = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
int
|
||||
a_readstring(attrib * a, FILE * f)
|
||||
{
|
||||
char zText[4096];
|
||||
read_quoted(f, zText, sizeof(zText));
|
||||
a->data.v = strdup(zText);
|
||||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
void
|
||||
a_writestring(const attrib * a, FILE * f)
|
||||
{
|
||||
assert(a->data.v);
|
||||
fprintf(f, "\"%s\" ", (char*)a->data.v);
|
||||
}
|
||||
|
||||
void
|
||||
a_finalizestring(attrib * a)
|
||||
{
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
int
|
||||
a_age(attrib ** p)
|
||||
{
|
||||
|
|
|
@ -55,13 +55,6 @@ typedef struct attrib_type {
|
|||
unsigned int hashkey;
|
||||
} attrib_type;
|
||||
|
||||
extern int a_readdefault(attrib * a, FILE * f);
|
||||
extern void a_writedefault(const attrib * a, FILE * f);
|
||||
|
||||
extern int a_readstring(attrib * a, FILE * f);
|
||||
extern void a_writestring(const attrib * a, FILE * f);
|
||||
extern void a_finalizestring(attrib * a);
|
||||
|
||||
extern void at_register(attrib_type * at);
|
||||
|
||||
extern attrib * a_select(attrib * a, const void * data, boolean(*compare)(const attrib *, const void *));
|
||||
|
@ -74,14 +67,12 @@ extern attrib * a_new(const attrib_type * at);
|
|||
extern void a_free(attrib * a);
|
||||
|
||||
extern int a_age(attrib ** attribs);
|
||||
extern int a_read(FILE * f, attrib ** attribs);
|
||||
extern void a_write(FILE * f, const attrib * attribs);
|
||||
extern int a_read(FILE * F, attrib ** attribs);
|
||||
extern void a_write(FILE * F, const attrib * attribs);
|
||||
|
||||
#define DEFAULT_AGE NULL
|
||||
#define DEFAULT_INIT NULL
|
||||
#define DEFAULT_FINALIZE NULL
|
||||
#define DEFAULT_WRITE a_writedefault
|
||||
#define DEFAULT_READ a_readdefault
|
||||
#define NO_WRITE NULL
|
||||
#define NO_READ NULL
|
||||
|
||||
|
|
Loading…
Reference in New Issue