forked from github/server
BUG 2425: lighthouses can see units.
This commit is contained in:
parent
6d98a5dc4f
commit
da984b5880
|
@ -1471,7 +1471,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
}
|
||||
|
||||
cr_output_travelthru(F, r, f);
|
||||
if (r->seen.mode >= seen_travel) {
|
||||
if (see_region_details(r)) {
|
||||
message_list *mlist = r_getmessages(r, f);
|
||||
cr_output_messages(F, r->msgs, f);
|
||||
if (mlist) {
|
||||
|
@ -1503,7 +1503,6 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
|
||||
/* visible units */
|
||||
for (u = r->units; u; u = u->next) {
|
||||
|
||||
if (visible_unit(u, f, stealthmod, r->seen.mode)) {
|
||||
cr_output_unit_compat(F, f, u, r->seen.mode);
|
||||
}
|
||||
|
|
|
@ -688,7 +688,7 @@ nr_unit(struct stream *out, const faction * f, const unit * u, int indent, seen_
|
|||
{
|
||||
char marker;
|
||||
int dh;
|
||||
bool isbattle = (bool)(mode == seen_battle);
|
||||
bool isbattle = (mode == seen_battle);
|
||||
char buf[8192];
|
||||
|
||||
if (fval(u_race(u), RCF_INVISIBLE))
|
||||
|
@ -2332,7 +2332,9 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (b) {
|
||||
nr_building(out, r, b, f);
|
||||
while (u && u->building == b) {
|
||||
if (visible_unit(u, f, stealthmod, r->seen.mode)) {
|
||||
nr_unit(out, f, u, 6, r->seen.mode);
|
||||
}
|
||||
u = u->next;
|
||||
}
|
||||
b = b->next;
|
||||
|
@ -2353,7 +2355,9 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
if (sh) {
|
||||
nr_ship(out, r, sh, f, u);
|
||||
while (u && u->ship == sh) {
|
||||
if (visible_unit(u, f, stealthmod, r->seen.mode)) {
|
||||
nr_unit(out, f, u, 6, r->seen.mode);
|
||||
}
|
||||
u = u->next;
|
||||
}
|
||||
sh = sh->next;
|
||||
|
|
|
@ -2445,13 +2445,18 @@ bool visible_unit(const unit *u, const faction *f, int stealthmod, seen_mode mod
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
if (stealthmod > INT_MIN && mode >= seen_unit) {
|
||||
if (stealthmod > INT_MIN && (mode == seen_lighthouse || mode >= seen_unit)) {
|
||||
return cansee(f, u->region, u, stealthmod);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool see_region_details(const region *r)
|
||||
{
|
||||
return r->seen.mode >= seen_travel;
|
||||
}
|
||||
|
||||
void register_reports(void)
|
||||
{
|
||||
/* register datatypes for the different message objects */
|
||||
|
|
|
@ -135,6 +135,7 @@ extern "C" {
|
|||
const char *get_mailcmd(const struct locale *loc);
|
||||
|
||||
bool visible_unit(const struct unit *u, const struct faction *f, int stealthmod, seen_mode mode);
|
||||
bool see_region_details(const struct region *r);
|
||||
|
||||
#define GR_PLURAL 0x01 /* grammar: plural */
|
||||
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
||||
|
|
|
@ -823,21 +823,37 @@ static void test_newbie_warning(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_cansee_spell(CuTest *tc) {
|
||||
static void test_visible_unit(CuTest *tc) {
|
||||
unit *u2;
|
||||
faction *f;
|
||||
ship *sh;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
sh = test_create_ship(u2->region, NULL);
|
||||
|
||||
CuAssertTrue(tc, cansee(f, u2->region, u2, 0));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_unit));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_battle));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_travel));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_none));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, 0, seen_neighbour));
|
||||
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 0, seen_lighthouse));
|
||||
CuAssertTrue(tc, !visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = sh;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = NULL;
|
||||
|
||||
set_level(u2, SK_STEALTH, 1);
|
||||
CuAssertTrue(tc, !cansee(f, u2->region, u2, 0));
|
||||
CuAssertTrue(tc, cansee(f, u2->region, u2, 1));
|
||||
|
||||
u2->ship = sh;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, -2, seen_lighthouse));
|
||||
u2->ship = NULL;
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_spell));
|
||||
CuAssertTrue(tc, visible_unit(u2, f, 1, seen_battle));
|
||||
|
||||
|
@ -873,6 +889,6 @@ CuSuite *get_reports_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_arg_resources);
|
||||
SUITE_ADD_TEST(suite, test_insect_warnings);
|
||||
SUITE_ADD_TEST(suite, test_newbie_warning);
|
||||
SUITE_ADD_TEST(suite, test_cansee_spell);
|
||||
SUITE_ADD_TEST(suite, test_visible_unit);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue