unified the determining of race prefix. it's either wrong everywhere or not, but at least it'll be equal in NR and CR :-)

This commit is contained in:
Enno Rehling 2003-09-21 08:20:58 +00:00
parent 13ef5bdb07
commit cae86ae4d5
3 changed files with 33 additions and 33 deletions

View File

@ -593,19 +593,15 @@ cr_output_unit(FILE * F, const region * r,
{ {
/* print faction information */ /* print faction information */
const faction * sf = visible_faction(f,u); const faction * sf = visible_faction(f, u);
const attrib *atyp = a_find(u->faction->attribs, &at_raceprefix); const char * prefix = raceprefix(u);
const attrib *a = a_find(u->attribs, &at_group);
if (a) {
const attrib *agrp = a_find(((const group*)a->data.v)->attribs, &at_raceprefix);
if (agrp) atyp = agrp;
}
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 * ap = 0; const attrib * ap = 0;
if (a) { const attrib *a = a_find(u->attribs, &at_group);
if (a!=NULL) {
const group * g = (const group*)a->data.v; const group * g = (const group*)a->data.v;
ap = a_find(g->attribs, &at_raceprefix); ap = a_find(g->attribs, &at_raceprefix);
fprintf(F, "%d;gruppe\n", g->gid); fprintf(F, "%d;gruppe\n", g->gid);
@ -633,9 +629,8 @@ cr_output_unit(FILE * F, const region * r,
} }
} }
} }
if (atyp) { if (prefix) {
const char * name = (const char*)atyp->data.v; fprintf(F, "\"%s\";typprefix\n", add_translation(prefix, LOC(f->locale, prefix)));
fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name)));
} }
} }
if (u->faction != f && a_fshidden if (u->faction != f && a_fshidden

View File

@ -334,39 +334,42 @@ rc_name(const race * rc, int n)
return mkname("race", rc->_name[n]); return mkname("race", rc->_name[n]);
} }
const char *
raceprefix(const unit *u)
{
attrib * agroup = a_find(u->attribs, &at_group);
attrib * asource = u->faction->attribs;
attrib * a2 = NULL;
if (agroup!=NULL) asource = ((group *)(agroup->data.v))->attribs;
a2 = a_find(asource, &at_raceprefix);
if (a2!=NULL) return (const char *)a2->data.v;
return NULL;
}
const char * const char *
racename(const struct locale *loc, const unit *u, const race * rc) racename(const struct locale *loc, const unit *u, const race * rc)
{ {
static char lbuf[80]; const char * prefix = raceprefix(u);
attrib *a, *a2; attrib * asyn = a_find(u->faction->attribs, &at_synonym);
if (prefix!=NULL) {
a = a_find(u->attribs, &at_group); static char lbuf[80];
if(a) { char * s = lbuf;
a2 = a_find(((group *)(a->data.v))->attribs, &at_raceprefix); strcpy(lbuf, locale_string(loc, prefix));
} else { s += strlen(lbuf);
a2 = a_find(u->faction->attribs, &at_raceprefix); if (asyn!=NULL) {
}
a = a_find(u->faction->attribs, &at_synonym);
if(a2) {
char s[32];
strcpy(lbuf, locale_string(loc, (char *)a2->data.v));
if(a) {
strcpy(s, locale_string(loc, strcpy(s, locale_string(loc,
((frace_synonyms *)(a->data.v))->synonyms[u->number != 1])); ((frace_synonyms *)(asyn->data.v))->synonyms[u->number != 1]));
} else { } else {
strcpy(s, LOC(loc, rc_name(rc, u->number != 1))); strcpy(s, LOC(loc, rc_name(rc, u->number != 1)));
} }
s[0] = (char)tolower(s[0]); s[0] = (char)tolower(s[0]);
strcat(lbuf, s);
return lbuf; return lbuf;
} } else if (asyn!=NULL) {
if(a) {
return(locale_string(loc, return(locale_string(loc,
((frace_synonyms *)(a->data.v))->synonyms[u->number != 1])); ((frace_synonyms *)(asyn->data.v))->synonyms[u->number != 1]));
} }
return LOC(loc, rc_name(rc, u->number != 1)); return LOC(loc, rc_name(rc, u->number != 1));
} }

View File

@ -166,6 +166,8 @@ extern const struct race_syn race_synonyms[];
extern void write_race_reference(const struct race * rc, FILE * F); extern void write_race_reference(const struct race * rc, FILE * F);
extern int read_race_reference(const struct race ** rp, FILE * F); extern int read_race_reference(const struct race ** rp, FILE * F);
extern const char * raceprefix(const struct unit *u);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif