Pārlūkot izejas kodu

Merged mageLevel.txt into buildings.json.

Frank Zago 14 gadi atpakaļ
vecāks
revīzija
74620dc685
3 mainītis faili ar 36 papildinājumiem un 24 dzēšanām
  1. 31 0
      config/buildings.json
  2. 0 14
      config/mageLevel.txt
  3. 5 10
      lib/CTownHandler.cpp

+ 31 - 0
config/buildings.json

@@ -5,6 +5,10 @@
 //              Then buildings in the list will be drawn in that order.
 //  creatures_basic: ids of the basic creatures in each dwelling, ordered by level. 8th is WoG and is ignored.
 //  creatures_upgraded: ids of the upgraded creatures in each dwelling, ordered by level
+//  horde: horde building creature levels (-1 if not present)
+//  mage_guild: maximum level of the mage guild
+//  primary_ressource: (1,3,4,5 for rares and 127 for wood+ore)
+//  war_machine: type of war machine that this city can build
 
 {
 	"town_type":
@@ -56,6 +60,9 @@
 		  "creatures_basic": [ 0, 2, 4, 6, 8, 10, 12, 150 ],
 		  "creatures_upgraded": [ 1, 3, 5, 7, 9, 11, 13 ],
 		  "horde": [ 2, -1 ],
+		  "mage_guild": 4,
+		  "primary_ressource": 127,
+		  "war_machine": 4,
 		},
 
 		{
@@ -109,6 +116,9 @@
 		  "creatures_basic": [ 14, 16, 18, 20, 22, 24, 26, 151 ],
 		  "creatures_upgraded": [ 15, 17, 19, 21, 23, 25, 27 ],
 		  "horde": [ 1, 4 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 4,
+		  "war_machine": 6,
 		},
 
 		{
@@ -156,6 +166,9 @@
 		  "creatures_basic": [ 28, 30, 32, 34, 36, 38, 40, 152 ],
 		  "creatures_upgraded": [ 29, 31, 33, 35, 37, 39, 41 ],
 		  "horde": [ 1, -1 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 5,
+		  "war_machine": 5,
 		},
 
 		{
@@ -204,6 +217,9 @@
 		  "creatures_basic": [ 42, 44, 46, 48, 50, 52, 54, 153 ],
 		  "creatures_upgraded": [ 43, 45, 47, 49, 51, 53, 55 ],
 		  "horde": [ 0, 2 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 1,
+		  "war_machine": 5,
 		},
 
 		{
@@ -256,6 +272,9 @@
 		  "creatures_basic": [ 56, 58, 60, 62, 64, 66, 68, 154 ],
 		  "creatures_upgraded": [ 57, 59, 61, 63, 65, 67, 69 ],
 		  "horde": [ 0, -1 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 127,
+		  "war_machine": 6,
 		},
 
 		{
@@ -303,6 +322,9 @@
 		  "creatures_basic": [ 70, 72, 74, 76, 78, 80, 82, 155 ],
 		  "creatures_upgraded": [ 71, 73, 75, 77, 79, 81, 83 ],
 		  "horde": [ 0, -1 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 3,
+		  "war_machine": 4,
 		},
 
 		{
@@ -349,6 +371,9 @@
 		  "creatures_basic": [ 84, 86, 88, 90, 92, 94, 96, 156 ],
 		  "creatures_upgraded": [ 85, 87, 89, 91, 93, 95, 97 ],
 		  "horde": [ 0, -1 ],
+		  "mage_guild": 3,
+		  "primary_ressource": 127,
+		  "war_machine": 5,
 		},
 
 		{
@@ -397,6 +422,9 @@
 		  "creatures_basic": [ 98, 100, 104, 106, 102, 108, 110, 157 ],
 		  "creatures_upgraded": [ 99, 101, 105, 107, 103, 109, 111 ],
 		  "horde": [ 0, -1 ],
+		  "mage_guild": 3,
+		  "primary_ressource": 127,
+		  "war_machine": 6,
 		},
 
 		{
@@ -449,6 +477,9 @@
 		  "creatures_basic": [ 118, 112, 115, 114, 113, 120, 130, 158 ],
 		  "creatures_upgraded": [ 119, 127, 123, 129, 125, 121, 131 ],
 		  "horde": [ 0, -1 ],
+		  "mage_guild": 5,
+		  "primary_ressource": 1,
+		  "war_machine": 4,
 		}
 	],
 

+ 0 - 14
config/mageLevel.txt

@@ -1,14 +0,0 @@
-9
-4	127	4
-5	4	6
-5	5	5
-5	1	5
-5	127	6
-5	3	4
-3	127	5
-3	127	6
-5	1	4
-
-FORMAT:
-#castles
-mage_guild_max_level	main_res (127 for wood&ore)

+ 5 - 10
lib/CTownHandler.cpp

@@ -33,7 +33,6 @@ CTownHandler::~CTownHandler()
 }
 void CTownHandler::loadStructures()
 {
-	int si, itr;
 	char bufname[75];
 	int townID;
 
@@ -125,6 +124,11 @@ void CTownHandler::loadStructures()
 			level ++;
 		}
 
+		// Misc.
+		towns[townID].mageLevel = town_node["mage_guild"].Float();
+		towns[townID].primaryRes  = town_node["primary_ressource"].Float();
+		towns[townID].warMachine = town_node["war_machine"].Float();
+
 		townID ++;
 	}
 
@@ -172,15 +176,6 @@ void CTownHandler::loadStructures()
 
 	std::ifstream of;
 
-	of.open(DATA_DIR "/config/mageLevel.txt");
-	of >> si;
-	for(itr=0; itr<si; itr++)
-	{
-		of >> towns[itr].mageLevel >> towns[itr].primaryRes >> towns[itr].warMachine;
-	}
-	of.close();
-	of.clear();
-
 	of.open(DATA_DIR "/config/requirements.txt");
 	requirements.resize(F_NUMBER);
 	while(!of.eof())