forked from github/server
add building_create, too
This commit is contained in:
parent
fc4f32f8e0
commit
25b5f797e9
2 changed files with 13 additions and 7 deletions
|
@ -366,8 +366,7 @@ int read_building_reference(gamedata * data, building **bp)
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
*bp = findbuilding(id);
|
*bp = findbuilding(id);
|
||||||
if (*bp == NULL) {
|
if (*bp == NULL) {
|
||||||
*bp = NULL;
|
*bp = building_create(id);
|
||||||
ur_add(RESOLVE_BUILDING | id, (void**)bp, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -376,17 +375,23 @@ int read_building_reference(gamedata * data, building **bp)
|
||||||
return id;
|
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,
|
building *new_building(const struct building_type * btype, region * r,
|
||||||
const struct locale * lang)
|
const struct locale * lang)
|
||||||
{
|
{
|
||||||
building **bptr = &r->buildings;
|
building **bptr = &r->buildings;
|
||||||
building *b = (building *)calloc(1, sizeof(building));
|
int id = newcontainerid();
|
||||||
|
building *b = building_create(id);
|
||||||
const char *bname;
|
const char *bname;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
b->no = newcontainerid();
|
|
||||||
bhash(b);
|
|
||||||
|
|
||||||
b->type = btype;
|
b->type = btype;
|
||||||
b->region = r;
|
b->region = r;
|
||||||
while (*bptr)
|
while (*bptr)
|
||||||
|
|
|
@ -127,8 +127,9 @@ extern "C" {
|
||||||
const char *write_buildingname(const building * b, char *ibuf,
|
const char *write_buildingname(const building * b, char *ibuf,
|
||||||
size_t size);
|
size_t size);
|
||||||
int buildingcapacity(const struct building *b);
|
int buildingcapacity(const struct building *b);
|
||||||
|
struct building *building_create(int id);
|
||||||
struct building *new_building(const struct building_type *typ,
|
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 build_building(struct unit *u, const struct building_type *typ,
|
||||||
int id, int size, struct order *ord);
|
int id, int size, struct order *ord);
|
||||||
bool building_finished(const struct building *b);
|
bool building_finished(const struct building *b);
|
||||||
|
|
Loading…
Reference in a new issue