mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Centralize arbitrary area volume limit and raise it (#15696)
This commit is contained in:
parent
af3f696423
commit
a99e985674
3 changed files with 15 additions and 17 deletions
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
Connection
|
||||
Network Protocol
|
||||
*/
|
||||
|
||||
#define PEER_ID_INEXISTENT 0
|
||||
|
@ -60,15 +60,16 @@
|
|||
// Use floatToInt(p, BS) and intToFloat(p, BS).
|
||||
#define BS 10.0f
|
||||
|
||||
// Dimension of a MapBlock
|
||||
// Dimension of a MapBlock in nodes
|
||||
#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
|
||||
#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
|
||||
*/
|
||||
|
@ -82,6 +83,10 @@
|
|||
// Default maximal breath of a player
|
||||
#define PLAYER_MAX_BREATH_DEFAULT 10
|
||||
|
||||
/*
|
||||
Misc
|
||||
*/
|
||||
|
||||
// Number of different files to try to save a player to if the first fails
|
||||
// (because of a case-insensitive filesystem)
|
||||
// TODO: Use case-insensitive player names instead of this hack.
|
||||
|
@ -93,8 +98,4 @@
|
|||
// the file attempting to ensure a unique filename
|
||||
#define SCREENSHOT_MAX_SERIAL_TRIES 1000
|
||||
|
||||
/*
|
||||
GUI related things
|
||||
*/
|
||||
|
||||
#define TTF_DEFAULT_FONT_SIZE (16)
|
||||
|
|
|
@ -847,9 +847,8 @@ int ModApiEnv::l_find_node_near(lua_State *L)
|
|||
void ModApiEnvBase::checkArea(v3s16 &minp, v3s16 &maxp)
|
||||
{
|
||||
auto volume = VoxelArea(minp, maxp).getVolume();
|
||||
// Volume limit equal to 8 default mapchunks, (80 * 2) ^ 3 = 4,096,000
|
||||
if (volume > 4096000) {
|
||||
throw LuaError("Area volume exceeds allowed value of 4096000");
|
||||
if (volume > MAX_WORKING_VOLUME) {
|
||||
throw LuaError("Area volume exceeds allowed value of " + std::to_string(MAX_WORKING_VOLUME));
|
||||
}
|
||||
|
||||
// Clamp to map range to avoid problems
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue