1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Added some checks & logs for empty def names, but it only delays the crash.

This commit is contained in:
DjWarmonger 2015-09-20 13:02:13 +02:00
parent e14faea181
commit 57637dd71a
4 changed files with 24 additions and 2 deletions

View File

@ -373,11 +373,21 @@ void Graphics::loadFonts()
CDefEssential * Graphics::getDef( const CGObjectInstance * obj )
{
if (obj->appearance.animationFile.empty())
{
logGlobal->warnStream() << boost::format("Def name for (%d,%d) is empty!") % obj->id % obj->subID;
return nullptr;
}
return advmapobjGraphics[obj->appearance.animationFile];
}
CDefEssential * Graphics::getDef( const ObjectTemplate & info )
{
if (info.animationFile.empty())
{
logGlobal->warnStream() << boost::format("Def name for obj (%d,%d) is empty!") % info.id % info.subid;
return nullptr;
}
return advmapobjGraphics[info.animationFile];
}

View File

@ -860,8 +860,15 @@ void CMapHandler::CMapBlitter::drawObjects(SDL_Surface * targetSurf, const Terra
if (!graphics->getDef(obj))
processDef(obj->appearance);
if (!graphics->getDef(obj) && !obj->appearance.animationFile.empty())
logGlobal->errorStream() << "Failed to load image " << obj->appearance.animationFile;
if (!graphics->getDef(obj))
{
if (!obj->appearance.animationFile.empty())
logGlobal->errorStream() << "Failed to load image " << obj->appearance.animationFile;
else
logGlobal->warnStream() << boost::format("Def name for (%d,%d) is empty!") % obj->id % obj->subID;
continue;
}
if (!canDrawObject(obj))
continue;

View File

@ -364,6 +364,7 @@
<ClInclude Include="spells\CreatureSpellMechanics.h" />
<ClInclude Include="spells\CSpellHandler.h" />
<ClInclude Include="spells\ISpellMechanics.h" />
<ClInclude Include="spells\Magic.h" />
<ClInclude Include="spells\SpellMechanics.h" />
<ClInclude Include="spells\ViewSpellInt.h" />
<ClInclude Include="StartInfo.h" />

View File

@ -225,6 +225,7 @@
<ClCompile Include="spells\CreatureSpellMechanics.cpp">
<Filter>spells</Filter>
</ClCompile>
<ClCompile Include="mapping\CDrawRoadsOperation.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="CCreatureSet.h">
@ -533,5 +534,8 @@
<ClInclude Include="spells\SpellMechanics.h">
<Filter>spells</Filter>
</ClInclude>
<ClInclude Include="spells\Magic.h">
<Filter>spells</Filter>
</ClInclude>
</ItemGroup>
</Project>