diff --git a/src/battle.c b/src/battle.c index 599631e30..4159cf0c7 100644 --- a/src/battle.c +++ b/src/battle.c @@ -1926,8 +1926,7 @@ int skilldiff(troop at, troop dt, int dist) } } if (b->type->flags & BTF_FORTIFICATION) { - int stage = buildingeffsize(b, false); - int beff = bt_protection(b->type, stage); + int beff = building_protection(b); if (beff > 0) { skdiff -= beff; is_protected = 2; diff --git a/src/kernel/building.c b/src/kernel/building.c index 7dd4a523f..86c0d2b35 100644 --- a/src/kernel/building.c +++ b/src/kernel/building.c @@ -335,6 +335,10 @@ int bt_protection(const building_type * btype, int stage) return watch_bonus[stage]; } +int building_protection(const building* b) { + return bt_protection(b->type, buildingeffsize(b, false)); +} + void write_building_reference(const struct building *b, struct storage *store) { WRITE_INT(store, (b && b->region) ? b->no : 0); diff --git a/src/kernel/building.h b/src/kernel/building.h index 7b48aa3ad..3ebb52ec2 100644 --- a/src/kernel/building.h +++ b/src/kernel/building.h @@ -106,7 +106,7 @@ extern "C" { const char *buildingtype(const building_type * btype, const struct building *b, int bsize); - const char *write_buildingname(const building * b, char *ibuf, + const char *write_buildingname(const building *b, char *ibuf, size_t size); int buildingcapacity(const struct building *b); struct building *building_create(int id); @@ -115,12 +115,13 @@ extern "C" { 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); + int building_protection(const struct building *b); int wage(const struct region *r, const struct race *rc); int peasant_wage(const struct region *r, bool mourn); - typedef int(*cmp_building_cb) (const struct building * b, - const struct building * a); + typedef int(*cmp_building_cb) (const struct building *b, + const struct building *a); struct building *largestbuilding(const struct region *r, cmp_building_cb, bool imaginary); int cmp_wage(const struct building *b, const struct building *bother);