Просмотр исходного кода

Created ressources.json from resources.txt.

Frank Zago 14 лет назад
Родитель
Сommit
11b50ca176
3 измененных файлов с 8 добавлено и 12 удалено
  1. 0 2
      config/resources.txt
  2. 4 0
      config/ressources.json
  3. 4 10
      lib/CObjectHandler.cpp

+ 0 - 2
config/resources.txt

@@ -1,2 +0,0 @@
-8
-250	500	250	500	500	500	1	0

+ 4 - 0
config/ressources.json

@@ -0,0 +1,4 @@
+{
+	// Price of each ressource in gold, in usual ressource order
+	"ressources_prices": [ 250, 500, 250, 500, 500, 500, 1, 0 ]
+}

+ 4 - 10
lib/CObjectHandler.cpp

@@ -196,18 +196,12 @@ void CObjectHandler::loadObjects()
 	}
 	tlog5 << "\t\tDone loading cregens!\n";
 
+	const JsonNode config2(DATA_DIR "/config/ressources.json");
+	BOOST_FOREACH(const JsonNode &price, config2["ressources_prices"].Vector())
 	{
-		int k = -1;
-		std::ifstream ifs(DATA_DIR "/config/resources.txt");
-		ifs >> k;
-		int pom;
-		for(int i=0;i<k;i++)
-		{
-			ifs >> pom;
-			resVals.push_back(pom);
-		}
-		tlog5 << "\t\tDone loading resource prices!\n";
+		resVals.push_back(price.Float());
 	}
+	tlog5 << "\t\tDone loading resource prices!\n";
 
 	std::ifstream istr;
 	istr.open(DATA_DIR "/config/bankconfig.txt", std::ios_base::binary);