Fix all horizontal movement being broken#1156
Merged
coelckers merged 5 commits intoZDoom:masterfrom Jul 17, 2025
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1141.
The commit 940e53a seems to have broken all horizontal movement in Raze. The commit copied a change to
vectors.hfrom GZDoom that makes it soTVector3::XY()returns a fresh TVector2 object instead of a reference to the TVector3 type-punned to look like a TVector2, which has the consequence that modifying the returned object (likevec3.XY() = someVec2;) no longer works to modify the TVector3. That wasn't an issue in GZDoom but this pattern is done in a ton of places in Raze.The commit changed
vectors.hto no longer use type-punning which seems like a reasonable goal, so I wanted to find a solution that didn't just revert that. I think it would be possible to make all of Raze's code continue working by making theTVector3::XY()method return a TVector2-like proxy object that contains references to the TVector3's X and Y properties and implements all of the same methods as TVector2 and support for being implicitly converted to a TVector2, but that struck me as a lot of duplication invectors.hwhich also wouldn't be useful for GZDoom. Instead I just went through all of the calls toTVector3::XY()that mutated the returned value and made them not do that.Here are the main kinds of changes I did many times:
I added a
TVector3::SetXY(const Vector2 &v)method instead of overloadingoperator=for Vector2 values because it seemed like the latter might allow accidents.The above works because TVector3 has methods like
TVector3 &operator+= (const Vector2 &other)and other compound assignment operators defined for it that only affects the X and Y properties.This had to be handled differently because
gs.playerfrictionis a number instead of a Vector2, so if I just removed the.XY()part again then all 3 coordinates would be modified, not just X and Y.Additionally, while working on this I discovered a bug in
source/games/blood/src/aiunicult.cppdudeLeechOperate()where the Z coordinate of a vector wasn't set to the intended value and was left uninitialized. It's fixed in its own commit, 3ff9ef5.