mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Fix crash on unknown map objects
If getHandlerFor() fails to find the handler, it returns a nullptr shared pointer, which is later dereferenced unconditionally. How to reproduce: Download map "Happy time Dragons!!!" from http://heroesportal.net/maps.php?type=H3AB-XL&sort=r => Failed to find object of type 5:144 SIGSEGV
This commit is contained in:
parent
8be660aae8
commit
92e011429f
@ -191,6 +191,12 @@ void CGObjectInstance::setType(si32 ID, si32 subID)
|
||||
//recalculate blockvis tiles - new appearance might have different blockmap than before
|
||||
cb->gameState()->map->removeBlockVisTiles(this, true);
|
||||
auto handler = VLC->objtypeh->getHandlerFor(ID, subID);
|
||||
if(!handler)
|
||||
{
|
||||
logGlobal->errorStream() << boost::format(
|
||||
"Unknown object type %d:%d at %s") % ID % subID % visitablePos();
|
||||
return;
|
||||
}
|
||||
if(!handler->getTemplates(tile.terType).empty())
|
||||
appearance = handler->getTemplates(tile.terType)[0];
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user