-
Notifications
You must be signed in to change notification settings - Fork 151
bugfix(projectile): Fix out-of-bounds access in DumbProjectile which causes mismatch with very high speed weapons at small hit distances #2087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks logical in principle.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks correct to me.
|
I hadn't at looked the Generals code until now. Lines 651 to 652 in 8c560e6
Lines 635 to 638 in 8c560e6
It doesn't have this particular OOB bug, but I'm not entirely sure why the code was updated for Zero Hour or how the behavior changed. |
|
Maybe we can just leave the Generals code 'as is', and look at it in more detail later as part of a unification effort for this code. |
|
Is the code very different yes? |
|
Check the links two comments back. It's not that different, but it doesn't have this particular OOB bug. |
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
Greptile Overview
|
| Filename | Overview |
|---|---|
| GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp | Adds bounds checking before accessing flight path indices to prevent out-of-bounds access with very high speed weapons |
Sequence Diagram
sequenceDiagram
participant Update as DumbProjectileBehavior::update()
participant FlightPath as m_flightPath vector
participant Fallback as Fallback coordinates
Update->>Update: Check m_currentFlightPathStep >= size()
alt Flight path exhausted
Update->>Update: detonate()
else Flight path available
Update->>FlightPath: Access m_flightPath[m_currentFlightPathStep]
Note over Update: flightStep = current position
alt m_currentFlightPathStep > 0
Update->>FlightPath: Access m_flightPath[step-1] and [step]
Update->>Update: Calculate orientation from previous to current
else m_currentFlightPathStep == 0 (first frame)
alt m_flightPath.size() >= 2
Update->>FlightPath: Access m_flightPath[0] and [1]
Update->>Update: Calculate orientation from [0] to [1]
else m_flightPath.size() < 2 (OUT OF BOUNDS BUG)
Note over Update: BEFORE FIX: Would access [1] and crash
Update->>Update: Check RETAIL_COMPATIBLE_CRC
Update->>Update: DEBUG_CRASH warning
Update->>Fallback: Use m_flightPathStart and m_flightPathEnd
Update->>Update: Set flightStep = m_flightPathEnd
Update->>Update: Calculate orientation deterministically
end
end
Update->>Update: Set transform matrix / position
end
Dismissing Approval because this needs one more looking regarding m_flightPathSegments ==1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 file reviewed, 1 comment
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
Moved code comment.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
Outdated
Show resolved
Hide resolved
xezon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Should be good then.
|
I'll put my last comment here, so it doesn't get buried. With fewer than 2 points, there's no visible projectile, but that's to be expected. There's also no bullet impact when force firing on the ground. Where the damage is applied needs more testing, because it seems like it's applied to a much wider field. |
This comment was marked as resolved.
This comment was marked as resolved.
Apparently 'flightStep' is used as the next position for the projectile.
Fixed. The projectile is still invisible, but that's alright. The projectile impact and damage are now properly applied to the projectile's destination. This PR is ready to be merged whenever the other PRs are. |
Sufficiently high weapon speeds expose an out-of-bounds access bug for
DumbProjectile, which is the reason for non-deterministic behavior across clients (i.e. mismatches).This PR fixes the bug properly in no retail mode, and makes behavior deterministic for patched clients in retail mode.
TODO:
[ ] Replicate in GeneralsGenerals doesn't have this particular out-of-bounds bug.