mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Merge pull request #5342 from IvanSavenko/crashfixes
[1.6.4] Workarounds for crashes from Google Play
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "../../lib/CConfigHandler.h"
|
#include "../../lib/CConfigHandler.h"
|
||||||
#include "../../lib/CThreadHelper.h"
|
#include "../../lib/CThreadHelper.h"
|
||||||
|
#include "../../lib/ExceptionsCommon.h"
|
||||||
#include "../../lib/VCMIDirs.h"
|
#include "../../lib/VCMIDirs.h"
|
||||||
#include "../../lib/constants/StringConstants.h"
|
#include "../../lib/constants/StringConstants.h"
|
||||||
#include "../../lib/entities/building/CBuilding.h"
|
#include "../../lib/entities/building/CBuilding.h"
|
||||||
@@ -146,13 +147,20 @@ RenderHandler::AnimationLayoutMap & RenderHandler::getAnimationLayout(const Anim
|
|||||||
|
|
||||||
for(auto & loader : configList)
|
for(auto & loader : configList)
|
||||||
{
|
{
|
||||||
auto stream = loader->load(jsonResource);
|
try {
|
||||||
std::unique_ptr<ui8[]> textData(new ui8[stream->getSize()]);
|
auto stream = loader->load(jsonResource);
|
||||||
stream->read(textData.get(), stream->getSize());
|
std::unique_ptr<ui8[]> textData(new ui8[stream->getSize()]);
|
||||||
|
stream->read(textData.get(), stream->getSize());
|
||||||
|
|
||||||
const JsonNode config(reinterpret_cast<const std::byte*>(textData.get()), stream->getSize(), path.getOriginalName());
|
const JsonNode config(reinterpret_cast<const std::byte*>(textData.get()), stream->getSize(), path.getOriginalName());
|
||||||
|
|
||||||
initFromJson(result, config, mode);
|
initFromJson(result, config, mode);
|
||||||
|
}
|
||||||
|
catch (const DataLoadingException & e)
|
||||||
|
{
|
||||||
|
// FIXME: sometimes triggered by generated animation assets, e.g. lava/water tiles
|
||||||
|
logGlobal->error("Failed to load animation file! Reason: %s", e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
animationLayouts[actualPath] = result;
|
animationLayouts[actualPath] = result;
|
||||||
|
@@ -118,7 +118,7 @@ public:
|
|||||||
if(hasToBeValid)
|
if(hasToBeValid)
|
||||||
{
|
{
|
||||||
if(x < 0 || x >= GameConstants::BFIELD_WIDTH || y < 0 || y >= GameConstants::BFIELD_HEIGHT)
|
if(x < 0 || x >= GameConstants::BFIELD_WIDTH || y < 0 || y >= GameConstants::BFIELD_HEIGHT)
|
||||||
throw std::runtime_error("Valid hex required");
|
throw std::runtime_error("Hex at (" + std::to_string(x) + ", " + std::to_string(y) + ") is not valid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
hex = x + y * GameConstants::BFIELD_WIDTH;
|
hex = x + y * GameConstants::BFIELD_WIDTH;
|
||||||
|
Reference in New Issue
Block a user