mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Fix missing limit check for block y pos (#14320)
This commit is contained in:
parent
e1f6108789
commit
9da1354f3a
42
src/map.cpp
42
src/map.cpp
@ -1506,12 +1506,11 @@ MapSector *ServerMap::createSector(v2s16 p2d)
|
|||||||
Do not create over max mapgen limit
|
Do not create over max mapgen limit
|
||||||
*/
|
*/
|
||||||
if (blockpos_over_max_limit(v3s16(p2d.X, 0, p2d.Y)))
|
if (blockpos_over_max_limit(v3s16(p2d.X, 0, p2d.Y)))
|
||||||
throw InvalidPositionException("createSector(): pos. over max mapgen limit");
|
throw InvalidPositionException("createSector(): pos over max mapgen limit");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Generate blank sector
|
Generate blank sector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sector = new MapSector(this, p2d, m_gamedef);
|
sector = new MapSector(this, p2d, m_gamedef);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1524,20 +1523,11 @@ MapSector *ServerMap::createSector(v2s16 p2d)
|
|||||||
|
|
||||||
MapBlock * ServerMap::createBlock(v3s16 p)
|
MapBlock * ServerMap::createBlock(v3s16 p)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
Do not create over max mapgen limit
|
|
||||||
*/
|
|
||||||
if (blockpos_over_max_limit(p))
|
|
||||||
throw InvalidPositionException("createBlock(): pos. over max mapgen limit");
|
|
||||||
|
|
||||||
v2s16 p2d(p.X, p.Z);
|
v2s16 p2d(p.X, p.Z);
|
||||||
s16 block_y = p.Y;
|
s16 block_y = p.Y;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This will create or load a sector if not found in memory.
|
This will create or load a sector if not found in memory.
|
||||||
If block exists on disk, it will be loaded.
|
|
||||||
|
|
||||||
NOTE: On old save formats, this will be slow, as it generates
|
|
||||||
lighting on blocks for them.
|
|
||||||
*/
|
*/
|
||||||
MapSector *sector;
|
MapSector *sector;
|
||||||
try {
|
try {
|
||||||
@ -1552,11 +1542,16 @@ MapBlock * ServerMap::createBlock(v3s16 p)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
MapBlock *block = sector->getBlockNoCreateNoEx(block_y);
|
MapBlock *block = sector->getBlockNoCreateNoEx(block_y);
|
||||||
if (block) {
|
if (block)
|
||||||
return block;
|
return block;
|
||||||
}
|
|
||||||
// Create blank
|
// Create blank
|
||||||
block = sector->createBlankBlock(block_y);
|
try {
|
||||||
|
block = sector->createBlankBlock(block_y);
|
||||||
|
} catch (InvalidPositionException &e) {
|
||||||
|
infostream << "createBlock: createBlankBlock() failed" << std::endl;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
@ -1576,10 +1571,10 @@ MapBlock * ServerMap::emergeBlock(v3s16 p, bool create_blank)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (create_blank) {
|
if (create_blank) {
|
||||||
MapSector *sector = createSector(v2s16(p.X, p.Z));
|
try {
|
||||||
MapBlock *block = sector->createBlankBlock(p.Y);
|
MapSector *sector = createSector(v2s16(p.X, p.Z));
|
||||||
|
return sector->createBlankBlock(p.Y);
|
||||||
return block;
|
} catch (InvalidPositionException &e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -2000,9 +1995,7 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
|
|||||||
u8 flags = 0;
|
u8 flags = 0;
|
||||||
MapBlock *block;
|
MapBlock *block;
|
||||||
v3s16 p(x,y,z);
|
v3s16 p(x,y,z);
|
||||||
std::map<v3s16, u8>::iterator n;
|
if (m_loaded_blocks.count(p) > 0)
|
||||||
n = m_loaded_blocks.find(p);
|
|
||||||
if(n != m_loaded_blocks.end())
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool block_data_inexistent = false;
|
bool block_data_inexistent = false;
|
||||||
@ -2020,10 +2013,7 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (load_if_inexistent && !blockpos_over_max_limit(p)) {
|
if (load_if_inexistent && !blockpos_over_max_limit(p)) {
|
||||||
ServerMap *svrmap = (ServerMap *)m_map;
|
block = m_map->emergeBlock(p, true);
|
||||||
block = svrmap->emergeBlock(p, false);
|
|
||||||
if (block == NULL)
|
|
||||||
block = svrmap->createBlock(p);
|
|
||||||
block->copyTo(*this);
|
block->copyTo(*this);
|
||||||
} else {
|
} else {
|
||||||
flags |= VMANIP_BLOCK_DATA_INEXIST;
|
flags |= VMANIP_BLOCK_DATA_INEXIST;
|
||||||
|
@ -71,6 +71,9 @@ std::unique_ptr<MapBlock> MapSector::createBlankBlockNoInsert(s16 y)
|
|||||||
{
|
{
|
||||||
assert(getBlockBuffered(y) == nullptr); // Pre-condition
|
assert(getBlockBuffered(y) == nullptr); // Pre-condition
|
||||||
|
|
||||||
|
if (blockpos_over_max_limit(v3s16(0, y, 0)))
|
||||||
|
throw InvalidPositionException("createBlankBlockNoInsert(): pos over max mapgen limit");
|
||||||
|
|
||||||
v3s16 blockpos_map(m_pos.X, y, m_pos.Y);
|
v3s16 blockpos_map(m_pos.X, y, m_pos.Y);
|
||||||
|
|
||||||
return std::make_unique<MapBlock>(blockpos_map, m_gamedef);
|
return std::make_unique<MapBlock>(blockpos_map, m_gamedef);
|
||||||
|
Loading…
Reference in New Issue
Block a user