make mimnimum ring check more readable.

This commit is contained in:
Enno Rehling 2021-06-21 20:29:20 +02:00
parent 15f6cd4206
commit aeed92fa80
1 changed files with 5 additions and 5 deletions

View File

@ -4036,6 +4036,7 @@ void turn_end(void)
*/ */
bool cansee(const faction * f, const region * r, const unit * u, int modifier) bool cansee(const faction * f, const region * r, const unit * u, int modifier)
{ {
unit *u2;
int stealth, rings; int stealth, rings;
if (u->faction == f || omniscient(f)) { 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); rings = invisible(u, NULL);
stealth = eff_stealth(u, r) - modifier; stealth = eff_stealth(u, r) - modifier;
unit *u2; if (rings < u->number && stealth <= 0) {
return true;
}
for (u2 = r->units; u2; u2 = u2->next) { for (u2 = r->units; u2; u2 = u2->next) {
if (u2->faction == f) { if (u2->faction == f) {
if (rings < u->number || invisible(u, u2) < u->number) { 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 */ /* bug 2763 and 2754: sea serpents are visible on oceans */
if ((u->region->terrain->flags & SEA_REGION) && (u_race(u)->weight >= 5000)) { if ((u->region->terrain->flags & SEA_REGION) && (u_race(u)->weight >= 5000)) {
return true; return true;