forked from github/server
BUG 2395: lighthouses were seeing units they should not.
DRY!
This commit is contained in:
parent
73f49ec90a
commit
6bd4e543ba
4 changed files with 20 additions and 12 deletions
|
@ -1295,12 +1295,6 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
int oc[4][2], o = 0;
|
||||
int uid = r->uid;
|
||||
|
||||
#ifdef OCEAN_NEIGHBORS_GET_NO_ID
|
||||
if (r->seen.mode <= seen_neighbour && !r->land) {
|
||||
uid = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opt_cr_absolute_coords) {
|
||||
nx = r->x;
|
||||
ny = r->y;
|
||||
|
@ -1487,8 +1481,7 @@ static void cr_output_region(FILE * F, report_context * ctx, region * r)
|
|||
/* visible units */
|
||||
for (u = r->units; u; u = u->next) {
|
||||
|
||||
if (u->building || u->ship || (stealthmod > INT_MIN
|
||||
&& cansee_ex(f, r, u, stealthmod, r->seen.mode))) {
|
||||
if (visible_unit(u, f, stealthmod)) {
|
||||
cr_output_unit_compat(F, r, f, u, r->seen.mode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2337,10 +2337,8 @@ report_plaintext(const char *filename, report_context * ctx,
|
|||
}
|
||||
}
|
||||
while (u && !u->ship) {
|
||||
if (stealthmod > INT_MIN && r->seen.mode >= seen_unit) {
|
||||
if (u->faction == f || cansee_ex(f, r, u, stealthmod, r->seen.mode)) {
|
||||
nr_unit(out, f, u, 4, r->seen.mode);
|
||||
}
|
||||
if (visible_unit(u, f, stealthmod)) {
|
||||
nr_unit(out, f, u, 4, r->seen.mode);
|
||||
}
|
||||
assert(!u->building);
|
||||
u = u->next;
|
||||
|
|
|
@ -2225,6 +2225,21 @@ int count_travelthru(struct region *r, const struct faction *f) {
|
|||
return data.n;
|
||||
}
|
||||
|
||||
bool visible_unit(const unit *u, const faction *f, int stealthmod)
|
||||
{
|
||||
if (u->faction == f) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
const region *r = u->region;
|
||||
seen_mode mode = r->seen.mode;
|
||||
if (stealthmod > INT_MIN && mode >= seen_unit) {
|
||||
return cansee_ex(f, r, u, stealthmod, mode);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void register_reports(void)
|
||||
{
|
||||
/* register datatypes for the different message objects */
|
||||
|
|
|
@ -137,6 +137,8 @@ extern "C" {
|
|||
int count_travelthru(struct region *r, const struct faction *f);
|
||||
const char *get_mailcmd(const struct locale *loc);
|
||||
|
||||
bool visible_unit(const struct unit *u, const struct faction *f, int stealthmod);
|
||||
|
||||
#define GR_PLURAL 0x01 /* grammar: plural */
|
||||
#define MAX_INVENTORY 128 /* maimum number of different items in an inventory */
|
||||
#define MAX_RAWMATERIALS 8 /* maximum kinds of raw materials in a regions */
|
||||
|
|
Loading…
Reference in a new issue