Browse Source

Merged creatures_upgr.txt and basicCres.txt into buildings.json.

Frank Zago 14 years ago
parent
commit
584e7e3c46
4 changed files with 50 additions and 171 deletions
  1. 0 72
      config/basicCres.txt
  2. 25 5
      config/buildings.json
  3. 0 63
      config/creatures_upgr.txt
  4. 25 31
      lib/CTownHandler.cpp

+ 0 - 72
config/basicCres.txt

@@ -1,72 +0,0 @@
-0	0	0
-0	1	2
-0	2	4
-0	3	6
-0	4	8
-0	5	10
-0	6	12
-0	7	150
-1	0	14
-1	1	16
-1	2	18
-1	3	20
-1	4	22
-1	5	24
-1	6	26
-1	7	151
-2	0	28
-2	1	30
-2	2	32
-2	3	34
-2	4	36
-2	5	38
-2	6	40
-2	7	152
-3	0	42
-3	1	44
-3	2	46
-3	3	48
-3	4	50
-3	5	52
-3	6	54
-3	7	153
-4	0	56
-4	1	58
-4	2	60
-4	3	62
-4	4	64
-4	5	66
-4	6	68
-4	7	154
-5	0	70
-5	1	72
-5	2	74
-5	3	76
-5	4	78
-5	5	80
-5	6	82
-5	7	155
-6	0	84
-6	1	86
-6	2	88
-6	3	90
-6	4	92
-6	5	94
-6	6	96
-6	7	156
-7	0	98
-7	1	100
-7	2	104
-7	3	106
-7	4	102
-7	5	108
-7	6	110
-7	7	157
-8	0	118
-8	1	112
-8	2	115
-8	3	114
-8	4	113
-8	5	120
-8	6	130
-8	7	158

+ 25 - 5
config/buildings.json

@@ -3,6 +3,8 @@
 //  defnames: Buildings coordinates inside a city
 //  blit_order: Buildings not mentioned in the file will be blitted first.
 //              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
 
 {
 	"town_type":
@@ -50,7 +52,9 @@
 			{ "id": 20, "defname": "TBCSBOAT.def", "x": 478, "y": 134, "border": "TOCSDKMN.bmp", "area": "TZCSDKMN.bmp" },
 			],
 
-		  "blit_order": [ 1, 2, 3, 10, 11, 12, 13, 5, 22, 30, 37, 16, 6, 20, 18, 19, 34, 41 ]	
+		  "blit_order": [ 1, 2, 3, 10, 11, 12, 13, 5, 22, 30, 37, 16, 6, 20, 18, 19, 34, 41 ],
+		  "creatures_basic": [ 0, 2, 4, 6, 8, 10, 12, 150 ],
+		  "creatures_upgraded": [ 1, 3, 5, 7, 9, 11, 13 ],
 		},
 
 		{
@@ -100,7 +104,9 @@
 			{ "id": 11, "defname": "TBRMHAL2.def", "x": 538, "y": 187, "border": "TORHAL2.bmp", "area": "TZRHAL2.bmp" },
 		  ],
 
-		  "blit_order": [ 33, 40, 35, 42, 16, 32, 39, 0, 1, 2, 3, 4, 31, 18, 38, 19, 34, 24, 41, 25, 5, 30, 37, 14, 10, 11, 12, 13, 17, 21, 22, -1, 27, 28, 29, 15 ]
+		  "blit_order": [ 33, 40, 35, 42, 16, 32, 39, 0, 1, 2, 3, 4, 31, 18, 38, 19, 34, 24, 41, 25, 5, 30, 37, 14, 10, 11, 12, 13, 17, 21, 22, -1, 27, 28, 29, 15 ],
+		  "creatures_basic": [ 14, 16, 18, 20, 22, 24, 26, 151 ],
+		  "creatures_upgraded": [ 15, 17, 19, 21, 23, 25, 27 ],
 		},
 
 		{
@@ -144,7 +150,9 @@
 			{ "id": 43, "defname": "TBTWUP_6.def", "x": 75, "y": 91, "border": "TOTTIT2.bmp", "area": "TZTTIT2.bmp" },
 			{ "id": 8, "defname": "TBTWCAS2.def", "x": 301, "y": 0, "border": "TOTCAS2.bmp", "area": "TZTCAS2.bmp" },
 		  ],
-		  "blit_order": [ 36, 43, 32, 39, 10, 11, 12, 13, 32, 35, 42, 15, 5, 18, 19 ]
+		  "blit_order": [ 36, 43, 32, 39, 10, 11, 12, 13, 32, 35, 42, 15, 5, 18, 19 ],
+		  "creatures_basic": [ 28, 30, 32, 34, 36, 38, 40, 152 ],
+		  "creatures_upgraded": [ 29, 31, 33, 35, 37, 39, 41 ],
 		},
 
 		{
@@ -189,7 +197,9 @@
 			{ "id": 43, "defname": "TBINUP_6.def", "x": 420, "y": 105, "border": "TOIDVL2.bmp", "area": "TZIDVL2.bmp" },
 			{ "id": 8, "defname": "TBINCAS2.def", "x": 222, "y": 44, "border": "TOICAS1A.bmp", "area": "TZICAS1A.bmp" },
 		  ],
