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

@ -13,7 +13,7 @@
*/ */
/* /*
Connection Network Protocol
*/ */
#define PEER_ID_INEXISTENT 0 #define PEER_ID_INEXISTENT 0
@ -60,15 +60,16 @@
// Use floatToInt(p, BS) and intToFloat(p, BS). // Use floatToInt(p, BS) and intToFloat(p, BS).
#define BS 10.0f #define BS 10.0f
// Dimension of a MapBlock // Dimension of a MapBlock in nodes
#define MAP_BLOCKSIZE 16 #define MAP_BLOCKSIZE 16
// This makes mesh updates too slow, as many meshes are updated during
// the main loop (related to TempMods and day/night)
//#define MAP_BLOCKSIZE 32
// Player step height in nodes // Player step height in nodes
#define PLAYER_DEFAULT_STEPHEIGHT 0.6f #define PLAYER_DEFAULT_STEPHEIGHT 0.6f
// Arbitrary volume limit for working with contiguous areas (in nodes)
// needs to safely fit in the VoxelArea class; used by e.g. VManips
#define MAX_WORKING_VOLUME 150000000UL
/* /*
Old stuff that shouldn't be hardcoded Old stuff that shouldn't be hardcoded
*/ */
@ -82,6 +83,10 @@
// Default maximal breath of a player // Default maximal breath of a player
#define PLAYER_MAX_BREATH_DEFAULT 10 #define PLAYER_MAX_BREATH_DEFAULT 10
/*
Misc
*/
// Number of different files to try to save a player to if the first fails // Number of different files to try to save a player to if the first fails
// (because of a case-insensitive filesystem) // (because of a case-insensitive filesystem)
// TODO: Use case-insensitive player names instead of this hack. // TODO: Use case-insensitive player names instead of this hack.
@ -93,8 +98,4 @@
// the file attempting to ensure a unique filename // the file attempting to ensure a unique filename
#define SCREENSHOT_MAX_SERIAL_TRIES 1000 #define SCREENSHOT_MAX_SERIAL_TRIES 1000
/*
GUI related things
*/
#define TTF_DEFAULT_FONT_SIZE (16) #define TTF_DEFAULT_FONT_SIZE (16)

View file

@ -847,9 +847,8 @@ int ModApiEnv::l_find_node_near(lua_State *L)
void ModApiEnvBase::checkArea(v3s16 &minp, v3s16 &maxp) void ModApiEnvBase::checkArea(v3s16 &minp, v3s16 &maxp)
{ {
auto volume = VoxelArea(minp, maxp).getVolume(); auto volume = VoxelArea(minp, maxp).getVolume();
// Volume limit equal to 8 default mapchunks, (80 * 2) ^ 3 = 4,096,000 if (volume > MAX_WORKING_VOLUME) {
if (volume > 4096000) { throw LuaError("Area volume exceeds allowed value of " + std::to_string(MAX_WORKING_VOLUME));
throw LuaError("Area volume exceeds allowed value of 4096000");
} }
// Clamp to map range to avoid problems // Clamp to map range to avoid problems

View file

@ -118,12 +118,10 @@ static inline void checkArea(const VoxelArea &a)
// won't overflow since cbrt(2^64) > 2^16 // won't overflow since cbrt(2^64) > 2^16
u64 real_volume = static_cast<u64>(a.getExtent().X) * a.getExtent().Y * a.getExtent().Z; 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 static_assert(MAX_WORKING_VOLUME < S32_MAX); // hard limit is somewhere here
// Note: the hard limit is somewhere around 2^31 due to s32 type if (real_volume > MAX_WORKING_VOLUME) {
constexpr u64 MAX_ALLOWED = 4096000;
if (real_volume > MAX_ALLOWED) {
throw BaseException("VoxelManipulator: " 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));
} }
} }