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

Method importTileDataFromStream

source/rooms/Room.cpp:520–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520bool Room::importTileDataFromStream(std::istream& is, Tile* tile, TileData* tileData)
521{
522 if(is.eof())
523 {
524 // Default initialization
525 tileData->mHP = DEFAULT_TILE_HP;
526 mCoveredTiles.push_back(tile);
527 tile->setCoveringBuilding(this);
528 return true;
529 }
530
531 // We read saved state
532 if(!(is >> tileData->mHP))
533 return false;
534
535 if(tileData->mHP > 0.0)
536 {
537 mCoveredTiles.push_back(tile);
538 tile->setCoveringBuilding(this);
539 }
540 else
541 {
542 mCoveredTilesDestroyed.push_back(tile);
543 }
544
545 GameMap* gameMap = getGameMap();
546 uint32_t nbSeatsVision;
547 if(!(is >> nbSeatsVision))
548 return false;
549 while(nbSeatsVision > 0)
550 {
551 --nbSeatsVision;
552 int seatId;
553 if(!(is >> seatId))
554 return false;
555
556 Seat* seat = gameMap->getSeatById(seatId);
557 if(seat == nullptr)
558 {
559 OD_LOG_ERR("room=" + getName() + ", seatId=" + Helper::toString(seatId));
560 continue;
561 }
562
563 if(seat->getPlayer() == nullptr)
564 continue;
565 if(!seat->getPlayer()->getIsHuman())
566 continue;
567
568 tileData->mSeatsVision.push_back(seat);
569 }
570
571 return true;
572}
573
574void Room::restoreInitialEntityState()
575{

Callers

nothing calls this directly

Calls 5

setCoveringBuildingMethod · 0.80
getSeatByIdMethod · 0.80
getIsHumanMethod · 0.80
toStringFunction · 0.50
getPlayerMethod · 0.45

Tested by

no test coverage detected