* BUGFIX: recycling bei gebäudeeinriss repariert

* BUGFIX: einlesen von mehr als einem konstruktionsmaterial
This commit is contained in:
Enno Rehling 2002-04-01 14:22:00 +00:00
parent 0ed7434f3c
commit fa4a09ae99
6 changed files with 109 additions and 177 deletions

View File

@ -46,6 +46,7 @@
#include <event.h>
#include <goodies.h>
#include <resolve.h>
#include <xml.h>
/* from libc */
#include <assert.h>
@ -1211,3 +1212,32 @@ do_misc(char try)
}
}
void
xml_readrequirement(const struct xml_tag * tag, construction * con)
{
requirement * radd;
const resource_type * rtype;
resource_t type = NORESOURCE;
assert(con!=NULL);
if (con->materials) {
int size = 0;
while (con->materials[size].number) ++size;
con->materials = realloc(con->materials, sizeof(requirement) * (size+2));
radd = con->materials+size;
} else {
radd = con->materials = malloc(sizeof(requirement) * 2);
}
radd->number = xml_ivalue(tag, "quantity");
radd->recycle = xml_fvalue(tag, "recycle");
rtype = rt_find(xml_value(tag, "type"));
for (type=0;type!=MAX_RESOURCES;++type) {
if (oldresourcetype[type]==rtype) {
radd->type = type;
break;
}
}
radd[1].number = 0;
radd[1].type = 0;
}

View File

@ -26,74 +26,7 @@
* wichtig
*/
#ifndef NEW_BUILDINGS
enum {
B_SITE,
#if LARGE_CASTLES
B_TRADEPOST,
#endif
B_FORTIFICATION,
B_TOWER,
B_CASTLE,
B_FORTRESS,
B_CITADEL,
MAXBUILDINGS
};
enum {
BT_BURG,
BT_LEUCHTTURM,
BT_BERGWERK,
BT_STEINBRUCH,
BT_HAFEN,
BT_UNIVERSITAET,
BT_MAGIERTURM,
BT_SCHMIEDE,
BT_SAEGEWERK,
BT_PFERDEZUCHT,
BT_MONUMENT,
BT_DAMM,
BT_KARAWANSEREI,
BT_TUNNEL,
BT_TAVERNE,
BT_STONECIRCLE,
BT_BLESSEDSTONECIRCLE,
BT_ICASTLE,
MAXBUILDINGTYPES,
NOBUILDING = -1
};
#endif
extern char *buildingnames[MAXBUILDINGS];
void destroy(struct region * r, struct unit * u, const char * cmd);
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
void do_siege(void);
void build_road(struct region * r, struct unit * u, int size, direction_t d);
void create_ship(struct region * r, struct unit * u, const struct ship_type * newtype, int size);
void continue_ship(struct region * r, struct unit * u, int size);
struct building * getbuilding(const struct region * r);
struct ship *getship(const struct region * r);
void remove_contacts(void);
void do_leave(void);
void do_misc(char try);
void reportevent(struct region * r, char *s);
void shash(struct ship * sh);
void sunhash(struct ship * sh);
void destroy_ship(struct ship * s, struct region * r);
/* ** ** ** ** ** ** *
* new build rules *
* ** ** ** ** ** ** */
struct xml_tag;
typedef struct requirement {
#ifdef NO_OLD_ITEMS
@ -125,8 +58,33 @@ typedef struct construction {
/* stores skill modifiers and other attributes */
} construction;
int build(struct unit * u, const construction * ctype, int completed, int want);
int maxbuild(const struct unit *u, const construction *cons);
void destroy(struct region * r, struct unit * u, const char * cmd);
extern boolean can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
void do_siege(void);
void build_road(struct region * r, struct unit * u, int size, direction_t d);
void create_ship(struct region * r, struct unit * u, const struct ship_type * newtype, int size);
void continue_ship(struct region * r, struct unit * u, int size);
struct building * getbuilding(const struct region * r);
struct ship *getship(const struct region * r);
void remove_contacts(void);
void do_leave(void);
void do_misc(char try);
void reportevent(struct region * r, char *s);
void shash(struct ship * sh);
void sunhash(struct ship * sh);
void destroy_ship(struct ship * s, struct region * r);
extern int build(struct unit * u, const construction * ctype, int completed, int want);
extern int maxbuild(const struct unit *u, const construction *cons);
extern void xml_readrequirement(const struct xml_tag * tag, construction * con);
/** error messages that build may return: */
#define ELOWSKILL -1

View File

@ -183,7 +183,6 @@ findbuilding(int i)
/** Building: Fortification */
#ifdef NEW_BUILDINGS
enum {
B_SITE,
#if LARGE_CASTLES
@ -196,7 +195,6 @@ enum {
B_CITADEL,
MAXBUILDINGS
};
#endif
static int
sm_smithy(const unit * u, const region * r, skill_t sk, int value) /* skillmod */
@ -408,34 +406,7 @@ tagbegin(struct xml_stack * stack)
if (xml_bvalue(tag, "variable")) mt[len].flags |= MTF_VARIABLE;
if (xml_bvalue(tag, "vital")) mt[len].flags |= MTF_VITAL;
} else if (strcmp(tag->name, "requirement")==0) {
construction * con = (construction *)bt->construction;
if (con!=NULL) {
const resource_type * rtype;
resource_t type = NORESOURCE;
requirement * radd = con->materials;
if (radd) {
requirement * rnew;
int size;
for (size=0;radd[size++].number;);
rnew = malloc(sizeof(requirement) * (size+2));
memcpy(rnew, radd, size*sizeof(requirement));
free(radd);
con->materials = rnew;
radd = rnew+size;
} else {
radd = con->materials = calloc(sizeof(requirement), 2);
}
radd[0].number = xml_ivalue(tag, "quantity");
rtype = rt_find(xml_value(tag, "type"));
for (type=0;type!=MAX_RESOURCES;++type) {
if (oldresourcetype[type]==rtype) {
radd[0].type = type;
break;
}
}
radd[1].number = 0;
radd[1].type = 0;
}
xml_readrequirement(tag, bt->construction);
}
}
return XML_OK;

