From 41708ce703573f393a5064451fca697ae786f655 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 23 Jul 2005 18:18:53 +0000 Subject: [PATCH] =?UTF-8?q?http://eressea.upb.de/mantis/view.php=3Fid=3D60?= =?UTF-8?q?6=20Traumschl=C3=B6=C3=9Fchen=20verschwindet=20nicht=20und=20fu?= =?UTF-8?q?nktioniert=20nicht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verschwinden tut es wohl immer noch nicht, aber immerhin funktioniert es. --- src/common/gamecode/creport.c | 38 ++++++++++++++++++++--------------- src/common/gamecode/report.c | 32 +++++++++++++++++++++-------- src/common/kernel/building.c | 15 ++++++++------ src/common/kernel/building.h | 2 +- src/common/kernel/spell.c | 8 ++++---- src/mapper/map_tools.c | 4 ++-- src/mapper/map_units.c | 5 +++-- 7 files changed, 65 insertions(+), 39 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 7ff08f7bd..418534076 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -531,31 +531,37 @@ cr_output_messages(FILE * F, message_list *msgs, faction * f) /* prints a building */ static void -cr_output_buildings(FILE * F, building * b, unit * u, int fno, faction *f) +cr_output_buildings(FILE * F, building * b, const unit * owner, int fno, faction *f) { - const building_type * type = b->type; - const char * bname = buildingtype(b, b->size); + const char * bname; + static const struct building_type * bt_illusion; + const building_type * type = b->type; + + if (!bt_illusion) bt_illusion = bt_find("illusion"); fprintf(F, "BURG %d\n", b->no); - if (!u || u->faction != f) { - const attrib * a = a_find(b->attribs, &at_icastle); - if (a) type = ((icastle_data*)a->data.v)->type; - } - fprintf(F, "\"%s\";Typ\n", add_translation(bname, LOC(f->locale, bname))); - fprintf(F, "\"%s\";Name\n", b->name); + + if (b->type==bt_illusion) { + const attrib * a = a_findc(b->attribs, &at_icastle); + if (a!=NULL) { + type = ((icastle_data*)a->data.v)->type; + } + bname = buildingtype(b->type, b, b->size); + if (owner!=NULL && owner->faction==f) { + fprintf(F, "\"%s\";wahrerTyp\n", add_translation(bname, LOC(f->locale, bname))); + } + } + bname = buildingtype(type, b, b->size); + fprintf(F, "\"%s\";Typ\n", add_translation(bname, LOC(f->locale, bname))); + fprintf(F, "\"%s\";Name\n", b->name); if (b->display && strlen(b->display)) fprintf(F, "\"%s\";Beschr\n", b->display); if (b->size) fprintf(F, "%d;Groesse\n", b->size); - if (u) - fprintf(F, "%d;Besitzer\n", u ? u->no : -1); + if (owner) + fprintf(F, "%d;Besitzer\n", owner ? owner->no : -1); if (fno >= 0) fprintf(F, "%d;Partei\n", fno); -#ifdef TODO - int cost = buildingdaten[b->type].per_size * b->size + buildingdaten[b->type].unterhalt; - if (u && u->faction == f && cost) - fprintf(F, "%d;Unterhalt\n", cost); -#endif if (b->besieged) fprintf(F, "%d;Belagerer\n", b->besieged); print_curses(F, f, b, TYP_BUILDING); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index af581bc00..7192fe35d 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1863,20 +1863,36 @@ report_building(FILE *F, const region * r, const building * b, const faction * f { int i; unit *u; - attrib * a = a_find(b->attribs, &at_icastle); + const char * bname; const struct locale * lang = NULL; const building_type * type = b->type; + static const struct building_type * bt_illusion; + if (!bt_illusion) bt_illusion = bt_find("illusion"); if (f) lang = f->locale; - if (a!=NULL) { - type = ((icastle_data*)a->data.v)->type; - } else { - type = b->type; - } + sprintf(buf, "%s, %s %d, ", buildingname(b), LOC(f->locale, "nr_size"), + b->size); + + if (b->type==bt_illusion) { + attrib * a = a_find(b->attribs, &at_icastle); + if (a!=NULL) { + type = ((icastle_data*)a->data.v)->type; + } + } + bname = LOC(lang, buildingtype(type, b, b->size)); + strcat(buf, bname); + if (type!=b->type) { + unit * owner = buildingowner(r, b); + if (owner && owner->faction==f) { + /* illusion. report real type */ + char lbuf[32]; + bname = LOC(lang, buildingtype(b->type, b, b->size)); + sprintf(lbuf, " (%s)", bname); + strcat(buf, lbuf); + } + } - sprintf(buf, "%s, %s %d, %s", buildingname(b), LOC(f->locale, "nr_size"), - b->size, LOC(lang, buildingtype(b, b->size))); if (b->size < type->maxsize) { scat(" (im Bau)"); } diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index de6b345c6..883de00bb 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -23,6 +23,7 @@ #include "unit.h" #include "region.h" #include "skill.h" +#include "magic.h" #include "save.h" /* util includes */ @@ -170,15 +171,17 @@ attrib_type at_building_generic_type = { }; const char * -buildingtype(const building * b, int bsize) +buildingtype(const building_type * btype, const building * b, int bsize) { const char * s = NULL; - const building_type * btype = b->type; static const struct building_type * bt_generic; - if (!bt_generic) bt_generic = bt_find("generic"); - assert(bt_generic); - if (btype == bt_generic) { + if (!bt_generic) { + bt_generic = bt_find("generic"); + assert(bt_generic); + } + + if (btype == bt_generic) { const attrib *a = a_find(b->attribs, &at_building_generic_type); if (a) s = (const char*)a->data.v; } @@ -457,7 +460,7 @@ new_building(const struct building_type * btype, region * r, const struct locale if (b->type->name) sprintf(buffer, "%s", locale_string(lang, btype->_name)); else - sprintf(buffer, "%s", LOC(lang, buildingtype(b, 0))); + sprintf(buffer, "%s", LOC(lang, buildingtype(btype, b, 0))); set_string(&b->name, buffer); } return b; diff --git a/src/common/kernel/building.h b/src/common/kernel/building.h index 5b0c31912..3509c76d3 100644 --- a/src/common/kernel/building.h +++ b/src/common/kernel/building.h @@ -110,7 +110,7 @@ extern void free_buildinglist(building_list *bl); extern void add_buildinglist(building_list **bl, struct building *b); extern struct attrib_type at_building_generic_type; -extern const char * buildingtype(const struct building * b, int bsize); +extern const char * buildingtype(const building_type * btype, const struct building * b, int bsize); extern const char * buildingname(const struct building * b); extern int buildingcapacity(const struct building * b); extern struct building *new_building(const struct building_type * typ, struct region * r, const struct locale * lang); diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 1752f80e8..37eed4c61 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -5161,14 +5161,14 @@ sp_icastle(castorder *co) b = new_building(bt_find("illusion"), r, mage->faction->locale); /* Größe festlegen. */ - if(type == bt_find("illusion")) { + if (type == bt_find("illusion")) { b->size = (rand()%(int)((power*power)+1)*10); - } else if (b->type->maxsize == -1) { + } else if (type->maxsize == -1) { b->size = ((rand()%(int)(power))+1)*5; } else { - b->size = b->type->maxsize; + b->size = type->maxsize; } - sprintf(buf, "%s %s", LOC(mage->faction->locale, buildingtype(b, 0)), buildingid(b)); + sprintf(buf, "%s %s", LOC(mage->faction->locale, buildingtype(type, b, 0)), buildingid(b)); set_string(&b->name, buf); /* TODO: Auf timeout und action_destroy umstellen */ diff --git a/src/mapper/map_tools.c b/src/mapper/map_tools.c index 23fc7f029..dbae53286 100644 --- a/src/mapper/map_tools.c +++ b/src/mapper/map_tools.c @@ -69,7 +69,7 @@ Buildingid(building * b) { static char buf[35]; sprintf(buf, "\002%s (%s), Größe %d", - buildingtype(b, b->size /*, NULL */), + buildingtype(b->type, b, b->size /*, NULL */), buildingid(b), b->size); return buf; } @@ -87,7 +87,7 @@ BuildingName(building * b) { static char buf[35]; sprintf(buf, "%s (%s)", - buildingtype(b, b->size /*, NULL*/), buildingid(b)); + buildingtype(b->type, b, b->size /*, NULL*/), buildingid(b)); return buf; } diff --git a/src/mapper/map_units.c b/src/mapper/map_units.c index b27b789b4..bd568e489 100644 --- a/src/mapper/map_units.c +++ b/src/mapper/map_units.c @@ -952,10 +952,11 @@ showunits(region * r) for (b = r->buildings; b; b = b->next) { if (b->type == bt_find("castle")) { - sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), b->size, buildingtype(b, b->size /*, NULL */)); + sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), b->size, + buildingtype(b->type, b, b->size /*, NULL */)); } else { sprintf(lbuf, "\002%s, Größe %d, %s", buildingname(b), - b->size, buildingtype(b, b->size /*, NULL */)); + b->size, buildingtype(b->type, b, b->size /*, NULL */)); if (b->type->maxsize > 0 && b->size < b->type->maxsize) { sncat(lbuf, " (im Bau)", BUFSIZE);