From 0fedaf43b2770a9868896419f0ab77162ce8581b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 28 May 2007 09:46:23 +0000 Subject: [PATCH] building_type::name gets an extra parameter (for future use) --- src/common/kernel/building.c | 21 ++++++--------------- src/common/kernel/building.h | 2 +- src/common/kernel/xmlreader.c | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 87d56e9e7..b843a47ee 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -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; diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index f16853264..4c49ab226 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -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; diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index 2850d433c..d68ffd2af 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -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 {