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

Method updateFromPacket

source/entities/Tile.cpp:1034–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1032}
1033
1034void Tile::updateFromPacket(ODPacket& is)
1035{
1036 GameEntity::updateFromPacket(is);
1037
1038 // This function should read parameters as sent by Tile::exportToPacketForUpdate
1039 int seatId;
1040 std::string meshName;
1041 std::stringstream ss;
1042
1043 // We set the seat if there is one
1044 OD_ASSERT_TRUE(is >> mIsRoom);
1045 OD_ASSERT_TRUE(is >> mIsTrap);
1046 OD_ASSERT_TRUE(is >> mRefundPriceRoom);
1047 OD_ASSERT_TRUE(is >> mRefundPriceTrap);
1048
1049 OD_ASSERT_TRUE(is >> mDisplayTileMesh);
1050 OD_ASSERT_TRUE(is >> mColorCustomMesh);
1051 OD_ASSERT_TRUE(is >> mHasBridge);
1052
1053 OD_ASSERT_TRUE(is >> seatId);
1054
1055 OD_ASSERT_TRUE(is >> meshName);
1056 setMeshName(meshName);
1057
1058 ss.str(std::string());
1059 ss << TILE_PREFIX;
1060 ss << getX();
1061 ss << "_";
1062 ss << getY();
1063
1064 setName(ss.str());
1065
1066 OD_ASSERT_TRUE(is >> mTileVisual);
1067
1068 if(seatId == -1)
1069 {
1070 setSeat(nullptr);
1071 }
1072 else
1073 {
1074 Seat* seat = getGameMap()->getSeatById(seatId);
1075 if(seat != nullptr)
1076 setSeat(seat);
1077
1078 }
1079
1080 // We need to check if the tile is unmarked after reading the needed information.
1081 if(getMarkedForDigging(getGameMap()->getLocalPlayer()) &&
1082 !isDiggable(getGameMap()->getLocalPlayer()->getSeat()))
1083 {
1084 removePlayerMarkingTile(getGameMap()->getLocalPlayer());
1085 }
1086
1087 // TODO: It would be nice to check if a noticeable value changed
1088 // before firing the event as it would avoid to update the minimap for
1089 // unchanged tiles
1090 fireTileStateChanged();
1091}

Callers 1

processMessageMethod · 0.45

Calls 3

getSeatByIdMethod · 0.80
getLocalPlayerMethod · 0.80
getSeatMethod · 0.45

Tested by

no test coverage detected