introduce new building_protection as a shortcut.

This commit is contained in:
Enno Rehling 2021-03-13 14:25:30 +01:00
parent 376b1106a6
commit c5b8839634
3 changed files with 9 additions and 5 deletions

View file

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

View file

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

View file

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