Przeglądaj źródła

- Fixed a scenario when AI could visit the town without picking troops, resulting in a lock
- Added ench0's patch for creature range tooltip (#948)

DjWarmonger 13 lat temu
rodzic
commit
18e53a1717

+ 5 - 1
AI/VCAI/VCAI.cpp

@@ -1031,7 +1031,11 @@ void VCAI::performObjectInteraction(const CGObjectInstance * obj, const CGHeroIn
 	switch (obj->ID)
 	{
 		case Obj::CREATURE_GENERATOR1:
-			recruitCreatures(dynamic_cast<const CGDwelling *>(obj));
+			recruitCreatures (dynamic_cast<const CGDwelling *>(obj));
+			break;
+		case GameConstants::TOWNI_TYPE:
+			moveCreaturesToHero (dynamic_cast<const CGTownInstance *>(obj));
+			break;
 		break;
 	}
 }

+ 19 - 0
client/BattleInterface/CBattleInterface.cpp

@@ -632,6 +632,25 @@ void CBattleInterface::show(SDL_Surface * to)
 						CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &temp_rect);
 					}
 				}
+				//patch by ench0
+				const CStack * const shere = curInt->cb->battleGetStackByPos(b, false);
+
+				// display the movement shadow of the stack at b (i.e. stack under mouse)
+				if(shere && shere->alive())
+				{
+					// activeStack == NULL means it is opponent's turn...
+					if (activeStack && shere != activeStack)
+					{
+						std::vector<BattleHex> v = curInt->cb->battleGetAvailableHexes(shere, true );
+						BOOST_FOREACH (BattleHex hex, v)
+						{
+							int x = 14 + ((hex / GameConstants::BFIELD_WIDTH ) % 2 == 0 ? 22 : 0) + 44 * (hex % GameConstants::BFIELD_WIDTH) + pos.x;
+							int y = 86 + 42 * (hex / GameConstants::BFIELD_WIDTH) + pos.y;
+							SDL_Rect temp_rect = genRect (cellShade->h, cellShade->w, x, y);
+							CSDL_Ext::blit8bppAlphaTo24bpp (cellShade, NULL, to, &temp_rect);
+						}
+					}
+				}
 				//always highlight pointed hex
 				int x = 14 + ((b/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(b%GameConstants::BFIELD_WIDTH) + pos.x;
 				int y = 86 + 42 * (b/GameConstants::BFIELD_WIDTH) + pos.y;

+ 1 - 3
lib/BattleState.cpp

@@ -396,9 +396,7 @@ BattleHex BattleInfo::getClosestTile (bool attackerOwned, int initialPos, std::s
 
 	auto notClosest = [closestDistance, initialPos](const BattleHex here) -> bool
 	{
-		int debug = here.getDistance (initialPos, here);
-		bool debug2 = closestDistance < debug;
-		return debug2;
+		return closestDistance < here.getDistance (initialPos, here);
 	};
 
 	sortedTiles.erase (boost::remove_if (sortedTiles, notClosest), sortedTiles.end()); //only closest tiles are interesting