Skip to content

Commit 0ee8090

Browse files
committed
Fix some small things
1 parent f0fb4de commit 0ee8090

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

src/Ext/Bullet/Hooks.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,9 @@ DEFINE_HOOK(0x46902C, BulletClass_Explode_Cluster, 0x6)
293293
constexpr bool CheckTrajectoryCanNotAlwaysSnap(const TrajectoryFlag flag)
294294
{
295295
return flag != TrajectoryFlag::Invalid;
296+
/* return flag == TrajectoryFlag::Straight
297+
|| flag == TrajectoryFlag::Bombard
298+
|| flag == TrajectoryFlag::Parabola;*/
296299
}
297300

298301
DEFINE_HOOK(0x467CCA, BulletClass_AI_TargetSnapChecks, 0x6)

src/Ext/Bullet/Trajectories/StraightTrajectory.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,11 +1046,14 @@ bool StraightTrajectory::PassAndConfineAtHeight(BulletClass* pBullet)
10461046
};
10471047

10481048
auto checkDifference = MapClass::Instance->GetCellFloorHeight(futureCoords) - futureCoords.Z;
1049-
const auto cellCoords = MapClass::Instance->GetCellAt(futureCoords)->GetCoordsWithBridge();
1050-
const auto differenceOnBridge = cellCoords.Z - futureCoords.Z;
10511049

1052-
if (std::abs(differenceOnBridge) < std::abs(checkDifference))
1053-
checkDifference = differenceOnBridge;
1050+
if (MapClass::Instance->GetCellAt(futureCoords)->ContainsBridge())
1051+
{
1052+
const auto differenceOnBridge = checkDifference + CellClass::BridgeHeight;
1053+
1054+
if (std::abs(differenceOnBridge) < std::abs(checkDifference))
1055+
checkDifference = differenceOnBridge;
1056+
}
10541057

10551058
// The height does not exceed the cliff, or the cliff can be ignored?
10561059
if (std::abs(checkDifference) < 384 || !pBullet->Type->SubjectToCliffs)

src/Ext/Techno/Hooks.ReceiveDamage.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
2323
const auto pExt = TechnoExt::ExtMap.Find(pThis);
2424
int nDamageLeft = *args->Damage;
2525

26+
// Raise Combat Alert
2627
if (pRules->CombatAlert && nDamageLeft > 1)
2728
{
28-
auto raiseCombatAlert = [pThis, pExt, pRules, args]()
29+
auto raiseCombatAlert = [&]()
2930
{
3031
const auto pHouse = pThis->Owner;
3132

@@ -57,7 +58,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
5758

5859
if (pRules->CombatAlert_SuppressIfInScreen)
5960
{
60-
TacticalClass* const pTactical = TacticalClass::Instance;
61+
const auto pTactical = TacticalClass::Instance();
6162
const auto coordInScreen = pTactical->CoordsToScreen(coordInMap) - pTactical->TacticalPos;
6263
const auto screenArea = DSurface::Composite->GetRect();
6364

@@ -84,6 +85,7 @@ DEFINE_HOOK(0x701900, TechnoClass_ReceiveDamage_Shield, 0x6)
8485
raiseCombatAlert();
8586
}
8687

88+
// Shield Receive Damage
8789
if (!args->IgnoreDefenses)
8890
{
8991
if (const auto pShieldData = pExt->Shield.get())

src/Misc/Hooks.BugFixes.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ DEFINE_HOOK(0x62AA32, ParasiteClass_TryInfect_MissBehaviorFix, 0x5)
5858
GET(bool, isReturnSuccess, EAX);
5959
GET(ParasiteClass* const, pParasite, ESI);
6060

61-
auto pParasiteTechno = pParasite->Owner;
61+
const auto pParasiteTechno = pParasite->Owner;
6262

6363
if (isReturnSuccess || !pParasiteTechno)
6464
return 0;
@@ -68,12 +68,11 @@ DEFINE_HOOK(0x62AA32, ParasiteClass_TryInfect_MissBehaviorFix, 0x5)
6868
if (!pType)
6969
return 0;
7070

71-
auto cell = MapClass::Instance->NearByLocation(pParasiteTechno->LastMapCoords,
72-
pType->SpeedType, -1, pType->MovementZone, false, 1, 1, false,
73-
false, false, true, CellStruct::Empty, false, false);
74-
auto crd = CellClass::Cell2Coord(cell);
75-
isReturnSuccess = pParasiteTechno->Unlimbo(crd, DirType::North);
76-
R->AL(isReturnSuccess);
71+
const auto cell = MapClass::Instance->NearByLocation(pParasiteTechno->LastMapCoords, pType->SpeedType, -1,
72+
pType->MovementZone, false, 1, 1, false, false, false, true, CellStruct::Empty, false, false);
73+
74+
if (cell != CellStruct::Empty) // Cell2Coord makes X/Y values of CoordStruct non-zero, additional checks are required
75+
R->AL(pParasiteTechno->Unlimbo(CellClass::Cell2Coord(cell), DirType::North));
7776

7877
return 0;
7978
}

0 commit comments

Comments
 (0)