From 1d959b51f7e632fc404090abee76149d189593c1 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Sun, 3 May 2026 04:45:09 +0800 Subject: [PATCH 1/6] initial --- docs/Whats-New.md | 1 + .../Bullet/Trajectories/BombardTrajectory.cpp | 5 +++++ .../Bullet/Trajectories/BombardTrajectory.h | 1 + .../Bullet/Trajectories/PhobosTrajectory.cpp | 20 +++++++++++++++++++ .../Bullet/Trajectories/PhobosTrajectory.h | 1 + .../Trajectories/StraightTrajectory.cpp | 5 +++++ .../Bullet/Trajectories/StraightTrajectory.h | 1 + 7 files changed, 34 insertions(+) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 2e4916855f..792aa28809 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -573,6 +573,7 @@ New: - [Allow replacing vanilla repairing with togglable auto repairing](User-Interface.md#allow-replacing-vanilla-repairing-with-togglable-auto-repairing) (by TaranDahl) - Use `OpenTopped.AllowFiringIfAttackedByLocomotor` to control whether the passengers of a non-building transport unit can fire when the unit is being attacked by a weapon whose warhead has `IsLocomotor=true` (by Noble_Fish) - Framework for dynamic sight (by TaranDahl) +- Allow the `.SubjectToGround` of the Trajectory type to consider bridges (by Noble_Fish) Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) diff --git a/src/Ext/Bullet/Trajectories/BombardTrajectory.cpp b/src/Ext/Bullet/Trajectories/BombardTrajectory.cpp index 7b713c8431..a78e91a527 100644 --- a/src/Ext/Bullet/Trajectories/BombardTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/BombardTrajectory.cpp @@ -610,3 +610,8 @@ void BombardTrajectory::RefreshBulletLineTrail(BulletClass* pBullet) pLineTrailer->Owner = pBullet; } } + +bool BombardTrajectory::ShouldSkipBridgeCheck() const +{ + return !this->Type->SubjectToGround; +} diff --git a/src/Ext/Bullet/Trajectories/BombardTrajectory.h b/src/Ext/Bullet/Trajectories/BombardTrajectory.h index 0486a1aac8..3ba5da97b2 100644 --- a/src/Ext/Bullet/Trajectories/BombardTrajectory.h +++ b/src/Ext/Bullet/Trajectories/BombardTrajectory.h @@ -92,6 +92,7 @@ class BombardTrajectory final : public PhobosTrajectory virtual void OnAIVelocity(BulletClass* pBullet, BulletVelocity* pSpeed, BulletVelocity* pPosition) override; virtual TrajectoryCheckReturnType OnAITargetCoordCheck(BulletClass* pBullet) override; virtual TrajectoryCheckReturnType OnAITechnoCheck(BulletClass* pBullet, TechnoClass* pTechno) override; + virtual bool ShouldSkipBridgeCheck() const override; const BombardTrajectoryType* Type; double Height; diff --git a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp index 794de60dbc..d52e469e72 100644 --- a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp @@ -451,6 +451,26 @@ DEFINE_HOOK(0x4666F7, BulletClass_AI_Trajectories, 0x6) return 0; } +/* ROT > 0. We temporarily do not need to make changes to the Bridge interaction for this scenario, but we will leave it here for now, as it may be used later. +DEFINE_HOOK(0x46703E, BulletClass_AI_SkipBridgeCheck1, 0x6) +{ + GET(BulletClass*, pThis, EBP); + auto const pExt = BulletExt::ExtMap.Find(pThis); + if (pExt && pExt->Trajectory) + return 0x467B7A; + return 0; +} +*/ + +DEFINE_HOOK(0x4674DA, BulletClass_AI_SkipBridgeCheck2, 0x6) +{ + GET(BulletClass*, pThis, EBP); + auto const pExt = BulletExt::ExtMap.Find(pThis); + if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) + return 0x467519; + return 0; +} + DEFINE_HOOK(0x467E53, BulletClass_AI_PreDetonation_Trajectories, 0x6) { GET(BulletClass*, pThis, EBP); diff --git a/src/Ext/Bullet/Trajectories/PhobosTrajectory.h b/src/Ext/Bullet/Trajectories/PhobosTrajectory.h index 2ce55bcb5a..1c22618c54 100644 --- a/src/Ext/Bullet/Trajectories/PhobosTrajectory.h +++ b/src/Ext/Bullet/Trajectories/PhobosTrajectory.h @@ -51,6 +51,7 @@ class PhobosTrajectory virtual void OnAIVelocity(BulletClass* pBullet, BulletVelocity* pSpeed, BulletVelocity* pPosition) = 0; virtual TrajectoryCheckReturnType OnAITargetCoordCheck(BulletClass* pBullet) = 0; virtual TrajectoryCheckReturnType OnAITechnoCheck(BulletClass* pBullet, TechnoClass* pTechno) = 0; + virtual bool ShouldSkipBridgeCheck() const { return false; } }; /* diff --git a/src/Ext/Bullet/Trajectories/StraightTrajectory.cpp b/src/Ext/Bullet/Trajectories/StraightTrajectory.cpp index 7818e0c991..f577cd9457 100644 --- a/src/Ext/Bullet/Trajectories/StraightTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/StraightTrajectory.cpp @@ -1054,3 +1054,8 @@ bool StraightTrajectory::PassAndConfineAtHeight(BulletClass* pBullet) return false; } + +bool StraightTrajectory::ShouldSkipBridgeCheck() const +{ + return !this->Type->SubjectToGround; +} diff --git a/src/Ext/Bullet/Trajectories/StraightTrajectory.h b/src/Ext/Bullet/Trajectories/StraightTrajectory.h index ca6c58bc8d..e1a25d4121 100644 --- a/src/Ext/Bullet/Trajectories/StraightTrajectory.h +++ b/src/Ext/Bullet/Trajectories/StraightTrajectory.h @@ -113,6 +113,7 @@ class StraightTrajectory final : public PhobosTrajectory virtual void OnAIVelocity(BulletClass* pBullet, BulletVelocity* pSpeed, BulletVelocity* pPosition) override; virtual TrajectoryCheckReturnType OnAITargetCoordCheck(BulletClass* pBullet) override; virtual TrajectoryCheckReturnType OnAITechnoCheck(BulletClass* pBullet, TechnoClass* pTechno) override; + virtual bool ShouldSkipBridgeCheck() const override; const StraightTrajectoryType* Type; Leptons DetonationDistance; From 6ddbe6d211e01b1d8137475eccf454e0fba264c0 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Sun, 3 May 2026 06:11:08 +0800 Subject: [PATCH 2/6] fix return 0 crash --- src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp index d52e469e72..049ffc843b 100644 --- a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp @@ -468,7 +468,7 @@ DEFINE_HOOK(0x4674DA, BulletClass_AI_SkipBridgeCheck2, 0x6) auto const pExt = BulletExt::ExtMap.Find(pThis); if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) return 0x467519; - return 0; + return 0x4674F6; } DEFINE_HOOK(0x467E53, BulletClass_AI_PreDetonation_Trajectories, 0x6) From 111e352733b08a094ce74a9e2ccd27fa01fd7a55 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Sun, 3 May 2026 05:33:19 +0800 Subject: [PATCH 3/6] [doc] enhance -> phobos fix --- docs/Whats-New.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 792aa28809..8fb8c2cc31 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -573,7 +573,6 @@ New: - [Allow replacing vanilla repairing with togglable auto repairing](User-Interface.md#allow-replacing-vanilla-repairing-with-togglable-auto-repairing) (by TaranDahl) - Use `OpenTopped.AllowFiringIfAttackedByLocomotor` to control whether the passengers of a non-building transport unit can fire when the unit is being attacked by a weapon whose warhead has `IsLocomotor=true` (by Noble_Fish) - Framework for dynamic sight (by TaranDahl) -- Allow the `.SubjectToGround` of the Trajectory type to consider bridges (by Noble_Fish) Vanilla fixes: - Fixed sidebar not updating queued unit numbers when adding or removing units when the production is on hold (by CrimRecya) @@ -695,6 +694,7 @@ Phobos fixes: - Fixed combat light ignoring / behaving differently from vanilla game regarding detail level and framerate checks (by Starkku) - Fixed a bug causing transfering AttachEffects (e.g on `DeploysInto`/`UndeploysInto`) not to immediately recalculate stats or tint (by Starkku) - Fixed a bug where updating the `OpenTopped` attribute during convert did not update the coordinates of passengers (by NetsuNegi) +- Fixed the bug where the .SubjectToGround of the Trajectory type did not consider bridges (by Noble_Fish) Fixes / interactions with other extensions: From c2896b5e53f18a70fccd06386580829240f08458 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Sun, 3 May 2026 06:12:11 +0800 Subject: [PATCH 4/6] [doc] format --- docs/Whats-New.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 8fb8c2cc31..c19b00ae14 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -694,7 +694,7 @@ Phobos fixes: - Fixed combat light ignoring / behaving differently from vanilla game regarding detail level and framerate checks (by Starkku) - Fixed a bug causing transfering AttachEffects (e.g on `DeploysInto`/`UndeploysInto`) not to immediately recalculate stats or tint (by Starkku) - Fixed a bug where updating the `OpenTopped` attribute during convert did not update the coordinates of passengers (by NetsuNegi) -- Fixed the bug where the .SubjectToGround of the Trajectory type did not consider bridges (by Noble_Fish) +- Fixed the bug where the `.SubjectToGround` of the Trajectory type did not consider bridges (by Noble_Fish) Fixes / interactions with other extensions: From 5b5feba3c04aa5b609bd032477ac51a440c1ecab Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 4 May 2026 14:42:43 +0800 Subject: [PATCH 5/6] update --- .../Bullet/Trajectories/PhobosTrajectory.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp index 049ffc843b..a4dfb575ef 100644 --- a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp @@ -462,13 +462,29 @@ DEFINE_HOOK(0x46703E, BulletClass_AI_SkipBridgeCheck1, 0x6) } */ -DEFINE_HOOK(0x4674DA, BulletClass_AI_SkipBridgeCheck2, 0x6) +DEFINE_HOOK(0x4674D4, BulletClass_AI_SkipBridgeCheck2, 0x6) { + __asm { push esi } + GET(BulletClass*, pThis, EBP); auto const pExt = BulletExt::ExtMap.Find(pThis); - if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) - return 0x467519; - return 0x4674F6; + + __asm { pop esi } + + CellClass* pCell = nullptr; + __asm { mov pCell, esi } + + if (pCell && pCell->ContainsBridge()) + { + if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) + return 0x4674DC; + else + return 0x4674F6; + } + else + { + return 0x4674DC; + } } DEFINE_HOOK(0x467E53, BulletClass_AI_PreDetonation_Trajectories, 0x6) From 59b240eb542921de0252032c50126adb9f2cc0a3 Mon Sep 17 00:00:00 2001 From: Noble_Fish <1065703286@qq.com> Date: Mon, 4 May 2026 14:53:31 +0800 Subject: [PATCH 6/6] update --- .../Bullet/Trajectories/PhobosTrajectory.cpp | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp index a4dfb575ef..b3aeacb4b9 100644 --- a/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp +++ b/src/Ext/Bullet/Trajectories/PhobosTrajectory.cpp @@ -464,27 +464,11 @@ DEFINE_HOOK(0x46703E, BulletClass_AI_SkipBridgeCheck1, 0x6) DEFINE_HOOK(0x4674D4, BulletClass_AI_SkipBridgeCheck2, 0x6) { - __asm { push esi } - GET(BulletClass*, pThis, EBP); auto const pExt = BulletExt::ExtMap.Find(pThis); - - __asm { pop esi } - - CellClass* pCell = nullptr; - __asm { mov pCell, esi } - - if (pCell && pCell->ContainsBridge()) - { - if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) - return 0x4674DC; - else - return 0x4674F6; - } - else - { - return 0x4674DC; - } + if (pExt && pExt->Trajectory && pExt->Trajectory->ShouldSkipBridgeCheck()) + return 0x467519; + return 0; } DEFINE_HOOK(0x467E53, BulletClass_AI_PreDetonation_Trajectories, 0x6)