mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 09:53:51 +00:00
Some additional safety checks for global map loading
This commit is contained in:
parent
f89b3cac02
commit
dea9d21db6
1 changed files with 11 additions and 1 deletions
|
@ -265,6 +265,10 @@ namespace MWRender
|
||||||
if (bounds.mMaxY-bounds.mMinY <= 0)
|
if (bounds.mMaxY-bounds.mMinY <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (bounds.mMinX > bounds.mMaxX
|
||||||
|
|| bounds.mMinY > bounds.mMaxY)
|
||||||
|
throw std::runtime_error("invalid map bounds");
|
||||||
|
|
||||||
Ogre::Image image;
|
Ogre::Image image;
|
||||||
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&map.mImageData[0], map.mImageData.size()));
|
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&map.mImageData[0], map.mImageData.size()));
|
||||||
image.load(stream, "png");
|
image.load(stream, "png");
|
||||||
|
@ -297,9 +301,15 @@ namespace MWRender
|
||||||
// If cell bounds of the currently loaded content and the loaded savegame do not match,
|
// If cell bounds of the currently loaded content and the loaded savegame do not match,
|
||||||
// we need to resize source/dest boxes to accommodate
|
// we need to resize source/dest boxes to accommodate
|
||||||
// This means nonexisting cells will be dropped silently
|
// This means nonexisting cells will be dropped silently
|
||||||
|
|
||||||
int cellImageSizeDst = 24;
|
int cellImageSizeDst = 24;
|
||||||
|
|
||||||
|
// Completely off-screen? -> no need to blit anything
|
||||||
|
if (bounds.mMaxX < mMinX
|
||||||
|
|| bounds.mMaxY < mMinY
|
||||||
|
|| bounds.mMinX > mMaxX
|
||||||
|
|| bounds.mMinY > mMaxY)
|
||||||
|
return;
|
||||||
|
|
||||||
int leftDiff = (mMinX - bounds.mMinX);
|
int leftDiff = (mMinX - bounds.mMinX);
|
||||||
int topDiff = (bounds.mMaxY - mMaxY);
|
int topDiff = (bounds.mMaxY - mMaxY);
|
||||||
int rightDiff = (bounds.mMaxX - mMaxX);
|
int rightDiff = (bounds.mMaxX - mMaxX);
|
||||||
|
|
Loading…
Reference in a new issue