Skip to content

Commit a6a6792

Browse files
authored
[Minor] Supplementary Convert.ResetMindControl (#1704)
1 parent 5724493 commit a6a6792

File tree

3 files changed

+27
-43
lines changed

3 files changed

+27
-43
lines changed

CREDITS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ This page lists all the individual contributions to the project by their author.
367367
- `600 The shield of the attached object is broken` bug fix for the triggered event
368368
- Fixed an issue where a portion of Ares's trigger event 75/77 was determined unsuccessfully
369369
- Second weapon with `ElectricAssault=yes` will not unconditionally attack your building with `Overpowerable=yes`
370+
- Fixed some units of Ares crashing after deployment conversion
370371
- **NetsuNegi**:
371372
- Forbidding parallel AI queues by type
372373
- Jumpjet crash speed fix when crashing onto building
@@ -415,6 +416,7 @@ This page lists all the individual contributions to the project by their author.
415416
- Build limit group
416417
- Customizing whether passengers are kicked out when an aircraft fires
417418
- New SuperWeapon Type template
419+
- Fixed some units of Ares crashing after deployment conversion
418420
- **TwinkleStar**:
419421
- Custom slaves free sound
420422
- Jumpjet crash rotation control
@@ -542,7 +544,6 @@ This page lists all the individual contributions to the project by their author.
542544
- AI vehicle production update code
543545
- parts of TechnoType conversion placeholder code
544546
- **ststl, FlyStar, NaotoYuuki, Saigyouji, JunJacobYoung** - Digital Display
545-
- **ststl, FlyStar** - Fixed some units of Ares crashing after deployment conversion
546547
- **SukaHati (Erzoid)** - Minimum interceptor guard range
547548
- **E1 Elite** - TileSet 255 and above bridge repair fix
548549
- **AutoGavy** - interceptor logic, Warhead critical hit logic

docs/New-or-Enhanced-Logics.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,9 @@ WarpOutWeapon= ; WeaponType
17551755
### Reset MindControl after transformation
17561756

17571757
- After the unit conversion is completed, its mind control can be reset.
1758-
- If `Convert.ResetMindControl=no` and there are no warheads in the unit that use `MindControl=yes`, then the controlled units that exceed the maximum value will be released.
1758+
- If all warheads don't have `MindControl=yes`, then `Convert.ResetMindControl=yes` will release all controlled units.
1759+
- If any warhead has `MindControl=yes`, then `Convert.ResetMindControl=yes` resets its maximum number of controls.
1760+
- If all weapons don't have `InfiniteMindControl=yes`, then `Convert.ResetMindControl=yes` release controlled units that exceed the limit.
17591761

17601762
In `rulesmd.ini`:
17611763
```ini

src/Ext/Techno/Body.Update.cpp

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ bool TechnoExt::ExtData::CheckDeathConditions(bool isInLimbo)
166166
if (affectedHouse == AffectedHouse::Owner)
167167
return allowLimbo ? HouseExt::ExtMap.Find(pThis->Owner)->CountOwnedPresentAndLimboed(pType) > 0 : pThis->Owner->CountOwnedAndPresent(pType) > 0;
168168

169-
for (HouseClass* pHouse : HouseClass::Array)
169+
for (auto const pHouse : HouseClass::Array)
170170
{
171171
if (EnumFunctions::CanTargetHouse(affectedHouse, pThis->Owner, pHouse)
172172
&& (allowLimbo ? HouseExt::ExtMap.Find(pHouse)->CountOwnedPresentAndLimboed(pType) > 0 : pHouse->CountOwnedAndPresent(pType) > 0))
@@ -603,7 +603,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
603603
// There are too few slaves here. More are needed.
604604
const int count = pCurrentType->SlavesNumber - pSlaveManager->SlaveCount;
605605

606-
for (int index = 0; index < count; index++)
606+
for (int i = 0; i < count; i++)
607607
{
608608
if (auto pSlaveNode = GameCreate<SlaveManagerClass::SlaveControl>())
609609
{
@@ -679,7 +679,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
679679
const int count = pCurrentType->SpawnsNumber - pSpawnManager->SpawnCount;
680680

681681
// 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++)
683683
{
684684
if (auto pSpawnNode = GameCreate<SpawnControl>())
685685
{
@@ -743,7 +743,7 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
743743
pSpawnManager->ResetTarget();
744744

745745
// 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)
747747
{
748748
const auto pAircraft = pSpawnNode->Unit;
749749
auto& pStatus = pSpawnNode->Status;
@@ -816,59 +816,40 @@ void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
816816
hasParasite = true;
817817
};
818818

819-
for (int index = 0; index < TechnoTypeClass::MaxWeapons; index++)
819+
for (int i = 0; i < TechnoTypeClass::MaxWeapons; i++)
820820
{
821-
checkWeapon(pThis->GetWeapon(index)->WeaponType);
821+
checkWeapon(pThis->GetWeapon(i)->WeaponType);
822822
}
823823

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-
838824
if (maxCapture > 0)
839825
{
840826
if (!pCaptureManager)
841827
{
842828
// Rebuild a CaptureManager
843829
pCaptureManager = GameCreate<CaptureManagerClass>(pThis, maxCapture, infiniteCapture);
844830
}
845-
else
831+
else if (pOldTypeExt->Convert_ResetMindControl)
846832
{
847-
if (!infiniteCapture)
833+
if (!infiniteCapture && pCaptureManager->ControlNodes.Count > maxCapture)
848834
{
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+
}
851841
}
852842

853843
pCaptureManager->MaxControlNodes = maxCapture;
854844
pCaptureManager->InfiniteMindControl = infiniteCapture;
855845
}
856846
}
857-
else if (pCaptureManager)
847+
else if (pCaptureManager && pOldTypeExt->Convert_ResetMindControl)
858848
{
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;
872853
}
873854

874855
if (hasTemporal)
@@ -971,7 +952,7 @@ void TechnoExt::ExtData::UpdateTypeData_Foot()
971952
if (auto const count = pCurrentType->MoveSound.Count)
972953
{
973954
// Play a new sound.
974-
int soundIndex = pCurrentType->MoveSound[Randomizer::Global.Random() % count];
955+
const int soundIndex = pCurrentType->MoveSound[Randomizer::Global.Random() % count];
975956
VocClass::PlayAt(soundIndex, pThis->Location, &pThis->MoveSoundAudioController);
976957
pThis->IsMoveSoundPlaying = true;
977958
}
@@ -1176,7 +1157,7 @@ void TechnoExt::ExtData::UpdateLaserTrails()
11761157
if (!this->IsInTunnel)
11771158
trail.Visible = true;
11781159

1179-
CoordStruct trailLoc = TechnoExt::GetFLHAbsoluteCoords(pThis, trail.FLH, trail.IsOnTurret);
1160+
auto const trailLoc = TechnoExt::GetFLHAbsoluteCoords(pThis, trail.FLH, trail.IsOnTurret);
11801161

11811162
if (pThis->CloakState == CloakState::Uncloaking && !trail.Type->CloakVisible)
11821163
trail.LastLocation = trailLoc;
@@ -1324,7 +1305,7 @@ void TechnoExt::ApplyGainedSelfHeal(TechnoClass* pThis)
13241305
|| (fromAllies && (!isCampaign || (!pHouse->IsHumanPlayer && !pHouse->IsInPlayerControl)) && pHouse->IsAlliedWith(pOwner));
13251306
};
13261307

1327-
for (auto pHouse : HouseClass::Array)
1308+
for (auto const pHouse : HouseClass::Array)
13281309
{
13291310
if (checkHouse(pHouse))
13301311
{

0 commit comments

Comments
 (0)