View File

@ -47,7 +47,7 @@ typedef struct building_type {
int fumblebonus; /* bonus that reduces fumbling */
double auraregen; /* modifier for aura regeneration inside building */
struct maintenance * maintenance; /* array of requirements */
const struct construction * construction; /* construction of 1 building-level */
struct construction * construction; /* construction of 1 building-level */
const char * (*name)(int size);
void (*init)(struct building_type*);

View File

@ -289,34 +289,7 @@ tagbegin(struct xml_stack * stack)
con->reqsize = xml_ivalue(tag, "reqsize");
con->skill = sk_find(xml_value(tag, "skill"));
} else if (strcmp(tag->name, "requirement")==0) {
construction * con = st->construction;
if (con!=NULL) {
const resource_type * rtype;
resource_t type = NORESOURCE;
requirement * radd = con->materials;
if (radd) {
requirement * rnew;
int size;
for (size=0;radd[size++].number;);
rnew = malloc(sizeof(requirement) * (size+2));
memcpy(rnew, radd, size*sizeof(requirement));
free(radd);
con->materials = rnew;
radd = rnew+size;
} else {
radd = con->materials = calloc(sizeof(requirement), 2);
}
radd[0].number = xml_ivalue(tag, "quantity");
rtype = rt_find(xml_value(tag, "type"));
for (type=0;type!=MAX_RESOURCES;++type) {
if (oldresourcetype[type]==rtype) {
radd[0].type = type;
break;
}
}
radd[1].number = 0;
radd[1].type = 0;
}
xml_readrequirement(tag, st->construction);
}
}
return XML_OK;

View File

