Skip to content

Commit 0455a77

Browse files
[Minor] Fix LimboKill function (#1378)
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]>
1 parent 6f19e74 commit 0455a77

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

CREDITS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ This page lists all the individual contributions to the project by their author.
353353
- Re-enable the Veinhole Monster and Weeds from TS
354354
- Recreate the weed-charging of SWs like the TS Chemical Missile
355355
- Allow to change the speed of gas particles
356+
- **CrimRecya**
357+
- Fix `LimboKill` not working reliably
356358
- **Ollerus**
357359
- Build limit group enhancement
358360
- Customizable rocker amplitude

docs/Whats-New.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ Phobos fixes:
564564
- Fixed frame by frame hotkey description to read `TXT_FRAME_BY_FRAME_DESC` instead of `TXT_DISPLAY_DAMAGE_DESC` (by DeathFishAtEase)
565565
- 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)
566566
- Fixed Phobos Warhead effects not reliably being applied on damage area as opposed to full weapon-based Warhead detonation (by Starkku)
567+
- Fix `LimboKill` not working reliably (by CrimRecya)
567568
568569
Fixes / interactions with other extensions:
569570
- `IsSimpleDeployer` units with Hover locomotor and `DeployToLand` no longer get stuck after deploying or play their move sound indefinitely (by Starkku)

src/Ext/SWType/FireSuperWeapon.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,6 @@ inline void LimboCreate(BuildingTypeClass* pType, HouseClass* pOwner, int ID)
120120
}
121121
}
122122

123-
inline void LimboDelete(BuildingClass* pBuilding, HouseClass* pTargetHouse)
124-
{
125-
auto pOwnerExt = HouseExt::ExtMap.Find(pTargetHouse);
126-
127-
// Remove building from list of owned limbo buildings
128-
auto& vec = pOwnerExt->OwnedLimboDeliveredBuildings;
129-
vec.erase(std::remove(vec.begin(), vec.end(), pBuilding), vec.end());
130-
131-
pBuilding->Stun();
132-
pBuilding->Limbo();
133-
pBuilding->RegisterDestruction(nullptr);
134-
pBuilding->UnInit();
135-
}
136-
137123
void SWTypeExt::ExtData::ApplyLimboDelivery(HouseClass* pHouse)
138124
{
139125
// random mode
@@ -174,13 +160,25 @@ void SWTypeExt::ExtData::ApplyLimboKill(HouseClass* pHouse)
174160
if (EnumFunctions::CanTargetHouse(this->LimboKill_Affected, pHouse, pTargetHouse))
175161
{
176162
auto const pHouseExt = HouseExt::ExtMap.Find(pTargetHouse);
163+
auto& vec = pHouseExt->OwnedLimboDeliveredBuildings;
177164

178-
for (const auto& pBuilding : pHouseExt->OwnedLimboDeliveredBuildings)
165+
for (auto it = vec.begin(); it != vec.end(); )
179166
{
167+
BuildingClass* const pBuilding = *it;
180168
auto const pBuildingExt = BuildingExt::ExtMap.Find(pBuilding);
181169

182170
if (pBuildingExt->LimboID == limboKillID)
183-
LimboDelete(pBuilding, pTargetHouse);
171+
{
172+
it = vec.erase(it);
173+
pBuilding->Stun();
174+
pBuilding->Limbo();
175+
pBuilding->RegisterDestruction(nullptr);
176+
pBuilding->UnInit();
177+
}
178+
else
179+
{
180+
++it;
181+
}
184182
}
185183
}
186184
}

0 commit comments

Comments
 (0)