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

Method exportTileToPacket

source/game/Seat.cpp:1633–1732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1631}
1632
1633void Seat::exportTileToPacket(ODPacket& os, const Tile* tile,
1634 bool hideSeatId) const
1635{
1636 if(getPlayer() == nullptr)
1637 {
1638 OD_LOG_ERR("SeatId=" + Helper::toString(getId()));
1639 return;
1640 }
1641 if(!getPlayer()->getIsHuman())
1642 {
1643 OD_LOG_ERR("SeatId=" + Helper::toString(getId()));
1644 return;
1645 }
1646
1647 if(tile->getX() >= static_cast<int>(mTilesStates.size()))
1648 {
1649 OD_LOG_ERR("Tile=" + Tile::displayAsString(tile));
1650 return;
1651 }
1652 if(tile->getY() >= static_cast<int>(mTilesStates[tile->getX()].size()))
1653 {
1654 OD_LOG_ERR("Tile=" + Tile::displayAsString(tile));
1655 return;
1656 }
1657
1658 const TileStateNotified& tileState = mTilesStates[tile->getX()][tile->getY()];
1659
1660 int tileSeatId = -1;
1661 // We only pass the tile seat to the client if the tile is fully claimed
1662 if(!hideSeatId)
1663 {
1664 switch(tileState.mTileVisual)
1665 {
1666 case TileVisual::claimedGround:
1667 case TileVisual::claimedFull:
1668 tileSeatId = tileState.mSeatIdOwner;
1669 break;
1670 case TileVisual::waterGround:
1671 case TileVisual::lavaGround:
1672 if(tileState.mBuilding != nullptr)
1673 tileSeatId = tileState.mSeatIdOwner;
1674 break;
1675 default:
1676 break;
1677 }
1678 }
1679
1680 std::string meshName;
1681
1682 if((tileState.mBuilding != nullptr) &&
1683 !tileState.mBuilding->getMeshName().empty())
1684 {
1685 meshName = tileState.mBuilding->getMeshName() + ".mesh";
1686 }
1687 else
1688 {
1689 // We set an empty mesh so that the client can compute the tile itself
1690 meshName.clear();

Callers 1

Calls 11

getIsHumanMethod · 0.80
clearMethod · 0.80
toStringFunction · 0.70
getXMethod · 0.45
getYMethod · 0.45
displayTileMeshMethod · 0.45
colorCustomMeshMethod · 0.45
getObjectTypeMethod · 0.45
getSeatMethod · 0.45
getTypeMethod · 0.45
isBridgeMethod · 0.45

Tested by

no test coverage detected