MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / restoreInitialEntityState

Method restoreInitialEntityState

source/rooms/Room.cpp:574–609  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574void Room::restoreInitialEntityState()
575{
576 // We restore the vision if we need to
577 std::map<Seat*, std::vector<Tile*>> tiles;
578 for(std::pair<Tile* const, TileData*>& p : mTileData)
579 {
580 if(p.second->mSeatsVision.empty())
581 continue;
582 for(Seat* seat : p.second->mSeatsVision)
583 {
584 seat->setVisibleBuildingOnTile(this, p.first);
585 tiles[seat].push_back(p.first);
586 }
587 }
588
589 // We notify the clients
590 for(std::pair<Seat* const, std::vector<Tile*>>& p : tiles)
591 {
592 if(p.first->getPlayer() == nullptr)
593 continue;
594 if(!p.first->getPlayer()->getIsHuman())
595 continue;
596
597 ServerNotification *serverNotification = new ServerNotification(
598 ServerNotificationType::refreshTiles, p.first->getPlayer());
599 std::vector<Tile*>& tilesRefresh = p.second;
600 uint32_t nbTiles = tilesRefresh.size();
601 serverNotification->mPacket << nbTiles;
602 for(Tile* tile : tilesRefresh)
603 {
604 getGameMap()->tileToPacket(serverNotification->mPacket, tile);
605 tile->exportToPacketForUpdate(serverNotification->mPacket, p.first);
606 }
607 ODServer::getSingleton().queueServerNotification(serverNotification);
608 }
609}
610
611bool Room::canBeRepaired() const
612{

Callers

nothing calls this directly

Calls 6

getIsHumanMethod · 0.80
tileToPacketMethod · 0.80
getPlayerMethod · 0.45

Tested by

no test coverage detected