| 177 | } |
| 178 | |
| 179 | bool RoomFactory::buildRoomDefault(GameMap* gameMap, Room* room, Seat* seat, const std::vector<Tile*>& tiles) const |
| 180 | { |
| 181 | if(tiles.empty()) |
| 182 | return false; |
| 183 | |
| 184 | room->setupRoom(gameMap->nextUniqueNameRoom(room->getType()), seat, tiles); |
| 185 | room->addToGameMap(); |
| 186 | room->createMesh(); |
| 187 | |
| 188 | if((seat->getPlayer() != nullptr) && |
| 189 | (seat->getPlayer()->getIsHuman())) |
| 190 | { |
| 191 | // We notify the clients with vision of the changed tiles. Note that we need |
| 192 | // to calculate per seat since they could have vision on different parts of the building |
| 193 | std::map<Seat*,std::vector<Tile*>> tilesPerSeat; |
| 194 | const std::vector<Seat*>& seats = gameMap->getSeats(); |
| 195 | for(Seat* tmpSeat : seats) |
| 196 | { |
| 197 | if(tmpSeat->getPlayer() == nullptr) |
| 198 | continue; |
| 199 | if(!tmpSeat->getPlayer()->getIsHuman()) |
| 200 | continue; |
| 201 | |
| 202 | for(Tile* tile : tiles) |
| 203 | { |
| 204 | if(!tmpSeat->hasVisionOnTile(tile)) |
| 205 | continue; |
| 206 | |
| 207 | tile->changeNotifiedForSeat(tmpSeat); |
| 208 | tilesPerSeat[tmpSeat].push_back(tile); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | for(const std::pair<Seat* const,std::vector<Tile*>>& p : tilesPerSeat) |
| 213 | { |
| 214 | uint32_t nbTiles = p.second.size(); |
| 215 | ServerNotification serverNotification( |
| 216 | ServerNotificationType::refreshTiles, p.first->getPlayer()); |
| 217 | serverNotification.mPacket << nbTiles; |
| 218 | for(Tile* tile : p.second) |
| 219 | { |
| 220 | gameMap->tileToPacket(serverNotification.mPacket, tile); |
| 221 | p.first->updateTileStateForSeat(tile, false); |
| 222 | tile->exportToPacketForUpdate(serverNotification.mPacket, p.first); |
| 223 | } |
| 224 | ODServer::getSingleton().sendAsyncMsg(serverNotification); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | room->checkForRoomAbsorbtion(); |
| 229 | room->updateActiveSpots(); |
| 230 | |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool RoomFactory::buildRoomDefaultEditor(GameMap* gameMap, Room* room, ODPacket& packet) const |
| 235 | { |
nothing calls this directly
no test coverage detected