[General] Remove unnecessary MapChanges struct from BaseWorldstate

remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent 59a56ca35e
commit bdf2f03c4f

@ -26,22 +26,22 @@ void WorldstateFunctions::CopyLastWorldstateToStore() noexcept
void WorldstateFunctions::ClearMapChanges() noexcept void WorldstateFunctions::ClearMapChanges() noexcept
{ {
writeWorldstate.mapChanges.mapTiles.clear(); writeWorldstate.mapTiles.clear();
} }
unsigned int WorldstateFunctions::GetMapChangesSize() noexcept unsigned int WorldstateFunctions::GetMapChangesSize() noexcept
{ {
return readWorldstate->mapChanges.mapTiles.size(); return readWorldstate->mapTiles.size();
} }
int WorldstateFunctions::GetMapTileCellX(unsigned int index) noexcept int WorldstateFunctions::GetMapTileCellX(unsigned int index) noexcept
{ {
return readWorldstate->mapChanges.mapTiles.at(index).x; return readWorldstate->mapTiles.at(index).x;
} }
int WorldstateFunctions::GetMapTileCellY(unsigned int index) noexcept int WorldstateFunctions::GetMapTileCellY(unsigned int index) noexcept
{ {
return readWorldstate->mapChanges.mapTiles.at(index).y; return readWorldstate->mapTiles.at(index).y;
} }
void WorldstateFunctions::SetHour(double hour) noexcept void WorldstateFunctions::SetHour(double hour) noexcept
@ -106,10 +106,10 @@ void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept
void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept
{ {
if (index >= readWorldstate->mapChanges.mapTiles.size()) if (index >= readWorldstate->mapTiles.size())
return; return;
const std::vector<char>& imageData = readWorldstate->mapChanges.mapTiles.at(index).imageData; const std::vector<char>& imageData = readWorldstate->mapTiles.at(index).imageData;
std::ofstream outputFile(filePath, std::ios::binary); std::ofstream outputFile(filePath, std::ios::binary);
std::ostream_iterator<char> outputIterator(outputFile); std::ostream_iterator<char> outputIterator(outputFile);
@ -133,7 +133,7 @@ void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char*
} }
else else
{ {
writeWorldstate.mapChanges.mapTiles.push_back(mapTile); writeWorldstate.mapTiles.push_back(mapTile);
} }
} }

@ -52,7 +52,7 @@ void Worldstate::markExploredMapTile(int cellX, int cellY)
void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector<char>& imageData) void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector<char>& imageData)
{ {
mapChanges.mapTiles.clear(); mapTiles.clear();
mwmp::MapTile mapTile; mwmp::MapTile mapTile;
mapTile.x = cellX; mapTile.x = cellX;
@ -61,7 +61,7 @@ void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector<char>&
LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Sending ID_PLAYER_MAP with x: %i, y: %i", cellX, cellY); LOG_MESSAGE_SIMPLE(Log::LOG_ERROR, "Sending ID_PLAYER_MAP with x: %i, y: %i", cellX, cellY);
mapChanges.mapTiles.push_back(mapTile); mapTiles.push_back(mapTile);
getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->setWorldstate(this); getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->setWorldstate(this);
getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->Send(); getNetworking()->getWorldstatePacket(ID_WORLD_MAP)->Send();
@ -69,7 +69,7 @@ void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector<char>&
void Worldstate::setMapExplored() void Worldstate::setMapExplored()
{ {
for (const auto &mapTile : mapChanges.mapTiles) for (const auto &mapTile : mapTiles)
{ {
const MWWorld::CellStore *cellStore = MWBase::Environment::get().getWorld()->getExterior(mapTile.x, mapTile.y); const MWWorld::CellStore *cellStore = MWBase::Environment::get().getWorld()->getExterior(mapTile.x, mapTile.y);

@ -18,11 +18,6 @@ namespace mwmp
std::vector<char> imageData; std::vector<char> imageData;
}; };
struct MapChanges
{
std::vector<MapTile> mapTiles;
};
class BaseWorldstate class BaseWorldstate
{ {
public: public:
@ -54,7 +49,7 @@ namespace mwmp
std::vector<std::string> enforcedCollisionRefIds; std::vector<std::string> enforcedCollisionRefIds;
MapChanges mapChanges; std::vector<MapTile> mapTiles;
bool isValid; bool isValid;
}; };

@ -17,17 +17,17 @@ void PacketWorldMap::Packet(RakNet::BitStream *bs, bool send)
uint32_t changesCount; uint32_t changesCount;
if (send) if (send)
changesCount = static_cast<uint32_t>(worldstate->mapChanges.mapTiles.size()); changesCount = static_cast<uint32_t>(worldstate->mapTiles.size());
RW(changesCount, send); RW(changesCount, send);
if (!send) if (!send)
{ {
worldstate->mapChanges.mapTiles.clear(); worldstate->mapTiles.clear();
worldstate->mapChanges.mapTiles.resize(changesCount); worldstate->mapTiles.resize(changesCount);
} }
for (auto &&mapTile : worldstate->mapChanges.mapTiles) for (auto &&mapTile : worldstate->mapTiles)
{ {
RW(mapTile.x, send); RW(mapTile.x, send);
RW(mapTile.y, send); RW(mapTile.y, send);

Loading…
Cancel
Save