- Einheiten mit otherfaction==u->faction
This commit is contained in:
Enno Rehling 2005-02-05 19:05:47 +00:00
parent 2079db13cf
commit f55639c4e7
3 changed files with 46 additions and 16 deletions

View File

@ -633,7 +633,7 @@ cr_output_unit(FILE * F, const region * r,
const faction * sf = visible_faction(f, u); const faction * sf = visible_faction(f, u);
const char * prefix = raceprefix(u); const char * prefix = raceprefix(u);
if (u->faction == f || omniscient(f)) { if (u->faction == f || omniscient(f)) {
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); const attrib * a_otherfaction = a_find(u->attribs, &at_otherfaction);
const faction * otherfaction = a_otherfaction?get_otherfaction(a_otherfaction):NULL; const faction * otherfaction = a_otherfaction?get_otherfaction(a_otherfaction):NULL;
/* my own faction, full info */ /* my own faction, full info */
const attrib *a = a_find(u->attribs, &at_group); const attrib *a = a_find(u->attribs, &at_group);
@ -645,23 +645,30 @@ cr_output_unit(FILE * F, const region * r,
if (sf!=u->faction) fprintf(F, "%d;Verkleidung\n", sf->no); if (sf!=u->faction) fprintf(F, "%d;Verkleidung\n", sf->no);
if (fval(u, UFL_PARTEITARNUNG)) if (fval(u, UFL_PARTEITARNUNG))
fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, UFL_PARTEITARNUNG))); fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, UFL_PARTEITARNUNG)));
if (otherfaction) if (otherfaction) {
if (otherfaction!=u->faction) {
fprintf(F, "%d;Anderepartei\n", otherfaction->no); fprintf(F, "%d;Anderepartei\n", otherfaction->no);
}
}
} else { } else {
if (fval(u, UFL_PARTEITARNUNG)) { if (fval(u, UFL_PARTEITARNUNG)) {
/* faction info is hidden */ /* faction info is hidden */
fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, UFL_PARTEITARNUNG))); fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, UFL_PARTEITARNUNG)));
} else { } else {
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); const attrib * a_otherfaction = a_find(u->attribs, &at_otherfaction);
const faction * otherfaction = a_otherfaction?get_otherfaction(a_otherfaction):NULL; const faction * otherfaction = a_otherfaction?get_otherfaction(a_otherfaction):NULL;
/* other unit. show visible faction, not u->faction */ /* other unit. show visible faction, not u->faction */
fprintf(F, "%d;Partei\n", sf->no); fprintf(F, "%d;Partei\n", sf->no);
if (sf == f) { if (sf == f) {
fprintf(F, "1;Verraeter\n"); fprintf(F, "1;Verraeter\n");
} }
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) { if (a_otherfaction) {
if (otherfaction!=u->faction) {
if (alliedunit(u, f, HELP_FSTEALTH)) {
fprintf(F, "%d;Anderepartei\n", otherfaction->no); fprintf(F, "%d;Anderepartei\n", otherfaction->no);
} }
}
}
} }
} }
if (prefix) { if (prefix) {

View File

@ -2235,8 +2235,7 @@ display_item(faction *f, unit *u, const item_type * itype)
sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name); sprintf(filename, "%s/%s/items/%s", resourcepath(), locale_name(default_locale), name);
fp = fopen(filename, "r"); fp = fopen(filename, "r");
} }
if (!fp) return false; if (fp!=NULL) {
buf[0]='\0'; buf[0]='\0';
while (fgets(t, NAMESIZE, fp) != NULL) { while (fgets(t, NAMESIZE, fp) != NULL) {
if (t[strlen(t) - 1] == '\n') { if (t[strlen(t) - 1] == '\n') {
@ -2246,6 +2245,9 @@ display_item(faction *f, unit *u, const item_type * itype)
} }
fclose(fp); fclose(fp);
info = buf; info = buf;
} else {
info = "Keine Informationen.";
}
} }
ADDMSG(&f->msgs, msg_message("displayitem", "weight item description", ADDMSG(&f->msgs, msg_message("displayitem", "weight item description",
itype->weight/1000, itype->rtype, strdup(info))); itype->weight/1000, itype->rtype, strdup(info)));

View File

@ -482,6 +482,26 @@ fix_firewalls(void)
} }
} }
static void
fix_otherfaction(void)
{
int count = 0;
region * r;
for (r=regions;r;r=r->next) {
unit * u;
for (u=r->units;u;u=u->next) {
attrib * a = a_find(u->attribs, &at_otherfaction);
faction * f = (faction*)a->data.v;
if (f==u->faction) {
a_remove(&u->attribs, a);
++ncount;
}
}
r = r->next;
}
if (count) log_warning(("%u units had otherfaction=own faction.\n"));
}
extern attrib * make_atgmcreate(const struct item_type * itype); extern attrib * make_atgmcreate(const struct item_type * itype);
extern attrib * make_atpermissions(void); extern attrib * make_atpermissions(void);
extern struct attrib_type at_permissions; extern struct attrib_type at_permissions;
@ -1093,6 +1113,7 @@ korrektur(void)
* to be on the safe side: * to be on the safe side:
*/ */
fix_demand(); fix_demand();
fix_otherfaction();
/* trade_orders(); */ /* trade_orders(); */
/* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich /* immer ausführen, wenn neue Sprüche dazugekommen sind, oder sich