Jelajahi Sumber

Created dwellings.json from cregens.txt.

Frank Zago 14 tahun lalu
induk
melakukan
029b77e7c4
3 mengubah file dengan 123 tambahan dan 119 penghapusan
  1. 0 101
      config/cregens.txt
  2. 108 0
      config/dwellings.json
  3. 15 18
      lib/CObjectHandler.cpp

+ 0 - 101
config/cregens.txt

@@ -1,101 +0,0 @@
-56	0
-57	2
-25	4
-58	6
-35	8
-5	10
-8	12
-80	150
-6	14
-12	16
-15	18
-50	20
-45	22
-51	24
-24	26
-81	151
-43	28
-17	30
-31	34
-18	36
-36	38
-44	40
-82	152
-29	42
-22	44
-27	46
-37	48
-40	50
-14	52
-10	54
-83	153
-54	56
-55	58
-48	60
-53	62
-52	64
-3	66
-4	68
-84	154
-46	70
-26	72
-2	74
-33	76
-34	78
-32	80
-41	82
-85	155
-21	84
-19	86
-39	88
-38	90
-42	92
-9	94
-1	96
-86	156
-20	98
-30	100
-11	104
-0	106
-23	102
-49	108
-28	110
-87	157
-59	118
-07	112
-69	112
-47	115
-72	115
-16	114
-71	114
-13	113
-70	113
-60	120
-61	130
-88	158
-74	139
-73	138
-75	140
-78	143
-77	142
-76	141
-67	137
-79	144
-66	136
-64	134
-65	135
-63	133
-62	132
-89	171
-90	170
-91	168
-92	172
-93	164
-94	169
-95	173
-96	192
-97	193
-98	194
-99	195
-100	196
-68	24

+ 108 - 0
config/dwellings.json

@@ -0,0 +1,108 @@
+{
+	// Indicate which dwelling produces which creature
+	// Note that it is 1<->n connection since
+	// a creature can be produced by more than one dwelling.
+	"dwellings": [
+		{ "dwelling": 0, "creature": 106 },
+		{ "dwelling": 1, "creature": 96 },
+		{ "dwelling": 2, "creature": 74 },
+		{ "dwelling": 3, "creature": 66 },
+		{ "dwelling": 4, "creature": 68 },
+		{ "dwelling": 5, "creature": 10 },
+		{ "dwelling": 6, "creature": 14 },
+		{ "dwelling": 7, "creature": 112 },
+		{ "dwelling": 8, "creature": 12 },
+		{ "dwelling": 9, "creature": 94 },
+		{ "dwelling": 10, "creature": 54 },
+		{ "dwelling": 11, "creature": 104 },
+		{ "dwelling": 12, "creature": 16 },
+		{ "dwelling": 13, "creature": 113 },
+		{ "dwelling": 14, "creature": 52 },
+		{ "dwelling": 15, "creature": 18 },
+		{ "dwelling": 16, "creature": 114 },
+		{ "dwelling": 17, "creature": 30 },
+		{ "dwelling": 18, "creature": 36 },
+		{ "dwelling": 19, "creature": 86 },
+		{ "dwelling": 20, "creature": 98 },
+		{ "dwelling": 21, "creature": 84 },
+		{ "dwelling": 22, "creature": 44 },
+		{ "dwelling": 23, "creature": 102 },
+		{ "dwelling": 24, "creature": 26 },
+		{ "dwelling": 25, "creature": 4 },
+		{ "dwelling": 26, "creature": 72 },
+		{ "dwelling": 27, "creature": 46 },
+		{ "dwelling": 28, "creature": 110 },
+		{ "dwelling": 29, "creature": 42 },
+		{ "dwelling": 30, "creature": 100 },
+		{ "dwelling": 31, "creature": 34 },
+		{ "dwelling": 32, "creature": 80 },
+		{ "dwelling": 33, "creature": 76 },
+		{ "dwelling": 34, "creature": 78 },
+		{ "dwelling": 35, "creature": 8 },
+		{ "dwelling": 36, "creature": 38 },
+		{ "dwelling": 37, "creature": 48 },
+		{ "dwelling": 38, "creature": 90 },
+		{ "dwelling": 39, "creature": 88 },
+		{ "dwelling": 40, "creature": 50 },
+		{ "dwelling": 41, "creature": 82 },
+		{ "dwelling": 42, "creature": 92 },
+		{ "dwelling": 43, "creature": 28 },
+		{ "dwelling": 44, "creature": 40 },
+		{ "dwelling": 45, "creature": 22 },
+		{ "dwelling": 46, "creature": 70 },
+		{ "dwelling": 47, "creature": 115 },
+		{ "dwelling": 48, "creature": 60 },
+		{ "dwelling": 49, "creature": 108 },
+		{ "dwelling": 50, "creature": 20 },
+		{ "dwelling": 51, "creature": 24 },
+		{ "dwelling": 52, "creature": 64 },
+		{ "dwelling": 53, "creature": 62 },
+		{ "dwelling": 54, "creature": 56 },
+		{ "dwelling": 55, "creature": 58 },
+		{ "dwelling": 56, "creature": 0 },
+		{ "dwelling": 57, "creature": 2 },
+		{ "dwelling": 58, "creature": 6 },
+		{ "dwelling": 59, "creature": 118 },
+		{ "dwelling": 60, "creature": 120 },
+		{ "dwelling": 61, "creature": 130 },
+		{ "dwelling": 62, "creature": 132 },
+		{ "dwelling": 63, "creature": 133 },
+		{ "dwelling": 64, "creature": 134 },
+		{ "dwelling": 65, "creature": 135 },
+		{ "dwelling": 66, "creature": 136 },
+		{ "dwelling": 67, "creature": 137 },
+		{ "dwelling": 68, "creature": 24 }
+		{ "dwelling": 69, "creature": 112 },
+		{ "dwelling": 70, "creature": 113 },
+		{ "dwelling": 71, "creature": 114 },
+		{ "dwelling": 72, "creature": 115 },
+		{ "dwelling": 73, "creature": 138 },
+		{ "dwelling": 74, "creature": 139 },
+		{ "dwelling": 75, "creature": 140 },
+		{ "dwelling": 76, "creature": 141 },
+		{ "dwelling": 77, "creature": 142 },
+		{ "dwelling": 78, "creature": 143 },
+		{ "dwelling": 79, "creature": 144 },
+		{ "dwelling": 80, "creature": 150 },
+		{ "dwelling": 81, "creature": 151 },
+		{ "dwelling": 82, "creature": 152 },
+		{ "dwelling": 83, "creature": 153 },
+		{ "dwelling": 84, "creature": 154 },
+		{ "dwelling": 85, "creature": 155 },
+		{ "dwelling": 86, "creature": 156 },
+		{ "dwelling": 87, "creature": 157 },
+		{ "dwelling": 88, "creature": 158 },
+		{ "dwelling": 89, "creature": 171 },
+		{ "dwelling": 90, "creature": 170 },
+		{ "dwelling": 91, "creature": 168 },
+		{ "dwelling": 92, "creature": 172 },
+		{ "dwelling": 93, "creature": 164 },
+		{ "dwelling": 94, "creature": 169 },
+		{ "dwelling": 95, "creature": 173 },
+		{ "dwelling": 96, "creature": 192 },
+		{ "dwelling": 97, "creature": 193 },
+		{ "dwelling": 98, "creature": 194 },
+		{ "dwelling": 99, "creature": 195 },
+		{ "dwelling": 100, "creature": 196 },
+	]
+}

