From 3db6b2a9fd427a7fc905f0c280dba0f5a317e3fb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 22 Jul 2005 17:13:51 +0000 Subject: [PATCH] =?UTF-8?q?ageing=20f=C3=BCr=20das=20at=5Fleftship=20attri?= =?UTF-8?q?but=20verhinder,=20dass=20Einheiten=20die=20ein=20Schiff=20verl?= =?UTF-8?q?assen=20haben=20in=20der=20Folgewoche=20immer=20noch=20im=20Rep?= =?UTF-8?q?ort=20stehen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Kosmetischer Fix an der Schock-Meldung. Weniger Aufrufe von invisible() wenn Einheiten garkeinen Ring haben. --- src/common/kernel/eressea.c | 47 ++++++++++++++++++++----------------- src/common/kernel/save.c | 2 +- src/common/kernel/unit.c | 14 ++++++++--- src/res/messages.xml | 2 +- 4 files changed, 39 insertions(+), 26 deletions(-) diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 1592e195d..02adbdc9e 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -1032,9 +1032,8 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) /* und es muss niemand aus f in der region sein, wenn sie vom Turm * erblickt wird */ { - int n; - boolean cansee = false; - unit *u2; + int stealth, rings; + unit *u2 = r->units; static const item_type * itype_grail; static boolean init; @@ -1060,30 +1059,36 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) if (leftship(u)) return true; if (itype_grail!=NULL && i_get(u->items, itype_grail)) return true; - n = eff_stealth(u, r) - modifier; - for (u2 = r->units; u2; u2 = u2->next) { - if (u2->faction == f) { - int o; + while (u2 && u2->faction != f) u2 = u2->next; + if (u2==NULL) return false; - if (getguard(u) || usiege(u) || u->building || u->ship) { - cansee = true; - break; - } + /* simple visibility, just gotta have a unit in the region to see 'em */ + if (getguard(u) || usiege(u) || u->building || u->ship) { + return true; + } - if (invisible(u, u2) >= u->number) continue; + stealth = eff_stealth(u, r) - modifier; + + rings = invisible(u, NULL); + while (u2) { + if (ringsnumber || invisible(u, u2) < u->number) { + int observation = eff_skill(u2, SK_OBSERVATION, r); - o = eff_skill(u2, SK_OBSERVATION, r); #ifdef NIGHTEYES - if (u2->enchanted == SP_NIGHT_EYES && o < NIGHT_EYE_TALENT) - o = NIGHT_EYE_TALENT; + if (u2->enchanted == SP_NIGHT_EYES && o < NIGHT_EYE_TALENT) + observation = NIGHT_EYE_TALENT; #endif - if (o >= n) { - cansee = true; - break; - } - } + if (observation >= stealth) { + return true; + } + } + + /* find next unit in our faction */ + do { + u2=u2->next; + } while (u2 && u2->faction != f); } - return cansee; + return false; } diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index 1d5391065..ea1586b9b 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -1646,7 +1646,7 @@ readfaction(FILE * F) i = f->options = ri(F); - if ((i & Pow(O_REPORT))==0 && (i & Pow(O_COMPUTER))==0) { + if ((i & ((1<no!=MONSTER_FACTION) { /* Kein Report eingestellt, Fehler */ f->options = f->options | Pow(O_REPORT) | Pow(O_ZUGVORLAGE); } diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index e621b8b4d..8ff5504e2 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -547,8 +547,16 @@ set_level(unit * u, skill_t sk, int value) sk_set(add_skill(u, sk), value); } +static int +leftship_age(struct attrib * a) +{ + /* must be aged, so it doesn't affect report generation (cansee) */ + unused(a); + return 0; /* remove me */ +} + static attrib_type at_leftship = { - "leftship", + "leftship", NULL, NULL, leftship_age }; static attrib * @@ -1115,12 +1123,12 @@ invisible(const unit *target, const unit * viewer) #if NEWATSROI == 1 return 0; #else - if (viewer->faction==target->faction) return 0; + if (viewer && viewer->faction==target->faction) return 0; else { int hidden = get_item(target, I_RING_OF_INVISIBILITY) + 100 * get_item(target, I_SPHERE_OF_INVISIBILITY); if (hidden) { hidden = min(hidden, target->number); - hidden -= get_item(viewer, I_AMULET_OF_TRUE_SEEING); + if (viewer) hidden -= get_item(viewer, I_AMULET_OF_TRUE_SEEING); } return hidden; } diff --git a/src/res/messages.xml b/src/res/messages.xml index f35a5a286..81d7c3161 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -1340,7 +1340,7 @@ - "$unit($mage) erleidet einen Schock ${reason}." + "$unit($mage) erleidet durch den Tod seines Vertrauten einen Schock."