Selaa lähdekoodia

Tweaks for obstacles.

Michał W. Urbańczyk 13 vuotta sitten
vanhempi
sitoutus
482051eb17
2 muutettua tiedostoa jossa 11 lisäystä ja 5 poistoa
  1. 1 1
      client/BattleInterface/CBattleInterface.cpp
  2. 10 4
      lib/BattleState.cpp

+ 1 - 1
client/BattleInterface/CBattleInterface.cpp

@@ -907,7 +907,7 @@ void CBattleInterface::showObstacles(std::multimap<BattleHex, int> *hexToObstacl
 		std::vector<Cimage> &images = idToObstacle[curOb.ID]->ourImages; //reference to animation of obstacle
 		Rect r = hexPosition(hex);
 		int offset = images.front().bitmap->h % 42;
-		if(offset > 15) //experimental value, may need tweaking if some obstacles are shown too low/high
+		if(offset > 7) //experimental value, may need tweaking if some obstacles are shown too low/high
 			offset -= 42;
 
 		r.y += 42 - images.front().bitmap->h + offset;

+ 10 - 4
lib/BattleState.cpp

@@ -1543,16 +1543,22 @@ struct RangeGenerator
 		remaining.resize(remainingCount, true);
 	}
 
+	int generateNumber()
+	{
+		if(!remainingCount)
+			throw ExhaustedPossibilities();
+		if(remainingCount == 1)
+			return 0;
+		return myRand() % remainingCount;
+	}
+
 	//get number fulfilling predicate. Never gives the same number twice.
 	int getSuchNumber(boost::function<bool(int)> goodNumberPred = 0)
 	{
 		int ret = -1;
 		do
 		{
-			if(!remainingCount)
-				throw ExhaustedPossibilities();
-
-			int n = myRand() % remainingCount;
+			int n = generateNumber();
 			int i = 0;
 			for(;;i++)
 			{