+ 15 - 18
lib/CObjectHandler.cpp

@@ -27,6 +27,7 @@
 #include <boost/format.hpp>
 #include <boost/algorithm/string/trim.hpp>
 #include "CBuildingHandler.h"
+#include "../lib/JsonNode.h"
 
 using namespace boost::assign;
 
@@ -181,27 +182,23 @@ void CObjectHandler::readConfigLine(std::ifstream &istr, int g)
 
 void CObjectHandler::loadObjects()
 {
+	tlog5 << "\t\tReading cregens \n";
+	cregens.resize(110); //TODO: hardcoded value - change
+	for(size_t i=0; i < cregens.size(); ++i)
 	{
-		tlog5 << "\t\tReading cregens \n";
-		cregens.resize(110); //TODO: hardcoded value - change
-		for(size_t i=0; i < cregens.size(); ++i)
-		{
-			cregens[i]=-1;
-		}
-		std::ifstream ifs(DATA_DIR "/config/cregens.txt");
-		while(!ifs.eof())
-		{
-			int dw, cr;
-			ifs >> dw >> cr;
-			cregens[dw]=cr;
-		}
-		tlog5 << "\t\tDone loading objects!\n";
+		cregens[i]=-1;
+	}
 
-		ifs.close();
-		ifs.clear();
+	const JsonNode config(DATA_DIR "/config/dwellings.json");
+	BOOST_FOREACH(const JsonNode &dwelling, config["dwellings"].Vector())
+	{
+		cregens[dwelling["dwelling"].Float()] = dwelling["creature"].Float();
+	}
+	tlog5 << "\t\tDone loading cregens!\n";
 
+	{
 		int k = -1;
-		ifs.open(DATA_DIR "/config/resources.txt");
+		std::ifstream ifs(DATA_DIR "/config/resources.txt");
 		ifs >> k;
 		int pom;
 		for(int i=0;i<k;i++)
@@ -7112,4 +7109,4 @@ int GrowthInfo::totalGrowth() const
 		ret += entry.count;
 
 	return ret;
-}
+}