@@ -166,7 +166,7 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo)
166
166
if (affectedHouse == AffectedHouse::Owner)
167
167
return allowLimbo ? HouseExt::ExtMap.Find (pThis->Owner )->CountOwnedPresentAndLimboed (pType) > 0 : pThis->Owner ->CountOwnedAndPresent (pType) > 0 ;
168
168
169
- for (HouseClass* pHouse : HouseClass::Array)
169
+ for (auto const pHouse : HouseClass::Array)
170
170
{
171
171
if (EnumFunctions::CanTargetHouse (affectedHouse, pThis->Owner , pHouse)
172
172
&& (allowLimbo ? HouseExt::ExtMap.Find (pHouse)->CountOwnedPresentAndLimboed (pType) > 0 : pHouse->CountOwnedAndPresent (pType) > 0 ))
@@ -603,7 +603,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
603
603
// There are too few slaves here. More are needed.
604
604
const int count = pCurrentType->SlavesNumber - pSlaveManager->SlaveCount ;
605
605
606
- for (int index = 0 ; index < count; index ++)
606
+ for (int i = 0 ; i < count; i ++)
607
607
{
608
608
if (auto pSlaveNode = GameCreate<SlaveManagerClass::SlaveControl>())
609
609
{
@@ -679,7 +679,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
679
679
const int count = pCurrentType->SpawnsNumber - pSpawnManager->SpawnCount ;
680
680
681
681
// Add the missing Spawns, but don't intend for them to be born right away.
682
- for (int index = 0 ; index < count; index ++)
682
+ for (int i = 0 ; i < count; i ++)
683
683
{
684
684
if (auto pSpawnNode = GameCreate<SpawnControl>())
685
685
{
@@ -743,7 +743,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
743
743
pSpawnManager->ResetTarget ();
744
744
745
745
// pSpawnManager->KillNodes() kills all Spawns, but it is not necessary to kill the parts that are not performing tasks.
746
- for (auto pSpawnNode : pSpawnManager->SpawnedNodes )
746
+ for (const auto pSpawnNode : pSpawnManager->SpawnedNodes )
747
747
{
748
748
const auto pAircraft = pSpawnNode->Unit ;
749
749
auto & pStatus = pSpawnNode->Status ;
@@ -816,59 +816,40 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
816
816
hasParasite = true ;
817
817
};
818
818
819
- for (int index = 0 ; index < TechnoTypeClass::MaxWeapons; index ++)
819
+ for (int i = 0 ; i < TechnoTypeClass::MaxWeapons; i ++)
820
820
{
821
- checkWeapon (pThis->GetWeapon (index )->WeaponType );
821
+ checkWeapon (pThis->GetWeapon (i )->WeaponType );
822
822
}
823
823
824
- auto clearMindControlNode = [pCaptureManager](const int & maxCapture)
825
- {
826
- // If not exceeded, then stop.
827
- if (pCaptureManager->ControlNodes .Count <= maxCapture)
828
- return ;
829
-
830
- // Remove excess nodes.
831
- for (int index = pCaptureManager->ControlNodes .Count - 1 ; index >= maxCapture; --index)
832
- {
833
- auto pControlNode = pCaptureManager->ControlNodes .GetItem (index);
834
- pCaptureManager->FreeUnit (pControlNode->Unit );
835
- }
836
- };
837
-
838
824
if (maxCapture > 0 )
839
825
{
840
826
if (!pCaptureManager)
841
827
{
842
828
// Rebuild a CaptureManager
843
829
pCaptureManager = GameCreate<CaptureManagerClass>(pThis, maxCapture, infiniteCapture);
844
830
}
845
- else
831
+ else if (pOldTypeExt-> Convert_ResetMindControl )
846
832
{
847
- if (!infiniteCapture)
833
+ if (!infiniteCapture && pCaptureManager-> ControlNodes . Count > maxCapture )
848
834
{
849
- // It can't be overloaded, so remove the excess nodes.
850
- clearMindControlNode (maxCapture);
835
+ // Remove excess nodes.
836
+ for (int i = pCaptureManager->ControlNodes .Count - 1 ; i >= maxCapture; --i)
837
+ {
838
+ auto const pControlNode = pCaptureManager->ControlNodes .GetItem (i);
839
+ pCaptureManager->FreeUnit (pControlNode->Unit );
840
+ }
851
841
}
852
842
853
843
pCaptureManager->MaxControlNodes = maxCapture;
854
844
pCaptureManager->InfiniteMindControl = infiniteCapture;
855
845
}
856
846
}
857
- else if (pCaptureManager)
847
+ else if (pCaptureManager && pOldTypeExt-> Convert_ResetMindControl )
858
848
{
859
- if (pOldTypeExt->Convert_ResetMindControl .Get ())
860
- {
861
- // Remove CaptureManager completely
862
- pCaptureManager->FreeAll ();
863
- GameDelete (pCaptureManager);
864
- pCaptureManager = nullptr ;
865
- }
866
- else
867
- {
868
- // Remove excess mind control node.
869
- clearMindControlNode (pCaptureManager->MaxControlNodes );
870
- pCaptureManager->InfiniteMindControl = false ;
871
- }
849
+ // Remove CaptureManager completely
850
+ pCaptureManager->FreeAll ();
851
+ GameDelete (pCaptureManager);
852
+ pCaptureManager = nullptr ;
872
853
}
873
854
874
855
if (hasTemporal)
@@ -971,7 +952,7 @@ void TechnoExt::ExtData::UpdateTypeData_Foot()
971
952
if (auto const count = pCurrentType->MoveSound .Count )
972
953
{
973
954
// Play a new sound.
974
- int soundIndex = pCurrentType->MoveSound [Randomizer::Global.Random () % count];
955
+ const int soundIndex = pCurrentType->MoveSound [Randomizer::Global.Random () % count];
975
956
VocClass::PlayAt (soundIndex, pThis->Location , &pThis->MoveSoundAudioController );
976
957
pThis->IsMoveSoundPlaying = true ;
977
958
}
@@ -1176,7 +1157,7 @@ void TechnoExt::ExtData::UpdateLaserTrails()
1176
1157
if (!this ->IsInTunnel )
1177
1158
trail.Visible = true ;
1178
1159
1179
- CoordStruct trailLoc = TechnoExt::GetFLHAbsoluteCoords (pThis, trail.FLH , trail.IsOnTurret );
1160
+ auto const trailLoc = TechnoExt::GetFLHAbsoluteCoords (pThis, trail.FLH , trail.IsOnTurret );
1180
1161
1181
1162
if (pThis->CloakState == CloakState::Uncloaking && !trail.Type ->CloakVisible )
1182
1163
trail.LastLocation = trailLoc;
@@ -1324,7 +1305,7 @@ void TechnoExt::ApplyGainedSelfHeal(TechnoClass* pThis)
1324
1305
|| (fromAllies && (!isCampaign || (!pHouse->IsHumanPlayer && !pHouse->IsInPlayerControl )) && pHouse->IsAlliedWith (pOwner));
1325
1306
};
1326
1307
1327
- for (auto pHouse : HouseClass::Array)
1308
+ for (auto const pHouse : HouseClass::Array)
1328
1309
{
1329
1310
if (checkHouse (pHouse))
1330
1311
{
0 commit comments