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

Method loadFromLine

source/entities/Tile.cpp:1093–1156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1091}
1092
1093void Tile::loadFromLine(const std::string& line, Tile *t)
1094{
1095 std::vector<std::string> elems = Helper::split(line, '\t');
1096
1097 int xLocation = Helper::toInt(elems[0]);
1098 int yLocation = Helper::toInt(elems[1]);
1099
1100 std::stringstream tileName("");
1101 tileName << TILE_PREFIX;
1102 tileName << xLocation;
1103 tileName << "_";
1104 tileName << yLocation;
1105
1106 t->setName(tileName.str());
1107 t->mX = xLocation;
1108 t->mY = yLocation;
1109 t->mPosition = Ogre::Vector3(static_cast<Ogre::Real>(t->mX), static_cast<Ogre::Real>(t->mY), 0.0f);
1110
1111 TileType tileType = static_cast<TileType>(Helper::toInt(elems[2]));
1112 t->setType(tileType);
1113
1114 // If the tile type is lava or water, we ignore fullness
1115 double fullness;
1116 switch(tileType)
1117 {
1118 case TileType::water:
1119 case TileType::lava:
1120 fullness = 0.0;
1121 break;
1122
1123 default:
1124 fullness = Helper::toDouble(elems[3]);
1125 break;
1126 }
1127 t->setFullnessValue(fullness);
1128
1129 bool shouldSetSeat = false;
1130 // We allow to set seat if the tile is dirt (full or not) or if it is gold (ground only)
1131 if(elems.size() >= 5)
1132 {
1133 if(tileType == TileType::dirt)
1134 {
1135 shouldSetSeat = true;
1136 }
1137 else if((tileType == TileType::gold) &&
1138 (fullness == 0.0))
1139 {
1140 shouldSetSeat = true;
1141 }
1142 }
1143
1144 if(!shouldSetSeat)
1145 {
1146 t->setSeat(nullptr);
1147 return;
1148 }
1149
1150 int seatId = Helper::toInt(elems[4]);

Callers

nothing calls this directly

Calls 10

splitFunction · 0.85
toIntFunction · 0.85
Vector3Class · 0.85
toDoubleFunction · 0.85
setNameMethod · 0.80
setTypeMethod · 0.80
setFullnessValueMethod · 0.80
setSeatMethod · 0.80
getSeatByIdMethod · 0.80
getGameMapMethod · 0.45

Tested by

no test coverage detected