فهرست منبع

Fixed bank randomization.

DjWarmonger 10 سال پیش
والد
کامیت
abe02247b5
1فایلهای تغییر یافته به همراه4 افزوده شده و 6 حذف شده
  1. 4 6
      lib/mapObjects/CommonConstructors.cpp

+ 4 - 6
lib/mapObjects/CommonConstructors.cpp

@@ -313,17 +313,15 @@ void CBankInstanceConstructor::configureObject(CGObjectInstance * object, CRando
 	si32 selectedChance = rng.nextInt(totalChance - 1);
 	//logGlobal->debugStream() << "Selected chance for bank config is " << selectedChance;
 
+	int cumulativeChance = 0;
 	for (auto & node : levels)
 	{
-		if (selectedChance < node["chance"].Float())
+		cumulativeChance += node["chance"].Float();
+		if (selectedChance < cumulativeChance)
 		{
 			 bank->setConfig(generateConfig(node, rng));
+			 break;
 		}
-		else
-		{
-			selectedChance -= node["chance"].Float();
-		}
-
 	}
 }