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

Method buildRoomDefaultEditor

source/rooms/RoomManager.cpp:234–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

232}
233
234bool 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
281void RoomManager::registerFactory(const RoomFactory* factory)
282{

Callers

nothing calls this directly

Calls 9

getSeatByIdMethod · 0.80
tileFromPacketMethod · 0.80
getCoveringBuildingMethod · 0.80
setTypeMethod · 0.80
setFullnessMethod · 0.80
claimTileMethod · 0.80
computeTileVisualMethod · 0.80
toStringFunction · 0.50
getTypeMethod · 0.45

Tested by

no test coverage detected