From 816243d2d711e25236ae0a22b520b6e37ff48aa7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 7 Aug 2015 15:52:10 +0200 Subject: [PATCH] magicians can always identify their own curse-effects. magic-resistance on a building is always visible to anybody, just like it is on units. --- res/core/messages.xml | 4 ++-- src/creport.c | 4 +--- src/kernel/curse.c | 11 +++++++++++ src/kernel/curse.h | 2 +- src/report.c | 4 +--- src/spells/magicresistance.c | 4 ++-- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index 237ab8c7a..c78b279d1 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -390,7 +390,7 @@ "Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))" "$unit($unit)'s equipment is invisible. ($int36($id))" - + @@ -398,7 +398,7 @@ "Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))" "The magical resistance has been strengthened. ($int36($id))" - + diff --git a/src/creport.c b/src/creport.c index 1ce5c2a30..06eccc536 100644 --- a/src/creport.c +++ b/src/creport.c @@ -250,9 +250,7 @@ cr_output_curses(stream *out, const faction * viewer, const void *obj, objtype_t curse *c = (curse *)a->data.v; message *msg; - if (c->type->cansee) { - self = c->type->cansee(viewer, obj, typ, c, self); - } + self = curse_cansee(c, viewer, typ, obj, self); msg = msg_curse(c, obj, typ, self); if (msg) { diff --git a/src/kernel/curse.c b/src/kernel/curse.c index f2e99778f..afa8ac2c3 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -642,6 +642,17 @@ void transfer_curse(unit * u, unit * u2, int n) /* ------------------------------------------------------------- */ +int curse_cansee(const curse *c, const faction *viewer, objtype_t typ, const void *obj, int self) { + if (self < 3 && c->magician && c->magician->faction == viewer) { + // magicians can see their own curses better than anybody, no exceptions + self = 3; + } + else if (c->type->cansee) { + self = c->type->cansee(viewer, obj, typ, c, self); + } + return self; +} + bool curse_active(const curse * c) { if (!c) diff --git a/src/kernel/curse.h b/src/kernel/curse.h index cd745bfdb..80ce3109d 100644 --- a/src/kernel/curse.h +++ b/src/kernel/curse.h @@ -303,7 +303,7 @@ extern "C" { const char *oldcursename(int id); struct message *cinfo_simple(const void *obj, objtype_t typ, const struct curse *c, int self); - + int curse_cansee(const struct curse *c, const struct faction *viewer, objtype_t typ, const void *obj, int self); #define is_cursed(a, id, id2) \ curse_active(get_curse(a, ct_find(oldcursename(id)))) #define get_curseeffect(a, id, id2) \ diff --git a/src/report.c b/src/report.c index 3d57ee4c2..f735e41ea 100644 --- a/src/report.c +++ b/src/report.c @@ -520,9 +520,7 @@ nr_curses_i(stream *out, int indent, const faction *viewer, objtype_t typ, const if (fval(a->type, ATF_CURSE)) { curse *c = (curse *)a->data.v; - if (c->type->cansee) { - self = c->type->cansee(viewer, obj, typ, c, self); - } + self = curse_cansee(c, viewer, typ, obj, self); msg = msg_curse(c, obj, typ, self); if (msg) { diff --git a/src/spells/magicresistance.c b/src/spells/magicresistance.c index 0a4ffaa9f..3587a1be6 100644 --- a/src/spells/magicresistance.c +++ b/src/spells/magicresistance.c @@ -9,14 +9,14 @@ static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, con if (typ == TYP_UNIT) { if (self != 0) { const struct unit *u = (const struct unit *)obj; - return msg_message(mkname("curseinfo", c->type->cname), "unit id", u, + return msg_message(mkname("curseinfo", "magicresistance_unit"), "unit id", u, c->no); } return NULL; } if (typ == TYP_BUILDING) { const struct building *b = (const struct building *)obj; - return msg_message(mkname("curseinfo", self ? "homestone" : "buildingunknown"), "id building", c->no, b); + return msg_message(mkname("curseinfo", "magicresistance_building"), "id building", c->no, b); } return 0; }