Skip to content

Commit

Permalink
[Minor] Fix LimboKill function (#1378)
Browse files Browse the repository at this point in the history
Fix a mistake of `LimboKill` that it did not update the iterators
correctly that cause it unable to correctly remove all buildings with
the same ID.

---------

Co-authored-by: Kerbiter <[email protected]>
  • Loading branch information
CrimRecya and Metadorius authored Sep 15, 2024
1 parent 6f19e74 commit 0455a77
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ This page lists all the individual contributions to the project by their author.
- Re-enable the Veinhole Monster and Weeds from TS
- Recreate the weed-charging of SWs like the TS Chemical Missile
- Allow to change the speed of gas particles
- **CrimRecya**
- Fix `LimboKill` not working reliably
- **Ollerus**
- Build limit group enhancement
- Customizable rocker amplitude
Expand Down
1 change: 1 addition & 0 deletions docs/Whats-New.md
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ Phobos fixes:
- Fixed frame by frame hotkey description to read `TXT_FRAME_BY_FRAME_DESC` instead of `TXT_DISPLAY_DAMAGE_DESC` (by DeathFishAtEase)
- Buildings considered vehicles (`ConsideredVehicle=true` or not set in conjunction with `UndeploysInto` & 1x1 foundation) are now considered units by affected target enum checks (by Starkku)
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
- Fix `LimboKill` not working reliably (by CrimRecya)
Fixes / interactions with other extensions:
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)
Expand Down
30 changes: 14 additions & 16 deletions src/Ext/SWType/FireSuperWeapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,6 @@ inline void LimboCreate(BuildingTypeClass* pType, HouseClass* pOwner, int ID)
}
}

inline void LimboDelete(BuildingClass* pBuilding, HouseClass* pTargetHouse)
{
auto pOwnerExt = HouseExt::ExtMap.Find(pTargetHouse);

// Remove building from list of owned limbo buildings
auto& vec = pOwnerExt->OwnedLimboDeliveredBuildings;
vec.erase(std::remove(vec.begin(), vec.end(), pBuilding), vec.end());

pBuilding->Stun();
pBuilding->Limbo();
pBuilding->RegisterDestruction(nullptr);
pBuilding->UnInit();
}

void SWTypeExt::ExtData::ApplyLimboDelivery(HouseClass* pHouse)
{
// random mode
Expand Down Expand Up @@ -174,13 +160,25 @@ void SWTypeExt::ExtData::ApplyLimboKill(HouseClass* pHouse)
if (EnumFunctions::CanTargetHouse(this->LimboKill_Affected, pHouse, pTargetHouse))
{
auto const pHouseExt = HouseExt::ExtMap.Find(pTargetHouse);
auto& vec = pHouseExt->OwnedLimboDeliveredBuildings;

for (const auto& pBuilding : pHouseExt->OwnedLimboDeliveredBuildings)
for (auto it = vec.begin(); it != vec.end(); )
{
BuildingClass* const pBuilding = *it;
auto const pBuildingExt = BuildingExt::ExtMap.Find(pBuilding);

if (pBuildingExt->LimboID == limboKillID)
LimboDelete(pBuilding, pTargetHouse);
{
it = vec.erase(it);
pBuilding->Stun();
pBuilding->Limbo();
pBuilding->RegisterDestruction(nullptr);
pBuilding->UnInit();
}
else
{
++it;
}
}
}
}
Expand Down

0 comments on commit 0455a77

Please sign in to comment.