fix shapeshifted units without a timer
do not transfer shapeshift spell when giving to a new unit.
This commit is contained in:
Enno Rehling 2021-01-07 20:59:25 +01:00
parent fb294d9118
commit af2dadfc8e
4 changed files with 48 additions and 14 deletions

View File

@ -530,9 +530,14 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
} }
if (u2->number == 0) { if (u2->number == 0) {
const race* rc = u_race(u);
if (rc->flags & RCF_SHAPESHIFT) {
set_racename(&u2->attribs, get_racename(u->attribs)); set_racename(&u2->attribs, get_racename(u->attribs));
u_setrace(u2, u_race(u)); }
u_setrace(u2, rc);
if (rc == get_race(RC_DAEMON)) {
u2->irace = u->irace; u2->irace = u->irace;
}
if (fval(u, UFL_HERO)) { if (fval(u, UFL_HERO)) {
fset(u2, UFL_HERO); fset(u2, UFL_HERO);
} }

View File

@ -48,8 +48,9 @@
#define SHIP_NUMBER_VERSION 370 /* ships have a number */ #define SHIP_NUMBER_VERSION 370 /* ships have a number */
#define FIX_SHAPESHIFT_VERSION 371 /* shapeshifting demons */ #define FIX_SHAPESHIFT_VERSION 371 /* shapeshifting demons */
#define FIX_SEAROADS_VERSION 372 /* removing roads in ocean regions */ #define FIX_SEAROADS_VERSION 372 /* removing roads in ocean regions */
#define FIX_SHAPESHIFT_SPELL_VERSION 373 /* shapeshift spell, bug 2719 */
#define RELEASE_VERSION FIX_SEAROADS_VERSION /* current datafile */ #define RELEASE_VERSION FIX_SHAPESHIFT_SPELL_VERSION /* current datafile */
#define MIN_VERSION UIDHASH_VERSION /* minimal datafile we support */ #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 */ #define MAX_VERSION RELEASE_VERSION /* change this if we can need to read the future datafile, and we can do so */

View File

@ -35,6 +35,7 @@
#include <attributes/attributes.h> #include <attributes/attributes.h>
#include <attributes/key.h> #include <attributes/key.h>
#include <attributes/racename.h> #include <attributes/racename.h>
#include <triggers/changerace.h>
#include <triggers/timeout.h> #include <triggers/timeout.h>
#include <triggers/shock.h> #include <triggers/shock.h>
@ -444,10 +445,12 @@ unit *read_unit(gamedata *data)
u_setrace(u, rc); u_setrace(u, rc);
READ_TOK(data->store, rname, sizeof(rname)); READ_TOK(data->store, rname, sizeof(rname));
if (rname[0]) if (rname[0]) {
u->irace = rc_find(rname); u->irace = rc_find(rname);
else }
else {
u->irace = NULL; u->irace = NULL;
}
READ_INT(data->store, &bn); READ_INT(data->store, &bn);
READ_INT(data->store, &sn); READ_INT(data->store, &sn);
@ -524,11 +527,12 @@ unit *read_unit(gamedata *data)
u->hp = u->number; u->hp = u->number;
} }
read_attribs(data, &u->attribs, u); read_attribs(data, &u->attribs, u);
if (rc_demon && data->version < FIX_SHAPESHIFT_VERSION) { if (rc_demon) {
if (u_race(u) == rc_demon) { if (u_race(u) == rc_demon) {
const char *zRace = get_racename(u->attribs); if (data->version < FIX_SHAPESHIFT_VERSION) {
const char* zRace = get_racename(u->attribs);
if (zRace) { if (zRace) {
const struct race *rc = rc_find(zRace); const struct race* rc = rc_find(zRace);
if (rc) { if (rc) {
set_racename(&u->attribs, NULL); set_racename(&u->attribs, NULL);
u->irace = rc; u->irace = rc;
@ -536,6 +540,30 @@ unit *read_unit(gamedata *data)
} }
} }
} }
else {
if (data->version < FIX_SHAPESHIFT_SPELL_VERSION) {
if (u->irace) {
/* Einheit ist rassengetarnt, aber hat sie einen changerace timer? */
trigger** trigs = get_triggers(u->attribs, "timer");
if (trigs) {
trigger* t = *trigs;
while (t != NULL) {
if (t->type == &tt_changerace) {
break;
}
t = t->next;
}
if (t == NULL) {
u->irace = NULL;
}
}
else {
u->irace = NULL;
}
}
}
}
}
resolve_unit(u); resolve_unit(u);
return u; return u;
} }

View File

@ -218,7 +218,7 @@ static void stealth_race(unit *u, const char *s) {
} }
/* Schablonen können sich als alles mögliche tarnen */ /* Schablonen können sich als alles mögliche tarnen */
if (u_race(u)->flags & RCF_SHAPESHIFT) { else if (u_race(u)->flags & RCF_SHAPESHIFT) {
u->irace = trace; u->irace = trace;
set_racename(&u->attribs, NULL); set_racename(&u->attribs, NULL);
} }