dasselbe für den cr

This commit is contained in:
Katja Zedel 2002-05-10 16:49:31 +00:00
parent 6fb8f03d8e
commit 8462fe496f
2 changed files with 67 additions and 20 deletions

View File

@ -172,9 +172,68 @@ cr_output_str_list(FILE * F, const char *title, const strlist * S, const faction
#include "objtypes.h" #include "objtypes.h"
static void static void
print_curses(FILE * F, const locale * lang, const void * obj, typ_t typ, const attrib *a, int self) print_curses(FILE * F, const faction * viewer, const void * obj, typ_t typ)
{ {
boolean header = false; boolean header = false;
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 */
}
while (a) { while (a) {
int dh = 0; int dh = 0;
curse *c; curse *c;
@ -183,7 +242,7 @@ print_curses(FILE * F, const locale * lang, const void * obj, typ_t typ, const a
c = (curse *)a->data.v; c = (curse *)a->data.v;
if (c->type->curseinfo) 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) { if (dh == 1) {
if (!header) { if (!header) {
header = 1; header = 1;
@ -411,7 +470,6 @@ static void
cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f) cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f)
{ {
const building_type * type = b->type; const building_type * type = b->type;
unit * bo = buildingowner(b->region, b);
const char * bname = buildingtype(b, b->size); const char * bname = buildingtype(b, b->size);
fprintf(F, "BURG %d\n", b->no); fprintf(F, "BURG %d\n", b->no);
@ -436,12 +494,7 @@ cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f)
#endif #endif
if (b->besieged) if (b->besieged)
fprintf(F, "%d;Belagerer\n", b->besieged); fprintf(F, "%d;Belagerer\n", b->besieged);
if(bo != NULL){ print_curses(F, f, b, TYP_BUILDING);
print_curses(F, f->locale, b, TYP_BUILDING, b->attribs,
(bo->faction == f)? 1 : 0);
} else {
print_curses(F, f->locale, b, TYP_BUILDING, b->attribs, 0);
}
} }
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
@ -482,12 +535,7 @@ cr_output_ship(FILE * F, const ship * s, const unit * u, int fcaptain, const fac
if (w != NODIRECTION) if (w != NODIRECTION)
fprintf(F, "%d;Kueste\n", w); fprintf(F, "%d;Kueste\n", w);
if(shipowner(r, s) != NULL){ print_curses(F, f, s, TYP_SHIP);
print_curses(F, f->locale, s, TYP_SHIP, s->attribs,
(shipowner(r, s)->faction == f)? 1 : 0);
} else {
print_curses(F, f->locale, s, TYP_SHIP, s->attribs, 0);
}
} }
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
@ -731,7 +779,7 @@ cr_output_unit(FILE * F, const region * r,
if ((u->faction == f || omniscient(f)) && u->botschaften) if ((u->faction == f || omniscient(f)) && u->botschaften)
cr_output_str_list(F, "EINHEITSBOTSCHAFTEN", u->botschaften, f); cr_output_str_list(F, "EINHEITSBOTSCHAFTEN", u->botschaften, f);
print_curses(F, f->locale, u, TYP_UNIT, u->attribs, (u->faction == f)? 1 : 0); print_curses(F, f, u, TYP_UNIT);
} }
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
@ -1199,7 +1247,7 @@ report_computer(FILE * F, faction * f, const seen_region * seen,
} }
} }
print_curses(F, f->locale, r, TYP_REGION, r->attribs, 0); print_curses(F, f, r, TYP_REGION);
/* describe both passed and inhabited regions */ /* describe both passed and inhabited regions */
show_active_spells(r); show_active_spells(r);
{ {

View File

@ -664,7 +664,7 @@ hat_in_region(item_t it, region * r, faction * f)
} }
static void static void
print_curses(FILE *F, faction *viewer, void * obj, typ_t typ, int indent) print_curses(FILE *F, const faction *viewer, const void * obj, typ_t typ, int indent)
{ {
attrib *a = NULL; attrib *a = NULL;
int self = 0; int self = 0;
@ -834,8 +834,7 @@ rpunit(FILE * F, const faction * f, const unit * u, int indent, int mode)
if(ug) { if(ug) {
int i; int i;
for(i=0; i<ug->members; i++) { for(i=0; i<ug->members; i++) {
u = ug->unit_array[i]; print_curses(F, f, ug->unit_array[i], TYP_UNIT, indent);
print_curses(F, f, u, TYP_UNIT, indent);
} }
} else } else
#endif /* USE_UGROUPS */ #endif /* USE_UGROUPS */