From aeed92fa80a60afa65e7c466f551e0136b423868 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 21 Jun 2021 20:29:20 +0200 Subject: [PATCH] make mimnimum ring check more readable. --- src/laws.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/laws.c b/src/laws.c index a81941217..6adcf5f02 100644 --- a/src/laws.c +++ b/src/laws.c @@ -4036,6 +4036,7 @@ void turn_end(void) */ bool cansee(const faction * f, const region * r, const unit * u, int modifier) { + unit *u2; int stealth, rings; if (u->faction == f || omniscient(f)) { @@ -4060,7 +4061,10 @@ bool cansee(const faction * f, const region * r, const unit * u, int modifier) rings = invisible(u, NULL); stealth = eff_stealth(u, r) - modifier; - unit *u2; + if (rings < u->number && stealth <= 0) { + return true; + } + for (u2 = r->units; u2; u2 = u2->next) { if (u2->faction == f) { if (rings < u->number || invisible(u, u2) < u->number) { @@ -4078,10 +4082,6 @@ bool cansee(const faction * f, const region * r, const unit * u, int modifier) } } - if (rings <= 0 && stealth <= 0) { - return true; - } - /* bug 2763 and 2754: sea serpents are visible on oceans */ if ((u->region->terrain->flags & SEA_REGION) && (u_race(u)->weight >= 5000)) { return true;