From ac8332c896dd34783c647e706a7c2c4dcc8e9a2e Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Sep 2016 10:24:08 +0200 Subject: [PATCH] re-enable report tests. RF_LIGHTHOUSE also flags for lighthouses with size 0. --- s/travis-build | 2 +- scripts/tests/e2/init.lua | 2 +- scripts/tests/process.lua | 2 +- src/lighthouse.c | 53 ++++++++++++++++++++------------------- src/lighthouse.test.c | 2 +- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/s/travis-build b/s/travis-build index 4c6dbcee8..45db05c60 100755 --- a/s/travis-build +++ b/s/travis-build @@ -25,4 +25,4 @@ cd $ROOT inifile s/runtests -# integraton_tests +integraton_tests diff --git a/scripts/tests/e2/init.lua b/scripts/tests/e2/init.lua index 1f325aa17..2fdad1898 100644 --- a/scripts/tests/e2/init.lua +++ b/scripts/tests/e2/init.lua @@ -8,7 +8,7 @@ require 'tests.e2.spells' require 'tests.e2.stealth' require 'tests.orders' require 'tests.common' --- require 'tests.report' +require 'tests.report' require 'tests.storage' require 'tests.magicbag' require 'tests.process' diff --git a/scripts/tests/process.lua b/scripts/tests/process.lua index 63b96ddcd..3256c73e6 100644 --- a/scripts/tests/process.lua +++ b/scripts/tests/process.lua @@ -23,7 +23,7 @@ local function assert_file(filename) os.remove(filename) end -function disable_test_process_turn() +function test_process_turn() u:add_order("NUMMER PARTEI 777") process_orders() assert_equal(0, init_reports()) diff --git a/src/lighthouse.c b/src/lighthouse.c index 54591cd16..96b42b333 100644 --- a/src/lighthouse.c +++ b/src/lighthouse.c @@ -26,36 +26,37 @@ const attrib_type at_lighthouse = { */ void update_lighthouse(building * lh) { - if (lh->size>0 && is_building_type(lh->type, "lighthouse")) { + if (is_building_type(lh->type, "lighthouse")) { region *r = lh->region; - int d = (int)log10(lh->size) + 1; - int x; r->flags |= RF_LIGHTHOUSE; + if (lh->size > 0) { + int d = (int)log10(lh->size) + 1; + int x; + for (x = -d; x <= d; ++x) { + int y; + for (y = -d; y <= d; ++y) { + attrib *a; + region *r2; + int px = r->x + x, py = r->y + y; - for (x = -d; x <= d; ++x) { - int y; - for (y = -d; y <= d; ++y) { - attrib *a; - region *r2; - int px = r->x + x, py = r->y + y; - - pnormalize(&px, &py, rplane(r)); - r2 = findregion(px, py); - if (!r2 || !fval(r2->terrain, SEA_REGION)) - continue; - if (distance(r, r2) > d) - continue; - a = a_find(r2->attribs, &at_lighthouse); - while (a && a->type == &at_lighthouse) { - building *b = (building *)a->data.v; - if (b == lh) - break; - a = a->next; - } - if (!a) { - a = a_add(&r2->attribs, a_new(&at_lighthouse)); - a->data.v = (void *)lh; + pnormalize(&px, &py, rplane(r)); + r2 = findregion(px, py); + if (!r2 || !fval(r2->terrain, SEA_REGION)) + continue; + if (distance(r, r2) > d) + continue; + a = a_find(r2->attribs, &at_lighthouse); + while (a && a->type == &at_lighthouse) { + building *b = (building *)a->data.v; + if (b == lh) + break; + a = a->next; + } + if (!a) { + a = a_add(&r2->attribs, a_new(&at_lighthouse)); + a->data.v = (void *)lh; + } } } } diff --git a/src/lighthouse.test.c b/src/lighthouse.test.c index d6c63bf9a..e06941bc1 100644 --- a/src/lighthouse.test.c +++ b/src/lighthouse.test.c @@ -65,7 +65,7 @@ static void test_lighthouse_update(CuTest * tc) r2 = test_create_region(1, 0, t_ocean); r3 = test_create_region(2, 0, t_ocean); b = test_create_building(r1, test_create_buildingtype("lighthouse")); - CuAssertIntEquals(tc, 0, r1->flags&RF_LIGHTHOUSE); + CuAssertIntEquals(tc, RF_LIGHTHOUSE, r1->flags&RF_LIGHTHOUSE); CuAssertPtrEquals(tc, NULL, r1->attribs); CuAssertPtrEquals(tc, NULL, r2->attribs); CuAssertPtrEquals(tc, NULL, r3->attribs);