forked from github/server
building_type::name gets an extra parameter (for future use)
This commit is contained in:
parent
e2c06c8b46
commit
0fedaf43b2
|
@ -186,7 +186,7 @@ buildingtype(const building_type * btype, const building * b, int bsize)
|
||||||
if (a) s = (const char*)a->data.v;
|
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;
|
if (s==NULL) s = btype->_name;
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ init_smithy(struct building_type * bt)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
castle_name(int bsize)
|
castle_name(const struct building_type* btype, int bsize)
|
||||||
{
|
{
|
||||||
const char * fname[MAXBUILDINGS] = {
|
const char * fname[MAXBUILDINGS] = {
|
||||||
"site",
|
"site",
|
||||||
|
@ -282,15 +282,10 @@ castle_name(int bsize)
|
||||||
"fortress",
|
"fortress",
|
||||||
"citadel" };
|
"citadel" };
|
||||||
const construction * ctype;
|
const construction * ctype;
|
||||||
static const struct building_type * bt_castle;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!bt_castle) bt_castle = bt_find("castle");
|
ctype = btype->construction;
|
||||||
assert(bt_castle);
|
while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
|
||||||
ctype = bt_castle->construction;
|
|
||||||
while (ctype &&
|
|
||||||
ctype->maxsize != -1
|
|
||||||
&& ctype->maxsize<=bsize) {
|
|
||||||
bsize-=ctype->maxsize;
|
bsize-=ctype->maxsize;
|
||||||
ctype=ctype->improvement;
|
ctype=ctype->improvement;
|
||||||
++i;
|
++i;
|
||||||
|
@ -301,17 +296,13 @@ castle_name(int bsize)
|
||||||
#ifdef WDW_PYRAMID
|
#ifdef WDW_PYRAMID
|
||||||
|
|
||||||
static const char *
|
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];
|
static char p_name_buf[32];
|
||||||
int level=0;
|
int level=0;
|
||||||
const construction * ctype;
|
const construction * ctype;
|
||||||
|
|
||||||
if(!bt_pyramid) bt_pyramid = bt_find("pyramid");
|
ctype = btype->construction;
|
||||||
assert(bt_pyramid);
|
|
||||||
|
|
||||||
ctype = bt_pyramid->construction;
|
|
||||||
|
|
||||||
while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
|
while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) {
|
||||||
bsize-=ctype->maxsize;
|
bsize-=ctype->maxsize;
|
||||||
|
|
|
@ -55,7 +55,7 @@ typedef struct building_type {
|
||||||
struct maintenance * maintenance; /* array of requirements */
|
struct maintenance * maintenance; /* array of requirements */
|
||||||
struct construction * construction; /* construction of 1 building-level */
|
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*);
|
void (*init)(struct building_type*);
|
||||||
struct attrib * attribs;
|
struct attrib * attribs;
|
||||||
} building_type;
|
} building_type;
|
||||||
|
|
|
@ -297,7 +297,7 @@ parse_buildings(xmlDocPtr doc)
|
||||||
}
|
}
|
||||||
assert(property!=NULL);
|
assert(property!=NULL);
|
||||||
if (strcmp((const char*)property, "name")==0) {
|
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) {
|
} else if (strcmp((const char*)property, "init")==0) {
|
||||||
btype->init = (void (*)(struct building_type*))fun;
|
btype->init = (void (*)(struct building_type*))fun;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue