forked from teamnwah/openmw-tes3coop
[General] Implement sending of image data for map tiles in PlayerMap
This commit is contained in:
parent
980ddcb114
commit
715012f087
14 changed files with 318 additions and 35 deletions
|
@ -17,7 +17,7 @@ void CellFunctions::InitializeMapChanges(unsigned short pid) noexcept
|
|||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
player->mapChanges.cellsExplored.clear();
|
||||
player->mapChanges.mapTiles.clear();
|
||||
}
|
||||
|
||||
unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
||||
|
@ -28,6 +28,14 @@ unsigned int CellFunctions::GetCellStateChangesSize(unsigned short pid) noexcept
|
|||
return player->cellStateChanges.count;
|
||||
}
|
||||
|
||||
unsigned int CellFunctions::GetMapChangesSize(unsigned short pid) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
|
||||
return player->mapChanges.mapTiles.size();
|
||||
}
|
||||
|
||||
unsigned int CellFunctions::GetCellStateType(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -95,6 +103,35 @@ bool CellFunctions::IsChangingRegion(unsigned short pid) noexcept
|
|||
return player->isChangingRegion;
|
||||
}
|
||||
|
||||
void CellFunctions::SaveMapTileImageFile(unsigned short pid, unsigned int i, const char *filePath) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player,);
|
||||
|
||||
if (i >= player->mapChanges.mapTiles.size())
|
||||
return;
|
||||
|
||||
const std::vector<char>& imageData = player->mapChanges.mapTiles.at(i).imageData;
|
||||
|
||||
std::ofstream output_file(filePath, std::ios::binary);
|
||||
std::ostream_iterator<char> output_iterator(output_file);
|
||||
std::copy(imageData.begin(), imageData.end(), output_iterator);
|
||||
}
|
||||
|
||||
int CellFunctions::GetMapTileCellX(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
return player->mapChanges.mapTiles.at(i).x;
|
||||
}
|
||||
|
||||
int CellFunctions::GetMapTileCellY(unsigned short pid, unsigned int i) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, 0);
|
||||
return player->mapChanges.mapTiles.at(i).y;
|
||||
}
|
||||
|
||||
void CellFunctions::SetCell(unsigned short pid, const char *cellDescription) noexcept
|
||||
{
|
||||
Player *player;
|
||||
|
@ -123,13 +160,19 @@ void CellFunctions::SetExteriorCell(unsigned short pid, int x, int y) noexcept
|
|||
player->cell.mData.mY = y;
|
||||
}
|
||||
|
||||
void CellFunctions::AddCellExplored(unsigned short pid, const char* cellDescription) noexcept
|
||||
void CellFunctions::LoadMapTileImageFile(unsigned short pid, int cellX, int cellY, const char* filePath) noexcept
|
||||
{
|
||||
Player *player;
|
||||
GET_PLAYER(pid, player, );
|
||||
|
||||
ESM::Cell cellExplored = Utils::getCellFromDescription(cellDescription);
|
||||
player->mapChanges.cellsExplored.push_back(cellExplored);
|
||||
mwmp::MapTile mapTile;
|
||||
mapTile.x = cellX;
|
||||
mapTile.y = cellY;
|
||||
|
||||
std::ifstream fin(filePath, std::ios::binary);
|
||||
mapTile.imageData = std::vector<char>(std::istreambuf_iterator<char>(fin), std::istreambuf_iterator<char>());
|
||||
|
||||
player->mapChanges.mapTiles.push_back(mapTile);
|
||||
}
|
||||
|
||||
void CellFunctions::SendCell(unsigned short pid) noexcept
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
{"InitializeMapChanges", CellFunctions::InitializeMapChanges},\
|
||||
\
|
||||
{"GetCellStateChangesSize", CellFunctions::GetCellStateChangesSize},\
|
||||
{"GetMapChangesSize", CellFunctions::GetMapChangesSize},\
|
||||
\
|
||||
{"GetCellStateType", CellFunctions::GetCellStateType},\
|
||||
{"GetCellStateDescription", CellFunctions::GetCellStateDescription},\
|
||||
|
@ -19,10 +20,14 @@
|
|||
{"GetRegion", CellFunctions::GetRegion},\
|
||||
{"IsChangingRegion", CellFunctions::IsChangingRegion},\
|
||||
\
|
||||
{"GetMapTileCellX", CellFunctions::GetMapTileCellX},\
|
||||
{"GetMapTileCellY", CellFunctions::GetMapTileCellY},\
|
||||
{"SaveMapTileImageFile", CellFunctions::SaveMapTileImageFile},\
|
||||
\
|
||||
{"SetCell", CellFunctions::SetCell},\
|
||||
{"SetExteriorCell", CellFunctions::SetExteriorCell},\
|
||||
\
|
||||
{"AddCellExplored", CellFunctions::AddCellExplored},\
|
||||
{"LoadMapTileImageFile", CellFunctions::LoadMapTileImageFile},\
|
||||
\
|
||||
{"SendCell", CellFunctions::SendCell},\
|
||||
{"SendMapChanges", CellFunctions::SendMapChanges}
|
||||
|
@ -50,6 +55,14 @@ public:
|
|||
*/
|
||||
static unsigned int GetCellStateChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the number of indexes in a player's latest map changes.
|
||||
*
|
||||
* \param pid The player ID whose map changes should be used.
|
||||
* \return The number of indexes.
|
||||
*/
|
||||
static unsigned int GetMapChangesSize(unsigned short pid) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the cell state type at a certain index in a player's latest cell state changes.
|
||||
*
|
||||
|
@ -118,6 +131,37 @@ public:
|
|||
*/
|
||||
static bool IsChangingRegion(unsigned short pid) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the X coordinate of the cell corresponding to the map tile at a certain index in a
|
||||
* player's latest map changes.
|
||||
*
|
||||
* \param pid The player ID whose map changes should be used.
|
||||
* \param i The index of the map tile.
|
||||
* \return The X coordinate of the cell.
|
||||
*/
|
||||
static int GetMapTileCellX(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Get the Y coordinate of the cell corresponding to the map tile at a certain index in a
|
||||
* player's latest map changes.
|
||||
*
|
||||
* \param pid The player ID whose map changes should be used.
|
||||
* \param i The index of the map tile.
|
||||
* \return The Y coordinate of the cell.
|
||||
*/
|
||||
static int GetMapTileCellY(unsigned short pid, unsigned int i) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Save the .png image data of the map tile at a certain index in a player's latest map changes
|
||||
* to a file.
|
||||
*
|
||||
* \param pid The player ID whose map changes should be used.
|
||||
* \param i The index of the map tile.
|
||||
* \param filePath The file path of the resulting file.
|
||||
* \return void
|
||||
*/
|
||||
static void SaveMapTileImageFile(unsigned short pid, unsigned int i, const char *filePath) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Set the cell of a player.
|
||||
*
|
||||
|
@ -147,13 +191,16 @@ public:
|
|||
static void SetExteriorCell(unsigned short pid, int x, int y) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Add a new explored cell to the map changes for a player.
|
||||
* \brief Load a .png file as the image data for a map tile and add it to the map changes for
|
||||
* a player.
|
||||
*
|
||||
* \param pid The player ID whose map changes should be used.
|
||||
* \param cellDescription The cell description of the explored cell.
|
||||
* \param cellX The X coordinate of the cell corresponding to the map tile.
|
||||
* \param cellY The Y coordinate of the cell corresponding to the map tile.
|
||||
* \param filePath The file path of the loaded file.
|
||||
* \return void
|
||||
*/
|
||||
static void AddCellExplored(unsigned short pid, const char* cellDescription) noexcept;
|
||||
static void LoadMapTileImageFile(unsigned short pid, int cellX, int cellY, const char* filePath) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Send a PlayerCellChange packet about a player.
|
||||
|
|
|
@ -17,9 +17,7 @@ namespace mwmp
|
|||
{
|
||||
DEBUG_PRINTF(strPacketID.c_str());
|
||||
|
||||
// Not currently implemented
|
||||
//
|
||||
// To be dealt with later to save explored areas on local maps
|
||||
Script::Call<Script::CallbackIdentity("OnPlayerMap")>(player.getId());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -213,9 +213,10 @@ namespace MWBase
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow setting a cell as explored from elsewhere in the code
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
virtual void setCellExplored(const MWWorld::CellStore* cell) = 0;
|
||||
virtual void setGlobalMapImage(int cellX, int cellY, const std::vector<char>& imageData) = 0;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -941,6 +941,20 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
void MapWindow::setGlobalMapImage(int cellX, int cellY, const std::vector<char>& imageData)
|
||||
{
|
||||
mGlobalMapRender->setImage(cellX, cellY, imageData);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void MapWindow::updateCustomMarkers()
|
||||
{
|
||||
LocalMapBase::updateCustomMarkers();
|
||||
|
|
|
@ -266,6 +266,17 @@ namespace MWGui
|
|||
void setGlobalMapPlayerPosition (float worldX, float worldY);
|
||||
void setGlobalMapPlayerDir(const float x, const float y);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
void setGlobalMapImage(int cellX, int cellY, const std::vector<char>& imageData);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
void ensureGlobalMapLoaded();
|
||||
|
||||
virtual void onOpen();
|
||||
|
|
|
@ -1005,11 +1005,12 @@ namespace MWGui
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow setting a cell as explored from elsewhere in the code
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
void WindowManager::setCellExplored(const MWWorld::CellStore* cell)
|
||||
void WindowManager::setGlobalMapImage(int cellX, int cellY, const std::vector<char>& imageData)
|
||||
{
|
||||
mMap->cellExplored(cell->getCell()->getGridX(), cell->getCell()->getGridY());
|
||||
mMap->setGlobalMapImage(cellX, cellY, imageData);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
|
|
|
@ -246,9 +246,10 @@ namespace MWGui
|
|||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow setting a cell as explored from elsewhere in the code
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
virtual void setCellExplored(const MWWorld::CellStore* cell);
|
||||
virtual void setGlobalMapImage(int cellX, int cellY, const std::vector<char>& imageData);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
|
|
@ -1294,12 +1294,14 @@ void LocalPlayer::setMapExplored()
|
|||
MWWorld::Ptr ptrPlayer = getPlayerPtr();
|
||||
MWMechanics::NpcStats &ptrNpcStats = ptrPlayer.getClass().getNpcStats(ptrPlayer);
|
||||
|
||||
for (const auto &cellExplored : mapChanges.cellsExplored)
|
||||
for (const auto &mapTile : mapChanges.mapTiles)
|
||||
{
|
||||
MWWorld::CellStore *ptrCellStore = Main::get().getCellController()->getCellStore(cellExplored);
|
||||
const MWWorld::CellStore *cellStore = MWBase::Environment::get().getWorld()->getExterior(mapTile.x, mapTile.y);
|
||||
|
||||
if (ptrCellStore)
|
||||
MWBase::Environment::get().getWindowManager()->setCellExplored(ptrCellStore);
|
||||
if (!cellStore->getCell()->mName.empty())
|
||||
MWBase::Environment::get().getWindowManager()->addVisitedLocation(cellStore->getCell()->mName, mapTile.x, mapTile.y);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->setGlobalMapImage(mapTile.x, mapTile.y, mapTile.imageData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1648,6 +1650,23 @@ void LocalPlayer::sendSelectedSpell(const std::string& newSelectedSpellId)
|
|||
getNetworking()->getPlayerPacket(ID_PLAYER_MISCELLANEOUS)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::sendMapExplored(int x, int y, const std::vector<char>& imageData)
|
||||
{
|
||||
mapChanges.mapTiles.clear();
|
||||
|
||||
mwmp::MapTile mapTile;
|
||||
mapTile.x = x;
|
||||
mapTile.y = y;
|
||||
mapTile.imageData = imageData;
|
||||
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Sending ID_PLAYER_MAP with x: %i, y: %i", x, y);
|
||||
|
||||
mapChanges.mapTiles.push_back(mapTile);
|
||||
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_MAP)->setPlayer(this);
|
||||
getNetworking()->getPlayerPacket(ID_PLAYER_MAP)->Send();
|
||||
}
|
||||
|
||||
void LocalPlayer::clearCellStates()
|
||||
{
|
||||
cellStateChanges.cellStates.clear();
|
||||
|
|
|
@ -64,10 +64,10 @@ namespace mwmp
|
|||
void setFactions();
|
||||
void setKills();
|
||||
void setBooks();
|
||||
void setMapExplored();
|
||||
void setShapeshift();
|
||||
void setMarkLocation();
|
||||
void setSelectedSpell();
|
||||
void setMapExplored();
|
||||
|
||||
void sendClass();
|
||||
void sendInventory();
|
||||
|
@ -90,6 +90,7 @@ namespace mwmp
|
|||
void sendWerewolfState(bool isWerewolf);
|
||||
void sendMarkLocation(const ESM::Cell& newMarkCell, const ESM::Position& newMarkPosition);
|
||||
void sendSelectedSpell(const std::string& newSelectedSpellId);
|
||||
void sendMapExplored(int x, int y, const std::vector<char>& imageData);
|
||||
|
||||
void clearCellStates();
|
||||
void clearCurrentContainer();
|
||||
|
|
|
@ -19,6 +19,18 @@
|
|||
|
||||
#include <components/esm/globalmap.hpp>
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Include additional headers for multiplayer purposes
|
||||
*/
|
||||
#include <components/openmw-mp/Log.hpp>
|
||||
#include "../mwmp/Main.hpp"
|
||||
#include "../mwmp/LocalPlayer.hpp"
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
||||
|
@ -96,6 +108,17 @@ namespace
|
|||
|
||||
namespace MWRender
|
||||
{
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Use maps to track which global map coordinates belong to which cell coordinates
|
||||
without having to significantly change other methods
|
||||
*/
|
||||
std::map<int, int> originToCellX;
|
||||
std::map<int, int> originToCellY;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
class CreateMapWorkItem : public SceneUtil::WorkItem
|
||||
{
|
||||
|
@ -382,6 +405,17 @@ namespace MWRender
|
|||
if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY)
|
||||
return;
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Track the cell coordinates corresponding to these map image coordinates
|
||||
*/
|
||||
originToCellX[originX] = cellX;
|
||||
originToCellY[originY - mCellSize] = cellY;
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
requestOverlayTextureUpdate(originX, mHeight - originY, mCellSize, mCellSize, localMapTexture, false, true);
|
||||
}
|
||||
|
||||
|
@ -598,6 +632,40 @@ namespace MWRender
|
|||
ensureLoaded();
|
||||
mOverlayImage->copySubImage(imageDest.mX, imageDest.mY, 0, imageDest.mImage);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Send an ID_PLAYER_MAP packet with this map tile to the server
|
||||
*/
|
||||
if (originToCellX.count(imageDest.mX) > 0 && originToCellY.count(imageDest.mY) > 0)
|
||||
{
|
||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "New global map tile corresponds to cell %i, %i", originToCellX.at(imageDest.mX), originToCellY.at(imageDest.mY));
|
||||
|
||||
osgDB::ReaderWriter* readerwriter = osgDB::Registry::instance()->getReaderWriterForExtension("png");
|
||||
if (!readerwriter)
|
||||
{
|
||||
std::cerr << "Error: Can't write temporary map image, no '" << "png" << "' readerwriter found" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
std::ostringstream ostream;
|
||||
|
||||
osgDB::ReaderWriter::WriteResult result = readerwriter->writeImage(*imageDest.mImage, ostream);
|
||||
|
||||
if (!result.success())
|
||||
{
|
||||
std::cerr << "Error: Can't write temporary map image: " << result.message() << " code " << result.status() << std::endl;
|
||||
}
|
||||
|
||||
std::string stringData = ostream.str();
|
||||
std::vector<char> vectorData = std::vector<char>(stringData.begin(), stringData.end());
|
||||
|
||||
mwmp::Main::get().getLocalPlayer()->sendMapExplored(originToCellX.at(imageDest.mX), originToCellY.at(imageDest.mY), vectorData);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
it = mPendingImageDest.erase(it);
|
||||
}
|
||||
}
|
||||
|
@ -607,4 +675,50 @@ namespace MWRender
|
|||
cam->removeChildren(0, cam->getNumChildren());
|
||||
mRoot->removeChild(cam);
|
||||
}
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
void GlobalMap::setImage(int cellX, int cellY, const std::vector<char>& imageData)
|
||||
{
|
||||
Files::IMemStream istream(&imageData[0], imageData.size());
|
||||
|
||||
osgDB::ReaderWriter* reader = osgDB::Registry::instance()->getReaderWriterForExtension("png");
|
||||
if (!reader)
|
||||
{
|
||||
std::cerr << "Error: Failed to read map tile image data, no png readerwriter found" << std::endl;
|
||||
return;
|
||||
}
|
||||
osgDB::ReaderWriter::ReadResult result = reader->readImage(istream);
|
||||
|
||||
if (!result.success())
|
||||
{
|
||||
std::cerr << "Error: Can't read map tile image: " << result.message() << " code " << result.status() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
osg::ref_ptr<osg::Image> image = result.getImage();
|
||||
|
||||
int posX = (cellX - mMinX) * mCellSize;
|
||||
int posY = (cellY - mMinY + 1) * mCellSize;
|
||||
|
||||
if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY)
|
||||
return;
|
||||
|
||||
osg::ref_ptr<osg::Texture2D> texture(new osg::Texture2D);
|
||||
texture->setImage(image);
|
||||
texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
|
||||
texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
|
||||
texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
|
||||
texture->setResizeNonPowerOfTwoHint(false);
|
||||
|
||||
requestOverlayTextureUpdate(posX, mHeight - posY, mCellSize, mCellSize, texture, true, false);
|
||||
}
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -60,6 +60,17 @@ namespace MWRender
|
|||
|
||||
void removeCamera(osg::Camera* cam);
|
||||
|
||||
/*
|
||||
Start of tes3mp addition
|
||||
|
||||
Allow the setting of the image data for a global map tile from elsewhere
|
||||
in the code
|
||||
*/
|
||||
void setImage(int cellX, int cellY, const std::vector<char>& imageData);
|
||||
/*
|
||||
End of tes3mp addition
|
||||
*/
|
||||
|
||||
/**
|
||||
* Mark a camera for cleanup in the next update. For internal use only.
|
||||
*/
|
||||
|
|
|
@ -95,6 +95,13 @@ namespace mwmp
|
|||
int type; // 0 - Cell load, 1 - Cell unload
|
||||
};
|
||||
|
||||
struct MapTile
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
std::vector<char> imageData;
|
||||
};
|
||||
|
||||
struct JournalChanges
|
||||
{
|
||||
std::vector<JournalItem> journalItems;
|
||||
|
@ -136,8 +143,7 @@ namespace mwmp
|
|||
|
||||
struct MapChanges
|
||||
{
|
||||
std::vector<ESM::Cell> cellsExplored;
|
||||
unsigned int count;
|
||||
std::vector<MapTile> mapTiles;
|
||||
};
|
||||
|
||||
struct InventoryChanges
|
||||
|
|
|
@ -13,24 +13,40 @@ void PacketPlayerMap::Packet(RakNet::BitStream *bs, bool send)
|
|||
{
|
||||
PlayerPacket::Packet(bs, send);
|
||||
|
||||
uint32_t changesCount;
|
||||
|
||||
if (send)
|
||||
player->mapChanges.count = (unsigned int)(player->mapChanges.cellsExplored.size());
|
||||
else
|
||||
player->mapChanges.cellsExplored.clear();
|
||||
changesCount = static_cast<uint32_t>(player->mapChanges.mapTiles.size());
|
||||
|
||||
RW(player->mapChanges.count, send);
|
||||
RW(changesCount, send);
|
||||
|
||||
for (unsigned int i = 0; i < player->mapChanges.count; i++)
|
||||
if (!send)
|
||||
{
|
||||
ESM::Cell cellExplored;
|
||||
player->mapChanges.mapTiles.clear();
|
||||
player->mapChanges.mapTiles.resize(changesCount);
|
||||
}
|
||||
|
||||
for (auto &&mapTile : player->mapChanges.mapTiles)
|
||||
{
|
||||
RW(mapTile.x, send);
|
||||
RW(mapTile.y, send);
|
||||
|
||||
uint32_t imageDataCount;
|
||||
|
||||
if (send)
|
||||
cellExplored = player->mapChanges.cellsExplored.at(i);
|
||||
imageDataCount = static_cast<uint32_t>(mapTile.imageData.size());
|
||||
|
||||
RW(cellExplored.mData, send, 1);
|
||||
RW(cellExplored.mName, send, 1);
|
||||
RW(imageDataCount, send);
|
||||
|
||||
if (!send)
|
||||
player->mapChanges.cellsExplored.push_back(cellExplored);
|
||||
{
|
||||
mapTile.imageData.clear();
|
||||
mapTile.imageData.resize(imageDataCount);
|
||||
}
|
||||
|
||||
for (auto &&imageChar : mapTile.imageData)
|
||||
{
|
||||
RW(imageChar, send);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue