Skip to content

Commit b3a2ef1

Browse files
sapiersapier
sapier
authored and
sapier
committed
Remove MapVoxelManipulator not really used by anyone
1 parent 8ad8376 commit b3a2ef1

File tree

2 files changed

+13
-190
lines changed

2 files changed

+13
-190
lines changed

src/map.cpp

+3-166
Original file line numberDiff line numberDiff line change
@@ -3484,180 +3484,17 @@ void ServerMap::PrintInfo(std::ostream &out)
34843484
out<<"ServerMap: ";
34853485
}
34863486

3487-
/*
3488-
MapVoxelManipulator
3489-
*/
3490-
3491-
MapVoxelManipulator::MapVoxelManipulator(Map *map)
3492-
{
3493-
m_map = map;
3494-
}
3495-
3496-
MapVoxelManipulator::~MapVoxelManipulator()
3497-
{
3498-
/*infostream<<"MapVoxelManipulator: blocks: "<<m_loaded_blocks.size()
3499-
<<std::endl;*/
3500-
}
3501-
3502-
void MapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
3503-
{
3504-
TimeTaker timer1("emerge", &emerge_time);
3505-
3506-
// Units of these are MapBlocks
3507-
v3s16 p_min = getNodeBlockPos(a.MinEdge);
3508-
v3s16 p_max = getNodeBlockPos(a.MaxEdge);
3509-
3510-
VoxelArea block_area_nodes
3511-
(p_min*MAP_BLOCKSIZE, (p_max+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
3512-
3513-
addArea(block_area_nodes);
3514-
3515-
for(s32 z=p_min.Z; z<=p_max.Z; z++)
3516-
for(s32 y=p_min.Y; y<=p_max.Y; y++)
3517-
for(s32 x=p_min.X; x<=p_max.X; x++)
3518-
{
3519-
u8 flags = 0;
3520-
MapBlock *block;
3521-
v3s16 p(x,y,z);
3522-
std::map<v3s16, u8>::iterator n;
3523-
n = m_loaded_blocks.find(p);
3524-
if(n != m_loaded_blocks.end())
3525-
continue;
3526-
3527-
bool block_data_inexistent = false;
3528-
try
3529-
{
3530-
TimeTaker timer1("emerge load", &emerge_load_time);
3531-
3532-
/*infostream<<"Loading block (caller_id="<<caller_id<<")"
3533-
<<" ("<<p.X<<","<<p.Y<<","<<p.Z<<")"
3534-
<<" wanted area: ";
3535-
a.print(infostream);
3536-
infostream<<std::endl;*/
3537-
3538-
block = m_map->getBlockNoCreate(p);
3539-
if(block->isDummy())
3540-
block_data_inexistent = true;
3541-
else
3542-
block->copyTo(*this);
3543-
}
3544-
catch(InvalidPositionException &e)
3545-
{
3546-
block_data_inexistent = true;
3547-
}
3548-
3549-
if(block_data_inexistent)
3550-
{
3551-
flags |= VMANIP_BLOCK_DATA_INEXIST;
3552-
3553-
VoxelArea a(p*MAP_BLOCKSIZE, (p+1)*MAP_BLOCKSIZE-v3s16(1,1,1));
3554-
// Fill with VOXELFLAG_NO_DATA
3555-
for(s32 z=a.MinEdge.Z; z<=a.MaxEdge.Z; z++)
3556-
for(s32 y=a.MinEdge.Y; y<=a.MaxEdge.Y; y++)
3557-
{
3558-
s32 i = m_area.index(a.MinEdge.X,y,z);
3559-
memset(&m_flags[i], VOXELFLAG_NO_DATA, MAP_BLOCKSIZE);
3560-
}
3561-
}
3562-
/*else if (block->getNode(0, 0, 0).getContent() == CONTENT_IGNORE)
3563-
{
3564-
// Mark that block was loaded as blank
3565-
flags |= VMANIP_BLOCK_CONTAINS_CIGNORE;
3566-
}*/
3567-
3568-
m_loaded_blocks[p] = flags;
3569-
}
3570-
3571-
//infostream<<"emerge done"<<std::endl;
3572-
}
3573-
3574-
/*
3575-
SUGG: Add an option to only update eg. water and air nodes.
3576-
This will make it interfere less with important stuff if
3577-
run on background.
3578-
*/
3579-
void MapVoxelManipulator::blitBack
3580-
(std::map<v3s16, MapBlock*> & modified_blocks)
3581-
{
3582-
if(m_area.getExtent() == v3s16(0,0,0))
3583-
return;
3584-
3585-
//TimeTaker timer1("blitBack");
3586-
3587-
/*infostream<<"blitBack(): m_loaded_blocks.size()="
3588-
<<m_loaded_blocks.size()<<std::endl;*/
3589-
3590-
/*
3591-
Initialize block cache
3592-
*/
3593-
v3s16 blockpos_last;
3594-
MapBlock *block = NULL;
3595-
bool block_checked_in_modified = false;
3596-
3597-
for(s32 z=m_area.MinEdge.Z; z<=m_area.MaxEdge.Z; z++)
3598-
for(s32 y=m_area.MinEdge.Y; y<=m_area.MaxEdge.Y; y++)
3599-
for(s32 x=m_area.MinEdge.X; x<=m_area.MaxEdge.X; x++)
3600-
{
3601-
v3s16 p(x,y,z);
3602-
3603-
u8 f = m_flags[m_area.index(p)];
3604-
if(f & (VOXELFLAG_NO_DATA))
3605-
continue;
3606-
3607-
MapNode &n = m_data[m_area.index(p)];
3608-
3609-
v3s16 blockpos = getNodeBlockPos(p);
3610-
3611-
try
3612-
{
3613-
// Get block
3614-
if(block == NULL || blockpos != blockpos_last){
3615-
block = m_map->getBlockNoCreate(blockpos);
3616-
blockpos_last = blockpos;
3617-
block_checked_in_modified = false;
3618-
}
3619-
3620-
// Calculate relative position in block
3621-
v3s16 relpos = p - blockpos * MAP_BLOCKSIZE;
3622-
3623-
// Don't continue if nothing has changed here
3624-
if(block->getNode(relpos) == n)
3625-
continue;
3626-
3627-
//m_map->setNode(m_area.MinEdge + p, n);
3628-
block->setNode(relpos, n);
3629-
3630-
/*
3631-
Make sure block is in modified_blocks
3632-
*/
3633-
if(block_checked_in_modified == false)
3634-
{
3635-
modified_blocks[blockpos] = block;
3636-
block_checked_in_modified = true;
3637-
}
3638-
}
3639-
catch(InvalidPositionException &e)
3640-
{
3641-
}
3642-
}
3643-
}
3644-
36453487
ManualMapVoxelManipulator::ManualMapVoxelManipulator(Map *map):
3646-
MapVoxelManipulator(map),
3647-
m_create_area(false)
3488+
VoxelManipulator(),
3489+
m_create_area(false),
3490+
m_map(map)
36483491
{
36493492
}
36503493

36513494
ManualMapVoxelManipulator::~ManualMapVoxelManipulator()
36523495
{
36533496
}
36543497

3655-
void ManualMapVoxelManipulator::emerge(VoxelArea a, s32 caller_id)
3656-
{
3657-
// Just create the area so that it can be pointed to
3658-
VoxelManipulator::addArea(a);
3659-
}
3660-
36613498
void ManualMapVoxelManipulator::initialEmerge(v3s16 blockpos_min,
36623499
v3s16 blockpos_max, bool load_if_inexistent)
36633500
{

src/map.h

+10-24
Original file line numberDiff line numberDiff line change
@@ -523,45 +523,25 @@ class ServerMap : public Map
523523
Database *dbase;
524524
};
525525

526+
526527
#define VMANIP_BLOCK_DATA_INEXIST 1
527528
#define VMANIP_BLOCK_CONTAINS_CIGNORE 2
528529

529-
class MapVoxelManipulator : public VoxelManipulator
530+
class ManualMapVoxelManipulator : public VoxelManipulator
530531
{
531532
public:
532-
MapVoxelManipulator(Map *map);
533-
virtual ~MapVoxelManipulator();
533+
ManualMapVoxelManipulator(Map *map);
534+
virtual ~ManualMapVoxelManipulator();
534535

535536
virtual void clear()
536537
{
537538
VoxelManipulator::clear();
538539
m_loaded_blocks.clear();
539540
}
540541

541-
virtual void emerge(VoxelArea a, s32 caller_id=-1);
542-
543-
void blitBack(std::map<v3s16, MapBlock*> & modified_blocks);
544-
545-
protected:
546-
Map *m_map;
547-
/*
548-
key = blockpos
549-
value = flags describing the block
550-
*/
551-
std::map<v3s16, u8> m_loaded_blocks;
552-
};
553-
554-
class ManualMapVoxelManipulator : public MapVoxelManipulator
555-
{
556-
public:
557-
ManualMapVoxelManipulator(Map *map);
558-
virtual ~ManualMapVoxelManipulator();
559-
560542
void setMap(Map *map)
561543
{m_map = map;}
562544

563-
virtual void emerge(VoxelArea a, s32 caller_id=-1);
564-
565545
void initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
566546
bool load_if_inexistent = true);
567547

@@ -570,6 +550,12 @@ class ManualMapVoxelManipulator : public MapVoxelManipulator
570550

571551
protected:
572552
bool m_create_area;
553+
Map *m_map;
554+
/*
555+
key = blockpos
556+
value = flags describing the block
557+
*/
558+
std::map<v3s16, u8> m_loaded_blocks;
573559
};
574560

575561
#endif

0 commit comments

Comments
 (0)