forked from github/server
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:
parent
13ef5bdb07
commit
cae86ae4d5
|
@ -593,19 +593,15 @@ cr_output_unit(FILE * F, const region * r,
|
|||
|
||||
{
|
||||
/* print faction information */
|
||||
const faction * sf = visible_faction(f,u);
|
||||
const attrib *atyp = a_find(u->faction->attribs, &at_raceprefix);
|
||||
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;
|
||||
}
|
||||
const faction * sf = visible_faction(f, u);
|
||||
const char * prefix = raceprefix(u);
|
||||
if (u->faction == f || omniscient(f)) {
|
||||
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||
const faction * otherfaction = a_otherfaction?get_otherfaction(a_otherfaction):NULL;
|
||||
/* my own faction, full info */
|
||||
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;
|
||||
ap = a_find(g->attribs, &at_raceprefix);
|
||||
fprintf(F, "%d;gruppe\n", g->gid);
|
||||
|
@ -633,9 +629,8 @@ cr_output_unit(FILE * F, const region * r,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (atyp) {
|
||||
const char * name = (const char*)atyp->data.v;
|
||||
fprintf(F, "\"%s\";typprefix\n", add_translation(name, LOC(f->locale, name)));
|
||||
if (prefix) {
|
||||
fprintf(F, "\"%s\";typprefix\n", add_translation(prefix, LOC(f->locale, prefix)));
|
||||
}
|
||||
}
|
||||
if (u->faction != f && a_fshidden
|
||||
|
|
|
@ -334,39 +334,42 @@ rc_name(const race * rc, int 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 *
|
||||
racename(const struct locale *loc, const unit *u, const race * rc)
|
||||
{
|
||||
const char * prefix = raceprefix(u);
|
||||
attrib * asyn = a_find(u->faction->attribs, &at_synonym);
|
||||
|
||||
if (prefix!=NULL) {
|
||||
static char lbuf[80];
|
||||
attrib *a, *a2;
|
||||
|
||||
|
||||
a = a_find(u->attribs, &at_group);
|
||||
if(a) {
|
||||
a2 = a_find(((group *)(a->data.v))->attribs, &at_raceprefix);
|
||||
} else {
|
||||
a2 = a_find(u->faction->attribs, &at_raceprefix);
|
||||
}
|
||||
|
||||
a = a_find(u->faction->attribs, &at_synonym);
|
||||
|
||||
if(a2) {
|
||||
char s[32];
|
||||
|
||||
strcpy(lbuf, locale_string(loc, (char *)a2->data.v));
|
||||
if(a) {
|
||||
char * s = lbuf;
|
||||
strcpy(lbuf, locale_string(loc, prefix));
|
||||
s += strlen(lbuf);
|
||||
if (asyn!=NULL) {
|
||||
strcpy(s, locale_string(loc,
|
||||
((frace_synonyms *)(a->data.v))->synonyms[u->number != 1]));
|
||||
((frace_synonyms *)(asyn->data.v))->synonyms[u->number != 1]));
|
||||
} else {
|
||||
strcpy(s, LOC(loc, rc_name(rc, u->number != 1)));
|
||||
}
|
||||
s[0] = (char)tolower(s[0]);
|
||||
strcat(lbuf, s);
|
||||
return lbuf;
|
||||
}
|
||||
if(a) {
|
||||
} else if (asyn!=NULL) {
|
||||
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));
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ extern const struct race_syn race_synonyms[];
|
|||
extern void write_race_reference(const struct race * rc, FILE * F);
|
||||
extern int read_race_reference(const struct race ** rp, FILE * F);
|
||||
|
||||
extern const char * raceprefix(const struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue