1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

#1065 - fix random hero initial position

This commit is contained in:
Andrii Danylchenko
2022-10-13 11:58:32 +03:00
parent 360f079bb7
commit 6cbaa40e29

View File

@ -197,9 +197,6 @@ void CGObjectInstance::setType(si32 ID, si32 subID)
{
const TerrainTile &tile = cb->gameState()->map->getTile(visitablePos());
this->ID = Obj(ID);
this->subID = 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);
@ -212,11 +209,16 @@ void CGObjectInstance::setType(si32 ID, si32 subID)
appearance = handler->getTemplates(tile.terType->id)[0];
else
appearance = handler->getTemplates()[0]; // get at least some appearance since alternative is crash
if (ID == Obj::HERO)
if(this->ID == Obj::PRISON && ID == Obj::HERO)
{
//adjust for the prison offset
pos = visitablePos();
}
this->ID = Obj(ID);
this->subID = subID;
cb->gameState()->map->addBlockVisTiles(this);
}