fix permanent smurfs
This commit is contained in:
Enno Rehling 2021-03-18 21:02:22 +01:00
parent 1370b63b8b
commit 16edaf9dba
2 changed files with 23 additions and 18 deletions

View File

@ -287,14 +287,12 @@ struct order *ord)
change_effect(u, itype, 100 * amount); change_effect(u, itype, 100 * amount);
} }
else { else {
const race *irace = u_irace(u);
if (irace == u_race(u)) {
const race *rcfailure = rc_find("smurf"); const race *rcfailure = rc_find("smurf");
if (!rcfailure) { if (!rcfailure) {
rcfailure = rc_find("toad"); rcfailure = rc_find("toad");
} }
if (rcfailure) { if (rcfailure) {
trigger *trestore = trigger_changerace(u, u_race(u), irace); trigger *trestore = trigger_changerace(u, u_race(u), u->irace);
if (trestore) { if (trestore) {
int duration = 2 + rng_int() % 8; int duration = 2 + rng_int() % 8;
@ -305,7 +303,6 @@ struct order *ord)
} }
} }
} }
}
use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE | GET_POOLED_SLACK,
amount); amount);

View File

@ -383,11 +383,12 @@ unit *read_unit(gamedata *data)
char obuf[DISPLAYSIZE]; char obuf[DISPLAYSIZE];
faction *f; faction *f;
char rname[32]; char rname[32];
static const struct race * rc_demon; static const struct race *rc_demon, *rc_smurf;
static int config; static int config;
if (rc_changed(&config)) { if (rc_changed(&config)) {
rc_demon = get_race(RC_DAEMON); rc_demon = get_race(RC_DAEMON);
rc_smurf = rc_find("smurf");
} }
READ_INT(data->store, &n); READ_INT(data->store, &n);
@ -529,11 +530,18 @@ unit *read_unit(gamedata *data)
} }
read_attribs(data, &u->attribs, u); read_attribs(data, &u->attribs, u);
if (rc_demon) { if (rc_demon) {
if (u_race(u) == rc_demon) { const struct race *rc = u_race(u);
if (rc == rc_smurf) {
if (!u->attribs) {
log_error("%s was a %s in a %s faction", unitname(u), rc->_name, u->faction->race->_name);
u->_race = u->faction->race;
}
}
if (rc == rc_demon) {
if (data->version < FIX_SHAPESHIFT_VERSION) { if (data->version < FIX_SHAPESHIFT_VERSION) {
const char* zRace = get_racename(u->attribs); const char* zRace = get_racename(u->attribs);
if (zRace) { if (zRace) {
const struct race* rc = rc_find(zRace); rc = rc_find(zRace);
if (rc) { if (rc) {
set_racename(&u->attribs, NULL); set_racename(&u->attribs, NULL);
u->irace = rc; u->irace = rc;