-		  "blit_order": [ 26, 21, 7, 8, 9, 22, 31, 38, 36, 43, 10, 11, 12, 13, 5, 32, 39, 24, 25, 33, 40, 34, 41, 30, 37, 18, 19, 14, 15, 16, 35, 42 ]
+		  "blit_order": [ 26, 21, 7, 8, 9, 22, 31, 38, 36, 43, 10, 11, 12, 13, 5, 32, 39, 24, 25, 33, 40, 34, 41, 30, 37, 18, 19, 14, 15, 16, 35, 42 ],
+		  "creatures_basic": [ 42, 44, 46, 48, 50, 52, 54, 153 ],
+		  "creatures_upgraded": [ 43, 45, 47, 49, 51, 53, 55 ],
 		},
 
 		{
@@ -239,6 +249,8 @@
 			{ "id": 20, "defname": "TBNCBOAT.def", "x": 617, "y": 265, "border": "TONSHPNA.bmp", "area": "TZNSHPNA.bmp" },
 		  ],
 		  "blit_order": [ 17, 0, 1, 2, 3, 4, 7, 8, 9, 32, 39, 26, 15, 14, 34, 41, 16, 5, 33, 40, 31, 38, 6, 30, 18, 37, 19, 22, 20 ]
+		  "creatures_basic": [ 56, 58, 60, 62, 64, 66, 68, 154 ],
+		  "creatures_upgraded": [ 57, 59, 61, 63, 65, 67, 69 ],
 		},
 
 		{
@@ -283,6 +295,8 @@
 			{ "id": 8, "defname": "TBDNCAS2.def", "x": 363, "y": 87, "border": "TODCAS2.bmp", "area": "TZDCAS2.bmp" },
 		  ],
 		  "blit_order": [ 0, 1, 2, 3, 4, 21, 35, 42, 5, 30, 18, 37, 19, 32, 39, 26, 7, 8, 9, 23 ]
+		  "creatures_basic": [ 70, 72, 74, 76, 78, 80, 82, 155 ],
+		  "creatures_upgraded": [ 71, 73, 75, 77, 79, 81, 83 ],
 		},
 
 		{
@@ -326,6 +340,8 @@
 			{ "id": 16, "defname": "TBSTBLAK.def", "x": 660, "y": 286, "border": "TOSBLK1.bmp", "area": "TZSBLK1.bmp" },
 		  ],
 		  "blit_order": [ 33, 40, 30, 18, 37, 19, 31, 38, 23, 26, 5, 32, 39, 15, 14, 21, 16, 22 ]
+		  "creatures_basic": [ 84, 86, 88, 90, 92, 94, 96, 156 ],
+		  "creatures_upgraded": [ 85, 87, 89, 91, 93, 95, 97 ],
 		},
 
 		{
@@ -371,6 +387,8 @@
 			{ "id": 20, "defname": "TBFRBOAT.def", "x": 197, "y": 294, "border": "TOFDCK1.bmp", "area": "TZFDCK1.bmp" },
 		  ],
 		  "blit_order": [ 16, 15, 14, 34, 41, 31, 38, 10, 11, 12, 13, 29, 0, 1, 2, 33, 40, 30, 18, 37, 19, 5, 36, 43, 26 ]
+		  "creatures_basic": [ 98, 100, 104, 106, 102, 108, 110, 157 ],
+		  "creatures_upgraded": [ 99, 101, 105, 107, 103, 109, 111 ],
 		},
 
 		{
@@ -419,7 +437,9 @@
 			{ "id": 43, "defname": "TBELUP_6.def", "x": 43, "y": 0, "border": "TOELUP_6.bmp", "area": "TZELUP_6.bmp" },
 			{ "id": 20, "defname": "TBELBOAT.def", "x": 239, "y": 215, "border": "TOELBOAT.bmp", "area": "TZELBOAT.bmp" }
 		  ],
-		  "blit_order": [ -1, 27, 28, 16, 34, 41, 6, 20, 33, 40, 36, 43, 21, 0, 1, 2, 3, 4, 5, 15, 14, 17, 35, 42, 30, 18, 37, 19, 10, 11, 12, 13, 29 ]
+		  "blit_order": [ -1, 27, 28, 16, 34, 41, 6, 20, 33, 40, 36, 43, 21, 0, 1, 2, 3, 4, 5, 15, 14, 17, 35, 42, 30, 18, 37, 19, 10, 11, 12, 13, 29 ],
+		  "creatures_basic": [ 118, 112, 115, 114, 113, 120, 130, 158 ],
+		  "creatures_upgraded": [ 119, 127, 123, 129, 125, 121, 131 ],
 		}
 	],
 