@ -15,35 +15,35 @@
<building name="blessedstonecircle" maxsize="100" nobuild magic magres="60" magresbonus="30" auraregen="1.50">
<construction skill="sk_building" minskill="2" reqsize="100" maxsize="100">
<requirement type="log" quantity="500"></requirement>
<requirement type="stone" quantity="500"></requirement>
<requirement type="log" recycle="0.5" quantity="500"></requirement>
<requirement type="stone" recycle="0.5" quantity="500"></requirement>
</construction>
</building>
<building name="stonecircle" maxsize="100">
<construction skill="sk_building" minskill="2" reqsize="100" maxsize="100">
<requirement type="log" quantity="500"></requirement>
<requirement type="stone" quantity="500"></requirement>
<requirement type="log" recycle="0.5" quantity="500"></requirement>
<requirement type="stone" recycle="0.5" quantity="500"></requirement>
</construction>
</building>
<building name="inn" capacity="1">
<maintenance type="money" amount="5" variable vital></maintenance>
<construction skill="sk_building" minskill="2" reqsize="10">
<requirement type="iron" quantity="10"></requirement>
<requirement type="log" quantity="30"></requirement>
<requirement type="stone" quantity="40"></requirement>
<requirement type="iron" recycle="0.5" quantity="10"></requirement>
<requirement type="log" recycle="0.5" quantity="30"></requirement>
<requirement type="stone" recycle="0.5" quantity="40"></requirement>
<requirement type="money" quantity="2000"></requirement>
</construction>
</building>
<building name="tunnel" capacity="1" maxsize="100">
<maintenance type="stone" amount="2"></maintenance>
<maintenance type="stone" recycle="0.5" amount="2"></maintenance>
<maintenance type="money" amount="100" vital></maintenance>
<construction skill="sk_building" minskill="6" reqsize="100" maxsize="100">
<requirement type="iron" quantity="100"></requirement>
<requirement type="log" quantity="500"></requirement>
<requirement type="stone" quantity="1000"></requirement>
<requirement type="iron" recycle="0.5" quantity="100"></requirement>
<requirement type="log" recycle="0.5" quantity="500"></requirement>
<requirement type="stone" recycle="0.5" quantity="1000"></requirement>
<requirement type="money" quantity="30000"></requirement>
</construction>
</building>
@ -52,29 +52,29 @@
<maintenance type="horse" amount="2"></maintenance>
<maintenance type="money" amount="3000" vital></maintenance>
<construction skill="sk_building" minskill="2" reqsize="10" maxsize="10">
<requirement type="iron" quantity="10"></requirement>
<requirement type="log" quantity="50"></requirement>
<requirement type="stone" quantity="10"></requirement>
<requirement type="iron" recycle="0.5" quantity="10"></requirement>
<requirement type="log" recycle="0.5" quantity="50"></requirement>
<requirement type="stone" recycle="0.5" quantity="10"></requirement>
<requirement type="money" quantity="5000"></requirement>
</construction>
</building>
<building name="dam" capacity="1" maxsize="50">
<maintenance type="log" amount="3"></maintenance>
<maintenance type="log" recycle="0.5" amount="3"></maintenance>
<maintenance type="money" amount="1000" vital></maintenance>
<construction skill="sk_building" minskill="4" reqsize="50" maxsize="50">
<requirement type="iron" quantity="50"></requirement>
<requirement type="log" quantity="500"></requirement>
<requirement type="stone" quantity="250"></requirement>
<requirement type="iron" recycle="0.5" quantity="50"></requirement>
<requirement type="log" recycle="0.5" quantity="500"></requirement>
<requirement type="stone" recycle="0.5" quantity="250"></requirement>
<requirement type="money" quantity="25000"></requirement>
</construction>
</building>
<building name="monument" capacity="1">
<construction skill="sk_building" minskill="4" reqsize="1">
<requirement type="log" quantity="1"></requirement>
<requirement type="stone" quantity="1"></requirement>
<requirement type="iron" quantity="1"></requirement>
<requirement type="log" recycle="0.5" quantity="1"></requirement>
<requirement type="stone" recycle="0.5" quantity="1"></requirement>
<requirement type="iron" recycle="0.5" quantity="1"></requirement>
<requirement type="money" quantity="400"></requirement>
</construction>
</building>
@ -82,9 +82,9 @@
<building name="stables" capacity="1">
<maintenance type="money" amount="150" vital></maintenance>
<construction skill="sk_building" minskill="2" reqsize="1">
<requirement type="log" quantity="4"></requirement>
<requirement type="stone" quantity="2"></requirement>
<requirement type="iron" quantity="1"></requirement>
<requirement type="log" recycle="0.5" quantity="4"></requirement>
<requirement type="stone" recycle="0.5" quantity="2"></requirement>
<requirement type="iron" recycle="0.5" quantity="1"></requirement>
<requirement type="money" quantity="100"></requirement>
</construction>
</building>
@ -92,9 +92,9 @@
<building name="sawmill" capacity="1">
<maintenance type="money" amount="250" vital></maintenance>
<construction skill="sk_building" minskill="3" reqsize="1">
<requirement type="log" quantity="5"></requirement>
<requirement type="stone" quantity="5"></requirement>
<requirement type="iron" quantity="3"></requirement>
<requirement type="log" recycle="0.5" quantity="5"></requirement>
<requirement type="stone" recycle="0.5" quantity="5"></requirement>
<requirement type="iron" recycle="0.5" quantity="3"></requirement>
<requirement type="money" quantity="200"></requirement>
</construction>
</building>
@ -102,11 +102,11 @@
<building name="smithy" capacity="1">
<function name="init" value="init_smithy"></function>
<maintenance type="money" amount="300" vital></maintenance>
<maintenance type="log" amount="1"></maintenance>
<maintenance type="log" recycle="0.5" amount="1"></maintenance>
<construction skill="sk_building" minskill="3" reqsize="1">
<requirement type="log" quantity="5"></requirement>
<requirement type="stone" quantity="5"></requirement>
<requirement type="iron" quantity="2"></requirement>
<requirement type="log" recycle="0.5" quantity="5"></requirement>
<requirement type="stone" recycle="0.5" quantity="5"></requirement>
<requirement type="iron" recycle="0.5" quantity="2"></requirement>
<requirement type="money" quantity="200"></requirement>
</construction>
</building>
@ -114,10 +114,10 @@
<building name="magictower" maxcapacity="2" maxsize="50" magic magres="40" fumblebonus="10" auraregen="1.75">
<maintenance type="money" amount="1000" vital></maintenance>
<construction skill="sk_building" minskill="5" reqsize="50" maxsize="50">
<requirement type="log" quantity="150"></requirement>
<requirement type="stone" quantity="250"></requirement>
<requirement type="log" recycle="0.5" quantity="150"></requirement>
<requirement type="stone" recycle="0.5" quantity="250"></requirement>
<requirement type="mallorn" quantity="100"></requirement>
<requirement type="iron" quantity="150"></requirement>
<requirement type="iron" recycle="0.5" quantity="150"></requirement>
<requirement type="laen" quantity="100"></requirement>
<requirement type="money" quantity="25000"></requirement>
</construction>
@ -126,9 +126,9 @@
<building name="academy" maxcapacity="25" maxsize="25">
<maintenance type="money" amount="1000" vital></maintenance>
<construction skill="sk_building" minskill="3" reqsize="25" maxsize="25">
<requirement type="log" quantity="125"></requirement>
<requirement type="stone" quantity="125"></requirement>
<requirement type="iron" quantity="25"></requirement>
<requirement type="log" recycle="0.5" quantity="125"></requirement>
<requirement type="stone" recycle="0.5" quantity="125"></requirement>
<requirement type="iron" recycle="0.5" quantity="25"></requirement>
<requirement type="money" quantity="12500"></requirement>
</construction>
</building>
@ -136,8 +136,8 @@
<building name="harbour" capacity="1" maxcapacity="25" maxsize="25">
<maintenance type="money" amount="250" vital></maintenance>
<construction skill="sk_building" minskill="3" reqsize="25" maxsize="25">
<requirement type="log" quantity="125"></requirement>
<requirement type="stone" quantity="125"></requirement>
<requirement type="log" recycle="0.5" quantity="125"></requirement>
<requirement type="stone" recycle="0.5" quantity="125"></requirement>
<requirement type="money" quantity="6250"></requirement>
</construction>
</building>
@ -145,9 +145,9 @@
<building name="quarry" capacity="1">
<maintenance type="money" amount="250" vital></maintenance>
<construction skill="sk_building" minskill="2" reqsize="1">
<requirement type="iron" quantity="1"></requirement>
<requirement type="log" quantity="5"></requirement>
<requirement type="stone" quantity="1"></requirement>
<requirement type="iron" recycle="0.5" quantity="1"></requirement>
<requirement type="log" recycle="0.5" quantity="5"></requirement>
<requirement type="stone" recycle="0.5" quantity="1"></requirement>
<requirement type="money" quantity="250"></requirement>
</construction>
</building>
@ -155,9 +155,9 @@
<building name="mine" capacity="1">
<maintenance type="money" amount="500" vital></maintenance>
<construction skill="sk_building" minskill="4" reqsize="1">
<requirement type="iron" quantity="1"></requirement>
<requirement type="log" quantity="10"></requirement>
<requirement type="stone" quantity="5"></requirement>
<requirement type="iron" recycle="0.5" quantity="1"></requirement>
<requirement type="log" recycle="0.5" quantity="10"></requirement>
<requirement type="stone" recycle="0.5" quantity="5"></requirement>
<requirement type="money" quantity="250"></requirement>
</construction>
</building>
@ -165,9 +165,9 @@
<building name="lighthouse" capacity="1" maxcapacity="4">
<maintenance type="money" amount="100" vital></maintenance>
<construction skill="sk_building" minskill="3" reqsize="1">
<requirement type="iron" quantity="1"></requirement>
<requirement type="log" quantity="1"></requirement>
<requirement type="stone" quantity="2"></requirement>
<requirement type="iron" recycle="0.5" quantity="1"></requirement>
<requirement type="log" recycle="0.5" quantity="1"></requirement>
<requirement type="stone" recycle="0.5" quantity="2"></requirement>
<requirement type="money" quantity="100"></requirement>
</construction>
</building>