|
|
|
@ -231,9 +231,8 @@ namespace MWRender
|
|
|
|
|
mOverlayTexture->getBuffer()->blitFromMemory(pb);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalMap::write(ESM::ESMWriter &writer)
|
|
|
|
|
void GlobalMap::write(ESM::GlobalMap& map)
|
|
|
|
|
{
|
|
|
|
|
ESM::GlobalMap map;
|
|
|
|
|
map.mBounds.mMinX = mMinX;
|
|
|
|
|
map.mBounds.mMaxX = mMaxX;
|
|
|
|
|
map.mBounds.mMinY = mMinY;
|
|
|
|
@ -244,19 +243,10 @@ namespace MWRender
|
|
|
|
|
Ogre::DataStreamPtr encoded = image.encode("png");
|
|
|
|
|
map.mImageData.resize(encoded->size());
|
|
|
|
|
encoded->read(&map.mImageData[0], encoded->size());
|
|
|
|
|
|
|
|
|
|
writer.startRecord(ESM::REC_GMAP);
|
|
|
|
|
map.save(writer);
|
|
|
|
|
writer.endRecord(ESM::REC_GMAP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GlobalMap::readRecord(ESM::ESMReader &reader, int32_t type, std::vector<std::pair<int, int> >& exploredCells)
|
|
|
|
|
{
|
|
|
|
|
if (type == ESM::REC_GMAP)
|
|
|
|
|
void GlobalMap::read(ESM::GlobalMap& map)
|
|
|
|
|
{
|
|
|
|
|
ESM::GlobalMap map;
|
|
|
|
|
map.load(reader);
|
|
|
|
|
|
|
|
|
|
const ESM::GlobalMap::Bounds& bounds = map.mBounds;
|
|
|
|
|
|
|
|
|
|
if (bounds.mMaxX-bounds.mMinX <= 0)
|
|
|
|
@ -280,23 +270,6 @@ namespace MWRender
|
|
|
|
|
if (int(image.getHeight() / yLength) != cellImageSizeSrc)
|
|
|
|
|
throw std::runtime_error("cell size must be quadratic");
|
|
|
|
|
|
|
|
|
|
// Determine which cells were explored by reading the image data
|
|
|
|
|
for (int x=0; x < xLength; ++x)
|
|
|
|
|
{
|
|
|
|
|
for (int y=0; y < yLength; ++y)
|
|
|
|
|
{
|
|
|
|
|
unsigned int imageX = (x) * cellImageSizeSrc;
|
|
|
|
|
// NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is
|
|
|
|
|
unsigned int imageY = (yLength - (y + 1)) * cellImageSizeSrc;
|
|
|
|
|
|
|
|
|
|
assert(imageX < image.getWidth());
|
|
|
|
|
assert(imageY < image.getHeight());
|
|
|
|
|
|
|
|
|
|
if (image.getColourAt(imageX, imageY, 0).a > 0)
|
|
|
|
|
exploredCells.push_back(std::make_pair(x+bounds.mMinX,y+bounds.mMinY));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If cell bounds of the currently loaded content and the loaded savegame do not match,
|
|
|
|
|
// we need to resize source/dest boxes to accommodate
|
|
|
|
|
// This means nonexisting cells will be dropped silently
|
|
|
|
@ -335,4 +308,3 @@ namespace MWRender
|
|
|
|
|
Ogre::TextureManager::getSingleton().remove("@temp");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|