+ 0 - 63
config/creatures_upgr.txt

@@ -1,63 +0,0 @@
-0	0	1
-0	1	3
-0	2	5
-0	3	7
-0	4	9
-0	5	11
-0	6	13
-1	0	15
-1	1	17
-1	2	19
-1	3	21
-1	4	23
-1	5	25
-1	6	27
-2	0	29
-2	1	31
-2	2	33
-2	3	35
-2	4	37
-2	5	39
-2	6	41
-3	0	43
-3	1	45
-3	2	47
-3	3	49
-3	4	51
-3	5	53
-3	6	55
-4	0	57
-4	1	59
-4	2	61
-4	3	63
-4	4	65
-4	5	67
-4	6	69
-5	0	71
-5	1	73
-5	2	75
-5	3	77
-5	4	79
-5	5	81
-5	6	83
-6	0	85
-6	1	87
-6	2	89
-6	3	91
-6	4	93
-6	5	95
-6	6	97
-7	0	99
-7	1	101
-7	2	105
-7	3	107
-7	4	103
-7	5	109
-7	6	111
-8	0	119
-8	1	127
-8	2	123
-8	3	129
-8	4	125
-8	5	121
-8	6	131

+ 25 - 31
lib/CTownHandler.cpp

@@ -46,6 +46,13 @@ void CTownHandler::loadStructures()
 		towns.push_back(town);
 	}
 
+	for(int x=0;x<towns.size();x++) {
+		/* There is actually 8 basic creatures, but we ignore the 8th
+		 * entry for now */
+		towns[x].basicCreatures.resize(7);
+		towns[x].upgradedCreatures.resize(7);
+	}
+
 	structures.resize(F_NUMBER);
 
 	// read city properties
@@ -54,6 +61,7 @@ void CTownHandler::loadStructures()
 	// Iterate for each city type
 	townID = 0;
 	BOOST_FOREACH(const JsonNode &town_node, config["town_type"].Vector()) {
+		int level;
 		std::map<int, Structure*> &town = structures[townID];
 
 		// Read buildings coordinates for that city
@@ -82,11 +90,8 @@ void CTownHandler::loadStructures()
 		}
 
 		// Read buildings blit order for that city
-		const JsonVector &blit_order_vec = town_node["blit_order"].Vector();
 		int itr = 1;
-
-		for (JsonVector::const_iterator it2 = blit_order_vec.begin(); it2!=blit_order_vec.end(); ++it2) {
-			const JsonNode &node = *it2;
+		BOOST_FOREACH(const JsonNode &node, town_node["blit_order"].Vector()) {
 			int buildingID = node.Float();
 
 			/* Find the building and set its order. */
@@ -97,6 +102,22 @@ void CTownHandler::loadStructures()
 				tlog3 << "Warning1: No building " << buildingID << " in the castle " << townID << std::endl;
 		}
 
+		// Read basic creatures belonging to that city
+		level = 0;
+		BOOST_FOREACH(const JsonNode &node, town_node["creatures_basic"].Vector()) {
+			// This if ignores the 8th field (WoG creature)
+			if (level < towns[townID].basicCreatures.size())
+				towns[townID].basicCreatures[level] = node.Float();
+			level ++;
+		}
+
+		// Read upgraded creatures belonging to that city
+		level = 0;
+		BOOST_FOREACH(const JsonNode &node, town_node["creatures_upgraded"].Vector()) {
+			towns[townID].upgradedCreatures[level] = node.Float();
+			level ++;
+		}
+
 		townID ++;
 	}
 
@@ -143,33 +164,6 @@ void CTownHandler::loadStructures()
 	}
 
 	std::ifstream of;
-	for(int x=0;x<towns.size();x++)
-		towns[x].basicCreatures.resize(7);
-
-	of.open(DATA_DIR "/config/basicCres.txt");
-	while(!of.eof())
-	{
-		int tid, lid, cid; //town,level,creature
-		of >> tid >> lid >> cid;
-		if(lid < towns[tid].basicCreatures.size())
-			towns[tid].basicCreatures[lid]=cid;
-	}
-	of.close();
-	of.clear();
-
-	for(int x=0;x<towns.size();x++)
-		towns[x].upgradedCreatures.resize(7);
-
-	of.open(DATA_DIR "/config/creatures_upgr.txt");
-	while(!of.eof())
-	{
-		int tid, lid, cid; //town,level,creature
-		of >> tid >> lid >> cid;
-		if(lid < towns[tid].upgradedCreatures.size())
-			towns[tid].upgradedCreatures[lid]=cid;
-	}
-	of.close();
-	of.clear();
 
 	of.open(DATA_DIR "/config/building_horde.txt");
 	while(!of.eof())