Skip to content
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

Fix diagonal movement speed bug #752

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

xezon
Copy link
Contributor

@xezon xezon commented Oct 3, 2022

This change fixes the diagonal movement speed bug.

Reference TheSuperHackers/GeneralsGamePatch#650

Demo

game.2022-10-03.20-18-12-35.mp4

@xezon
Copy link
Contributor Author

xezon commented Oct 3, 2022

I suggest to merge this fix later when we no longer need game state to be consistent with original. For now it will be good to have Thyme work similar to Original, so we can use Original Replays to backtest and find issues. This change would break this ability.

@xezon xezon marked this pull request as draft October 4, 2022 07:08
@xezon
Copy link
Contributor Author

xezon commented Oct 4, 2022

Fix is done, but converting to Draft for the time being.

@xezon
Copy link
Contributor Author

xezon commented Oct 18, 2022

Functions were moved from header to cpp file. Change updated accordingly.

const float dir_len = GameMath::Sqrt(dir->x * dir->x + dir->y * dir->y);
float len = vel_len * dir_len;
// Scale len by (1 + sqrt(2)) / 2 to adjust to the average of the former min/max movement speed.
len /= 1.20710678f;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well multiply by the inverse (may be faster).
Would need to think about if this factor is the correct one. It should be scaled by:

speed *= average_before/average_after

What is average_before though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiplication indeed is favourable here. That would be 1/1.20... = 0.82842712 then.

@xezon xezon force-pushed the fix-diagonal-movement-bug branch from 74cc4c4 to 4b6826b Compare August 9, 2023 19:48
@codecov-commenter
Copy link

codecov-commenter commented Aug 9, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (e1609b2) 2.67% compared to head (4b6826b) 2.67%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##           develop    #752   +/-   ##
=======================================
  Coverage     2.67%   2.67%           
=======================================
  Files          822     822           
  Lines        89290   89294    +4     
  Branches     14799   14799           
=======================================
+ Hits          2387    2390    +3     
- Misses       86559   86560    +1     
  Partials       344     344           
Files Changed Coverage Δ
src/game/logic/object/update/physicsupdate.cpp 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants