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

API: CSPlayer new members (physics related) #851

Merged
merged 7 commits into from
Sep 5, 2023

Conversation

dystopm
Copy link
Contributor

@dystopm dystopm commented Jul 17, 2023

  • Added 4 members to CSPlayer class:
    • m_flJumpHeight: player vertical jump force, 0 = default (~268.3)
    • m_flLongJumpHeight: player vertical jump force with longjump enabled, 0 = default (~299.3)
    • m_flLongJumpForce: player horizontal jump force with longjump enabled, 0 = default (560.0)
    • m_flDuckSpeedMultiplier: player duck speed multiplier, 0 = default (0.3333)
  • Cached pmove player's CSPlayer pointer in a global variable

@dystopm
Copy link
Contributor Author

dystopm commented Jul 17, 2023

@wopox1337 @s1lentq need a hand here, any clue of why test demos are failing with this?

@s1lentq
Copy link
Owner

s1lentq commented Jul 18, 2023

@dystopm

Fields in structs clientdata_t, entity_state_t, etc. are transmitted over the network, so input data of these fields are registered in the demo through sendto.
There is a possibility that differences between double and float with a difference of >0.0001 lead to fail the demo test because output data is not equal to input data.
Thus the demo file was recorded in completely vanilla code and PLAYER_DUCKING MULTIPLIER explicitly uses double-precision floatpoint (without .f), but in this PR use float type.
In practice, this difference is insignificant, but it is important to maintain it for the purpose of the demo test.

Use explicitly double precision to fix test demo
@dystopm
Copy link
Contributor Author

dystopm commented Jul 18, 2023

@dystopm

Fields in structs clientdata_t, entity_state_t, etc. are transmitted over the network, so input data of these fields are registered in the demo through sendto. There is a possibility that differences between double and float with a difference of >0.0001 lead to fail the demo test because output data is not equal to input data. Thus the demo file was recorded in completely vanilla code and PLAYER_DUCKING MULTIPLIER explicitly uses double-precision floatpoint (without .f), but in this PR use float type. In practice, this difference is insignificant, but it is important to maintain it for the purpose of the demo test.

That was clever. I thought for a moment of that kind of issue guessing about a precision issue but I just stared at the fact all three memory types were float, I totally dismissed PLAYER_DUCKING_MULTIPLIER is a double for no having .f suffix. Thanks again! 👌🏼

regamedll/pm_shared/pm_shared.cpp Outdated Show resolved Hide resolved
regamedll/pm_shared/pm_shared.cpp Outdated Show resolved Hide resolved
- Cached CSPlayer pointer in a global variable
- Changed PM_JumpHeight from lambda function to an inline function
- Changed m_flDuckSpeedMultiplier data type to double
@s1lentq s1lentq merged commit f441279 into s1lentq:master Sep 5, 2023
3 checks passed
@dystopm dystopm deleted the csplayer-members branch October 11, 2023 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants