Skip to content

Commit cd719fc

Browse files
committed
Fix c3e7202 may lose anim ownership
1 parent ab341e9 commit cd719fc

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/Ext/Anim/Body.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,7 @@ void AnimExt::CreateRandomAnim(const std::vector<AnimTypeClass*>& AnimList, Coor
376376
return;
377377

378378
auto const pAnim = GameCreate<AnimClass>(pAnimType, coords);
379-
380-
if (!pTechno)
381-
return;
382-
383-
AnimExt::SetAnimOwnerHouseKind(pAnim, pHouse ? pHouse : pTechno->Owner, nullptr, false, true);
379+
AnimExt::SetAnimOwnerHouseKind(pAnim, (pHouse ? pHouse : (pTechno ? pTechno->Owner : nullptr)), nullptr, false, true);
384380

385381
if (ownedObject)
386382
pAnim->SetOwnerObject(pTechno);

src/Ext/Techno/Body.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,10 @@ bool TechnoExt::ConvertToType(FootClass* pThis, TechnoTypeClass* pToType)
317317
if (AresFunctions::ConvertTypeTo(pThis, pToType))
318318
{
319319
// Fixed an issue where morphing could result in -1 health.
320-
double ratio = static_cast<double>(pToType->Strength) / pType->Strength;
320+
const double ratio = static_cast<double>(pToType->Strength) / pType->Strength;
321321
pThis->Health = static_cast<int>(oldHealth * ratio + 0.5);
322322

323-
auto const pTypeExt = TechnoExt::ExtMap.Find(static_cast<TechnoClass*>(pThis));
323+
auto const pTypeExt = TechnoExt::ExtMap.Find(pThis);
324324
pTypeExt->UpdateTypeData(pToType);
325325
pTypeExt->UpdateTypeData_Foot();
326326
return true;
@@ -418,7 +418,7 @@ bool TechnoExt::ConvertToType(FootClass* pThis, TechnoTypeClass* pToType)
418418
if (pToType->BalloonHover && pToType->DeployToLand && prevType->Locomotor != jjLoco && toLoco == jjLoco)
419419
pThis->Locomotor->Move_To(pThis->Location);
420420

421-
auto const pTypeExt = TechnoExt::ExtMap.Find(static_cast<TechnoClass*>(pThis));
421+
auto const pTypeExt = TechnoExt::ExtMap.Find(pThis);
422422
pTypeExt->UpdateTypeData(pToType);
423423
pTypeExt->UpdateTypeData_Foot();
424424
return true;

0 commit comments

Comments
 (0)