forked from github/server
new lighthouse behavior as described in http://bugs.eressea.de/view.php?id=1847
This commit is contained in:
parent
28a1e8d3cc
commit
ec9e7bf833
|
@ -864,6 +864,33 @@ function test_coordinates_noname_plane()
|
||||||
assert_true(find_in_report(f, r.name .. " %(0,0%), Berg"))
|
assert_true(find_in_report(f, r.name .. " %(0,0%), Berg"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_lighthouse()
|
||||||
|
local r = region.create(0, 0, "mountain")
|
||||||
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
region.create(1, 0, "mountain")
|
||||||
|
region.create(2, 0, "ocean")
|
||||||
|
region.create(0, 1, "firewall")
|
||||||
|
region.create(3, 0, "mountain")
|
||||||
|
region.create(4, 0, "plain")
|
||||||
|
local u = unit.create(f, r, 1)
|
||||||
|
local b = building.create(r, "lighthouse")
|
||||||
|
b.size = 100
|
||||||
|
u.building = b
|
||||||
|
u:set_skill("perception", 9)
|
||||||
|
u:add_item("money", 1000)
|
||||||
|
assert_not_nil(b)
|
||||||
|
|
||||||
|
init_reports()
|
||||||
|
write_report(f)
|
||||||
|
assert_true(find_in_report(f, " %(1,0%) %(vom Turm erblickt%)"))
|
||||||
|
assert_true(find_in_report(f, " %(2,0%) %(vom Turm erblickt%)"))
|
||||||
|
assert_true(find_in_report(f, " %(3,0%) %(vom Turm erblickt%)"))
|
||||||
|
|
||||||
|
assert_false(find_in_report(f, " %(0,0%) %(vom Turm erblickt%)"))
|
||||||
|
assert_false(find_in_report(f, " %(0,1%) %(vom Turm erblickt%)"))
|
||||||
|
assert_false(find_in_report(f, " %(4,0%) %(vom Turm erblickt%)"))
|
||||||
|
end
|
||||||
|
|
||||||
module("tests.parser", package.seeall, lunit.testcase)
|
module("tests.parser", package.seeall, lunit.testcase)
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
|
|
|
@ -1373,14 +1373,37 @@ static void view_regatta(struct seen_region **seen, region * r, faction * f)
|
||||||
recurse_regatta(seen, r, r, f, skill / 2);
|
recurse_regatta(seen, r, r, f, skill / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void prepare_lighthouse(building * b, faction * f)
|
||||||
|
{
|
||||||
|
int range = lighthouse_range(b, f);
|
||||||
|
region_list *rlist = get_regions_distance(b->region, range);
|
||||||
|
region_list *rp = rlist;
|
||||||
|
|
||||||
|
while (rp) {
|
||||||
|
region *rl = rp->data;
|
||||||
|
if (!fval(rl->terrain, FORBIDDEN_REGION)) {
|
||||||
|
int d;
|
||||||
|
add_seen(f->seen, rl, see_lighthouse, false);
|
||||||
|
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||||
|
region *rn = rconnect(rl, d);
|
||||||
|
if (rn != NULL) {
|
||||||
|
add_seen(f->seen, rn, see_neighbour, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rp = rp->next;
|
||||||
|
}
|
||||||
|
free_regionlist(rlist);
|
||||||
|
}
|
||||||
|
|
||||||
static void prepare_reports(void)
|
static void prepare_reports(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
faction *f;
|
faction *f;
|
||||||
static const struct building_type *bt_lighthouse = NULL;
|
static const struct building_type *bt_lighthouse = NULL;
|
||||||
if (bt_lighthouse == NULL)
|
if (bt_lighthouse == NULL) {
|
||||||
bt_lighthouse = bt_find("lighthouse");
|
bt_lighthouse = bt_find("lighthouse");
|
||||||
|
}
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
if (f->seen)
|
if (f->seen)
|
||||||
seen_done(f->seen);
|
seen_done(f->seen);
|
||||||
|
@ -1407,25 +1430,7 @@ static void prepare_reports(void)
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (u->building && u->building->type == bt_lighthouse) {
|
if (u->building && u->building->type == bt_lighthouse) {
|
||||||
/* we are in a lighthouse. add the regions we can see from here! */
|
/* we are in a lighthouse. add the regions we can see from here! */
|
||||||
int range = lighthouse_range(u->building, u->faction);
|
prepare_lighthouse(u->building, u->faction);
|
||||||
region_list *rlist = get_regions_distance(r, range);
|
|
||||||
region_list *rp = rlist;
|
|
||||||
|
|
||||||
while (rp) {
|
|
||||||
region *rl = rp->data;
|
|
||||||
if (fval(rl->terrain, SEA_REGION)) {
|
|
||||||
direction_t d;
|
|
||||||
add_seen(u->faction->seen, rl, see_lighthouse, false);
|
|
||||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
|
||||||
region *rn = rconnect(rl, d);
|
|
||||||
if (rn != NULL) {
|
|
||||||
add_seen(u->faction->seen, rn, see_neighbour, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rp = rp->next;
|
|
||||||
}
|
|
||||||
free_regionlist(rlist);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
|
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
|
||||||
|
|
Loading…
Reference in New Issue