bug 2686: stealth races not translated correctly.

This commit is contained in:
Enno Rehling 2020-08-03 10:31:58 +02:00
parent f39873fc59
commit 3b864b10fc
5 changed files with 50 additions and 29 deletions

View File

@ -4,7 +4,7 @@
<!-- begin main races -->
<race name="template" maintenance="0" magres="100" maxaura="0" regaura="0" weight="0" capacity="1000" speed="10.000000" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" shapeshiftany="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
<race name="template" maintenance="0" magres="100" maxaura="0" regaura="0" weight="0" capacity="1000" speed="10.0" hp="10" damage="1d4" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" fly="yes" swim="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" recruitunlimited="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<attack type="1" damage="1d4"/>
</race>
@ -101,7 +101,7 @@
<!-- begin secondary races -->
<race name="demon" magres="15" maxaura="1" regaura="1.1" recruitcost="360" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="30" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
<race name="demon" magres="15" maxaura="1" regaura="1.1" recruitcost="360" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="30" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="cartmaking" modifier="-2"/>
<skill name="forestry" modifier="1"/>

View File

@ -840,7 +840,7 @@
<familiar race="tunnelworm"/>
<familiar race="imp"/>
</race>
<race name="demon" magres="15" maxaura="1" regaura="1.25" recruitcost="150" maintenance="10" weight="1000" capacity="540" speed="1" hp="50" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" shapeshift="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
<race name="demon" magres="15" maxaura="1" regaura="1.25" recruitcost="150" maintenance="10" weight="1000" capacity="540" speed="1" hp="50" ac="2" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" recruitethereal="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
<skill name="alchemy" modifier="2"/>
<skill name="trade" modifier="-3"/>

View File

@ -117,6 +117,7 @@ static translation *junkyard;
static const char *translate(const char *key, const char *value)
{
if (value) {
int kk = ((key[0] << 5) + key[0]) % TRANSMAXHASH;
translation *t = translation_table[kk];
while (t && strcmp(t->key, key) != 0)
@ -136,6 +137,7 @@ static const char *translate(const char *key, const char *value)
t->next = translation_table[kk];
translation_table[kk] = t;
}
}
return crtag(key);
}
@ -796,19 +798,18 @@ void cr_output_unit(stream *out, const faction * f,
pzTmp = get_racename(u->attribs);
if (pzTmp) {
const char *pzRace = locale_string(lang, mkname("race", pzTmp), false);
char buffer[64];
const char *key = rc_key(pzTmp, NAME_PLURAL, buffer, sizeof(buffer));
const char *pzRace = locale_string(lang, key, false);
if (pzRace) {
/* ex: "Ritter von Go */
pzTmp = pzRace;
}
pzRace = translate(pzTmp, locale_string(lang, pzTmp, false));
pzRace = translate(key, pzTmp);
if (!pzRace) {
pzRace = pzTmp;
}
stream_printf(out, "\"%s\";Typ\n", pzRace);
if (u->faction == f && fval(u_race(u), RCF_SHAPESHIFTANY)) {
pzRace = rc_name_s(u_race(u), NAME_PLURAL);
stream_printf(out, "\"%s\";wahrerTyp\n", pzRace);
}
}
else {
const race *irace = u_irace(u);

View File

@ -45,9 +45,10 @@
#define FIX_RES_BASE_VERSION 367 /* fixing resource base */
#define FIX_CLONES_VERSION 368 /* dissolve clones */
#define FIX_MIGRANT_AURA_VERSION 369 /* bug 2585, migrants with aura */
#define SHIP_NUMBER_VERISON 370 /* ships have a number */
#define SHIP_NUMBER_VERSION 370 /* ships have a number */
#define FIX_SHAPESHIFT_VERSION 371 /* ships have a number */
#define RELEASE_VERSION SHIP_NUMBER_VERISON /* current datafile */
#define RELEASE_VERSION FIX_SHAPESHIFT_VERSION /* current datafile */
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */
#define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */

View File

@ -34,6 +34,7 @@
/* attributes includes */
#include <attributes/attributes.h>
#include <attributes/key.h>
#include <attributes/racename.h>
#include <triggers/timeout.h>
#include <triggers/shock.h>
@ -381,6 +382,12 @@ unit *read_unit(gamedata *data)
char obuf[DISPLAYSIZE];
faction *f;
char rname[32];
static const struct race * rc_demon;
static int config;
if (rc_changed(&config)) {
rc_demon = get_race(RC_DAEMON);
}
READ_INT(data->store, &n);
if (n <= 0) {
@ -518,6 +525,18 @@ unit *read_unit(gamedata *data)
u->hp = u->number;
}
read_attribs(data, &u->attribs, u);
if (rc_demon && data->version < FIX_SHAPESHIFT_VERSION) {
if (u_race(u) == rc_demon) {
const char *zRace = get_racename(u->attribs);
if (zRace) {
const struct race *rc = rc_find(zRace);
if (rc) {
set_racename(&u->attribs, NULL);
u->irace = rc;
}
}
}
}
resolve_unit(u);
return u;
}
@ -1322,7 +1341,7 @@ ship *read_ship(gamedata *data)
}
assert(sh->type || !"ship_type not registered!");
if (data->version < SHIP_NUMBER_VERISON) {
if (data->version < SHIP_NUMBER_VERSION) {
sh->number = 1;
}
else {