BUG 2337: lighthouse capacity is # of units, not people.

This commit is contained in:
Enno Rehling 2017-07-17 17:08:27 +02:00
parent f8de1bf29e
commit 233ea9dce4
4 changed files with 20 additions and 2 deletions

View File

@ -35,6 +35,7 @@
"rules.guard.guard_number_stop_prob": 0.001, "rules.guard.guard_number_stop_prob": 0.001,
"rules.guard.castle_stop_prob": 0.05, "rules.guard.castle_stop_prob": 0.05,
"rules.guard.region_type_stop_prob": 0.05, "rules.guard.region_type_stop_prob": 0.05,
"rules.economy.repopulate_maximum": 500 "rules.economy.repopulate_maximum": 500,
"rules.lighthouse.unit_capacity": true
} }
} }

View File

@ -92,6 +92,7 @@
"rules.grow.formula": 1, "rules.grow.formula": 1,
"rules.tactics.formula": 1, "rules.tactics.formula": 1,
"rules.help.mask": "fight guard money give", "rules.help.mask": "fight guard money give",
"rules.lighthouse.unit_capacity": true,
"movement.shipspeed.skillbonus": 6, "movement.shipspeed.skillbonus": 6,
"alliance.auto": "fight", "alliance.auto": "fight",
"alliance.restricted": "fight" "alliance.restricted": "fight"

View File

@ -1405,10 +1405,12 @@ void prepare_report(report_context *ctx, faction *f)
region *r; region *r;
static int config; static int config;
static bool rule_region_owners; static bool rule_region_owners;
static bool rule_lighthouse_units;
const struct building_type *bt_lighthouse = bt_find("lighthouse"); const struct building_type *bt_lighthouse = bt_find("lighthouse");
if (bt_lighthouse && config_changed(&config)) { if (bt_lighthouse && config_changed(&config)) {
rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name); rule_region_owners = config_token("rules.region_owner_pay_building", bt_lighthouse->_name);
rule_lighthouse_units = config_get_int("rules.lighthouse.unit_capacity", 0) != 0;
} }
if (f->age <= 2) { if (f->age <= 2) {
@ -1471,7 +1473,12 @@ void prepare_report(report_context *ctx, faction *f)
c = buildingcapacity(b); c = buildingcapacity(b);
br = 0; br = 0;
} }
c -= u->number; if (rule_lighthouse_units) {
--c;
}
else {
c -= u->number;
}
if (u->faction == f && c >= 0) { if (u->faction == f && c >= 0) {
/* unit is one of ours, and inside the current lighthouse */ /* unit is one of ours, and inside the current lighthouse */
if (br == 0) { if (br == 0) {

View File

@ -496,6 +496,15 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode); CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode);
finish_reports(&ctx); finish_reports(&ctx);
// lighthouse capacity is # of units, not people:
config_set_int("rules.lighthouse.unit_capacity", 1);
prepare_report(&ctx, u2->faction);
CuAssertPtrEquals(tc, r1, ctx.first);
CuAssertPtrEquals(tc, 0, ctx.last);
CuAssertIntEquals(tc, seen_unit, r1->seen.mode);
CuAssertIntEquals(tc, seen_lighthouse, r2->seen.mode);
finish_reports(&ctx);
test_cleanup(); test_cleanup();
} }