diff --git a/src/kernel/building.c b/src/kernel/building.c index 8cbe5c180..456ad1704 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -366,8 +366,7 @@ int read_building_reference(gamedata * data, building **bp) if (id > 0) { *bp = findbuilding(id); if (*bp == NULL) { - *bp = NULL; - ur_add(RESOLVE_BUILDING | id, (void**)bp, NULL); + *bp = building_create(id); } } else { @@ -376,17 +375,23 @@ int read_building_reference(gamedata * data, building **bp) return id; } +building *building_create(int id) +{ + building *b = (building *)calloc(1, sizeof(building)); + b->no = id; + bhash(b); + return b; +} + building *new_building(const struct building_type * btype, region * r, const struct locale * lang) { building **bptr = &r->buildings; - building *b = (building *)calloc(1, sizeof(building)); + int id = newcontainerid(); + building *b = building_create(id); const char *bname; char buffer[32]; - b->no = newcontainerid(); - bhash(b); - b->type = btype; b->region = r; while (*bptr) diff --git a/src/kernel/building.h b/src/kernel/building.h index 2a0a77cde..a5419325f 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -127,8 +127,9 @@ extern "C" { const char *write_buildingname(const building * b, char *ibuf, size_t size); int buildingcapacity(const struct building *b); + struct building *building_create(int id); struct building *new_building(const struct building_type *typ, - struct region *r, const struct locale *lang); + struct region *r, const struct locale *lang); int build_building(struct unit *u, const struct building_type *typ, int id, int size, struct order *ord); bool building_finished(const struct building *b);