1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Merge pull request #591 from dydzio0614/ShipyardCrashFix

Spawn ship placed outside map if it has visitable position inside map
This commit is contained in:
Alexander Shishkin
2019-05-21 09:47:51 +03:00
committed by GitHub

View File

@@ -675,9 +675,23 @@ DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
}
DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
{
ETerrainType terrainType;
if(ID == Obj::BOAT && !gs->isInTheMap(pos)) //special handling for bug #3060 - pos outside map but visitablePos is not
{
CGObjectInstance testObject = CGObjectInstance();
testObject.pos = pos;
testObject.appearance = VLC->objtypeh->getHandlerFor(ID, subID)->getTemplates(ETerrainType::WATER).front();
const int3 previousXAxisTile = int3(pos.x - 1, pos.y, pos.z);
assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile));
}
else
{
const TerrainTile & t = gs->map->getTile(pos);
ETerrainType terrainType = t.terType;
terrainType = t.terType;
}
CGObjectInstance *o = nullptr;
switch(ID)