From bdf2f03c4f3cd605b5b1eb5b8e0306415ff95b36 Mon Sep 17 00:00:00 2001 From: David Cernat Date: Thu, 12 Jul 2018 05:06:31 +0300 Subject: [PATCH] [General] Remove unnecessary MapChanges struct from BaseWorldstate --- apps/openmw-mp/Script/Functions/Worldstate.cpp | 14 +++++++------- apps/openmw/mwmp/Worldstate.cpp | 6 +++--- components/openmw-mp/Base/BaseWorldstate.hpp | 7 +------ .../Packets/Worldstate/PacketWorldMap.cpp | 8 ++++---- 4 files changed, 15 insertions(+), 20 deletions(-) diff --git a/apps/openmw-mp/Script/Functions/Worldstate.cpp b/apps/openmw-mp/Script/Functions/Worldstate.cpp index 1a2582c09..8ad64a9c5 100644 --- a/apps/openmw-mp/Script/Functions/Worldstate.cpp +++ b/apps/openmw-mp/Script/Functions/Worldstate.cpp @@ -26,22 +26,22 @@ void WorldstateFunctions::CopyLastWorldstateToStore() noexcept void WorldstateFunctions::ClearMapChanges() noexcept { - writeWorldstate.mapChanges.mapTiles.clear(); + writeWorldstate.mapTiles.clear(); } unsigned int WorldstateFunctions::GetMapChangesSize() noexcept { - return readWorldstate->mapChanges.mapTiles.size(); + return readWorldstate->mapTiles.size(); } 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 { - return readWorldstate->mapChanges.mapTiles.at(index).y; + return readWorldstate->mapTiles.at(index).y; } void WorldstateFunctions::SetHour(double hour) noexcept @@ -106,10 +106,10 @@ void WorldstateFunctions::ClearEnforcedCollisionRefIds() noexcept void WorldstateFunctions::SaveMapTileImageFile(unsigned int index, const char *filePath) noexcept { - if (index >= readWorldstate->mapChanges.mapTiles.size()) + if (index >= readWorldstate->mapTiles.size()) return; - const std::vector& imageData = readWorldstate->mapChanges.mapTiles.at(index).imageData; + const std::vector& imageData = readWorldstate->mapTiles.at(index).imageData; std::ofstream outputFile(filePath, std::ios::binary); std::ostream_iterator outputIterator(outputFile); @@ -133,7 +133,7 @@ void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char* } else { - writeWorldstate.mapChanges.mapTiles.push_back(mapTile); + writeWorldstate.mapTiles.push_back(mapTile); } } diff --git a/apps/openmw/mwmp/Worldstate.cpp b/apps/openmw/mwmp/Worldstate.cpp index 1995f2b39..db9ff265e 100644 --- a/apps/openmw/mwmp/Worldstate.cpp +++ b/apps/openmw/mwmp/Worldstate.cpp @@ -52,7 +52,7 @@ void Worldstate::markExploredMapTile(int cellX, int cellY) void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector& imageData) { - mapChanges.mapTiles.clear(); + mapTiles.clear(); mwmp::MapTile mapTile; mapTile.x = cellX; @@ -61,7 +61,7 @@ void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector& 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)->Send(); @@ -69,7 +69,7 @@ void Worldstate::sendMapExplored(int cellX, int cellY, const std::vector& 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); diff --git a/components/openmw-mp/Base/BaseWorldstate.hpp b/components/openmw-mp/Base/BaseWorldstate.hpp index 863dd7abc..96506b33d 100644 --- a/components/openmw-mp/Base/BaseWorldstate.hpp +++ b/components/openmw-mp/Base/BaseWorldstate.hpp @@ -18,11 +18,6 @@ namespace mwmp std::vector imageData; }; - struct MapChanges - { - std::vector mapTiles; - }; - class BaseWorldstate { public: @@ -54,7 +49,7 @@ namespace mwmp std::vector enforcedCollisionRefIds; - MapChanges mapChanges; + std::vector mapTiles; bool isValid; }; diff --git a/components/openmw-mp/Packets/Worldstate/PacketWorldMap.cpp b/components/openmw-mp/Packets/Worldstate/PacketWorldMap.cpp index 43b72bb64..266f02546 100644 --- a/components/openmw-mp/Packets/Worldstate/PacketWorldMap.cpp +++ b/components/openmw-mp/Packets/Worldstate/PacketWorldMap.cpp @@ -17,17 +17,17 @@ void PacketWorldMap::Packet(RakNet::BitStream *bs, bool send) uint32_t changesCount; if (send) - changesCount = static_cast(worldstate->mapChanges.mapTiles.size()); + changesCount = static_cast(worldstate->mapTiles.size()); RW(changesCount, send); if (!send) { - worldstate->mapChanges.mapTiles.clear(); - worldstate->mapChanges.mapTiles.resize(changesCount); + worldstate->mapTiles.clear(); + worldstate->mapTiles.resize(changesCount); } - for (auto &&mapTile : worldstate->mapChanges.mapTiles) + for (auto &&mapTile : worldstate->mapTiles) { RW(mapTile.x, send); RW(mapTile.y, send);