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

Incorrect usage of FLT_MIN #519

Open
Kefta opened this issue Aug 6, 2021 · 9 comments
Open

Incorrect usage of FLT_MIN #519

Kefta opened this issue Aug 6, 2021 · 9 comments

Comments

@Kefta
Copy link

Kefta commented Aug 6, 2021

Reposting from #518 since the creator is banned. These usages from FLT_MIN should be replaced with std::numeric_limits<float>::lowest(), and FLT_MAX with std::numeric_limit<float>::max() for consistency though these are standard to be equivalent. Here are all the incorrect usages in the public repo:

pBBox[iBox].vMax.Init( FLT_MIN, FLT_MIN, FLT_MIN );

Vector vecMax( FLT_MIN, FLT_MIN, FLT_MIN );

Vector vecMax( FLT_MIN, FLT_MIN, FLT_MIN );

m_vecMax.Init( FLT_MIN, FLT_MIN, FLT_MIN );

This has been (incorrectly but passably) fixed in Garry's Mod as of Aug 6: https://commits.facepunch.com/388626

@Paradise-floor

This comment has been minimized.

@punishman

This comment has been minimized.

@SC1040-TS2
Copy link

SC1040-TS2 commented Aug 9, 2021

Replying to #519 (comment)

Hang on, are there also Source SDK MP analogues for these, or were these only found in the Singleplayer branch?

@Voltstro
Copy link

Voltstro commented Aug 9, 2021

@SC1040-TS2 They are also in the MP branch.

@Kefta
Copy link
Author

Kefta commented Aug 9, 2021

The code for these portions is identical between MP and SP.

@SC1040-TS2
Copy link

SC1040-TS2 commented Aug 9, 2021

Understood. Just clarifying that given MP entries were not posted.

On a different relevant note, I noticed that the vecMin values are specified as FLT_MAX, while the vecMax values are specified as FLT_MIN. Is this correct, or also an incorrect usage that must be swapped to fix?

@Kefta
Copy link
Author

Kefta commented Aug 9, 2021

It is a correct usage - they are used in a loop to pick the min/max values from a range, so everything less than FLT_MAX/greater than std::numeric_limits::lowest() respectively should be considered. If they were swapped, the checks would never pass and thus the vectors would always keep their extreme values.

@SC1040-TS2
Copy link

It is a correct usage - they are used in a loop to pick the min/max values from a range, so everything less than FLT_MAX/greater than std::numeric_limits::lowest() respectively should be considered. If they were swapped, the checks would never pass and thus the vectors would always keep their extreme values.

Understood. Just making sure that was the case, for my own understanding's sake.

@punishman
Copy link

punishman commented Aug 10, 2021

I think it will not be correct usage.
Need init values with first value, and FLT_MIN/FLT_MAX not be used????

TotallyMehis added a commit to zm-reborn/zmr-game that referenced this issue Oct 8, 2021
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

No branches or pull requests

5 participants