From 233ea9dce4e393e4a4b0ab68db0863e93f7b9fab Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 17 Jul 2017 17:08:27 +0200 Subject: [PATCH] BUG 2337: lighthouse capacity is # of units, not people. --- conf/e2/config.json | 3 ++- conf/e3/config.json | 1 + src/reports.c | 9 ++++++++- src/reports.test.c | 9 +++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/conf/e2/config.json b/conf/e2/config.json index fb231e2eb..b8ca2f178 100644 --- a/conf/e2/config.json +++ b/conf/e2/config.json @@ -35,6 +35,7 @@ "rules.guard.guard_number_stop_prob": 0.001, "rules.guard.castle_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 } } diff --git a/conf/e3/config.json b/conf/e3/config.json index bfd1bd0fc..3305ce221 100644 --- a/conf/e3/config.json +++ b/conf/e3/config.json @@ -92,6 +92,7 @@ "rules.grow.formula": 1, "rules.tactics.formula": 1, "rules.help.mask": "fight guard money give", + "rules.lighthouse.unit_capacity": true, "movement.shipspeed.skillbonus": 6, "alliance.auto": "fight", "alliance.restricted": "fight" diff --git a/src/reports.c b/src/reports.c index 1a269caa5..e989aee40 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1405,10 +1405,12 @@ void prepare_report(report_context *ctx, faction *f) region *r; static int config; static bool rule_region_owners; + static bool rule_lighthouse_units; const struct building_type *bt_lighthouse = bt_find("lighthouse"); if (bt_lighthouse && config_changed(&config)) { 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) { @@ -1471,7 +1473,12 @@ void prepare_report(report_context *ctx, faction *f) c = buildingcapacity(b); br = 0; } - c -= u->number; + if (rule_lighthouse_units) { + --c; + } + else { + c -= u->number; + } if (u->faction == f && c >= 0) { /* unit is one of ours, and inside the current lighthouse */ if (br == 0) { diff --git a/src/reports.test.c b/src/reports.test.c index 74750e9b5..1efd6369a 100644 --- a/src/reports.test.c +++ b/src/reports.test.c @@ -496,6 +496,15 @@ void test_prepare_lighthouse_capacity(CuTest *tc) { CuAssertIntEquals(tc, seen_neighbour, r2->seen.mode); 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(); }