diff --git a/rts/Sim/Misc/ModInfo.cpp b/rts/Sim/Misc/ModInfo.cpp index 08aade523c..4e7723b5dc 100644 --- a/rts/Sim/Misc/ModInfo.cpp +++ b/rts/Sim/Misc/ModInfo.cpp @@ -131,6 +131,9 @@ void CModInfo::ResetState() // make windChangeReportPeriod equal to EnvResourceHandler::WIND_UPDATE_RATE = 15 * GAME_SPEED; windChangeReportPeriod = 15 * GAME_SPEED; } + { + selectableKilled = true; + } } void CModInfo::Init(const std::string& modFileName) @@ -341,6 +344,10 @@ void CModInfo::Init(const std::string& modFileName) windChangeReportPeriod = static_cast(math::roundf(misc.GetFloat("windChangeReportPeriod", static_cast(windChangeReportPeriod) / GAME_SPEED) * GAME_SPEED)); } + { + //selection + selectableKilled = root.GetBool("selectableKilled", selectableKilled); + } if (!std::has_single_bit (quadFieldQuadSizeInElmos)) throw content_error("quadFieldQuadSizeInElmos modrule has to be a power of 2"); diff --git a/rts/Sim/Misc/ModInfo.h b/rts/Sim/Misc/ModInfo.h index 825c8d223a..e91b77900b 100644 --- a/rts/Sim/Misc/ModInfo.h +++ b/rts/Sim/Misc/ModInfo.h @@ -237,6 +237,9 @@ class CModInfo // how often to report wind speed/direction to wind gens int windChangeReportPeriod; + + // selection behaviour + bool selectableKilled; }; extern CModInfo modInfo; diff --git a/rts/Sim/Units/Unit.cpp b/rts/Sim/Units/Unit.cpp index 9f1ec62fbd..cd6ae2e744 100644 --- a/rts/Sim/Units/Unit.cpp +++ b/rts/Sim/Units/Unit.cpp @@ -484,8 +484,14 @@ void CUnit::ForcedKillUnit(CUnit* attacker, bool selfDestruct, bool reclaimed, i eventHandler.UnitDestroyed(this, attacker, weaponDefID); eoh->UnitDestroyed(*this, attacker, weaponDefID); - // Will be called in the destructor again, but this can not hurt - SetGroup(nullptr); + // release from selection + if (!modInfo.selectableKilled) { + noSelect = true; + if (isSelected) + selectedUnitsHandler.RemoveUnit(this); + + SetGroup(nullptr); + } if (unitDef->windGenerator > 0.0f) envResHandler.DelGenerator(this);