Michał W. Urbańczyk 14 年之前
父節點
當前提交
5cc9d16014
共有 2 個文件被更改,包括 4 次插入4 次删除
  1. 2 2
      lib/NetPacksLib.cpp
  2. 2 2
      server/CGameHandler.cpp

+ 2 - 2
lib/NetPacksLib.cpp

@@ -326,8 +326,8 @@ void TryMoveHero::applyGs( CGameState *gs )
 	if(result == EMBARK) //hero enters boat at dest tile
 	{
 		const TerrainTile &tt = gs->map->getTile(CGHeroInstance::convertPosition(end, false));
-		assert(tt.visitableObjects.size() == 1  &&  tt.visitableObjects.front()->ID == 8); //the only vis obj at dest is Boat
-		CGBoat *boat = static_cast<CGBoat*>(tt.visitableObjects.front());
+		assert(tt.visitableObjects.size() >= 1  &&  tt.visitableObjects.back()->ID == 8); //the only vis obj at dest is Boat
+		CGBoat *boat = static_cast<CGBoat*>(tt.visitableObjects.back());
 
 		gs->map->removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat
 		h->boat = boat;

+ 2 - 2
server/CGameHandler.cpp

@@ -1355,7 +1355,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 	//OR hero is on land and dest is water and (there is not present only one object - boat)
 	if((t.tertype == TerrainTile::rock  ||  (t.blocked && !t.visitable && !h->hasBonusOfType(Bonus::FLYING_MOVEMENT) )) 
 			&& complain("Cannot move hero, destination tile is blocked!") 
-		|| (!h->boat && !h->canWalkOnSea() && t.tertype == TerrainTile::water && (t.visitableObjects.size() != 1 ||  (t.visitableObjects.front()->ID != 8 && t.visitableObjects.front()->ID != HEROI_TYPE)))  //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land)
+		|| (!h->boat && !h->canWalkOnSea() && t.tertype == TerrainTile::water && (t.visitableObjects.size() < 1 ||  (t.visitableObjects.back()->ID != 8 && t.visitableObjects.back()->ID != HEROI_TYPE)))  //hero is not on boat/water walking and dst water tile doesn't contain boat/hero (objs visitable from land) -> we test back cause boat may be on top of another object (#276)
 			&& complain("Cannot move hero, destination tile is on water!")
 		|| (h->boat && t.tertype != TerrainTile::water && t.blocked)
 			&& complain("Cannot disembark hero, tile is blocked!")
@@ -1370,7 +1370,7 @@ bool CGameHandler::moveHero( si32 hid, int3 dst, ui8 instant, ui8 asker /*= 255*
 	}
 
 	//hero enters the boat
-	if(!h->boat && t.visitableObjects.size() && t.visitableObjects.front()->ID == 8)
+	if(!h->boat && t.visitableObjects.size() && t.visitableObjects.back()->ID == 8)
 	{
 		tmh.result = TryMoveHero::EMBARK;
 		tmh.movePoints = 0; //embarking takes all move points