forked from Mirrorlandia_minetest/minetest
Make MapEditEvent more complete
SetBlocksNotSent is no longer used.
This commit is contained in:
parent
62ee02b8ba
commit
7701e70dc9
@ -722,8 +722,15 @@ void *EmergeThread::run()
|
||||
if (block)
|
||||
modified_blocks[pos] = block;
|
||||
|
||||
if (!modified_blocks.empty())
|
||||
m_server->SetBlocksNotSent(modified_blocks);
|
||||
if (!modified_blocks.empty()) {
|
||||
MapEditEvent event;
|
||||
event.type = MEET_OTHER;
|
||||
for (const auto &pair : modified_blocks) {
|
||||
event.modified_blocks.insert(pair.first);
|
||||
}
|
||||
MutexAutoLock envlock(m_server->m_env_mutex);
|
||||
m_map->dispatchEvent(event);
|
||||
}
|
||||
modified_blocks.clear();
|
||||
}
|
||||
} catch (VersionMismatchException &e) {
|
||||
|
16
src/map.h
16
src/map.h
@ -79,21 +79,21 @@ struct MapEditEvent
|
||||
|
||||
MapEditEvent() = default;
|
||||
|
||||
// Sets the event's position and marks the block as modified.
|
||||
void setPositionModified(v3s16 pos)
|
||||
{
|
||||
p = pos;
|
||||
modified_blocks.insert(getNodeBlockPos(pos));
|
||||
}
|
||||
|
||||
VoxelArea getArea() const
|
||||
{
|
||||
switch(type){
|
||||
case MEET_ADDNODE:
|
||||
return VoxelArea(p);
|
||||
case MEET_REMOVENODE:
|
||||
return VoxelArea(p);
|
||||
case MEET_SWAPNODE:
|
||||
return VoxelArea(p);
|
||||
case MEET_BLOCK_NODE_METADATA_CHANGED:
|
||||
{
|
||||
v3s16 np1 = p*MAP_BLOCKSIZE;
|
||||
v3s16 np2 = np1 + v3s16(1,1,1)*MAP_BLOCKSIZE - v3s16(1,1,1);
|
||||
return VoxelArea(np1, np2);
|
||||
}
|
||||
return VoxelArea(p);
|
||||
case MEET_OTHER:
|
||||
{
|
||||
VoxelArea a;
|
||||
|
@ -175,7 +175,7 @@ bool RollbackAction::applyRevert(Map *map, InventoryManager *imgr, IGameDef *gam
|
||||
// Inform other things that the meta data has changed
|
||||
MapEditEvent event;
|
||||
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
|
||||
event.p = p;
|
||||
event.setPositionModified(p);
|
||||
map->dispatchEvent(event);
|
||||
} catch (InvalidPositionException &e) {
|
||||
infostream << "RollbackAction::applyRevert(): "
|
||||
|
@ -66,7 +66,7 @@ void NodeMetaRef::reportMetadataChange(const std::string *name)
|
||||
|
||||
MapEditEvent event;
|
||||
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
|
||||
event.p = m_p;
|
||||
event.setPositionModified(m_p);
|
||||
event.is_private_change = name && meta && meta->isPrivate(*name);
|
||||
m_env->getMap().dispatchEvent(event);
|
||||
}
|
||||
|
@ -696,11 +696,13 @@ void Server::AsyncRunStep(bool initial_step)
|
||||
std::map<v3s16, MapBlock*> modified_blocks;
|
||||
m_env->getServerMap().transformLiquids(modified_blocks, m_env);
|
||||
|
||||
/*
|
||||
Set the modified blocks unsent for all the clients
|
||||
*/
|
||||
if (!modified_blocks.empty()) {
|
||||
SetBlocksNotSent(modified_blocks);
|
||||
MapEditEvent event;
|
||||
event.type = MEET_OTHER;
|
||||
for (const auto &pair : modified_blocks) {
|
||||
event.modified_blocks.insert(pair.first);
|
||||
}
|
||||
m_env->getMap().dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
m_clients.step(dtime);
|
||||
@ -1253,17 +1255,6 @@ void Server::onMapEditEvent(const MapEditEvent &event)
|
||||
m_unsent_map_edit_queue.push(new MapEditEvent(event));
|
||||
}
|
||||
|
||||
void Server::SetBlocksNotSent(std::map<v3s16, MapBlock *>& block)
|
||||
{
|
||||
std::vector<session_t> clients = m_clients.getClientIDs();
|
||||
ClientInterface::AutoLock clientlock(m_clients);
|
||||
// Set the modified blocks unsent for all the clients
|
||||
for (const session_t client_id : clients) {
|
||||
if (RemoteClient *client = m_clients.lockedGetClientNoEx(client_id))
|
||||
client->SetBlocksNotSent(block);
|
||||
}
|
||||
}
|
||||
|
||||
void Server::peerAdded(con::Peer *peer)
|
||||
{
|
||||
verbosestream<<"Server::peerAdded(): peer->id="
|
||||
|
@ -439,9 +439,6 @@ private:
|
||||
void SendNodeDef(session_t peer_id, const NodeDefManager *nodedef,
|
||||
u16 protocol_version);
|
||||
|
||||
/* mark blocks not sent for all clients */
|
||||
void SetBlocksNotSent(std::map<v3s16, MapBlock *>& block);
|
||||
|
||||
|
||||
virtual void SendChatMessage(session_t peer_id, const ChatMessage &message);
|
||||
void SendTimeOfDay(session_t peer_id, u16 time, f32 time_speed);
|
||||
|
@ -95,7 +95,7 @@ void ServerInventoryManager::setInventoryModified(const InventoryLocation &loc)
|
||||
case InventoryLocation::NODEMETA: {
|
||||
MapEditEvent event;
|
||||
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
|
||||
event.p = loc.p;
|
||||
event.setPositionModified(loc.p);
|
||||
m_env->getMap().dispatchEvent(event);
|
||||
} break;
|
||||
case InventoryLocation::DETACHED: {
|
||||
|
Loading…
Reference in New Issue
Block a user