font_shadow_alpha);
if (font) {
- font->grab();
m_font_cache[mode][basesize] = font;
return;
}
}
}
- if (font) {
- font->grab();
+ if (font)
m_font_cache[mode][basesize] = font;
- }
}
true, Environment, this, spec.fid, rect, is_editable, is_multiline);
e->drop();
} else {
- if (is_multiline)
+ if (is_multiline) {
e = new GUIEditBoxWithScrollBar(spec.fdefault.c_str(), true,
Environment, this, spec.fid, rect, is_editable, true);
- else if (is_editable)
+ e->drop();
+ } else if (is_editable) {
e = Environment->addEditBox(spec.fdefault.c_str(), rect, true,
this, spec.fid);
+ }
}
if (e) {
m_event_receivers.erase(event_receiver);
}
-void Map::dispatchEvent(MapEditEvent *event)
+void Map::dispatchEvent(const MapEditEvent &event)
{
for (MapEventReceiver *event_receiver : m_event_receivers) {
event_receiver->onMapEditEvent(event);
succeeded = false;
}
- dispatchEvent(&event);
+ dispatchEvent(event);
return succeeded;
}
succeeded = false;
}
- dispatchEvent(&event);
+ dispatchEvent(event);
return succeeded;
}
for (it = modified_blocks.begin();
it != modified_blocks.end(); ++it)
event.modified_blocks.insert(it->first);
- dispatchEvent(&event);
+ dispatchEvent(event);
}
}
return block;
MapEditEvent() = default;
- MapEditEvent * clone()
- {
- MapEditEvent *event = new MapEditEvent();
- event->type = type;
- event->p = p;
- event->n = n;
- event->modified_blocks = modified_blocks;
- event->is_private_change = is_private_change;
- return event;
- }
-
- VoxelArea getArea()
+ VoxelArea getArea() const
{
switch(type){
case MEET_ADDNODE:
{
public:
// event shall be deleted by caller after the call.
- virtual void onMapEditEvent(MapEditEvent *event) = 0;
+ virtual void onMapEditEvent(const MapEditEvent &event) = 0;
};
class Map /*: public NodeContainer*/
void addEventReceiver(MapEventReceiver *event_receiver);
void removeEventReceiver(MapEventReceiver *event_receiver);
// event shall be deleted by caller after the call.
- void dispatchEvent(MapEditEvent *event);
+ void dispatchEvent(const MapEditEvent &event);
// On failure returns NULL
MapSector * getSectorNoGenerateNoLock(v2s16 p2d);
for (it = modified_blocks.begin(); it != modified_blocks.end(); ++it)
event.modified_blocks.insert(it->first);
- map->dispatchEvent(&event);
+ map->dispatchEvent(event);
}
event.type = MEET_OTHER;
for (auto &modified_block : modified_blocks)
event.modified_blocks.insert(modified_block.first);
- map->dispatchEvent(&event);
+ map->dispatchEvent(event);
return SUCCESS;
}
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
event.p = p;
- map->dispatchEvent(&event);
+ map->dispatchEvent(event);
} catch (InvalidPositionException &e) {
infostream << "RollbackAction::applyRevert(): "
<< "InvalidPositionException: " << e.what()
for (auto &modified_block : modified_blocks)
event.modified_blocks.insert(modified_block.first);
- map.dispatchEvent(&event);
+ map.dispatchEvent(event);
}
lua_pushboolean(L, success);
}
}
- map.dispatchEvent(&event);
+ map.dispatchEvent(event);
lua_pushboolean(L, success);
return 1;
}
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
event.p = m_p;
event.is_private_change = name && meta && meta->isPrivate(*name);
- m_env->getMap().dispatchEvent(&event);
+ m_env->getMap().dispatchEvent(event);
}
// Exported functions
for (const auto &modified_block : o->modified_blocks)
event.modified_blocks.insert(modified_block.first);
- map->dispatchEvent(&event);
+ map->dispatchEvent(event);
o->modified_blocks.clear();
return 0;
for (auto &detached_inventory : m_detached_inventories) {
delete detached_inventory.second;
}
+
+ while (!m_unsent_map_edit_queue.empty()) {
+ delete m_unsent_map_edit_queue.front();
+ m_unsent_map_edit_queue.pop();
+ }
}
void Server::init()
m_time_of_day_send_timer = 0;
}
-void Server::onMapEditEvent(MapEditEvent *event)
+void Server::onMapEditEvent(const MapEditEvent &event)
{
- if (m_ignore_map_edit_events_area.contains(event->getArea()))
+ if (m_ignore_map_edit_events_area.contains(event.getArea()))
return;
- MapEditEvent *e = event->clone();
- m_unsent_map_edit_queue.push(e);
+
+ m_unsent_map_edit_queue.push(new MapEditEvent(event));
}
Inventory* Server::getInventory(const InventoryLocation &loc)
MapEditEvent event;
event.type = MEET_BLOCK_NODE_METADATA_CHANGED;
event.p = loc.p;
- m_env->getMap().dispatchEvent(&event);
+ m_env->getMap().dispatchEvent(event);
}
break;
case InventoryLocation::DETACHED:
This is accessed by the map, which is inside the environment,
so it shouldn't be a problem.
*/
- void onMapEditEvent(MapEditEvent *event);
+ void onMapEditEvent(const MapEditEvent &event);
/*
Shall be called with the environment and the connection locked.