void Update::exec(uint id) { Room * room = roomIndex()[id]; if (room) { factory()->update(room, &props); RoomCollection * newHome = treeRoot().insertRoom(&props); vector<RoomCollection *> & homes = roomHomes(); RoomCollection * oldHome = homes[id]; if (oldHome) oldHome->erase(room); homes[id] = newHome; newHome->insert(room); } }
void MergeRelative::exec(uint id) { Room *source = roomIndex()[id]; if (!source) return; Map &roomMap = map(); vector<Room *> &rooms = roomIndex(); const Coordinate &c = source->getPosition(); Coordinate newPos = c + move; Room *target = roomMap.get(newPos); if (target) { factory()->update(target, source); ParseEvent *props = factory()->getEvent(target); uint oid = target->getId(); RoomCollection *newHome = treeRoot().insertRoom(props); vector<RoomCollection *> &homes = roomHomes(); RoomCollection *oldHome = homes[oid]; if (oldHome) oldHome->erase(target); homes[oid] = newHome; if (newHome) newHome->insert(target); const ExitsList &exits = source->getExitsList(); for (int dir = 0; dir < exits.size(); ++dir) { const Exit &e = exits[dir]; for (set<uint>::const_iterator i = e.inBegin(); i != e.inEnd(); ++i) { uint oeid = *i; Room *oe = rooms[oeid]; if (oe) { oe->exit(Mmapper2Exit::opposite(dir)).addOut(oid); target->exit(dir).addIn(oeid); } } for (set<uint>::const_iterator i = e.outBegin(); i != e.outEnd(); ++i) { uint oeid = *i; Room *oe = rooms[oeid]; if (oe) { oe->exit(Mmapper2Exit::opposite(dir)).addIn(oid); target->exit(dir).addOut(oeid); } } } Remove::exec(source->getId()); } else { Coordinate newPos = c + move; roomMap.setNearest(newPos, source); } }