-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[CR] Use units::volume instead of full type #47311
Conversation
Ok, so this breaks the item test because of integer overflow. The volume type uses int, but that occurence uses int64 to avoid that. Is it supposed to be like that? If yes, this can be closed. Though I'm not sure what happens when there's enough charges to actually go beyond maxint ml. (I guess this is prevented by implausability anyway.) |
If the purpose of it is to avoid the overflow, perhaps a comment in the code would be a good idea? |
Yeah, I can change the PR to do that instead, if I get a confirmation. |
See this commit, although there was a more recent one by @KorGgenT. |
I'm more concerned with the left side. |
Ping: @jbytheway |
It's divided by stack size before being assigned to Doing the division first would be incorrect, because it would round improperly. |
That makes me somewhat question the test case that makes this require to be an int64, then. It's testing the overflow safety when it shouldn't get anywhere near those values ever. |
Is the 1000L limit intentional, or due to the same sort of thing that limits monster volume/size? |
Answer could possibly be here - #35411 |
So I think the limit might not be 1000L. At some point, around when these 64-bit integers were originally introduced, it was constructed such that there was an upper limit on any vehicle part size (which was set to match the blazemod cargo dimension), and a lower limit on item volume, such that the maximum stack size in any available volume wouldn't exceed 2^31. I guess now we have to worry about pocket sizes as well as vehicle part capacities. Someone could cause an error here by creating a very generous bag-of-holding item. |
Summary
None
Purpose of change
Just came across this when looking at code and thought I'd clean it up.
It's the only occurence of any of the units not using their alias I found.
Describe the solution
Use alias.
Testing
Item stacks still have their volume.