Merge pull request #272 from ennorehling/feature/bug-2121-homestone-messages

Bug 2121: wrong messages for homestone spell effects
This commit is contained in:
Enno Rehling 2015-08-07 16:34:13 +02:00
commit a634b115a7
6 changed files with 26 additions and 23 deletions

View File

@ -390,7 +390,7 @@
<text locale="de">"Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))"</text> <text locale="de">"Die Ausrüstung von $unit($unit) scheint unsichtbar. ($int36($id))"</text>
<text locale="en">"$unit($unit)'s equipment is invisible. ($int36($id))"</text> <text locale="en">"$unit($unit)'s equipment is invisible. ($int36($id))"</text>
</message> </message>
<message name="curseinfo::magicresistance" section="events"> <message name="curseinfo::magicresistance_unit" section="events">
<type> <type>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="id" type="int"/> <arg name="id" type="int"/>
@ -398,7 +398,7 @@
<text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text> <text locale="de">"Die natürliche Widerstandskraft gegen Verzauberung ist gestärkt. ($int36($id))"</text>
<text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text> <text locale="en">"The magical resistance has been strengthened. ($int36($id))"</text>
</message> </message>
<message name="curseinfo::homestone" section="events"> <message name="curseinfo::magicresistance_building" section="events">
<type> <type>
<arg name="building" type="building"/> <arg name="building" type="building"/>
<arg name="id" type="int"/> <arg name="id" type="int"/>
@ -914,7 +914,7 @@
<arg name="transparent" type="int"/> <arg name="transparent" type="int"/>
<arg name="object" type="string"/> <arg name="object" type="string"/>
</type> </type>
<text locale="de">"$if($transparent," befindet sich"," versperrt") ${object} $if($transparent,""," die Sicht")."</text> <text locale="de">"$if($transparent," befindet sich"," versperrt") ${object}$if($transparent,""," die Sicht")."</text>
<text locale="en">"$if($transparent," there is"," sight is blocked by ") ${object}."</text> <text locale="en">"$if($transparent," there is"," sight is blocked by ") ${object}."</text>
</message> </message>
<message name="nr_building_besieged" section="nr"> <message name="nr_building_besieged" section="nr">

View File

@ -250,9 +250,7 @@ cr_output_curses(stream *out, const faction * viewer, const void *obj, objtype_t
curse *c = (curse *)a->data.v; curse *c = (curse *)a->data.v;
message *msg; message *msg;
if (c->type->cansee) { self = curse_cansee(c, viewer, typ, obj, self);
self = c->type->cansee(viewer, obj, typ, c, self);
}
msg = msg_curse(c, obj, typ, self); msg = msg_curse(c, obj, typ, self);
if (msg) { if (msg) {

View File

@ -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) bool curse_active(const curse * c)
{ {
if (!c) if (!c)

View File

@ -303,7 +303,7 @@ extern "C" {
const char *oldcursename(int id); const char *oldcursename(int id);
struct message *cinfo_simple(const void *obj, objtype_t typ, struct message *cinfo_simple(const void *obj, objtype_t typ,
const struct curse *c, int self); 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) \ #define is_cursed(a, id, id2) \
curse_active(get_curse(a, ct_find(oldcursename(id)))) curse_active(get_curse(a, ct_find(oldcursename(id))))
#define get_curseeffect(a, id, id2) \ #define get_curseeffect(a, id, id2) \

View File

@ -515,33 +515,27 @@ nr_curses_i(stream *out, int indent, const faction *viewer, objtype_t typ, const
{ {
for (; a; a = a->next) { for (; a; a = a->next) {
char buf[4096]; char buf[4096];
message *msg; message *msg = 0;
if (fval(a->type, ATF_CURSE)) { if (fval(a->type, ATF_CURSE)) {
curse *c = (curse *)a->data.v; curse *c = (curse *)a->data.v;
if (c->type->cansee) { self = curse_cansee(c, viewer, typ, obj, self);
self = c->type->cansee(viewer, obj, typ, c, self);
}
msg = msg_curse(c, obj, typ, self); msg = msg_curse(c, obj, typ, self);
if (msg) {
newline(out);
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
paragraph(out, buf, indent, 2, 0);
msg_release(msg);
}
} }
else if (a->type == &at_effect && self) { else if (a->type == &at_effect && self) {
effect_data *data = (effect_data *)a->data.v; effect_data *data = (effect_data *)a->data.v;
if (data->value > 0) { if (data->value > 0) {
msg = msg_message("nr_potion_effect", "potion left", msg = msg_message("nr_potion_effect", "potion left",
data->type->itype->rtype, data->value); data->type->itype->rtype, data->value);
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
paragraph(out, buf, indent, 2, 0);
msg_release(msg);
} }
} }
if (msg) {
newline(out);
nr_render(msg, viewer->locale, buf, sizeof(buf), viewer);
paragraph(out, buf, indent, 2, 0);
msg_release(msg);
}
} }
} }

View File

@ -9,14 +9,14 @@ static struct message *cinfo_magicresistance(const void *obj, objtype_t typ, con
if (typ == TYP_UNIT) { if (typ == TYP_UNIT) {
if (self != 0) { if (self != 0) {
const struct unit *u = (const struct unit *)obj; 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); c->no);
} }
return NULL; return NULL;
} }
if (typ == TYP_BUILDING) { if (typ == TYP_BUILDING) {
const struct building *b = (const struct building *)obj; 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; return 0;
} }