1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Centralize arbitrary area volume limit and raise it (#15696)

This commit is contained in:
sfan5 2025-01-23 12:18:20 +01:00 committed by GitHub
parent af3f696423
commit a99e985674
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 17 deletions

View file

@ -118,12 +118,10 @@ static inline void checkArea(const VoxelArea &a)
// won't overflow since cbrt(2^64) > 2^16
u64 real_volume = static_cast<u64>(a.getExtent().X) * a.getExtent().Y * a.getExtent().Z;
// Volume limit equal to 8 default mapchunks, (80 * 2) ^ 3 = 4,096,000
// Note: the hard limit is somewhere around 2^31 due to s32 type
constexpr u64 MAX_ALLOWED = 4096000;
if (real_volume > MAX_ALLOWED) {
static_assert(MAX_WORKING_VOLUME < S32_MAX); // hard limit is somewhere here
if (real_volume > MAX_WORKING_VOLUME) {
throw BaseException("VoxelManipulator: "
"Area volume exceeds allowed value of " + std::to_string(MAX_ALLOWED));
"Area volume exceeds allowed value of " + std::to_string(MAX_WORKING_VOLUME));
}
}