From 607702d0462c4aa1bd9e4d9a3f986b1b9510cc41 Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 26 Oct 2022 08:22:40 +0200 Subject: [PATCH] make sure to reload also icons and other missiles on unit redef in game --- src/unit/script_unittype.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index bb22e51cc..0420ae8b5 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -607,6 +607,9 @@ static int CclDefineUnitType(lua_State *l) } else if (!strcmp(value, "Icon")) { type->Icon.Name = LuaToString(l, -1); type->Icon.Icon = NULL; + if (GameRunning) { + type->Icon.Load(); + } } else if (!strcmp(value, "Portrait")) { #ifdef USE_MNG if (!lua_istable(l, -1)) { @@ -751,6 +754,11 @@ static int CclDefineUnitType(lua_State *l) } else if (!strcmp(value, "Corpse")) { type->CorpseName = LuaToString(l, -1); type->CorpseType = NULL; + if (GameRunning) { + if (!type->CorpseName.empty()) { + type->CorpseType = UnitTypeByIdent(type->CorpseName); + } + } } else if (!strcmp(value, "DamageType")) { value = LuaToString(l, -1); //int check = ExtraDeathIndex(value); @@ -759,6 +767,9 @@ static int CclDefineUnitType(lua_State *l) type->ExplodeWhenKilled = 1; type->Explosion.Name = LuaToString(l, -1); type->Explosion.Missile = NULL; + if (GameRunning) { + type->Explosion.MapMissile(); + } } else if (!strcmp(value, "TeleportCost")) { type->TeleportCost = LuaToNumber(l, -1); } else if (!strcmp(value, "TeleportEffectIn")) { @@ -817,9 +828,15 @@ static int CclDefineUnitType(lua_State *l) if (!strcmp(dtype, "general")) { type->Impact[ANIMATIONS_DEATHTYPES].Name = LuaToString(l, -1, k + 1); type->Impact[ANIMATIONS_DEATHTYPES].Missile = NULL; + if (GameRunning) { + type->Impact[ANIMATIONS_DEATHTYPES].MapMissile(); + } } else if (!strcmp(dtype, "shield")) { type->Impact[ANIMATIONS_DEATHTYPES + 1].Name = LuaToString(l, -1, k + 1); type->Impact[ANIMATIONS_DEATHTYPES + 1].Missile = NULL; + if (GameRunning) { + type->Impact[ANIMATIONS_DEATHTYPES + 1].MapMissile(); + } } else { int num = 0; for (; num < ANIMATIONS_DEATHTYPES; ++num) { @@ -832,6 +849,9 @@ static int CclDefineUnitType(lua_State *l) } else { type->Impact[num].Name = LuaToString(l, -1, k + 1); type->Impact[num].Missile = NULL; + if (GameRunning) { + type->Impact[num].MapMissile(); + } } } }