From 6fb8f03d8e18507c0873bd5c8105ff42510e36a8 Mon Sep 17 00:00:00 2001 From: Katja Zedel Date: Fri, 10 May 2002 16:09:07 +0000 Subject: [PATCH] =?UTF-8?q?print=5Fcurses=20f=C3=BCr=20nr=20umgestellt,=20?= =?UTF-8?q?bietet=20die=20M=C3=B6glichkeit=20verschiedene=20Sichtbarkeitss?= =?UTF-8?q?tufen=20f=C3=BCr=20Curses=20zu=20haben,=20zb=20das=20Magier=20A?= =?UTF-8?q?ntimagiezonen=20sp=C3=BCren,=20Geb=C3=A4udebesitzer=20einen=20g?= =?UTF-8?q?enaue=20Beschreibung=20sehen,=20Geb=C3=A4udeinsassen=20eine=20a?= =?UTF-8?q?ndere=20und=20alle=20von=20Au=C3=9Fen=20gar=20nix.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/gamecode/report.c | 86 ++++++++++++++++++++++++------- src/common/spells/buildingcurse.c | 6 +-- src/common/spells/regioncurse.c | 1 - 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 8ebd402d3..3f9bc8eab 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -664,15 +664,74 @@ hat_in_region(item_t it, region * r, faction * f) } static void -print_curses(FILE *F, const locale * lang, const void * obj, typ_t typ, const attrib *a, int self, int indent) +print_curses(FILE *F, faction *viewer, void * obj, typ_t typ, int indent) { + attrib *a = NULL; + int self = 0; + region *r; + + /* Die Sichtbarkeit eines Zaubers und die Zaubermeldung sind bei + * Gebäuden und Schiffen je nach, ob man Besitzer ist, verschieden. + * Bei Einheiten sieht man Wirkungen auf eigene Einheiten immer. + * Spezialfälle (besonderes Talent, verursachender Magier usw. werde + * bei jedem curse gesondert behandelt. */ + if (typ == TYP_SHIP){ + ship * sh = (ship*)obj; + unit * owner; + a = sh->attribs; + r = sh->region; + if((owner = shipowner(r,sh)) != NULL){ + if (owner->faction == viewer){ + self = 2; + } else { /* steht eine person der Partei auf dem Schiff? */ + unit *u = NULL; + for (u = r->units; u; u = u->next) { + if (u->ship == sh) { + self = 1; + break; + } + } + } + } + } else if (typ == TYP_BUILDING) { + building * b = (building*)obj; + unit * owner; + a = b->attribs; + r = b->region; + if((owner = buildingowner(r,b)) != NULL){ + if (owner->faction == viewer){ + self = 2; + } else { /* steht eine Person der Partei in der Burg? */ + unit *u = NULL; + for (u = r->units; u; u = u->next) { + if (u->building == b) { + self = 1; + break; + } + } + } + } + } else if (typ == TYP_UNIT) { + unit *u = (unit *)obj; + a = u->attribs; + r = u->region; + if (u->faction == viewer){ + self = 2; + } + } else if (typ == TYP_REGION) { + r = (region *)obj; + a = r->attribs; + } else { + /* fehler */ + } + for(;a;a=a->next) { int dh = 0; if (fval(a->type, ATF_CURSE)) { curse *c = (curse *)a->data.v; if (c->type->curseinfo) - dh = c->type->curseinfo(lang, obj, typ, c, self); + dh = c->type->curseinfo(viewer->locale, obj, typ, c, self); if (dh == 1) { rnl(F); rparagraph(F, buf, indent, 0); @@ -775,11 +834,12 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode) if(ug) { int i; for(i=0; imembers; i++) { - print_curses(F, f->locale, u, TYP_UNIT, ug->unit_array[i]->attribs, (u->faction == f)? 1 : 0, indent); + u = ug->unit_array[i]; + print_curses(F, f, u, TYP_UNIT, indent); } } else #endif /* USE_UGROUPS */ - print_curses(F, f->locale, u, TYP_UNIT, u->attribs, (u->faction == f)? 1 : 0, indent); + print_curses(F, f, u, TYP_UNIT, indent); } #ifdef USE_UGROUPS @@ -1281,7 +1341,7 @@ describe(FILE * F, const region * r, int partial, faction * f) n = 0; /* Wirkungen permanenter Sprüche */ - print_curses(F, f->locale, r, TYP_REGION, r->attribs, 0, 0); + print_curses(F, f, r, TYP_REGION,0); /* Produktionsreduktion */ a = a_find(r->attribs, &at_reduceproduction); @@ -1783,13 +1843,7 @@ report_building(FILE *F, const region * r, const building * b, const faction * f if (modelocale, b, TYP_BUILDING, b->attribs, - (buildingowner(r,b)->faction == f)? 1 : 0, 4); - } else { - print_curses(F, f->locale, b, TYP_BUILDING, b->attribs, 0, 4); - } + print_curses(F, f, b, TYP_BUILDING, 4); for (u = r->units; u; u = u->next) if (u->building == b && fval(u, FL_OWNER)) { @@ -2179,13 +2233,7 @@ report(FILE *F, faction * f, const faction_list * addresses, rparagraph(F, buf, 2, 0); - /* Leere Schiffe verursachten sonst segfault! */ - if(shipowner(r,sh) != NULL){ - print_curses(F, f->locale, sh, TYP_SHIP, sh->attribs, - (shipowner(r,sh)->faction == f)? 1 : 0, 4); - } else { - print_curses(F, f->locale, sh, TYP_SHIP, sh->attribs, 0, 4); - } + print_curses(F,f,sh,TYP_SHIP,4); for (u = r->units; u; u = u->next) if (u->ship == sh && fval(u, FL_OWNER)) { diff --git a/src/common/spells/buildingcurse.c b/src/common/spells/buildingcurse.c index e6eb8cb87..81468e74a 100644 --- a/src/common/spells/buildingcurse.c +++ b/src/common/spells/buildingcurse.c @@ -41,7 +41,7 @@ cinfo_building(const locale * lang, void * obj, typ_t typ, curse *c, int self) unused(typ); assert(typ == TYP_BUILDING); - if (self == 1){ /* owner or inside */ + if (self != 0){ /* owner or inside */ msg = msg_message(mkname("curseinfo", c->type->cname), "id", c->no); } else { /* outside */ msg = msg_message(mkname("curseinfo", "buildingunknown"), "id", c->no); @@ -61,7 +61,7 @@ cinfo_magicrunes(void * obj, typ_t typ, curse *c, int self) if (typ == TYP_BUILDING){ building * b; b = (building*)obj; - if (self){ + if (self != 0){ sprintf(buf, "Auf den Mauern von %s erkennt man seltsame Runen. (%s)", b->name, curseid(c)); return 1; @@ -69,7 +69,7 @@ cinfo_magicrunes(void * obj, typ_t typ, curse *c, int self) } else if (typ == TYP_SHIP) { ship *sh; sh = (ship*)obj; - if (self){ + if (self != 0){ sprintf(buf, "Auf den Planken von %s erkennt man seltsame Runen. (%s)", sh->name, curseid(c)); return 1; diff --git a/src/common/spells/regioncurse.c b/src/common/spells/regioncurse.c index fb57d504d..f6b855168 100644 --- a/src/common/spells/regioncurse.c +++ b/src/common/spells/regioncurse.c @@ -147,7 +147,6 @@ cinfo_farvision(const locale * lang, const void * obj, typ_t typ, curse *c, int message * msg; unused(typ); - unused(self); unused(obj); assert(typ == TYP_REGION);