make sure to reload also icons and other missiles on unit redef in game

This commit is contained in:
Tim Felgentreff 2022-10-26 08:22:40 +02:00
parent ae504303a6
commit 607702d046

View file

@ -607,6 +607,9 @@ static int CclDefineUnitType(lua_State *l)
} else if (!strcmp(value, "Icon")) { } else if (!strcmp(value, "Icon")) {
type->Icon.Name = LuaToString(l, -1); type->Icon.Name = LuaToString(l, -1);
type->Icon.Icon = NULL; type->Icon.Icon = NULL;
if (GameRunning) {
type->Icon.Load();
}
} else if (!strcmp(value, "Portrait")) { } else if (!strcmp(value, "Portrait")) {
#ifdef USE_MNG #ifdef USE_MNG
if (!lua_istable(l, -1)) { if (!lua_istable(l, -1)) {
@ -751,6 +754,11 @@ static int CclDefineUnitType(lua_State *l)
} else if (!strcmp(value, "Corpse")) { } else if (!strcmp(value, "Corpse")) {
type->CorpseName = LuaToString(l, -1); type->CorpseName = LuaToString(l, -1);
type->CorpseType = NULL; type->CorpseType = NULL;
if (GameRunning) {
if (!type->CorpseName.empty()) {
type->CorpseType = UnitTypeByIdent(type->CorpseName);
}
}
} else if (!strcmp(value, "DamageType")) { } else if (!strcmp(value, "DamageType")) {
value = LuaToString(l, -1); value = LuaToString(l, -1);
//int check = ExtraDeathIndex(value); //int check = ExtraDeathIndex(value);
@ -759,6 +767,9 @@ static int CclDefineUnitType(lua_State *l)
type->ExplodeWhenKilled = 1; type->ExplodeWhenKilled = 1;
type->Explosion.Name = LuaToString(l, -1); type->Explosion.Name = LuaToString(l, -1);
type->Explosion.Missile = NULL; type->Explosion.Missile = NULL;
if (GameRunning) {
type->Explosion.MapMissile();
}
} else if (!strcmp(value, "TeleportCost")) { } else if (!strcmp(value, "TeleportCost")) {
type->TeleportCost = LuaToNumber(l, -1); type->TeleportCost = LuaToNumber(l, -1);
} else if (!strcmp(value, "TeleportEffectIn")) { } else if (!strcmp(value, "TeleportEffectIn")) {
@ -817,9 +828,15 @@ static int CclDefineUnitType(lua_State *l)
if (!strcmp(dtype, "general")) { if (!strcmp(dtype, "general")) {
type->Impact[ANIMATIONS_DEATHTYPES].Name = LuaToString(l, -1, k + 1); type->Impact[ANIMATIONS_DEATHTYPES].Name = LuaToString(l, -1, k + 1);
type->Impact[ANIMATIONS_DEATHTYPES].Missile = NULL; type->Impact[ANIMATIONS_DEATHTYPES].Missile = NULL;
if (GameRunning) {
type->Impact[ANIMATIONS_DEATHTYPES].MapMissile();
}
} else if (!strcmp(dtype, "shield")) { } else if (!strcmp(dtype, "shield")) {
type->Impact[ANIMATIONS_DEATHTYPES + 1].Name = LuaToString(l, -1, k + 1); type->Impact[ANIMATIONS_DEATHTYPES + 1].Name = LuaToString(l, -1, k + 1);
type->Impact[ANIMATIONS_DEATHTYPES + 1].Missile = NULL; type->Impact[ANIMATIONS_DEATHTYPES + 1].Missile = NULL;
if (GameRunning) {
type->Impact[ANIMATIONS_DEATHTYPES + 1].MapMissile();
}
} else { } else {
int num = 0; int num = 0;
for (; num < ANIMATIONS_DEATHTYPES; ++num) { for (; num < ANIMATIONS_DEATHTYPES; ++num) {
@ -832,6 +849,9 @@ static int CclDefineUnitType(lua_State *l)
} else { } else {
type->Impact[num].Name = LuaToString(l, -1, k + 1); type->Impact[num].Name = LuaToString(l, -1, k + 1);
type->Impact[num].Missile = NULL; type->Impact[num].Missile = NULL;
if (GameRunning) {
type->Impact[num].MapMissile();
}
} }
} }
} }