forked from github/server
re-enable report tests.
RF_LIGHTHOUSE also flags for lighthouses with size 0.
This commit is contained in:
parent
a5d44f9638
commit
ac8332c896
|
@ -25,4 +25,4 @@ cd $ROOT
|
||||||
inifile
|
inifile
|
||||||
s/runtests
|
s/runtests
|
||||||
|
|
||||||
# integraton_tests
|
integraton_tests
|
||||||
|
|
|
@ -8,7 +8,7 @@ require 'tests.e2.spells'
|
||||||
require 'tests.e2.stealth'
|
require 'tests.e2.stealth'
|
||||||
require 'tests.orders'
|
require 'tests.orders'
|
||||||
require 'tests.common'
|
require 'tests.common'
|
||||||
-- require 'tests.report'
|
require 'tests.report'
|
||||||
require 'tests.storage'
|
require 'tests.storage'
|
||||||
require 'tests.magicbag'
|
require 'tests.magicbag'
|
||||||
require 'tests.process'
|
require 'tests.process'
|
||||||
|
|
|
@ -23,7 +23,7 @@ local function assert_file(filename)
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
function disable_test_process_turn()
|
function test_process_turn()
|
||||||
u:add_order("NUMMER PARTEI 777")
|
u:add_order("NUMMER PARTEI 777")
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(0, init_reports())
|
assert_equal(0, init_reports())
|
||||||
|
|
|
@ -26,36 +26,37 @@ const attrib_type at_lighthouse = {
|
||||||
*/
|
*/
|
||||||
void update_lighthouse(building * lh)
|
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;
|
region *r = lh->region;
|
||||||
int d = (int)log10(lh->size) + 1;
|
|
||||||
int x;
|
|
||||||
|
|
||||||
r->flags |= RF_LIGHTHOUSE;
|
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) {
|
pnormalize(&px, &py, rplane(r));
|
||||||
int y;
|
r2 = findregion(px, py);
|
||||||
for (y = -d; y <= d; ++y) {
|
if (!r2 || !fval(r2->terrain, SEA_REGION))
|
||||||
attrib *a;
|
continue;
|
||||||
region *r2;
|
if (distance(r, r2) > d)
|
||||||
int px = r->x + x, py = r->y + y;
|
continue;
|
||||||
|
a = a_find(r2->attribs, &at_lighthouse);
|
||||||
pnormalize(&px, &py, rplane(r));
|
while (a && a->type == &at_lighthouse) {
|
||||||
r2 = findregion(px, py);
|
building *b = (building *)a->data.v;
|
||||||
if (!r2 || !fval(r2->terrain, SEA_REGION))
|
if (b == lh)
|
||||||
continue;
|
break;
|
||||||
if (distance(r, r2) > d)
|
a = a->next;
|
||||||
continue;
|
}
|
||||||
a = a_find(r2->attribs, &at_lighthouse);
|
if (!a) {
|
||||||
while (a && a->type == &at_lighthouse) {
|
a = a_add(&r2->attribs, a_new(&at_lighthouse));
|
||||||
building *b = (building *)a->data.v;
|
a->data.v = (void *)lh;
|
||||||
if (b == lh)
|
}
|
||||||
break;
|
|
||||||
a = a->next;
|
|
||||||
}
|
|
||||||
if (!a) {
|
|
||||||
a = a_add(&r2->attribs, a_new(&at_lighthouse));
|
|
||||||
a->data.v = (void *)lh;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ static void test_lighthouse_update(CuTest * tc)
|
||||||
r2 = test_create_region(1, 0, t_ocean);
|
r2 = test_create_region(1, 0, t_ocean);
|
||||||
r3 = test_create_region(2, 0, t_ocean);
|
r3 = test_create_region(2, 0, t_ocean);
|
||||||
b = test_create_building(r1, test_create_buildingtype("lighthouse"));
|
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, r1->attribs);
|
||||||
CuAssertPtrEquals(tc, NULL, r2->attribs);
|
CuAssertPtrEquals(tc, NULL, r2->attribs);
|
||||||
CuAssertPtrEquals(tc, NULL, r3->attribs);
|
CuAssertPtrEquals(tc, NULL, r3->attribs);
|
||||||
|
|
Loading…
Reference in New Issue