Open Violet-Nonbloosom opened 5 months ago
Pro Tip! You can help us label your Pull Requests by using the following branch naming convention next time you create a pull request. ❤️ Branch naming convention | Label |
---|---|
feature/** |
🎈 Feature |
fix/** |
✨ Fix |
chore/** |
🧹 Chores |
api/** |
🔧 API |
performance/** |
💡 Performance Optimization |
compatibility/** |
🤝 Compatibility |
If your changes do not fall into any of these categories, don't worry. You can just ignore this message in that case! 👀
A Slimefun preview build is available for testing! Commit: afc73256
https://preview-builds.walshy.dev/download/Slimefun/4163/afc73256
Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!
Why are we moving it to a long? Aren’t we delaying the issue then, this isn’t solving the issue.
should limit it to a value instead of moving the problem in my opinion
Why are we moving it to a long? Aren’t we delaying the issue then, this isn’t solving the issue.
should limit it to a value instead of moving the problem in my opinion
Though it may be more robust, I have no idea what will be happening in future overflow bug.
If long
was not enough for complexity², int
might not be suitable for complexity as well, which meant a thorough rework would be needed.
Besides, I have another subject to work at present, so my solution ends here.
Why are we moving it to a long? Aren’t we delaying the issue then, this isn’t solving the issue.
should limit it to a value instead of moving the problem in my opinion
@J3fftw1 As you wish.
Description
In TP time calculation, $\rm complexity \times complexity$ may result in int overflow when complexity is higher than $4\times 10^{4}$, not difficult to achieve with several popular addons.
Compared with original solution based on
Math
function, it is better to avoid overflow directly.Proposed changes
Use
long
to storage temporary speed variable, which hardly overflow in TP time calculation.If $\rm speed > distance$, time cost must be 1 tick, so we can skip calculation.
Otherwise, $\rm \dfrac {distance}{speed} \geq 1$, while speed must be in range of
int
.Therefore we can simply convert speed to int variable to calculate ultimate time cost.
Related Issues (if applicable)
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values