diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index b25827b23..9d6eff8cb 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -255,15 +255,8 @@ init_smithy(struct building_type * bt) static const char * castle_name_i(const struct building_type* btype, int bsize, const char * fname[]) { - const construction * ctype; - int i = 0; + int i = bt_effsize(btype, bsize); - ctype = btype->construction; - while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) { - bsize-=ctype->maxsize; - ctype=ctype->improvement; - ++i; - } return fname[i]; } @@ -304,16 +297,7 @@ fort_name(const struct building_type* btype, int bsize) "guardhouse", "guardtower", }; - const construction * ctype; - int i = 0; - - ctype = btype->construction; - while (ctype && ctype->maxsize != -1 && ctype->maxsize<=bsize) { - bsize-=ctype->maxsize; - ctype=ctype->improvement; - ++i; - } - return fname[i]; + return castle_name_i(btype, bsize, fname); } #ifdef WDW_PYRAMID @@ -577,8 +561,6 @@ extern struct attrib_type at_icastle; int buildingeffsize(const building * b, boolean img) { - int i = b->size, n = 0; - const construction * cons; const struct building_type * btype = NULL; if (b==NULL) return 0; @@ -590,7 +572,14 @@ buildingeffsize(const building * b, boolean img) btype = (const struct building_type *)a->data.v; } } - cons = btype->construction; + return bt_effsize(btype, b->size); +} + +int bt_effsize(const building_type * btype, int bsize) +{ + int i = bsize, n = 0; + const construction * cons = btype->construction; + if (!cons || !cons->improvement) { return 0; } diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index 0e379571f..8e46168ed 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -67,7 +67,8 @@ typedef struct building_type { extern building_type * bt_find(const char* name); extern void register_buildings(void); -extern void bt_register(building_type * type); +extern void bt_register(struct building_type * type); +extern int bt_effsize(const struct building_type * btype, int bsize); /* buildingt => building_type * Name => locale_string(name) diff --git a/src/res/buildings/castle-2.xml b/src/res/buildings/castle-2.xml index cda8b8f67..5f48e73ee 100644 --- a/src/res/buildings/castle-2.xml +++ b/src/res/buildings/castle-2.xml @@ -3,19 +3,19 @@ - + - + - + - + - + diff --git a/src/res/e3a/buildings.xml b/src/res/e3a/buildings.xml index 015d57fe4..f6d89512d 100644 --- a/src/res/e3a/buildings.xml +++ b/src/res/e3a/buildings.xml @@ -7,13 +7,13 @@ - + - + - +