beyond-all-reason / beyond-all-reason/RecoilEngine
Spring.DestroyUnit() bypasses killing buildee unit from factory
- Dominant language
- C++
- Stars
- 679
- Forks
- 290
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 40
Description
```cpp
void CFactory::KillUnit(CUnit* attacker, bool selfDestruct, bool reclaimed, int weaponDefID)
{
RECOIL_DETAILED_TRACY_ZONE;
if (curBuild != nullptr) {
curBuild->KillUnit(nullptr, false, true, -CSolidObject::DAMAGE_FACTORY_KILLED);
curBuild = nullptr;
}
CUnit::KillUnit(attacker, selfDestruct, reclaimed, weaponDefID);
}
```
This patch of code supposedly is responsible for killing buildee from a lab upon death.
But when the death is caused by Spring.DestroyUnit, unit->ForcedKillUnit() is called and this isn't, meaning a buildee will stay alive.
``` unit->ForcedKillUnit(attacker, selfDestr, reclaimed, -CSolidObject::DAMAGE_KILLED_LUA); ```
Maybe add an exception for factories that would have to call both unit->ForcedKillUnit() and factory->curBuild -> KillUnit ?
Contributor guide
Research direction
Start at Spring.DestroyUnit and its call to unit->ForcedKillUnit(), then compare that path with CFactory::KillUnit(), especially the curBuild cleanup. Reproduce or inspect the factory-death case and confirm that the buildee is removed through both paths; done means Spring.DestroyUnit no longer leaves the buildee alive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100