| 21 | } |
| 22 | |
| 23 | bool CaptureManagerExt::FreeUnit(CaptureManagerClass* pManager, TechnoClass* pTarget, bool silent) |
| 24 | { |
| 25 | if (pTarget) |
| 26 | { |
| 27 | for (int i = pManager->ControlNodes.Count - 1; i >= 0; --i) |
| 28 | { |
| 29 | const auto pNode = pManager->ControlNodes[i]; |
| 30 | if (pTarget == pNode->Unit) |
| 31 | { |
| 32 | if (pTarget->MindControlRingAnim) |
| 33 | { |
| 34 | pTarget->MindControlRingAnim->UnInit(); |
| 35 | pTarget->MindControlRingAnim = nullptr; |
| 36 | } |
| 37 | |
| 38 | if (!silent) |
| 39 | { |
| 40 | int nSound = pTarget->GetTechnoType()->MindClearedSound; |
| 41 | |
| 42 | if (nSound == -1) |
| 43 | nSound = RulesClass::Instance->MindClearedSound; |
| 44 | if (nSound != -1) |
| 45 | VocClass::PlayIndexAtPos(nSound, pTarget->GetCoords()); |
| 46 | } |
| 47 | |
| 48 | // Fix : Player defeated should not get this unit. |
| 49 | auto pOriginOwner = pNode->OriginalOwner->Defeated ? |
| 50 | HouseClass::FindNeutral() : pNode->OriginalOwner; |
| 51 | |
| 52 | pTarget->SetOwningHouse(pOriginOwner, !silent); |
| 53 | pManager->DecideUnitFate(pTarget); |
| 54 | pTarget->MindControlledBy = nullptr; |
| 55 | |
| 56 | GameDelete(pNode); |
| 57 | |
| 58 | pManager->ControlNodes.RemoveItem(i); |
| 59 | |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | return false; |
| 66 | } |
| 67 | |
| 68 | bool CaptureManagerExt::CaptureUnit(CaptureManagerClass* pManager, TechnoClass* pTarget, |
| 69 | bool bRemoveFirst, AnimTypeClass* pControlledAnimType, bool silent) |
no test coverage detected