building_type::name gets an extra parameter (for future use)

This commit is contained in:
Enno Rehling 2007-05-28 09:46:23 +00:00
parent e2c06c8b46
commit 0fedaf43b2
3 changed files with 8 additions and 17 deletions

View File

@ -186,7 +186,7 @@ buildingtype(const building_type * btype, const building * b, int bsize)
if (a) s = (const char*)a->data.v;
}
if (btype->name) s = btype->name(bsize);
if (btype->name) s = btype->name(btype, bsize);
if (s==NULL) s = btype->_name;
return s;
}
@ -271,7 +271,7 @@ init_smithy(struct building_type * bt)
}
static const char *
castle_name(int bsize)
castle_name(const struct building_type* btype, int bsize)
{
const char * fname[MAXBUILDINGS] = {
"site",
@ -282,15 +282,10 @@ castle_name(int bsize)
"fortress",
"citadel" };
const construction * ctype;
static const struct building_type * bt_castle;
int i = 0;
if (!bt_castle) bt_castle = bt_find("castle");
assert(bt_castle);
ctype = bt_castle->construction;
while (ctype &&
ctype->maxsize != -1
&& ctype->maxsize<=bsize) {
ctype = btype->construction;
while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
bsize-=ctype->maxsize;
ctype=ctype->improvement;
++i;
@ -301,17 +296,13 @@ castle_name(int bsize)
#ifdef WDW_PYRAMID
static const char *
pyramid_name(int bsize)
pyramid_name(const struct building_type* btype, int bsize)
{
static const struct building_type * bt_pyramid;
static char p_name_buf[32];
int level=0;
const construction * ctype;
if(!bt_pyramid) bt_pyramid = bt_find("pyramid");
assert(bt_pyramid);
ctype = bt_pyramid->construction;
ctype = btype->construction;
while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
bsize-=ctype->maxsize;

View File

@ -55,7 +55,7 @@ typedef struct building_type {
struct maintenance * maintenance; /* array of requirements */
struct construction * construction; /* construction of 1 building-level */
const char * (*name)(int size);
const char * (*name)(const struct building_type*, int size);
void (*init)(struct building_type*);
struct attrib * attribs;
} building_type;

View File

@ -297,7 +297,7 @@ parse_buildings(xmlDocPtr doc)
}
assert(property!=NULL);
if (strcmp((const char*)property, "name")==0) {
btype->name = (const char * (*)(int size))fun;
btype->name = (const char * (*)(const struct building_type*, int size))fun;
} else if (strcmp((const char*)property, "init")==0) {
btype->init = (void (*)(struct building_type*))fun;
} else {