add building_create, too

This commit is contained in:
Enno Rehling 2018-11-01 21:18:24 +01:00
parent fc4f32f8e0
commit 25b5f797e9
2 changed files with 13 additions and 7 deletions

View file

@ -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)

View file

@ -127,6 +127,7 @@ 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);
int build_building(struct unit *u, const struct building_type *typ,