浏览代码

Rolled back some incorrect values.

DjWarmonger 11 年之前
父节点
当前提交
eae7e5c51f
共有 2 个文件被更改,包括 6 次插入6 次删除
  1. 4 4
      lib/rmg/CMapGenOptions.cpp
  2. 2 2
      lib/rmg/CMapGenOptions.h

+ 4 - 4
lib/rmg/CMapGenOptions.cpp

@@ -194,7 +194,7 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
 		auto possiblePlayers = mapTemplate->getPlayers().getNumbers();
 		possiblePlayers.erase(possiblePlayers.begin(), possiblePlayers.lower_bound(countHumanPlayers()));
 		assert(!possiblePlayers.empty());
-		playerCount = rand.nextInt(possiblePlayers.size());
+		playerCount = *RandomGeneratorUtil::nextItem(possiblePlayers, rand);
 		updatePlayers();
 	}
 	if(teamCount == RANDOM_SIZE)
@@ -204,7 +204,7 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
 	if(compOnlyPlayerCount == RANDOM_SIZE)
 	{
 		auto possiblePlayers = mapTemplate->getCpuPlayers().getNumbers();
-		compOnlyPlayerCount = rand.nextInt(possiblePlayers.size());
+		compOnlyPlayerCount = *RandomGeneratorUtil::nextItem(possiblePlayers, rand);
 		updateCompOnlyPlayers();
 	}
 	if(compOnlyTeamCount == RANDOM_SIZE)
@@ -220,11 +220,11 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
 
 	if(waterContent == EWaterContent::RANDOM)
 	{
-		waterContent = static_cast<EWaterContent::EWaterContent>(rand.nextInt(EWaterContent::TOTAL_COUNT));
+		waterContent = static_cast<EWaterContent::EWaterContent>(rand.nextInt(EWaterContent::LAST_ITEM));
 	}
 	if(monsterStrength == EMonsterStrength::RANDOM)
 	{
-		monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::TOTAL_COUNT));
+		monsterStrength = static_cast<EMonsterStrength::EMonsterStrength>(rand.nextInt(EMonsterStrength::LAST_ITEM));
 	}
 }
 

+ 2 - 2
lib/rmg/CMapGenOptions.h

@@ -24,7 +24,7 @@ namespace EWaterContent
 		NONE,
 		NORMAL,
 		ISLANDS,
-		TOTAL_COUNT
+		LAST_ITEM = ISLANDS
 	};
 }
 
@@ -36,7 +36,7 @@ namespace EMonsterStrength
 		WEAK,
 		NORMAL,
 		STRONG,
-		TOTAL_COUNT
+		LAST_ITEM = STRONG
 	};
 }