Explorar o código

boat offsets for shipyards are counted from visitable position

Ivan Savenko %!s(int64=2) %!d(string=hai) anos
pai
achega
caccd58eb0

+ 9 - 5
lib/mapObjects/CGHeroInstance.cpp

@@ -953,11 +953,15 @@ BoatId CGHeroInstance::getBoatType() const
 
 void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
 {
-	// FIXME: Offsets need to be fixed once we get rid of convertPosition
-	// Check issue 515 for details
-	offsets =
-	{
-		int3(-1,1,0), int3(-1,-1,0), int3(-2,0,0), int3(0,0,0), int3(0,1,0), int3(-2,1,0), int3(0,-1,0), int3(-2,-1,0)
+	offsets = {
+		{0, -1, 0},
+		{+1, -1, 0},
+		{+1, 0, 0},
+		{+1, +1, 0},
+		{0, +1, 0},
+		{-1, +1, 0},
+		{-1, 0, 0},
+		{-1, -1, 0},
 	};
 }
 

+ 1 - 1
lib/mapObjects/CGTownInstance.cpp

@@ -585,7 +585,7 @@ bool CGTownInstance::passableFor(PlayerColor color) const
 
 void CGTownInstance::getOutOffsets( std::vector<int3> &offsets ) const
 {
-	offsets = {int3(-1,2,0), int3(-3,2,0)};
+	offsets = {int3(-1,2,0), int3(+1,2,0)};
 }
 
 CGTownInstance::EGeneratorState CGTownInstance::shipyardStatus() const

+ 3 - 1
lib/mapObjects/IObjectInterface.cpp

@@ -92,7 +92,9 @@ int3 IBoatGenerator::bestLocation() const
 
 	for (auto & offset : offsets)
 	{
-		if(const TerrainTile *tile = getObject()->cb->getTile(getObject()->getPosition() + offset, false)) //tile is in the map
+		const TerrainTile *tile = getObject()->cb->getTile(getObject()->visitablePos() + offset, false);
+
+		if(tile) //tile is in the map
 		{
 			if(tile->terType->isWater()  &&  (!tile->blocked || tile->blockingObjects.front()->ID == Obj::BOAT)) //and is water and is not blocked or is blocked by boat
 				return getObject()->getPosition() + offset;

+ 12 - 3
lib/mapObjects/MiscObjects.cpp

@@ -1355,9 +1355,18 @@ void CGShipyard::getOutOffsets( std::vector<int3> &offsets ) const
 	// A x S x B
 	// C E G F D
 	offsets = {
-		int3(-3,0,0), int3(1,0,0), //AB
-		int3(-3,1,0), int3(1,1,0), int3(-2,1,0), int3(0,1,0), int3(-1,1,0), //CDEFG
-		int3(-3,-1,0), int3(1,-1,0), int3(-2,-1,0), int3(0,-1,0), int3(-1,-1,0) //HIJKL
+		{-2, 0,  0}, // A
+		{+2, 0,  0}, // B
+		{-2, 1,  0}, // C
+		{+2, 1,  0}, // D
+		{-1, 1,  0}, // E
+		{+1, 1,  0}, // F
+		{0,  1,  0}, // G
+		{-2, -1, 0}, // H
+		{+2, -1, 0}, // I
+		{-1, -1, 0}, // G
+		{+1, -1, 0}, // K
+		{0,  -1, 0}, // L
 	};
 }