1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +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
commit 40d65b40a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -676,8 +676,22 @@ DLL_LINKAGE void GiveHero::applyGs(CGameState *gs)
DLL_LINKAGE void NewObject::applyGs(CGameState *gs)
{
const TerrainTile &t = gs->map->getTile(pos);
ETerrainType terrainType = t.terType;
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);
terrainType = t.terType;
}
CGObjectInstance *o = nullptr;
switch(ID)