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