| 232 | } |
| 233 | |
| 234 | bool RoomFactory::buildRoomDefaultEditor(GameMap* gameMap, Room* room, ODPacket& packet) const |
| 235 | { |
| 236 | int32_t seatId; |
| 237 | OD_ASSERT_TRUE(packet >> seatId); |
| 238 | Seat* seatRoom = gameMap->getSeatById(seatId); |
| 239 | if(seatRoom == nullptr) |
| 240 | { |
| 241 | OD_LOG_ERR("seatId=" + Helper::toString(seatId)); |
| 242 | return false; |
| 243 | } |
| 244 | |
| 245 | std::vector<Tile*> tiles; |
| 246 | uint32_t nbTiles; |
| 247 | OD_ASSERT_TRUE(packet >> nbTiles); |
| 248 | |
| 249 | while(nbTiles > 0) |
| 250 | { |
| 251 | --nbTiles; |
| 252 | Tile* tile = gameMap->tileFromPacket(packet); |
| 253 | if(tile == nullptr) |
| 254 | { |
| 255 | OD_LOG_ERR("unexpected null tile room=" + room->getName()); |
| 256 | return false; |
| 257 | } |
| 258 | |
| 259 | // If the tile is not buildable, we change it |
| 260 | if(tile->getCoveringBuilding() != nullptr) |
| 261 | { |
| 262 | OD_LOG_ERR("tile=" + Tile::displayAsString(tile) + ", seatId=" + Helper::toString(seatId)); |
| 263 | continue; |
| 264 | } |
| 265 | |
| 266 | tiles.push_back(tile); |
| 267 | if((tile->getType() != TileType::gold) && |
| 268 | (tile->getType() != TileType::dirt)) |
| 269 | { |
| 270 | tile->setType(TileType::dirt); |
| 271 | } |
| 272 | tile->setFullness(0.0); |
| 273 | tile->claimTile(seatRoom); |
| 274 | tile->computeTileVisual(); |
| 275 | } |
| 276 | |
| 277 | |
| 278 | return buildRoomDefault(gameMap, room, seatRoom, tiles); |
| 279 | } |
| 280 | |
| 281 | void RoomManager::registerFactory(const RoomFactory* factory) |
| 282 | { |
nothing calls this directly
no test coverage detected