Browse Source

multiple changes in config system, breaks existing mods. See upcoming post on forums.
- filesystem initialization works in conjuction with modHandler
- (config) split buildings.json in multiple files in "factions" directory
- (mods) merged filesystem.json and config/mod.json into mod.json

Ivan Savenko 13 years ago
parent
commit
04358ed0c6

+ 5 - 1
Mods/WoG/filesystem.json → Mods/WoG/mod.json

@@ -31,5 +31,9 @@
 		[
 		[
 			{"type" : "dir", "path" : "ALL/MODS/WOG/Maps"}
 			{"type" : "dir", "path" : "ALL/MODS/WOG/Maps"}
 		],
 		],
-	}
+	},
+
+	"name" : "In The Wake of Gods",
+	"description" : "Unnofficial addon for Heroes of Might and Magic III",
+	"priority" : 5
 }
 }

+ 5 - 1
Mods/vcmi/filesystem.json → Mods/vcmi/mod.json

@@ -13,5 +13,9 @@
 		[
 		[
 			{"type" : "dir",  "path" : "ALL/MODS/VCMI/Maps"}
 			{"type" : "dir",  "path" : "ALL/MODS/VCMI/Maps"}
 		]
 		]
-	}
+	},
+
+	"name" : "VCMI essential files",
+	"description" : "Essential files required for VCMI to run correctly",
+	"priority" : 10
 }
 }

+ 2 - 2
client/CMT.cpp

@@ -130,7 +130,7 @@ void init()
 	tlog0<<"\tInitializing sound: "<<pomtime.getDiff()<<std::endl;
 	tlog0<<"\tInitializing sound: "<<pomtime.getDiff()<<std::endl;
 	tlog0<<"Initializing screen and sound handling: "<<tmh.getDiff()<<std::endl;
 	tlog0<<"Initializing screen and sound handling: "<<tmh.getDiff()<<std::endl;
 
 
-	initDLL(::console,logfile);
+	loadDLLClasses();
 	const_cast<CGameInfo*>(CGI)->setFromLib();
 	const_cast<CGameInfo*>(CGI)->setFromLib();
 	CCS->soundh->initCreaturesSounds(CGI->creh->creatures);
 	CCS->soundh->initCreaturesSounds(CGI->creh->creatures);
 	CCS->soundh->initSpellsSounds(CGI->spellh->spells);
 	CCS->soundh->initSpellsSounds(CGI->spellh->spells);
@@ -241,7 +241,7 @@ int main(int argc, char** argv)
 	atexit(dispose);
 	atexit(dispose);
 	tlog0 <<"Creating console and logfile: "<<pomtime.getDiff() << std::endl;
 	tlog0 <<"Creating console and logfile: "<<pomtime.getDiff() << std::endl;
 
 
-	LibClasses::loadFilesystem();
+	preinitDLL(::console, logfile);
 
 
 	settings.init();
 	settings.init();
 	conf.init();
 	conf.init();

+ 0 - 2225
config/buildings.json

@@ -1,2225 +0,0 @@
-{
-	"castle" :
-	{
-		"index" : 0,
-		"nativeTerrain": "grass",
-		"alignment" : "good",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASCAS",
-			"130px" : "CRBKGCAS"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZCAS",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 39 },
-				{ "x": 7, "y": 30, "index": 41 },
-				{ "x": 7, "y": 102, "index": 1 },
-				{ "x": 7, "y": 156, "index": 23 },
-				{ "x": 7, "y": 202, "index": 6 },
-				{ "x": 7, "y": 320, "index": 13 },
-				{ "x": 16, "y": 8, "index": 39 },
-				{ "x": 22, "y": 406, "index": 2 },
-				{ "x": 70, "y": 301, "index": 22 },
-				{ "x": 72, "y": 194, "index": 11 },
-				{ "x": 101, "y": 332, "index": 8 },
-				{ "x": 106, "y": 8, "index": 9 },
-				{ "x": 106, "y": 31, "index": 29 },
-				{ "x": 114, "y": 60, "index": 7 },
-				{ "x": 126, "y": 329, "index": 17 },
-				{ "x": 128, "y": 191, "index": 21 },
-				{ "x": 152, "y": 347, "index": 27 },
-				{ "x": 154, "y": 239, "index": 31 },
-				{ "x": 157, "y": 429, "index": 34 },
-				{ "x": 166, "y": 470, "index": 4 },
-				{ "x": 185, "y": 127, "index": 30 },
-				{ "x": 212, "y": 335, "index": 36 },
-				{ "x": 214, "y": 191, "index": 48 },
-				{ "x": 217, "y": 226, "index": 43 },
-				{ "x": 235, "y": 147, "index": 35 },
-				{ "x": 245, "y": 77, "index": 16 },
-				{ "x": 266, "y": 384, "index": 42 },
-				{ "x": 288, "y": 288, "index": 45 },
-				{ "x": 298, "y": 8, "index": 26 },
-				{ "x": 321, "y": 177, "index": 46 },
-				{ "x": 346, "y": 67, "index": 38 },
-				{ "x": 354, "y": 459, "index": 20 },
-				{ "x": 355, "y": 397, "index": 25 },
-				{ "x": 375, "y": 162, "index": 28 },
-				{ "x": 382, "y": 255, "index": 32 },
-				{ "x": 408, "y": 32, "index": 37 },
-				{ "x": 408, "y": 111, "index": 14 },
-				{ "x": 421, "y": 147, "index": 19 },
-				{ "x": 422, "y": 466, "index": 12 },
-				{ "x": 426, "y": 8, "index": 15 },
-				{ "x": 436, "y": 238, "index": 24 },
-				{ "x": 458, "y": 336, "index": 44 },
-				{ "x": 486, "y": 8, "index": 40 },
-				{ "x": 487, "y": 144, "index": 33 },
-				{ "x": 517, "y": 145, "index": 18 },
-				{ "x": 520, "y": 68, "index": 5 },
-				{ "x": 524, "y": 234, "index": 10 },
-				{ "x": 525, "y": 327, "index": 3 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCcasx0.def",
-				"village" : "AVCCAST0.DEF",
-				"capitol" : "AVCCASZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBCSEXT2.def", "x" : 46,  "y" : 119 },
-				{ "id" : 0,  "animation" : "TBCSMAGE.def", "x" : 707, "y" : 166, "z" : 1, "border" : "TOCSMAG1.bmp", "area" : "TZCSMAG1.bmp" },
-				{ "id" : 1,  "animation" : "TBCSMAG2.def", "x" : 706, "y" : 135, "z" : 1, "border" : "TOCSMAG2.bmp", "area" : "TZCSMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBCSMAG3.def", "x" : 704, "y" : 107, "z" : 1, "border" : "TOCSM301.bmp", "area" : "TZCSM301.bmp" },
-				{ "id" : 3,  "animation" : "TBCSMAG4.def", "x" : 704, "y" : 76,  "z" : 1, "border" : "TOCSM401.bmp", "area" : "TZCSM401.bmp" },
-				{ "id" : 5,  "animation" : "TBCSTVRN.def", "x" : 0,   "y" : 230, "z" : 1, "border" : "TOCSTAV1.bmp", "area" : "TZCSTAV1.bmp" },
-				{ "id" : 6,  "animation" : "TBCSDOCK.def", "x" : 478, "y" : 134, "border" : "TOCSDKMS.bmp", "area" : "TZCSDKMS.bmp" },
-				{ "id" : 7,  "animation" : "TBCSCSTL.def", "x" : 595, "y" : 66,  "border" : "TOCSCAS1.bmp", "area" : "TZCSCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBCSCAS2.def", "x" : 478, "y" : 66,  "border" : "TOCSCAS2.bmp", "area" : "TZCSCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBCSCAS3.def", "x" : 478, "y" : 37,  "border" : "TOCSCAS3.bmp", "area" : "TZCSCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBCSHALL.def", "x" : 0,   "y" : 209, "border" : "TOCSH101.bmp", "area" : "TZCSH101.bmp" },
-				{ "id" : 11, "animation" : "TBCSHAL2.def", "x" : 0,   "y" : 176, "border" : "TOCSH201.bmp", "area" : "TZCSH201.bmp" },
-				{ "id" : 12, "animation" : "TBCSHAL3.def", "x" : 0,   "y" : 164, "border" : "TOCSH301.bmp", "area" : "TZCSH301.bmp" },
-				{ "id" : 13, "animation" : "TBCSHAL4.def", "x" : 0,   "y" : 154, "border" : "TOCSH401.bmp", "area" : "TZCSH401.bmp" },
-				{ "id" : 14, "animation" : "TBCSMARK.def", "x" : 413, "y" : 264, "border" : "TOCSMRK1.bmp", "area" : "TZCSMRK1.bmp" },
-				{ "id" : 15, "animation" : "TBCSSILO.def", "x" : 488, "y" : 228, "border" : "TOCSMRK2.bmp", "area" : "TZCSMRK2.bmp" },
-				{ "id" : 16, "animation" : "TBCSBLAK.def", "x" : 213, "y" : 251, "border" : "TOCSBLAK.bmp", "area" : "TZCSBLAK.bmp" },
-				{ "id" : 17, "animation" : "TBCSSPEC.def", "x" : 533, "y" : 71,  "border" : "TOCSLT01.bmp", "area" : "TZCSLT01.bmp" },
-				{ "id" : 18, "animation" : "TBCSHRD1.def", "x" : 76,  "y" : 53,  "border" : "TOCSGR1H.bmp", "area" : "TZCSGR1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBCSHRD2.def", "x" : 76,  "y" : 35,  "border" : "TOCSGR2H.bmp", "area" : "TZCSGR2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 20, "animation" : "TBCSBOAT.def", "x" : 478, "y" : 134, "border" : "TOCSDKMN.bmp", "area" : "TZCSDKMN.bmp", "hidden" : true },
-				{ "id" : 21, "animation" : "TBCSEXT0.def", "x" : 384, "y" : 193, "z" : -2, "border" : "TOCSCAVM.bmp", "area" : "TZCSCAVM.bmp" },
-				{ "id" : 22, "animation" : "TBCSEXT1.def", "x" : 0,   "y" : 198, "z" :  1, "border" : "TOCSTAV2.bmp", "area" : "TZCSTAV2.bmp" },
-				{ "id" : 26, "animation" : "TBCSHOLY.def", "x" : 456, "y" : 109, "z" : -1, "border" : "TOCSHOLY.bmp", "area" : "TZCSHOLY.bmp" },
-				{ "id" : 30, "animation" : "TBCSDW_0.def", "x" : 304, "y" : 92,  "border" : "TOCSPIK1.bmp", "area" : "TZCSPIK1.bmp" },
-				{ "id" : 31, "animation" : "TBCSDW_1.def", "x" : 360, "y" : 130, "border" : "TOCSCRS1.bmp", "area" : "TZCSCRS1.bmp" },
-				{ "id" : 32, "animation" : "TBCSDW_2.def", "x" : 76,  "y" : 57,  "border" : "TOCSGR1N.bmp", "area" : "TZCSGR1N.bmp" },
-				{ "id" : 33, "animation" : "TBCSDW_3.def", "x" : 176, "y" : 101, "border" : "TOCSSWD1.bmp", "area" : "TZCSSWD1.bmp" },
-				{ "id" : 34, "animation" : "TBCSDW_4.def", "x" : 563, "y" : 211, "z" : 1,  "border" : "TOCSMON1.bmp", "area" : "TZCSMON1.bmp" },
-				{ "id" : 35, "animation" : "TBCSDW_5.def", "x" : 174, "y" : 190, "z" : -1, "border" : "TOCSC101.bmp", "area" : "TZCSCAV1.bmp" },
-				{ "id" : 36, "animation" : "TBCSDW_6.def", "x" : 303, "y" : 0,   "z" : -1, "border" : "TOCSANG1.bmp", "area" : "TZCSANG1.bmp" },
-				{ "id" : 37, "animation" : "TBCSUP_0.def", "x" : 304, "y" : 65,  "border" : "TOCSPIK2.bmp", "area" : "TZCSPIK2.bmp" },
-				{ "id" : 38, "animation" : "TBCSUP_1.def", "x" : 360, "y" : 115, "border" : "TOCSCRS2.bmp", "area" : "TZCSCRS2.bmp" },
-				{ "id" : 39, "animation" : "TBCSUP_2.def", "x" : 76,  "y" : 35,  "border" : "TOCSGR2N.bmp", "area" : "TZCSGR2N.bmp" },
-				{ "id" : 40, "animation" : "TBCSUP_3.def", "x" : 176, "y" : 85,  "border" : "TOCSSWD2.bmp", "area" : "TZCSSWD2.bmp" },
-				{ "id" : 41, "animation" : "TBCSUP_4.def", "x" : 563, "y" : 173, "z" : 1,  "border" : "TOCSMON2.bmp", "area" : "TZCSMON2.bmp" },
-				{ "id" : 42, "animation" : "TBCSUP_5.def", "x" : 160, "y" : 190, "z" : -1, "border" : "TOCSCAV2.bmp", "area" : "TZCSCAV2.bmp" },
-				{ "id" : 43, "animation" : "TBCSUP_6.def", "x" : 303, "y" : 0,   "z" : -1, "border" : "TOCSANG2.bmp", "area" : "TZCSANG2.bmp" },
-
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 18, "built" : 19 },
-				"fort"    : {"normal" : 0,  "built" : 1 }
-			},
-
-			"musicTheme" : "music/CstleTown",
-
-			"townBackground": "TBCSBACK.bmp",
-			"guildWindow": "TPMAGECS.bmp",
-			"buildingsIcons": "HALLCSTL.DEF",
-			"hallBackground": "TPTHBKCS.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5, 22 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3 ], [ 6, 17 ] ],
-				[ [ 21 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Pikeman", "Halberdier"],
-				["Archer", "HeavyCrossbowman"],
-				["Griffin", "RoyalGriffin"],
-				["Swordsman", "Crusader"],
-				["Monk", "Zealot"],
-				["Cavalier", "Champion"],
-				["Angel", "Archangel"]
-			],
-			"horde" : [ 2, -1 ],
-			"mageGuild" : 4,
-			"warMachine" : "Ballista",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 6 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 6 ] },
-				{ "id" : 18, "upgrades" : 32 },
-				{ "id" : 19, "upgrades" : 39, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 20, "upgrades" : 6 },
-				{ "id" : 21, "requires" : [ 33 ] },
-				{ "id" : 22, "upgrades" : 5 },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 33 ] },
-				{ "id" : 33, "requires" : [ 16, 30 ] },
-				{ "id" : 34, "requires" : [ 0, 33 ] },
-				{ "id" : 35, "requires" : [ 21 ] },
-				{ "id" : 36, "requires" : [ 34 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33 },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Archer",
-				"imagePrefix" : "SGCS",
-				"gate" :
-				{
-					"arch" : { "x" : 477, "y" : 238 },
-					"gate" : { "x" : 399, "y" : 274 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 403, "y" : 80 },
-					"moat" : { "x" : 410, "y" : 90 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 600, "y" : 49 },
-					"bottom" : { "x" : 512, "y" : 347 },
-					"top" : { "x" : 489, "y" : 79 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 602, "y" : 500 },
-						"creature" : { "x" : 394, "y" : 299	},
-						"tower" : { "x" : 602, "y" : 500 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 720, "y" : 158 },
-						"creature" : { "x" : 526, "y" : -29 },
-						"tower" : { "x" : 720, "y" : 158 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 557, "y" : 24 },
-						"creature" : { "x" : 342, "y" : -187 },
-						"tower" : { "x" : 569, "y" : 35 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 528, "y" : 350 },
-					"bottomMid" : { "x" : 469, "y" : 291 },
-					"upper" : { "x" : 524, "y" : 32 },
-					"upperMid" : { "x" : 470, "y" : 127 }
-				}
-			}
-		}
-	},
-	"rampart" :
-	{
-		"index" : 1,
-		"nativeTerrain": "grass",
-		"alignment" : "good",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASRAM",
-			"130px" : "CRBKGRAM"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZRAM",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 2 },
-				{ "x": 7, "y": 101, "index": 13 },
-				{ "x": 7, "y": 195, "index": 20 },
-				{ "x": 7, "y": 310, "index": 6 },
-				{ "x": 7, "y": 378, "index": 22 },
-				{ "x": 7, "y": 449, "index": 21 },
-				{ "x": 61, "y": 8, "index": 19 },
-				{ "x": 97, "y": 42, "index": 8 },
-				{ "x": 98, "y": 201, "index": 24 },
-				{ "x": 108, "y": 308, "index": 36 },
-				{ "x": 115, "y": 461, "index": 1 },
-				{ "x": 129, "y": 366, "index": 7 },
-				{ "x": 134, "y": 8, "index": 4 },
-				{ "x": 157, "y": 188, "index": 25 },
-				{ "x": 160, "y": 309, "index": 39 },
-				{ "x": 162, "y": 441, "index": 11 },
-				{ "x": 164, "y": 126, "index": 28 },
-				{ "x": 174, "y": 390, "index": 33 },
-				{ "x": 178, "y": 188, "index": 46 },
-				{ "x": 187, "y": 258, "index": 41 },
-				{ "x": 190, "y": 24, "index": 38 },
-				{ "x": 215, "y": 272, "index": 45 },
-				{ "x": 255, "y": 443, "index": 9 },
-				{ "x": 265, "y": 323, "index": 40 },
-				{ "x": 277, "y": 45, "index": 47 },
-				{ "x": 278, "y": 383, "index": 27 },
-				{ "x": 292, "y": 196, "index": 43 },
-				{ "x": 294, "y": 266, "index": 48 },
-				{ "x": 310, "y": 8, "index": 17 },
-				{ "x": 330, "y": 493, "index": 16 },
-				{ "x": 339, "y": 8, "index": 12 },
-				{ "x": 339, "y": 167, "index": 29 },
-				{ "x": 344, "y": 108, "index": 35 },
-				{ "x": 361, "y": 239, "index": 31 },
-				{ "x": 363, "y": 385, "index": 44 },
-				{ "x": 398, "y": 310, "index": 42 },
-				{ "x": 400, "y": 130, "index": 23 },
-				{ "x": 404, "y": 436, "index": 32 },
-				{ "x": 421, "y": 127, "index": 26 },
-				{ "x": 429, "y": 8, "index": 37 },
-				{ "x": 430, "y": 106, "index": 30 },
-				{ "x": 462, "y": 393, "index": 14 },
-				{ "x": 469, "y": 270, "index": 10 },
-				{ "x": 486, "y": 8, "index": 3 },
-				{ "x": 499, "y": 481, "index": 15 },
-				{ "x": 511, "y": 255, "index": 34 },
-				{ "x": 516, "y": 48, "index": 18 },
-				{ "x": 525, "y": 169, "index": 5 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCramx0.def",
-				"village" : "AVCRAMP0.DEF",
-				"capitol" : "AVCRAMZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBRMEXT2.def", "x" : 327, "y" : 236 },
-				{ "id" : 0,  "animation" : "TBRMMAGE.def", "x" : 454, "y" : 200, "z" : -1, "border" : "TORMAG1.bmp",  "area" : "TZRMAG1.bmp" },
-				{ "id" : 1,  "animation" : "TBRMMAG2.def", "x" : 438, "y" : 178, "z" : -1, "border" : "TORMAG2.bmp",  "area" : "TZRMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBRMMAG3.def", "x" : 418, "y" : 153, "z" : -1, "border" : "TORMAG3.bmp",  "area" : "TZRMAG3.bmp" },
-				{ "id" : 3,  "animation" : "TBRMMAG4.def", "x" : 406, "y" : 129, "z" : -1, "border" : "TORMAG4.bmp",  "area" : "TZRMAG4.bmp" },
-				{ "id" : 4,  "animation" : "TBRMMAG5.def", "x" : 384, "y" : 104, "z" : -1, "border" : "TORMAG5.bmp",  "area" : "TZRMAG5.bmp" },
-				{ "id" : 5,  "animation" : "TBRMTVRN.def", "x" : 181, "y" : 229, "z" : 1,  "border" : "TORTAV.bmp",   "area" : "TZRTAV.bmp" },
-				{ "id" : 7,  "animation" : "TBRMCSTL.def", "x" : 63,  "y" : 25,  "z" : -2, "border" : "TORCAS1.bmp",  "area" : "TZRCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBRMCAS2.def", "x" : 79,  "y" : 18,  "z" : -2, "border" : "TORCAS3.bmp",  "area" : "TZRCAS3.bmp" },
-				{ "id" : 9,  "animation" : "TBRMCAS3.def", "x" : 79,  "y" : 18,  "z" : -2, "border" : "TORCAS2.bmp",  "area" : "TZRCAS2.bmp" },
-				{ "id" : 10, "animation" : "TBRMHALL.def", "x" : 565, "y" : 216, "border" : "TORHAL1.bmp",  "area" : "TZRHAL1.bmp" },
-				{ "id" : 11, "animation" : "TBRMHAL2.def", "x" : 538, "y" : 187, "border" : "TORHAL2.bmp",  "area" : "TZRHAL2.bmp" },
-				{ "id" : 12, "animation" : "TBRMHAL3.def", "x" : 538, "y" : 187, "border" : "TORHAL3.bmp",  "area" : "TZRHAL3.bmp" },
-				{ "id" : 13, "animation" : "TBRMHAL4.def", "x" : 534, "y" : 187, "border" : "TORHAL4.bmp",  "area" : "TZRHAL4.bmp" },
-				{ "id" : 14, "animation" : "TBRMMARK.def", "x" : 129, "y" : 301, "z" : 3,  "border" : "TORMRK1.bmp",  "area" : "TZRMRK1.bmp" },
-				{ "id" : 15, "animation" : "TBRMSILO.def", "x" : 245, "y" : 324, "z" : 4,  "border" : "TORMRK2.bmp",  "area" : "TZRMRK2.bmp" },
-				{ "id" : 16, "animation" : "TBRMBLAK.def", "x" : 558, "y" : 105, "z" : -3, "border" : "TORAID.bmp",   "area" : "TZRAID.bmp" },
-				{ "id" : 17, "animation" : "TBRMSPEC.def", "x" : 555, "y" : 297, "border" : "TORGAR1A.bmp", "area" : "TZRGAR1A.bmp" },
-				{ "id" : 18, "animation" : "TBRMHRD1.def", "x" : 0,   "y" : 154, "border" : "TORDWF1H.bmp", "area" : "TZRDWF1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBRMHRD2.def", "x" : 0,   "y" : 143, "border" : "TORDWF2H.bmp", "area" : "TZRDWF2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 21, "animation" : "TBRMEXT0.def", "x" : 555, "y" : 297, "z" : 2, "border" : "TORGAR2A.bmp", "area" : "TZRGAR2A.bmp" },
-				{ "id" : 22, "animation" : "TBRMEXT1.def", "x" : 0,   "y" : 181, "z" : 1, "border" : "TORDWFT.bmp",  "area" : "TZRDWFT.bmp" },
-				{ "id" : 24, "animation" : "TBRMHRD3.def", "x" : 47,  "y" : 142, "z" : -1, "border" : "TORTRE1H.bmp", "area" : "TZRTRE1H.bmp", "hidden" : true },
-				{ "id" : 25, "animation" : "TBRMHRD4.def", "x" : 47,  "y" : 142, "z" : -1, "border" : "TORTRE2H.bmp", "area" : "TZRTRE2H.bmp", "hidden" : true, "builds" : 24 },
-				{ "id" : 26, "animation" : "TBRMHOLY.def", "x" : 0,   "y" : 54,  "z" : -1, "border" : "TORHOLY.bmp",  "area" : "TZRHOLY.bmp" },
-				{ "id" : 27, "animation" : "TBRMEXT3.def", "x" : 293, "y" : 235 },
-				{ "id" : 28, "animation" : "TBRMEXT4.def", "x" : 295, "y" : 191 },
-				{ "id" : 29, "animation" : "TBRMEXT5.def", "x" : 260, "y" : 171 },
-				{ "id" : 30, "animation" : "TBRMDW_0.def", "x" : 0,   "y" : 236, "z" : 2,  "border" : "TORCEN1A.bmp", "area" : "TZRCEN1A.bmp" },
-				{ "id" : 31, "animation" : "TBRMDW_1.def", "x" : 0,   "y" : 154, "border" : "TORDWF1.bmp",  "area" : "TZRDWF1.bmp" },
-				{ "id" : 32, "animation" : "TBRMDW_2.def", "x" : 668, "y" : 101, "border" : "TORELF1.bmp",  "area" : "TZRELF1.bmp" },
-				{ "id" : 33, "animation" : "TBRMDW_3.def", "x" : 287, "y" : 73,  "z" : -1, "border" : "TORPEG1A.bmp", "area" : "TZRPEG1A.bmp" },
-				{ "id" : 34, "animation" : "TBRMDW_4.def", "x" : 68,  "y" : 146, "z" : -1, "border" : "TORTRE1.bmp",  "area" : "TZRTRE1.bmp" },
-				{ "id" : 35, "animation" : "TBRMDW_5.def", "x" : 362, "y" : 90,  "z" : -2, "border" : "TORUNI1.bmp",  "area" : "TZRUNI1.bmp" },
-				{ "id" : 36, "animation" : "TBRMDW_6.def", "x" : 502, "y" : 27,  "z" : -5, "border" : "TORDR1AA.bmp", "area" : "TZRDR1AA.bmp" },
-				{ "id" : 37, "animation" : "TBRMUP_0.def", "x" : 0,   "y" : 236, "z" : 2,  "border" : "TORCEN2A.bmp", "area" : "TZRCEN2A.bmp" },
-				{ "id" : 38, "animation" : "TBRMUP_1.def", "x" : 0,   "y" : 143, "border" : "TORDWF2.bmp",  "area" : "TZRDWF2.bmp" },
-				{ "id" : 39, "animation" : "TBRMUP_2.def", "x" : 665, "y" : 101, "border" : "TORELF2.bmp",  "area" : "TZRELF2.bmp" },
-				{ "id" : 40, "animation" : "TBRMUP_3.def", "x" : 287, "y" : 28,  "z" : -1, "border" : "TORPEG2A.bmp", "area" : "TZRPEG2A.bmp" },
-				{ "id" : 41, "animation" : "TBRMUP_4.def", "x" : 63,  "y" : 146, "z" : -1, "border" : "TORTRE2.bmp",  "area" : "TZRTRE2.bmp" },
-				{ "id" : 42, "animation" : "TBRMUP_5.def", "x" : 362, "y" : 90,  "z" : -2, "border" : "TORUNI2.bmp",  "area" : "TZRUNI2.bmp" },
-				{ "id" : 43, "animation" : "TBRMUP_6.def", "x" : 502, "y" : 5,   "z" : -5, "border" : "TORDR2AA.bmp", "area" : "TZRDR2AA.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 20, "built" : 21 },
-				"fort"    : {"normal" : 2,  "built" : 3 }
-			},
-
-			"musicTheme" : "music/Rampart",
-
-			"townBackground": "TBRMBACK.bmp",
-			"guildWindow": "TPMAGERM.bmp",
-			"buildingsIcons": "HALLRAMP.DEF",
-			"hallBackground": "TPTHBKRM.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 17, 21 ] ],
-				[ [ 22 ], [ 24, 25 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Centaur", "EliteCentaur"],
-				["Dwarf", "BattleDwarf"],
-				["WoodElf", "GrandElf"],
-				["Pegasus", "SilverPegasus"],
-				["Treefolk", "BriarTreefolk"],
-				["Unicorn", "WarUnicorn"],
-				["GreenDragon", "GoldDragon"]
-			],
-			"horde" : [ 1, 4 ],
-			"mageGuild" : 5,
-			"primaryResource" : "crystal",
-			"warMachine" : "FirstAidTent",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17 },
-				{ "id" : 18, "upgrades" : 31 },
-				{ "id" : 19, "upgrades" : 38, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 21, "requires" : [ 17 ] },
-				{ "id" : 22, "requires" : [ 18, 19 ] },
-				{ "id" : 24, "upgrades" : 34 },
-				{ "id" : 25, "upgrades" : 41, "requires" : [ 24 ], "mode" : "auto" },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 26 },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 32 ] },
-				{ "id" : 34, "requires" : [ 32 ] },
-				{ "id" : 35, "requires" : [ 33, 34 ] },
-				{ "id" : 36, "requires" : [ 35, 1 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33 },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36, "requires" : [ 2 ] }
-			],
-
-			"siege" :
-			{
-				"shooter" : "WoodElf",
-				"imagePrefix" : "SGRM",
-				"gate" :
-				{
-					"arch" : { "x" : 460, "y" : 220 },
-					"gate" : { "x" : 403, "y" : 271 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 410, "y" : 97 },
-					"moat" : { "x" : 410, "y" : 77 }
-				},
-				"shooterHeight" : 232,
-				"static" :
-				{
-					"background" : { "x" : 608, "y" : 46 },
-					"bottom" : { "x" : 510, "y" : 364 },
-					"top" : { "x" : 492, "y" : 103 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 594, "y" : 511 },
-						"creature" : { "x" : 371, "y" : 296 },
-						"tower" : { "x" : 594, "y" : 511 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 724, "y" : 189 },
-						"creature" : { "x" : 532, "y" : -27 },
-						"tower" : { "x" : 724, "y" : 189 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 566, "y" : 31 },
-						"creature" : { "x" : 341, "y" : -186 },
-						"tower" : { "x" : 565, "y" : 31 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 549, "y" : 451 },
-					"bottomMid" : { "x" : 469, "y" : 309 },
-					"upper" : { "x" : 530, "y" : 57 },
-					"upperMid" : { "x" : 469, "y" : 186 }
-				}
-			}
-		}
-	},
-	"tower" :
-	{
-		"index" : 2,
-		"nativeTerrain" : "snow",
-		"alignment" : "good",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASTOW",
-			"130px" : "CRBKGTOW"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZTOW",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 1 },
-				{ "x": 7, "y": 52, "index": 13 },
-				{ "x": 7, "y": 243, "index": 8 },
-				{ "x": 7, "y": 486, "index": 22 },
-				{ "x": 26, "y": 391, "index": 7 },
-				{ "x": 27, "y": 31, "index": 23 },
-				{ "x": 27, "y": 89, "index": 31 },
-				{ "x": 28, "y": 303, "index": 20 },
-				{ "x": 28, "y": 336, "index": 25 },
-				{ "x": 37, "y": 234, "index": 33 },
-				{ "x": 59, "y": 77, "index": 6 },
-				{ "x": 76, "y": 462, "index": 15 },
-				{ "x": 91, "y": 245, "index": 34 },
-				{ "x": 114, "y": 31, "index": 19 },
-				{ "x": 118, "y": 323, "index": 42 },
-				{ "x": 132, "y": 87, "index": 36 },
-				{ "x": 163, "y": 370, "index": 40 },
-				{ "x": 171, "y": 255, "index": 21 },
-				{ "x": 192, "y": 8, "index": 28 },
-				{ "x": 212, "y": 483, "index": 38 },
-				{ "x": 228, "y": 95, "index": 44 },
-				{ "x": 231, "y": 205, "index": 46 },
-				{ "x": 293, "y": 380, "index": 10 },
-				{ "x": 297, "y": 190, "index": 43 },
-				{ "x": 297, "y": 260, "index": 48 },
-				{ "x": 298, "y": 8, "index": 17 },
-				{ "x": 298, "y": 89, "index": 35 },
-				{ "x": 312, "y": 462, "index": 29 },
-				{ "x": 320, "y": 261, "index": 45 },
-				{ "x": 340, "y": 17, "index": 37 },
-				{ "x": 350, "y": 121, "index": 12 },
-				{ "x": 350, "y": 174, "index": 41 },
-				{ "x": 355, "y": 371, "index": 27 },
-				{ "x": 357, "y": 469, "index": 3 },
-				{ "x": 376, "y": 289, "index": 11 },
-				{ "x": 388, "y": 8, "index": 4 },
-				{ "x": 407, "y": 45, "index": 47 },
-				{ "x": 421, "y": 284, "index": 30 },
-				{ "x": 436, "y": 159, "index": 39 },
-				{ "x": 445, "y": 8, "index": 18 },
-				{ "x": 445, "y": 211, "index": 26 },
-				{ "x": 463, "y": 422, "index": 24 },
-				{ "x": 477, "y": 29, "index": 2 },
-				{ "x": 497, "y": 153, "index": 5 },
-				{ "x": 499, "y": 108, "index": 14 },
-				{ "x": 503, "y": 281, "index": 16 },
-				{ "x": 537, "y": 418, "index": 9 },
-				{ "x": 556, "y": 215, "index": 32 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCtowx0.def",
-				"village" : "AVCTOWR0.DEF",
-				"capitol" : "AVCTOWZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "id" : 0,  "animation" : "TBTWMAGE.def", "x" : 597, "y" : 82,  "border" : "TOTGLD1.bmp",  "area" : "TZTGLD1.bmp" },
-				{ "id" : 1,  "animation" : "TBTWMAG2.def", "x" : 593, "y" : 65,  "border" : "TOTGLD2.bmp",  "area" : "TZTGLD2.bmp" },
-				{ "id" : 2,  "animation" : "TBTWMAG3.def", "x" : 593, "y" : 48,  "border" : "TOTGLD3.bmp",  "area" : "TZTGLD3.bmp" },
-				{ "id" : 3,  "animation" : "TBTWMAG4.def", "x" : 593, "y" : 31,  "border" : "TOTGLD4.bmp",  "area" : "TZTGLD4.bmp" },
-				{ "id" : 4,  "animation" : "TBTWMAG5.def", "x" : 593, "y" : 14,  "border" : "TOTGLD5.bmp",  "area" : "TZTGLD5.bmp" },
-				{ "id" : 5,  "animation" : "TBTWTVRN.def", "x" : 375, "y" : 278, "z" : 1, "border" : "TOTTAV.bmp",   "area" : "TZTTAV.bmp" },
-				{ "id" : 7,  "animation" : "TBTWCSTL.def", "x" : 304, "y" : 0,   "border" : "TOTCAS1.bmp",  "area" : "TZTCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBTWCAS2.def", "x" : 301, "y" : 0,   "border" : "TOTCAS2.bmp",  "area" : "TZTCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBTWCAS3.def", "x" : 301, "y" : 0,   "border" : "TOTCAS3.bmp",  "area" : "TZTCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBTWHALL.def", "x" : 0,   "y" : 259, "z" : 1,  "border" : "TOTHAL1.bmp",  "area" : "TZTHAL1.bmp" },
-				{ "id" : 11, "animation" : "TBTWHAL2.def", "x" : 0,   "y" : 220, "z" : 1,  "border" : "TOTHAL2.bmp",  "area" : "TZTHAL2.bmp" },
-				{ "id" : 12, "animation" : "TBTWHAL3.def", "x" : 0,   "y" : 82,  "z" : 1,  "border" : "TOTHAL3.bmp",  "area" : "TZTHAL3.bmp" },
-				{ "id" : 13, "animation" : "TBTWHAL4.def", "x" : 0,   "y" : 82,  "z" : 1,  "border" : "TOTHAL4.bmp",  "area" : "TZTHAL4.bmp" },
-				{ "id" : 14, "animation" : "TBTWMARK.def", "x" : 614, "y" : 292, "border" : "TOTMRK.bmp",   "area" : "TZTMRK.bmp" },
-				{ "id" : 15, "animation" : "TBTWSILO.def", "x" : 763, "y" : 214, "z" : 3, "border" : "TOTMRKS.bmp",  "area" : "TZTMRKS.bmp" },
-				{ "id" : 16, "animation" : "TBTWBLAK.def", "x" : 478, "y" : 211, "border" : "TOTBLKA.bmp",  "area" : "TZTBLKA.bmp" },
-				{ "id" : 17, "animation" : "TBTWSPEC.def", "x" : 674, "y" : 276, "z" : 2, "border" : "TOTMRKA.bmp",  "area" : "TZTMRKA.bmp" },
-				{ "id" : 18, "animation" : "TBTWHRD1.def", "x" : 0,   "y" : 47,  "border" : "TOTGAR1H.bmp", "area" : "TZTGAR1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBTWHRD2.def", "x" : 0,   "y" : 28,  "border" : "TOTGAR2H.bmp", "area" : "TZTGAR2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 21, "animation" : "TBTWEXT0.def", "x" : 409, "y" : 82,  "border" : "TOTCASW.bmp",  "area" : "TZTCASW.bmp" },
-				{ "id" : 22, "animation" : "TBTWEXT1.def", "x" : 702, "y" : 115, "border" : "TOTGLDL.bmp",  "area" : "TZTGLDL.bmp" },
-				{ "id" : 23, "animation" : "TBTWEXT2.def", "x" : 592, "y" : 189, "z" : 1,  "border" : "TOTGLDW.bmp",  "area" : "TZTGLDW.bmp" },
-				{ "id" : 26, "animation" : "TBTWHOLY.def", "x" : 237, "y" : 14,  "z" : -1, "border" : "TOTHOLYA.bmp", "area" : "TZTHOLYA.bmp" },
-				{ "id" : 30, "animation" : "TBTWDW_0.def", "x" : 453, "y" : 221, "z" : 1,  "border" : "TOTGRM1A.bmp", "area" : "TZTGRM1A.bmp" },
-				{ "id" : 31, "animation" : "TBTWDW_1.def", "x" : 4,   "y" : 46,  "border" : "TOTGAR1.bmp",  "area" : "TZTGAR1.bmp" },
-				{ "id" : 32, "animation" : "TBTWDW_2.def", "x" : 209, "y" : 177, "z" : 1,  "border" : "TOTGOL1A.bmp", "area" : "TZTGOL1A.bmp" },
-				{ "id" : 33, "animation" : "TBTWDW_3.def", "x" : 613, "y" : 95,  "border" : "TOTMAG1.bmp",  "area" : "TZTMAG1.bmp" },
-				{ "id" : 34, "animation" : "TBTWDW_4.def", "x" : 511, "y" : 75,  "border" : "TOTGEN1.bmp",  "area" : "TZTGEN1.bmp" },
-				{ "id" : 35, "animation" : "TBTWDW_5.def", "x" : 681, "y" : 208, "z" : 2,  "border" : "TOTNAG1.bmp",  "area" : "TZTNAG1.bmp" },
-				{ "id" : 36, "animation" : "TBTWDW_6.def", "x" : 75,  "y" : 144, "z" : -1, "border" : "TOTTIT1.bmp",  "area" : "TZTTIT1.bmp" },
-				{ "id" : 37, "animation" : "TBTWUP_0.def", "x" : 446, "y" : 221, "z" : 1,  "border" : "TOTGRM2A.bmp", "area" : "TZTGRM2A.bmp" },
-				{ "id" : 38, "animation" : "TBTWUP_1.def", "x" : 4,   "y" : 28,  "border" : "TOTGAR2.bmp",  "area" : "TZTGAR2.bmp" },
-				{ "id" : 39, "animation" : "TBTWUP_2.def", "x" : 209, "y" : 177, "z" : 1,  "border" : "TOTGOL2A.bmp", "area" : "TZTGOL2A.bmp" },
-				{ "id" : 40, "animation" : "TBTWUP_3.def", "x" : 613, "y" : 74,  "border" : "TOTMAG2.bmp",  "area" : "TZTMAG2.bmp" },
-				{ "id" : 41, "animation" : "TBTWUP_4.def", "x" : 511, "y" : 8,   "border" : "TOTGEN2.bmp",  "area" : "TZTGEN2.bmp" },
-				{ "id" : 42, "animation" : "TBTWUP_5.def", "x" : 681, "y" : 157, "z" : 2,  "border" : "TOTNAG2.bmp",  "area" : "TZTNAG2.bmp" },
-				{ "id" : 43, "animation" : "TBTWUP_6.def", "x" : 75,  "y" : 91,  "z" : -1, "border" : "TOTTIT2.bmp",  "area" : "TZTTIT2.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 22, "built" : 23 },
-				"fort"    : {"normal" : 4,  "built" : 5 }
-			},
-
-			"musicTheme" : "music/TowerTown",
-
-			"townBackground": "TBTWBACK.bmp",
-			"guildWindow": "TPMAGETW.bmp",
-			"buildingsIcons": "HALLTOWR.DEF",
-			"hallBackground": "TPTHBKTW.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 22 ], [ 23 ] ],
-				[ [ 17 ], [ 21 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["ApprenticeGremlin", "MasterGremlin"],
-				["StoneGargoyle", "ObsidianGargoyle"],
-				["IronGolem", "StoneGolem"],
-				["Mage", "ArchMage"],
-				["Genie", "Caliph"],
-				["NagaSentinel", "NagaGuardian"],
-				["LesserTitan", "GreaterTitan"]
-			],
-			"horde" : [ 1, -1 ],
-			"primaryResource" : "gems",
-			"mageGuild" : 5,
-			"warMachine" : "AmmoCart",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 14 ] },
-				{ "id" : 18, "upgrades" : 31 },
-				{ "id" : 19, "upgrades" : 38, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 21, "requires" : [ 7 ] },
-				{ "id" : 22, "requires" : [ 0 ] },
-				{ "id" : 23, "requires" : [ 0 ] },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 0, 31, 32 ] },
-				{ "id" : 34, "requires" : [ 33 ] },
-				{ "id" : 35, "requires" : [ 33 ] },
-				{ "id" : 36, "requires" : [ 34, 35 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33, "requires" : [ 22 ] },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Mage",
-				"imagePrefix" : "SGTW",
-				"gate" :
-				{
-					"arch" : { "x" : 471, "y" : 187 },
-					"gate" : { "x" : 400, "y" : 253 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 410, "y" : 80 },
-					"moat" : { "x" : 410, "y" : 90 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 615, "y" : 57 },
-					"bottom" : { "x" : 517, "y" : 365 },
-					"top" : { "x" : 514, "y" : 79 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 592, "y" : 516 },
-						"creature" : { "x" : 355, "y" : 311 },
-						"tower" : { "x" : 592, "y" : 516 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 726, "y" : 148 },
-						"creature" : { "x" : 499, "y" : -16 },
-						"tower" : { "x" : 726, "y" : 148 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 580, "y" : 36 },
-						"creature" : { "x" : 346, "y" : -175 },
-						"tower" : { "x" : 580, "y" : 36 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 547, "y" : 452 },
-					"bottomMid" : { "x" : 475, "y" : 298 },
-					"upper" : { "x" : 547, "y" : 66 },
-					"upperMid" : { "x" : 488, "y" : 190 }
-				}
-			}
-		}
-	},
-	"inferno" :
-	{
-		"index" : 3,
-		"nativeTerrain": "lava",
-		"alignment" : "evil",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASINF",
-			"130px" : "CRBKGINF"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZINF",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 30 },
-				{ "x": 7, "y": 16, "index": 2 },
-				{ "x": 7, "y": 95, "index": 12 },
-				{ "x": 7, "y": 271, "index": 27 },
-				{ "x": 7, "y": 308, "index": 8 },
-				{ "x": 7, "y": 464, "index": 1 },
-				{ "x": 16, "y": 164, "index": 26 },
-				{ "x": 41, "y": 378, "index": 39 },
-				{ "x": 50, "y": 471, "index": 13 },
-				{ "x": 51, "y": 101, "index": 17 },
-				{ "x": 80, "y": 260, "index": 35 },
-				{ "x": 81, "y": 48, "index": 4 },
-				{ "x": 91, "y": 143, "index": 47 },
-				{ "x": 115, "y": 8, "index": 25 },
-				{ "x": 141, "y": 360, "index": 28 },
-				{ "x": 153, "y": 269, "index": 41 },
-				{ "x": 164, "y": 55, "index": 44 },
-				{ "x": 173, "y": 101, "index": 36 },
-				{ "x": 173, "y": 492, "index": 6 },
-				{ "x": 187, "y": 160, "index": 48 },
-				{ "x": 194, "y": 388, "index": 19 },
-				{ "x": 200, "y": 373, "index": 20 },
-				{ "x": 204, "y": 282, "index": 45 },
-				{ "x": 239, "y": 469, "index": 11 },
-				{ "x": 240, "y": 8, "index": 32 },
-				{ "x": 271, "y": 163, "index": 43 },
-				{ "x": 276, "y": 255, "index": 46 },
-				{ "x": 296, "y": 428, "index": 3 },
-				{ "x": 297, "y": 281, "index": 16 },
-				{ "x": 306, "y": 8, "index": 10 },
-				{ "x": 317, "y": 17, "index": 15 },
-				{ "x": 327, "y": 84, "index": 29 },
-				{ "x": 348, "y": 142, "index": 40 },
-				{ "x": 348, "y": 342, "index": 21 },
-				{ "x": 370, "y": 405, "index": 22 },
-				{ "x": 401, "y": 103, "index": 18 },
-				{ "x": 407, "y": 40, "index": 31 },
-				{ "x": 421, "y": 508, "index": 7 },
-				{ "x": 453, "y": 215, "index": 33 },
-				{ "x": 455, "y": 377, "index": 34 },
-				{ "x": 460, "y": 170, "index": 38 },
-				{ "x": 475, "y": 319, "index": 42 },
-				{ "x": 488, "y": 412, "index": 37 },
-				{ "x": 504, "y": 8, "index": 24 },
-				{ "x": 515, "y": 67, "index": 5 },
-				{ "x": 517, "y": 211, "index": 14 },
-				{ "x": 532, "y": 305, "index": 23 },
-				{ "x": 556, "y": 335, "index": 9 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCinfx0.def",
-				"village" : "AVCINFT0.DEF",
-				"capitol" : "AVCINFZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "id" : 0,  "animation" : "TBINMAGE.def", "x" : 667, "y" : 127, "border" : "TOIMAG1A.bmp", "area" : "TZIMAG1A.bmp" },
-				{ "id" : 1,  "animation" : "TBINMAG2.def", "x" : 667, "y" : 101, "border" : "TOIMAG2A.bmp", "area" : "TZIMAG2A.bmp" },
-				{ "id" : 2,  "animation" : "TBINMAG3.def", "x" : 667, "y" : 83,  "border" : "TOIMAG3A.bmp", "area" : "TZIMAG3A.bmp" },
-				{ "id" : 3,  "animation" : "TBINMAG4.def", "x" : 667, "y" : 56,  "border" : "TOIMAG4A.bmp", "area" : "TZIMAG4A.bmp" },
-				{ "id" : 4,  "animation" : "TBINMAG5.def", "x" : 667, "y" : 35,  "border" : "TOIMAG5A.bmp", "area" : "TZIMAG5A.bmp" },
-				{ "id" : 5,  "animation" : "TBINTVRN.def", "x" : 105, "y" : 219, "z" : 1,  "border" : "TOITAV.bmp",   "area" : "TZITAV.bmp" },
-				{ "id" : 7,  "animation" : "TBINCSTL.def", "x" : 222, "y" : 44,  "border" : "TOICAS2A.bmp", "area" : "TZICAS2A.bmp" },
-				{ "id" : 8,  "animation" : "TBINCAS2.def", "x" : 222, "y" : 44,  "border" : "TOICAS1A.bmp", "area" : "TZICAS1A.bmp" },
-				{ "id" : 9,  "animation" : "TBINCAS3.def", "x" : 222, "y" : 18,  "border" : "TOICAS3A.bmp", "area" : "TZICAS3A.bmp" },
-				{ "id" : 10, "animation" : "TBINHALL.def", "x" : 0,   "y" : 174, "border" : "TOIHAL1.bmp",  "area" : "TZIHAL1.bmp"  },
-				{ "id" : 11, "animation" : "TBINHAL2.def", "x" : 0,   "y" : 174, "border" : "TOIHAL2.bmp",  "area" : "TZIHAL2.bmp"  },
-				{ "id" : 12, "animation" : "TBINHAL3.def", "x" : 0,   "y" : 174, "border" : "TOIHAL3.bmp",  "area" : "TZIHAL3.bmp"  },
-				{ "id" : 13, "animation" : "TBINHAL4.def", "x" : 0,   "y" : 131, "border" : "TOIHAL4.bmp",  "area" : "TZIHAL4.bmp"  },
-				{ "id" : 14, "animation" : "TBINMARK.def", "x" : 511, "y" : 301, "z" : 4,  "border" : "TOIMAR1.bmp",  "area" : "TZIMAR1.bmp" },
-				{ "id" : 15, "animation" : "TBINSILO.def", "x" : 497, "y" : 337, "z" : 5,  "border" : "TOIMAR2.bmp",  "area" : "TZIMAR2.bmp" },
-				{ "id" : 16, "animation" : "TBINBLAK.def", "x" : 684, "y" : 253, "z" : 1,  "border" : "TOIBLKA.bmp",  "area" : "TZIBLKA.bmp" },
-				{ "id" : 18, "animation" : "TBINHRD1.def", "x" : 614, "y" : 256, "border" : "TOIMP1HA.bmp", "area" : "TZIMP1HA.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBINHRD2.def", "x" : 614, "y" : 221, "border" : "TOIMP2HA.bmp", "area" : "TZIMP2HA.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 21, "animation" : "TBINEXT0.def", "x" : 297, "y" : 0,   "z" : -1, "border" : "TOICAB1A.bmp", "area" : "TZICAB1A.bmp" },
-				{ "id" : 22, "animation" : "TBINEXT1.def", "x" : 227, "y" : 174, "z" : 2,  "border" : "TOICASGA.bmp", "area" : "TZICASGA.bmp" },
-				{ "id" : 23, "animation" : "TBINEXT2.def", "x" : 593, "y" : 104, "border" : "TOIPAIN.bmp",  "area" : "TZIPAIN.bmp"  },
-				{ "id" : 24, "animation" : "TBINHRD3.def", "x" : 10,  "y" : 301, "border" : "TOIHND1H.bmp", "area" : "TZIHND1H.bmp", "hidden" : true },
-				{ "id" : 25, "animation" : "TBINHRD4.def", "x" : 9,   "y" : 273, "border" : "TOIHND2H.bmp", "area" : "TZIHND2H.bmp", "hidden" : true, "builds" : 24 },
-				{ "id" : 26, "animation" : "TBINHOLY.def", "x" : 24,  "y" : 10,  "z" : -1, "border" : "TOIHOLY.bmp",  "area" : "TZIHOLY.bmp" },
-				{ "id" : 30, "animation" : "TBINDW_0.def", "x" : 614, "y" : 256, "border" : "TOIMP1A.bmp",  "area" : "TZIMP1A.bmp"  },
-				{ "id" : 31, "animation" : "TBINDW_1.def", "x" : 187, "y" : 248, "z" : 4,  "border" : "TOIGOG1A.bmp", "area" : "TZIGOG1A.bmp" },
-				{ "id" : 32, "animation" : "TBINDW_2.def", "x" : 9,   "y" : 325, "border" : "TOIHND1.bmp",  "area" : "TZIHND1.bmp"  },
-				{ "id" : 33, "animation" : "TBINDW_3.def", "x" : 414, "y" : 204, "z" : 2,  "border" : "TOIDMN1.bmp",  "area" : "TZIDMN1.bmp" },
-				{ "id" : 34, "animation" : "TBINDW_4.def", "x" : 359, "y" : 296, "z" : 3,  "border" : "TOIPIT1.bmp",  "area" : "TZIPIT1.bmp" },
-				{ "id" : 35, "animation" : "TBINDW_5.def", "x" : 220, "y" : 350, "z" : 5,  "border" : "TOIEFR1.bmp",  "area" : "TZIEFR1.bmp" },
-				{ "id" : 36, "animation" : "TBINDW_6.def", "x" : 420, "y" : 153, "z" : -1, "border" : "TOIDVL1.bmp",  "area" : "TZIDVL1.bmp" },
-				{ "id" : 37, "animation" : "TBINUP_0.def", "x" : 614, "y" : 221, "border" : "TOIMP2A.bmp",  "area" : "TZIMP2A.bmp"  },
-				{ "id" : 38, "animation" : "TBINUP_1.def", "x" : 187, "y" : 212, "z" : 4,  "border" : "TOIGOG2A.bmp", "area" : "TZIGOG2A.bmp" },
-				{ "id" : 39, "animation" : "TBINUP_2.def", "x" : 9,   "y" : 273, "border" : "TOIHND2.bmp",  "area" : "TZIHND2.bmp"  },
-				{ "id" : 40, "animation" : "TBINUP_3.def", "x" : 412, "y" : 197, "z" : 2,  "border" : "TOIDMN2.bmp",  "area" : "TZIDMN2.bmp" },
-				{ "id" : 41, "animation" : "TBINUP_4.def", "x" : 359, "y" : 244, "z" : 3,  "border" : "TOIPIT2.bmp",  "area" : "TZIPIT2.bmp" },
-				{ "id" : 42, "animation" : "TBINUP_5.def", "x" : 220, "y" : 282, "z" : 5,  "border" : "TOIEFR2.bmp",  "area" : "TZIEFR2.bmp" },
-				{ "id" : 43, "animation" : "TBINUP_6.def", "x" : 420, "y" : 105, "z" : -1, "border" : "TOIDVL2.bmp",  "area" : "TZIDVL2.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 24, "built" : 25 },
-				"fort"    : {"normal" : 6,  "built" : 7 }
-			},
-			"musicTheme" : "music/InfernoTown",
-
-			"townBackground": "TBINBACK.bmp",
-			"guildWindow": "TPMAGEIN.bmp",
-			"buildingsIcons": "HALLINFR.DEF",
-			"hallBackground": "TPTHBKIN.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 23 ], [ 21 ] ],
-				[ [ 22 ], [ 18, 19 ], [ 24, 25 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Imp", "Familiar"],
-				["Gog", "Magog"],
-				["HellHound", "Cerberus"],
-				["Single-HornedDemon", "Dual-HornedDemon"],
-				["PitFiend", "PitFoe"],
-				["Efreet", "EfreetSultan"],
-				["Devil", "ArchDevil"]
-			],
-			"horde" : [ 0, 2 ],
-			"mageGuild" : 5,
-			"primaryResource" : "mercury",
-			"warMachine" : "Ballista",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 18, "upgrades" : 30 },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18, 19 ], "mode" : "auto" },
-				{ "id" : 21, "requires" : [ 7 ] },
-				{ "id" : 22, "requires" : [ 8 ] },
-				{ "id" : 23, "requires" : [ 0 ] },
-				{ "id" : 24, "upgrades" : 32 },
-				{ "id" : 25, "upgrades" : 39, "requires" : [ 24, 25 ], "mode" : "auto" },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 26 },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 31 ] },
-				{ "id" : 34, "requires" : [ 33 ] },
-				{ "id" : 35, "requires" : [ 0, 33 ] },
-				{ "id" : 36, "requires" : [ 34, 35 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33 },
-				{ "id" : 41, "upgrades" : 34, "requires" : [ 1 ] },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Gog",
-				"imagePrefix" : "SGIN",
-				"gate" :
-				{
-					"arch" : { "x" : 477, "y" : 221 },
-					"gate" : { "x" : 408, "y" : 254 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 403, "y" : 68 },
-					"moat" : { "x" : 403, "y" : 68 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 606, "y" : 52 },
-					"bottom" : { "x" : 522, "y" : 376 },
-					"top" : { "x" : 502, "y" : 92 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 595, "y" : 514 },
-						"creature" : { "x" : 369, "y" : 298 },
-						"tower" : { "x" : 595, "y" : 514 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 730, "y" : 179 },
-						"creature" : { "x" : 511, "y" : -37 },
-						"tower" : { "x" : 730, "y" : 179 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 569, "y" : 27 },
-						"creature" : { "x" : 341, "y" : -187 },
-						"tower" : { "x" : 569, "y" : 27 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 561, "y" : 451 },
-					"bottomMid" : { "x" : 485, "y" : 316 },
-					"upper" : { "x" : 532, "y" : 71 },
-					"upperMid" : { "x" : 480, "y" : 151 }
-				}
-			}
-		}
-	},
-	"necropolis" :
-	{
-		"index" : 4,
-		"nativeTerrain": "dirt",
-		"alignment" : "evil",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASNEC",
-			"130px" : "CRBKGNEC"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZNEC",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 22 },
-				{ "x": 7, "y": 188, "index": 1 },
-				{ "x": 7, "y": 329, "index": 20 },
-				{ "x": 7, "y": 403, "index": 24 },
-				{ "x": 8, "y": 8, "index": 47 },
-				{ "x": 14, "y": 138, "index": 30 },
-				{ "x": 15, "y": 8, "index": 9 },
-				{ "x": 34, "y": 374, "index": 31 },
-				{ "x": 55, "y": 82, "index": 25 },
-				{ "x": 55, "y": 150, "index": 38 },
-				{ "x": 57, "y": 281, "index": 8 },
-				{ "x": 94, "y": 188, "index": 36 },
-				{ "x": 108, "y": 344, "index": 6 },
-				{ "x": 119, "y": 424, "index": 13 },
-				{ "x": 124, "y": 256, "index": 37 },
-				{ "x": 131, "y": 8, "index": 7 },
-				{ "x": 139, "y": 92, "index": 11 },
-				{ "x": 145, "y": 371, "index": 29 },
-				{ "x": 148, "y": 42, "index": 21 },
-				{ "x": 175, "y": 200, "index": 44 },
-				{ "x": 200, "y": 291, "index": 45 },
-				{ "x": 201, "y": 66, "index": 42 },
-				{ "x": 210, "y": 482, "index": 18 },
-				{ "x": 247, "y": 98, "index": 28 },
-				{ "x": 250, "y": 227, "index": 48 },
-				{ "x": 262, "y": 8, "index": 15 },
-				{ "x": 293, "y": 373, "index": 32 },
-				{ "x": 303, "y": 286, "index": 46 },
-				{ "x": 318, "y": 173, "index": 43 },
-				{ "x": 345, "y": 444, "index": 2 },
-				{ "x": 356, "y": 8, "index": 5 },
-				{ "x": 357, "y": 386, "index": 17 },
-				{ "x": 362, "y": 38, "index": 40 },
-				{ "x": 382, "y": 8, "index": 19 },
-				{ "x": 382, "y": 119, "index": 35 },
-				{ "x": 421, "y": 164, "index": 27 },
-				{ "x": 422, "y": 249, "index": 4 },
-				{ "x": 428, "y": 52, "index": 14 },
-				{ "x": 429, "y": 101, "index": 10 },
-				{ "x": 443, "y": 132, "index": 41 },
-				{ "x": 452, "y": 239, "index": 34 },
-				{ "x": 465, "y": 441, "index": 23 },
-				{ "x": 469, "y": 300, "index": 39 },
-				{ "x": 476, "y": 20, "index": 3 },
-				{ "x": 537, "y": 249, "index": 33 },
-				{ "x": 547, "y": 430, "index": 12 },
-				{ "x": 559, "y": 140, "index": 26 },
-				{ "x": 558, "y": 8, "index": 16 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCnecx0.def",
-				"village" : "AVCNECR0.DEF",
-				"capitol" : "AVCNECZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBNCEXT2.def", "x" : 25,  "y" : 279 },
-				{ "id" : 0,  "animation" : "TBNCMAGE.def", "x" : 341, "y" : 116, "z" : -1, "border" : "TONMAG1.bmp",  "area" : "TZNMAG1.bmp" },
-				{ "id" : 1,  "animation" : "TBNCMAG2.def", "x" : 341, "y" : 97,  "z" : -1, "border" : "TONMAG2.bmp",  "area" : "TZNMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBNCMAG3.def", "x" : 341, "y" : 78,  "z" : -1, "border" : "TONMAG3.bmp",  "area" : "TZNMAG3.bmp" },
-				{ "id" : 3,  "animation" : "TBNCMAG4.def", "x" : 340, "y" : 62,  "z" : -1, "border" : "TONMAG4.bmp",  "area" : "TZNMAG4.bmp" },
-				{ "id" : 4,  "animation" : "TBNCMAG5.def", "x" : 343, "y" : 35,  "z" : -1, "border" : "TONMAG5.bmp",  "area" : "TZNMAG5.bmp" },
-				{ "id" : 5,  "animation" : "TBNCTVRN.def", "x" : 508, "y" : 189, "border" : "TONTAV.bmp",   "area" : "TZNTAV.bmp"  },
-				{ "id" : 6,  "animation" : "TBNCDOCK.def", "x" : 617, "y" : 265, "z" : -2, "border" : "TONSHPBA.bmp", "area" : "TZNSHPBA.bmp" },
-				{ "id" : 7,  "animation" : "TBNCCSTL.def", "x" : 138, "y" : 66,  "border" : "TONCAS1.bmp",  "area" : "TZNCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBNCCAS2.def", "x" : 139, "y" : 66,  "border" : "TONCAS2.bmp",  "area" : "TZNCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBNCCAS3.def", "x" : 34,  "y" : 18,  "border" : "TONCAS3.bmp",  "area" : "TZNCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBNCHALL.def", "x" : 468, "y" : 76,  "z" : -1, "border" : "TONHAL1.bmp",  "area" : "TZNHAL1.bmp" },
-				{ "id" : 11, "animation" : "TBNCHAL2.def", "x" : 482, "y" : 56,  "z" : -1, "border" : "TONHAL2.bmp",  "area" : "TZNHAL2.bmp" },
-				{ "id" : 12, "animation" : "TBNCHAL3.def", "x" : 478, "y" : 26,  "z" : -1, "border" : "TONHAL3.bmp",  "area" : "TZNHAL3.bmp" },
-				{ "id" : 13, "animation" : "TBNCHAL4.def", "x" : 481, "y" : 26,  "z" : -1, "border" : "TONHAL4.bmp",  "area" : "TZNHAL4.bmp" },
-				{ "id" : 14, "animation" : "TBNCMARK.def", "x" : 347, "y" : 215, "z" : 2,  "border" : "TONMRK1.bmp",  "area" : "TZNMRK1.bmp" },
-				{ "id" : 15, "animation" : "TBNCSILO.def", "x" : 276, "y" : 185, "z" : 1,  "border" : "TONMRK2.bmp",  "area" : "TZNMRK2.bmp" },
-				{ "id" : 16, "animation" : "TBNCBLAK.def", "x" : 382, "y" : 252, "z" : 4,  "border" : "TONSMITA.bmp", "area" : "TZNSMITA.bmp" },
-				{ "id" : 17, "animation" : "TBNCSPEC.def", "x" : 18,  "y" : 0,   "z" : -1, "border" : "TONSHRDA.bmp", "area" : "TZNSHRDA.bmp" },
-				{ "id" : 18, "animation" : "TBNCHRD1.def", "x" : 80,  "y" : 222, "z" : 4, "border" : "TONSKE1H.bmp", "area" : "TZNSKE1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBNCHRD2.def", "x" : 64,  "y" : 222, "z" : 4, "border" : "TONSKE2H.bmp", "area" : "TZNSKE2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 20, "animation" : "TBNCBOAT.def", "x" : 617, "y" : 265, "z" : -2, "border" : "TONSHPNA.bmp", "area" : "TZNSHPNA.bmp", "hidden" : true },
-				{ "id" : 21, "animation" : "TBNCEXT0.def", "x" : 307, "y" : 61,  "z" : -2, "border" : "TONNECRA.bmp", "area" : "TZNNECRA.bmp" },
-				{ "id" : 22, "animation" : "TBNCEXT1.def", "x" : 247, "y" : 275, "z" : 4,  "border" : "TONSKELT.bmp", "area" : "TZNSKELT.bmp" },
-				{ "id" : 26, "animation" : "TBNCHOLY.def", "x" : 410, "y" : 88,  "border" : "TONHOLYA.bmp", "area" : "TZNHOLYA.bmp" },
-				{ "id" : 27, "animation" : "TBNCEXT3.def", "x" : 0,   "y" : 241 },
-				{ "id" : 28, "animation" : "TBNCEXT4.def", "x" : 321, "y" : 255 },
-				{ "id" : 29, "animation" : "TBNCEXT5.def", "x" : 475, "y" : 257 },
-				{ "id" : 30, "animation" : "TBNCDW_0.def", "x" : 80,  "y" : 222, "z" : 4, "border" : "TONSKEL1.bmp", "area" : "TZNSKEL1.bmp" },
-				{ "id" : 31, "animation" : "TBNCDW_1.def", "x" : 502, "y" : 223, "border" : "TONZOMB1.bmp", "area" : "TZNZOMB1.bmp" },
-				{ "id" : 32, "animation" : "TBNCDW_2.def", "x" : 0,   "y" : 187, "z" : 2, "border" : "TONWIGH1.bmp", "area" : "TZNWIGH1.bmp" },
-				{ "id" : 33, "animation" : "TBNCDW_3.def", "x" : 607, "y" : 212, "z" : 2, "border" : "TONVAM1.bmp",  "area" : "TZNVAM1.bmp" },
-				{ "id" : 34, "animation" : "TBNCDW_4.def", "x" : 206, "y" : 207, "z" : 3, "border" : "TONLICH1.bmp", "area" : "TZNLICH1.bmp" },
-				{ "id" : 35, "animation" : "TBNCDW_5.def", "x" : 0,   "y" : 31,  "border" : "TONBKN1.bmp",  "area" : "TZNBKN1.bmp" },
-				{ "id" : 36, "animation" : "TBNCDW_6.def", "x" : 663, "y" : 25,  "border" : "TONBON1.bmp",  "area" : "TZNBON1.bmp" },
-				{ "id" : 37, "animation" : "TBNCUP_0.def", "x" : 64,  "y" : 222, "z" : 4, "border" : "TONSKEL2.bmp", "area" : "TZNSKEL2.bmp" },
-				{ "id" : 38, "animation" : "TBNCUP_1.def", "x" : 498, "y" : 224, "border" : "TONZOMB2.bmp", "area" : "TZNZOMB2.bmp" },
-				{ "id" : 39, "animation" : "TBNCUP_2.def", "x" : 0,   "y" : 179, "z" : 2, "border" : "TONWIGH2.bmp", "area" : "TZNWIGH2.bmp" },
-				{ "id" : 40, "animation" : "TBNCUP_3.def", "x" : 615, "y" : 193, "z" : 2, "border" : "TONVAM2.bmp",  "area" : "TZNVAM2.bmp" },
-				{ "id" : 41, "animation" : "TBNCUP_4.def", "x" : 222, "y" : 171, "z" : 3, "border" : "TONLICH2.bmp", "area" : "TZNLICH2.bmp" },
-				{ "id" : 42, "animation" : "TBNCUP_5.def", "x" : 0,   "y" : 30,  "border" : "TONBKN2.bmp",  "area" : "TZNBKN2.bmp" },
-				{ "id" : 43, "animation" : "TBNCUP_6.def", "x" : 662, "y" : 23,  "border" : "TONBON2.bmp",  "area" : "TZNBON2.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 26, "built" : 27 },
-				"fort"    : {"normal" : 8,  "built" : 9 }
-			},
-			"musicTheme" : "music/NecroTown",
-
-			"townBackground": "TBNCBACK.bmp",
-			"guildWindow": "TPMAGENC.bmp",
-			"buildingsIcons": "HALLNECR.DEF",
-			"hallBackground": "TPTHBKNC.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 6 ] ],
-				[ [ 17 ], [ 22 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Skeleton", "SkeletonWarrior"],
-				["Zombie", "ZombieLord"],
-				["Wight", "Wraith"],
-				["Vampire", "Nosferatu"],
-				["Lich", "PowerLich"],
-				["BlackKnight", "BlackLord"],
-				["BoneDragon", "GhostDragon"]
-			],
-			"horde" : [ 0, -1 ],
-			"mageGuild" : 5,
-			"warMachine" : "FirstAidTent",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 6 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 7 ] },
-				{ "id" : 18, "upgrades" : 30, "requires" : [ 22 ] },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 20, "upgrades" : 6 },
-				{ "id" : 21, "requires" : [ 0 ] },
-				{ "id" : 22, "requires" : [ 30 ] },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 31 ] },
-				{ "id" : 34, "requires" : [ 0, 31 ] },
-				{ "id" : 35, "requires" : [ 33, 34 ] },
-				{ "id" : 36, "requires" : [ 35 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33, "requires" : [ 21 ] },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Lich",
-				"imagePrefix" : "SGNC",
-				"gate" :
-				{
-					"arch" : { "x" : 474, "y" : 240 },
-					"gate" : { "x" : 401, "y" : 262 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : -1, "y" : -1 },
-					"moat" : { "x" : 406, "y" : 77 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 604, "y" : 58 },
-					"bottom" : { "x" : 509, "y" : 372 },
-					"top" : { "x" : 504, "y" : 97 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 592, "y" : 512 },
-						"creature" : { "x" : 371, "y" : 303 },
-						"tower" : { "x" : 592, "y" : 512 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 730, "y" : 164 },
-						"creature" : { "x" : 501, "y" : 98 },
-						"tower" : { "x" : 730, "y" : 164 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 561, "y" : 26 },
-						"creature" : { "x" : 339, "y" : -177 },
-						"tower" : { "x" : 561, "y" : 26 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 536, "y" : 445 },
-					"bottomMid" : { "x" : 478, "y" : 323 },
-					"upper" : { "x" : 543, "y" : 66 },
-					"upperMid" : { "x" : 487, "y" : 164 }
-				}
-			}
-		}
-	},
-	"dungeon" :
-	{
-		"index" : 5,
-		"nativeTerrain": "subterra",
-		"alignment" : "evil",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASDUN",
-			"130px" : "CRBKGDUN"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZDUN",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 31 },
-				{ "x": 7, "y": 125, "index": 1 },
-				{ "x": 7, "y": 353, "index": 33 },
-				{ "x": 7, "y": 394, "index": 6 },
-				{ "x": 30, "y": 101, "index": 36 },
-				{ "x": 33, "y": 219, "index": 16 },
-				{ "x": 57, "y": 171, "index": 13 },
-				{ "x": 62, "y": 8, "index": 47 },
-				{ "x": 63, "y": 90, "index": 41 },
-				{ "x": 83, "y": 471, "index": 10 },
-				{ "x": 94, "y": 117, "index": 21 },
-				{ "x": 99, "y": 8, "index": 5 },
-				{ "x": 113, "y": 258, "index": 32 },
-				{ "x": 156, "y": 146, "index": 28 },
-				{ "x": 165, "y": 288, "index": 42 },
-				{ "x": 172, "y": 388, "index": 44 },
-				{ "x": 177, "y": 36, "index": 39 },
-				{ "x": 194, "y": 235, "index": 46 },
-				{ "x": 204, "y": 502, "index": 3 },
-				{ "x": 236, "y": 320, "index": 23 },
-				{ "x": 238, "y": 8, "index": 20 },
-				{ "x": 245, "y": 75, "index": 25 },
-				{ "x": 247, "y": 396, "index": 29 },
-				{ "x": 247, "y": 459, "index": 14 },
-				{ "x": 253, "y": 152, "index": 48 },
-				{ "x": 301, "y": 233, "index": 43 },
-				{ "x": 323, "y": 8, "index": 12 },
-				{ "x": 323, "y": 178, "index": 45 },
-				{ "x": 328, "y": 342, "index": 30 },
-				{ "x": 329, "y": 428, "index": 19 },
-				{ "x": 339, "y": 8, "index": 26 },
-				{ "x": 357, "y": 141, "index": 27 },
-				{ "x": 374, "y": 8, "index": 15 },
-				{ "x": 374, "y": 236, "index": 34 },
-				{ "x": 392, "y": 439, "index": 35 },
-				{ "x": 400, "y": 291, "index": 40 },
-				{ "x": 401, "y": 103, "index": 18 },
-				{ "x": 422, "y": 381, "index": 37 },
-				{ "x": 436, "y": 8, "index": 17 },
-				{ "x": 438, "y": 336, "index": 24 },
-				{ "x": 449, "y": 131, "index": 9 },
-				{ "x": 453, "y": 161, "index": 11 },
-				{ "x": 471, "y": 267, "index": 38 },
-				{ "x": 477, "y": 64, "index": 22 },
-				{ "x": 480, "y": 456, "index": 8 },
-				{ "x": 485, "y": 8, "index": 2 },
-				{ "x": 536, "y": 197, "index": 4 },
-				{ "x": 541, "y": 22, "index": 7 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCdunx0.def",
-				"village" : "AVCDUNG0.DEF",
-				"capitol" : "AVCDUNZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "id" : 0,  "animation" : "TBDNMAGE.def", "x" : 164, "y" : 119, "z" : -1, "border" : "TODMAG1.bmp",  "area" : "TZDMAG1.bmp" },
-				{ "id" : 1,  "animation" : "TBDNMAG2.def", "x" : 164, "y" : 97,  "z" : -1, "border" : "TODMAG2.bmp",  "area" : "TZDMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBDNMAG3.def", "x" : 164, "y" : 77,  "z" : -1, "border" : "TODMAG3.bmp",  "area" : "TZDMAG3.bmp" },
-				{ "id" : 3,  "animation" : "TBDNMAG4.def", "x" : 164, "y" : 61,  "z" : -1, "border" : "TODMAG4.bmp",  "area" : "TZDMAG4.bmp" },
-				{ "id" : 4,  "animation" : "TBDNMAG5.def", "x" : 164, "y" : 15,  "z" : -1, "border" : "TODMAG5.bmp",  "area" : "TZDMAG5.bmp" },
-				{ "id" : 5,  "animation" : "TBDNTVRN.def", "x" : 211, "y" : 297, "border" : "TODTAV.bmp",   "area" : "TZDTAV.bmp" },
-				{ "id" : 7,  "animation" : "TBDNCSTL.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS1.bmp",  "area" : "TZDCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBDNCAS2.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS2.bmp",  "area" : "TZDCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBDNCAS3.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS3.bmp",  "area" : "TZDCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBDNHALL.def", "x" : 0,   "y" : 234, "border" : "TODHALL1.bmp", "area" : "TZDHALL1.bmp" },
-				{ "id" : 11, "animation" : "TBDNHAL2.def", "x" : 0,   "y" : 223, "border" : "TODHALL2.bmp", "area" : "TZDHALL2.bmp" },
-				{ "id" : 12, "animation" : "TBDNHAL3.def", "x" : 0,   "y" : 223, "border" : "TODHALL3.bmp", "area" : "TZDHALL3.bmp" },
-				{ "id" : 13, "animation" : "TBDNHAL4.def", "x" : 0,   "y" : 203, "z" : -1, "border" : "TODHALL4.bmp", "area" : "TZDHALL4.bmp" },
-				{ "id" : 14, "animation" : "TBDNMARK.def", "x" : 590, "y" : 318, "z" : -2, "border" : "TODMARK.bmp",  "area" : "TZDMARK.bmp" },
-				{ "id" : 15, "animation" : "TBDNSILO.def", "x" : 624, "y" : 335, "z" : 1,  "border" : "TODSILO.bmp",  "area" : "TZDSILO.bmp" },
-				{ "id" : 16, "animation" : "TBDNBLAK.def", "x" : 544, "y" : 248, "z" : -3, "border" : "TODSMITH.bmp", "area" : "TZDSMITH.bmp" },
-				{ "id" : 17, "animation" : "TBDNSPEC.def", "x" : 746, "y" : 294, "z" : 1,  "border" : "TODART.bmp",   "area" : "TZDART.bmp" },
-				{ "id" : 18, "animation" : "TBDNHRD1.def", "x" : 0,   "y" : 326, "z" : 2,  "border" : "TODTR1HA.bmp", "area" : "TZDTR1HA.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBDNHRD2.def", "x" : 0,   "y" : 300, "z" : 2,  "border" : "TODTR2HA.bmp", "area" : "TZDTR2HA.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 21, "animation" : "TBDNEXT0.def", "x" : 131, "y" : 26 , "border" : "TODVOR1A.bmp", "area" : "TZDVOR1A.bmp" },
-				{ "id" : 22, "animation" : "TBDNEXT1.def", "x" : 687, "y" : 177, "border" : "TODPORTA.bmp", "area" : "TZDPORTA.bmp" },
-				{ "id" : 23, "animation" : "TBDNEXT2.def", "x" : 313, "y" : 298, "border" : "TODACAD.bmp",  "area" : "TZDACAD.bmp" },
-				{ "id" : 26, "animation" : "TBDNHOLY.def", "x" : 562, "y" : 24,  "z" : 1,  "border" : "TODHOLY.bmp",  "area" : "TZDHOLY.bmp" },
-				{ "id" : 30, "animation" : "TBDNDW_0.def", "x" : 0,   "y" : 326, "z" : 2,  "border" : "TODTRG1A.bmp", "area" : "TZDTRG1A.bmp" },
-				{ "id" : 31, "animation" : "TBDNDW_1.def", "x" : 0,   "y" : 26,  "border" : "TODHAR1.bmp",  "area" : "TZDHAR1.bmp" },
-				{ "id" : 32, "animation" : "TBDNDW_2.def", "x" : 118, "y" : 308, "z" : 1,  "border" : "TODBEH1A.bmp", "area" : "TZDBEH1A.bmp" },
-				{ "id" : 33, "animation" : "TBDNDW_3.def", "x" : 300, "y" : 29,  "z" : -1, "border" : "TODMED1.bmp",  "area" : "TZDMED1.bmp" },
-				{ "id" : 34, "animation" : "TBDNDW_4.def", "x" : 551, "y" : 186, "z" : 1,  "border" : "TODMIN1.bmp",  "area" : "TZDMIN1.bmp" },
-				{ "id" : 35, "animation" : "TBDNDW_5.def", "x" : 270, "y" : 253, "z" : -1, "border" : "TODMAN1.bmp",  "area" : "TZDMAN1.bmp" },
-				{ "id" : 36, "animation" : "TBDNDW_6.def", "x" : 550, "y" : 0,   "z" : -1, "border" : "TODDRA1A.bmp", "area" : "TZDDRA1A.bmp" },
-				{ "id" : 37, "animation" : "TBDNUP_0.def", "x" : 0,   "y" : 300, "z" : 2,  "border" : "TODTRG2A.bmp", "area" : "TZDTRG2A.bmp" },
-				{ "id" : 38, "animation" : "TBDNUP_1.def", "x" : 0,   "y" : 26,  "border" : "TODHAR2.bmp",  "area" : "TZDHAR2.bmp" },
-				{ "id" : 39, "animation" : "TBDNUP_2.def", "x" : 118, "y" : 256, "z" : 1,  "border" : "TODBEH2A.bmp", "area" : "TZDBEH2A.bmp" },
-				{ "id" : 40, "animation" : "TBDNUP_3.def", "x" : 300, "y" : 29,  "z" : -1, "border" : "TODMED2.bmp",  "area" : "TZDMED2.bmp" },
-				{ "id" : 41, "animation" : "TBDNUP_4.def", "x" : 519, "y" : 172, "z" : 1,  "border" : "TODMIN2.bmp",  "area" : "TZDMIN2.bmp" },
-				{ "id" : 42, "animation" : "TBDNUP_5.def", "x" : 270, "y" : 253, "z" : -1, "border" : "TODMAN2.bmp",  "area" : "TZDMAN2.bmp" },
-				{ "id" : 43, "animation" : "TBDNUP_6.def", "x" : 550, "y" : 0,   "z" : -1, "border" : "TODDRA2A.bmp", "area" : "TZDDRA2A.bmp" },
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 28, "built" : 29 },
-				"fort"    : {"normal" : 10, "built" : 11 }
-			},
-			"musicTheme" : "music/Dungeon",
-
-			"townBackground": "TBDNBACK.bmp",
-			"guildWindow": "TPMAGEDN.bmp",
-			"buildingsIcons": "HALLDUNG.DEF",
-			"hallBackground": "TPTHBKDG.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 22 ] ],
-				[ [ 17 ], [ 23 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Troglodyte", "InfernalTroglodyte"],
-				["Harpy", "HarpyHag"],
-				["Beholder", "EvilEye"],
-				["Medusa", "MedusaQueen"],
-				["Minotaur", "MinotaurKing"],
-				["Manticore", "Scorpicore"],
-				["RedDragon", "BlackDragon"]
-			],
-			"horde" : [ 0, -1 ],
-			"mageGuild" : 5,
-			"primaryResource" : "sulfur",
-			"warMachine" : "Ballista",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 14 ] },
-				{ "id" : 18, "upgrades" : 30 },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 21, "requires" : [ 0 ] },
-				{ "id" : 22 },
-				{ "id" : 23 },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 31, 32 ] },
-				{ "id" : 34, "requires" : [ 33 ] },
-				{ "id" : 35, "requires" : [ 33 ] },
-				{ "id" : 36, "requires" : [ 1, 34, 35 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33 },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36, "requires" : [ 2 ] }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Beholder",
-				"imagePrefix" : "SGDN",
-				"gate" :
-				{
-					"arch" : { "x" : 471, "y" : 164 },
-					"gate" : { "x" : 395, "y" : 260 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 283, "y" : 94 },
-					"moat" : { "x" : 283, "y" : 94 }
-				},
-				"shooterHeight" : 230,
-				"static" :
-				{
-					"background" : { "x" : 608, "y" : 50 },
-					"bottom" : { "x" : 522, "y" : 305 },
-					"top" : { "x" : 494, "y" : 53 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 600, "y" : 495 },
-						"creature" : { "x" : 410, "y" : 293 },
-						"tower" : { "x" : 560, "y" : 495 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 732, "y" : 162 },
-						"creature" : { "x" : 570, "y" : -50 },
-						"tower" : { "x" : 732, "y" : 162 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 565, "y" : 15 },
-						"creature" : { "x" : 381, "y" : -187 },
-						"tower" : { "x" : 565, "y" : 15 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 559, "y" : 448 },
-					"bottomMid" : { "x" : 471, "y" : 296 },
-					"upper" : { "x" : 523, "y" : 56 },
-					"upperMid" : { "x" : 477, "y" : 180 }
-				}
-			}
-		}
-	},
-	"stronghold" :
-	{
-		"index" : 6,
-		"nativeTerrain": "rough",
-		"alignment" : "neutral",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASSTR",
-			"130px" : "CRBKGSTR"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZSTR",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 6 },
-				{ "x": 7, "y": 229, "index": 14 },
-				{ "x": 7, "y": 405, "index": 15 },
-				{ "x": 7, "y": 465, "index": 10 },
-				{ "x": 12, "y": 8, "index": 9 },
-				{ "x": 32, "y": 245, "index": 21 },
-				{ "x": 32, "y": 277, "index": 33 },
-				{ "x": 36, "y": 337, "index": 19 },
-				{ "x": 39, "y": 15, "index": 36 },
-				{ "x": 47, "y": 115, "index": 23 },
-				{ "x": 49, "y": 178, "index": 25 },
-				{ "x": 70, "y": 8, "index": 1 },
-				{ "x": 101, "y": 35, "index": 41 },
-				{ "x": 111, "y": 311, "index": 44 },
-				{ "x": 123, "y": 156, "index": 45 },
-				{ "x": 138, "y": 423, "index": 32 },
-				{ "x": 140, "y": 224, "index": 43 },
-				{ "x": 144, "y": 136, "index": 11 },
-				{ "x": 149, "y": 452, "index": 18 },
-				{ "x": 158, "y": 475, "index": 5 },
-				{ "x": 191, "y": 68, "index": 7 },
-				{ "x": 202, "y": 12, "index": 39 },
-				{ "x": 218, "y": 349, "index": 34 },
-				{ "x": 219, "y": 285, "index": 42 },
-				{ "x": 222, "y": 96, "index": 28 },
-				{ "x": 262, "y": 8, "index": 8 },
-				{ "x": 279, "y": 166, "index": 48 },
-				{ "x": 279, "y": 425, "index": 22 },
-				{ "x": 303, "y": 314, "index": 27 },
-				{ "x": 320, "y": 109, "index": 16 },
-				{ "x": 326, "y": 146, "index": 47 },
-				{ "x": 333, "y": 160, "index": 46 },
-				{ "x": 362, "y": 26, "index": 4 },
-				{ "x": 365, "y": 441, "index": 17 },
-				{ "x": 380, "y": 297, "index": 38 },
-				{ "x": 392, "y": 242, "index": 29 },
-				{ "x": 427, "y": 275, "index": 40 },
-				{ "x": 445, "y": 85, "index": 2 },
-				{ "x": 446, "y": 424, "index": 30 },
-				{ "x": 459, "y": 347, "index": 37 },
-				{ "x": 463, "y": 53, "index": 24 },
-				{ "x": 484, "y": 210, "index": 20 },
-				{ "x": 488, "y": 8, "index": 26 },
-				{ "x": 489, "y": 303, "index": 35 },
-				{ "x": 529, "y": 8, "index": 31 },
-				{ "x": 529, "y": 421, "index": 3 },
-				{ "x": 558, "y": 87, "index": 13 },
-				{ "x": 563, "y": 261, "index": 12 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCstrx0.def",
-				"village" : "AVCSTRO0.DEF",
-				"capitol" : "AVCSTRZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBSTEXT3.def", "x" : 23,  "y" : 20 },
-				{ "id" : 0,  "animation" : "TBSTMAGE.def", "x" : 473, "y" : 67,  "z" : -1, "border" : "TOSMAG1.bmp",  "area" : "TZSMAG1.bmp" },
-				{ "id" : 1,  "animation" : "TBSTMAG2.def", "x" : 473, "y" : 37,  "z" : -1, "border" : "TOSMAG2.bmp",  "area" : "TZSMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBSTMAG3.def", "x" : 473, "y" : 1,   "z" : -1, "border" : "TOSMAG3.bmp",  "area" : "TZSMAG3.bmp" },
-				{ "id" : 5,  "animation" : "TBSTTVRN.def", "x" : 170, "y" : 280, "z" : 2,  "border" : "TOSTAV.bmp",   "area" : "TZSTAV.bmp" },
-				{ "id" : 7,  "animation" : "TBSTCSTL.def", "x" : 402, "y" : 148, "z" : -1, "border" : "TOSCA1.bmp",   "area" : "TZSCA1.bmp" },
-				{ "id" : 8,  "animation" : "TBSTCAS2.def", "x" : 402, "y" : 114, "z" : -1, "border" : "TOSCA2.bmp",   "area" : "TZSCA2.bmp" },
-				{ "id" : 9,  "animation" : "TBSTCAS3.def", "x" : 402, "y" : 114, "z" : -1, "border" : "TOSCA3.bmp",   "area" : "TZSCA3.bmp" },
-				{ "id" : 10, "animation" : "TBSTHALL.def", "x" : 0,   "y" : 259, "border" : "TOSHAL1A.bmp", "area" : "TZSHAL1A.bmp" },
-				{ "id" : 11, "animation" : "TBSTHAL2.def", "x" : 0,   "y" : 225, "border" : "TOSHAL2A.bmp", "area" : "TZSHAL2A.bmp" },
-				{ "id" : 12, "animation" : "TBSTHAL3.def", "x" : 0,   "y" : 201, "border" : "TOSHAL3A.bmp", "area" : "TZSHAL3A.bmp" },
-				{ "id" : 13, "animation" : "TBSTHAL4.def", "x" : 0,   "y" : 148, "border" : "TOSHAL4A.bmp", "area" : "TZSHAL4A.bmp" },
-				{ "id" : 14, "animation" : "TBSTMARK.def", "x" : 397, "y" : 308, "z" : 1,  "border" : "TOSMRK1.bmp",  "area" : "TZSMRK1.bmp" },
-				{ "id" : 15, "animation" : "TBSTSILO.def", "x" : 458, "y" : 248, "z" : 1,  "border" : "TOSMRK2.bmp",  "area" : "TZSMRK2.bmp" },
-				{ "id" : 16, "animation" : "TBSTBLAK.def", "x" : 660, "y" : 286, "border" : "TOSBLK1.bmp",  "area" : "TZSBLK1.bmp" },
-				{ "id" : 17, "animation" : "TBSTSPEC.def", "x" : 550, "y" : 229, "border" : "TOSCA1EA.bmp", "area" : "TZSCA1EA.bmp" },
-				{ "id" : 18, "animation" : "TBSTHRD1.def", "x" : 373, "y" : 239, "border" : "TOSGOB1H.bmp", "area" : "TZSGOB1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBSTHRD2.def", "x" : 373, "y" : 220, "border" : "TOSGOB2H.bmp", "area" : "TZSGOB2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 21, "animation" : "TBSTEXT0.def", "x" : 473, "y" : 282, "z" : 3,  "border" : "TOSMRK1C.bmp", "area" : "TZSMRK1C.bmp" },
-				{ "id" : 22, "animation" : "TBSTEXT1.def", "x" : 617, "y" : 286, "z" : 1,  "border" : "TOSBLK2.bmp",  "area" : "TZSBLK2.bmp" },
-				{ "id" : 23, "animation" : "TBSTEXT2.def", "x" : 313, "y" : 13,  "z" : -1, "border" : "TOSVAH.bmp",   "area" : "TZSVAH.bmp" },
-				{ "id" : 26, "animation" : "TBSTHOLY.def", "x" : 321, "y" : 105, "z" : 2,  "border" : "TOSHOLYA.bmp", "area" : "TZSHOLYA.bmp" },
-				{ "id" : 30, "animation" : "TBSTDW_0.def", "x" : 373, "y" : 239, "border" : "TOSGOB1.bmp",  "area" : "TZSGOB1.bmp" },
-				{ "id" : 31, "animation" : "TBSTDW_1.def", "x" : 266, "y" : 246, "z" : 1,  "border" : "TOSWOL1.bmp",  "area" : "TZSWOL1.bmp" },
-				{ "id" : 32, "animation" : "TBSTDW_2.def", "x" : 566, "y" : 232, "z" : 2,  "border" : "TOSORC1.bmp",  "area" : "TZSORC1.bmp" },
-				{ "id" : 33, "animation" : "TBSTDW_3.def", "x" : 197, "y" : 204, "border" : "TOSOGR1.bmp",  "area" : "TZSOGR1.bmp" },
-				{ "id" : 34, "animation" : "TBSTDW_4.def", "x" : 137, "y" : 30,  "z" : -1, "border" : "TOSROC1.bmp",  "area" : "TZSROC1.bmp" },
-				{ "id" : 35, "animation" : "TBSTDW_5.def", "x" : 622, "y" : 160, "z" : -2, "border" : "TOSCYC1.bmp",  "area" : "TZSCYC1.bmp" },
-				{ "id" : 36, "animation" : "TBSTDW_6.def", "x" : 604, "y" : 0,   "border" : "TOSBEH1A.bmp", "area" : "TZSBEH1A.bmp" },
-				{ "id" : 37, "animation" : "TBSTUP_0.def", "x" : 373, "y" : 220, "border" : "TOSGOB2.bmp",  "area" : "TZSGOB2.bmp" },
-				{ "id" : 38, "animation" : "TBSTUP_1.def", "x" : 266, "y" : 225, "z" : 1,  "border" : "TOSWOL2.bmp",  "area" : "TZSWOL2.bmp" },
-				{ "id" : 39, "animation" : "TBSTUP_2.def", "x" : 566, "y" : 158, "z" : 2,  "border" : "TOSORC2.bmp",  "area" : "TZSORC2.bmp" },
-				{ "id" : 40, "animation" : "TBSTUP_3.def", "x" : 197, "y" : 137, "border" : "TOSOGR2.bmp",  "area" : "TZSOGR2.bmp" },
-				{ "id" : 41, "animation" : "TBSTUP_4.def", "x" : 129, "y" : 15,  "z" : -1, "border" : "TOSROC2.bmp",  "area" : "TZSROC2.bmp" },
-				{ "id" : 42, "animation" : "TBSTUP_5.def", "x" : 616, "y" : 93,  "z" : -2, "border" : "TOSCYC2A.bmp", "area" : "TZSCYC2A.bmp" },
-				{ "id" : 43, "animation" : "TBSTUP_6.def", "x" : 604, "y" : 0,   "border" : "TOSBEH2A.bmp", "area" : "TZSBEH2A.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 30, "built" : 31 },
-				"fort"    : {"normal" : 12, "built" : 13 }
-			},
-			"musicTheme" : "music/Stronghold",
-
-			"townBackground": "TBSTBACK.bmp",
-			"guildWindow": "TPMAGEST.bmp",
-			"buildingsIcons": "HALLSTRN.DEF",
-			"hallBackground": "TPTHBKTW.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2 ], [ 23 ], [ 17 ] ],
-				[ [ 21 ], [ 22 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Goblin", "Hobgoblin"],
-				["GoblinWolfRider", "HobgoblinWolfRider"],
-				["Orc", "OrcChieftain"],
-				["Ogre", "OgreMage"],
-				["Roc", "Thunderbird"],
-				["Cyclops", "CyclopsLord"],
-				["YoungBehemoth", "AncientBehemoth"]
-			],
-			"horde" : [ 0, -1 ],
-			"mageGuild" : 3,
-			"warMachine" : "AmmoCart",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 7 ] },
-				{ "id" : 18, "upgrades" : 30 },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 21, "requires" : [ 14 ] },
-				{ "id" : 22, "requires" : [ 16 ] },
-				{ "id" : 23, "requires" : [ 7 ] },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 32 ] },
-				{ "id" : 34, "requires" : [ 31 ] },
-				{ "id" : 35, "requires" : [ 33 ] },
-				{ "id" : 36, "requires" : [ 34 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31, "requires" : [ 37 ] },
-				{ "id" : 39, "upgrades" : 32, "requires" : [ 16 ] },
-				{ "id" : 40, "upgrades" : 33, "requires" : [ 0 ] },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "Orc",
-				"imagePrefix" : "SGST",
-				"gate" :
-				{
-					"arch" : { "x" : 478, "y" : 235 },
-					"gate" : { "x" : 407, "y" : 266 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 410, "y" : 91 },
-					"moat" : { "x" : 410, "y" : 90 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 617, "y" : 62 },
-					"bottom" : { "x" : 511, "y" : 380 },
-					"top" : { "x" : 499, "y" : 107}
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 586, "y" : 508 },
-						"creature" : { "x" : 361, "y" : 290 },
-						"tower" : { "x" : 586, "y" : 508 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 731, "y" : 168 },
-						"creature" : { "x" : 531, "y" : -45 },
-						"tower" : { "x" : 731, "y" : 168 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 568, "y" : 30 },
-						"creature" : { "x" : 342, "y" : -187 },
-						"tower" : { "x" : 568, "y" : 30 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 553, "y" : 440 },
-					"bottomMid" : { "x" : 483, "y" : 304 },
-					"upper" : { "x" : 534, "y" : 69 },
-					"upperMid" : { "x" : 476, "y" : 189 }
-				}
-			}
-		}
-	},
-	"fortress" :
-	{
-		"index" : 7,
-		"nativeTerrain": "swamp",
-		"alignment" : "neutral",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASFOR",
-			"130px" : "CRBKGFOR"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZFOR",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 36 },
-				{ "x": 7, "y": 152, "index": 25 },
-				{ "x": 7, "y": 306, "index": 34 },
-				{ "x": 7, "y": 388, "index": 23 },
-				{ "x": 7, "y": 434, "index": 15 },
-				{ "x": 23, "y": 417, "index": 37 },
-				{ "x": 32, "y": 232, "index": 38 },
-				{ "x": 42, "y": 137, "index": 39 },
-				{ "x": 47, "y": 440, "index": 8 },
-				{ "x": 56, "y": 19, "index": 47 },
-				{ "x": 71, "y": 8, "index": 1 },
-				{ "x": 87, "y": 219, "index": 30 },
-				{ "x": 90, "y": 26, "index": 41 },
-				{ "x": 104, "y": 397, "index": 33 },
-				{ "x": 116, "y": 345, "index": 40 },
-				{ "x": 134, "y": 215, "index": 11 },
-				{ "x": 175, "y": 168, "index": 19 },
-				{ "x": 191, "y": 428, "index": 13 },
-				{ "x": 200, "y": 326, "index": 24 },
-				{ "x": 216, "y": 98, "index": 18 },
-				{ "x": 221, "y": 398, "index": 20 },
-				{ "x": 225, "y": 235, "index": 46 },
-				{ "x": 239, "y": 8, "index": 9 },
-				{ "x": 245, "y": 40, "index": 7 },
-				{ "x": 248, "y": 208, "index": 48 },
-				{ "x": 261, "y": 439, "index": 5 },
-				{ "x": 262, "y": 134, "index": 26 },
-				{ "x": 297, "y": 352, "index": 22 },
-				{ "x": 309, "y": 99, "index": 16 },
-				{ "x": 320, "y": 262, "index": 43 },
-				{ "x": 323, "y": 404, "index": 10 },
-				{ "x": 326, "y": 200, "index": 45 },
-				{ "x": 331, "y": 20, "index": 17 },
-				{ "x": 345, "y": 178, "index": 21 },
-				{ "x": 353, "y": 8, "index": 3 },
-				{ "x": 358, "y": 290, "index": 42 },
-				{ "x": 381, "y": 399, "index": 14 },
-				{ "x": 400, "y": 65, "index": 12 },
-				{ "x": 428, "y": 160, "index": 35 },
-				{ "x": 448, "y": 293, "index": 29 },
-				{ "x": 451, "y": 94, "index": 27 },
-				{ "x": 453, "y": 424, "index": 2 },
-				{ "x": 462, "y": 397, "index": 32 },
-				{ "x": 465, "y": 8, "index": 4 },
-				{ "x": 486, "y": 163, "index": 44 },
-				{ "x": 492, "y": 184, "index": 31 },
-				{ "x": 517, "y": 304, "index": 6 },
-				{ "x": 549, "y": 8, "index": 28 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "AVCftrx0.def",
-				"village" : "AVCFTRT0.DEF",
-				"capitol" : "AVCFORZ0.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBFREXT2.def", "x" : 372, "y" : 227 },
-				{ "id" : 0,  "animation" : "TBFRMAGE.def", "x" : 0,   "y" : 200, "z" : -1, "border" : "TOFMAG1A.bmp", "area" : "TZFMAG1A.bmp" },
-				{ "id" : 1,  "animation" : "TBFRMAG2.def", "x" : 0,   "y" : 177, "z" : -1, "border" : "TOFMAG2A.bmp", "area" : "TZFMAG2A.bmp" },
-				{ "id" : 2,  "animation" : "TBFRMAG3.def", "x" : 0,   "y" : 135, "z" : -1, "border" : "TOFMAG3A.bmp", "area" : "TZFMAG3A.bmp" },
-				{ "id" : 5,  "animation" : "TBFRTVRN.def", "x" : 634, "y" : 219, "z" : 3,  "border" : "TOFTAVA.bmp",  "area" : "TZFTAVA.bmp" },
-				{ "id" : 6,  "animation" : "TBFRDOCK.def", "x" : 197, "y" : 294, "border" : "TOFDCK2.bmp",  "area" : "TZFDCK2.bmp" },
-				{ "id" : 7,  "animation" : "TBFRCSTL.def", "x" : 368, "y" : 118, "z" : -1, "border" : "TOFCAS1.bmp",  "area" : "TZFCAS1.bmp" },
-				{ "id" : 8,  "animation" : "TBFRCAS2.def", "x" : 368, "y" : 98,  "z" : -1, "border" : "TOFCAS2.bmp",  "area" : "TZFCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBFRCAS3.def", "x" : 368, "y" : 55,  "z" : -1, "border" : "TOFCAS3.bmp",  "area" : "TZFCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBFRHALL.def", "x" : 166, "y" : 128, "z" : 1,  "border" : "TOFHAL1.bmp",  "area" : "TZFHAL1.bmp" },
-				{ "id" : 11, "animation" : "TBFRHAL2.def", "x" : 166, "y" : 97,  "z" : 1,  "border" : "TOFHAL2.bmp",  "area" : "TZFHAL2.bmp" },
-				{ "id" : 12, "animation" : "TBFRHAL3.def", "x" : 166, "y" : 51,  "z" : 1,  "border" : "TOFHAL3.bmp",  "area" : "TZFHAL3.bmp" },
-				{ "id" : 13, "animation" : "TBFRHAL4.def", "x" : 166, "y" : 2,   "z" : 1,  "border" : "TOFHAL4.bmp",  "area" : "TZFHAL4.bmp" },
-				{ "id" : 14, "animation" : "TBFRMARK.def", "x" : 382, "y" : 219, "z" : 4,  "border" : "TOFMRKAA.bmp", "area" : "TZFMRKAA.bmp" },
-				{ "id" : 15, "animation" : "TBFRSILO.def", "x" : 448, "y" : 210, "z" : 2,  "border" : "TOFMRK2A.bmp", "area" : "TZFMRK2A.bmp" },
-				{ "id" : 16, "animation" : "TBFRBLAK.def", "x" : 360, "y" : 160, "border" : "TOFAIDA.bmp",  "area" : "TZFAIDA.bmp" },
-				{ "id" : 17, "animation" : "TBFRSPEC.def", "x" : 703, "y" : 36,  "border" : "TOFCAGE.bmp",  "area" : "TZFCAGE.bmp" },
-				{ "id" : 18, "animation" : "TBFRHRD1.def", "x" : 641, "y" : 121, "z" : 1,  "border" : "TOFGNL1H.bmp", "area" : "TZFGNL1H.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBFRHRD2.def", "x" : 641, "y" : 68,  "z" : 1,  "border" : "TOFGNL2H.bmp", "area" : "TZFGNL2H.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 20, "animation" : "TBFRBOAT.def", "x" : 197, "y" : 294, "z" : 1,  "border" : "TOFDCK1.bmp",  "area" : "TZFDCK1.bmp", "hidden" : true },
-				{ "id" : 21, "animation" : "TBFREXT0.def", "x" : 341, "y" : 174, "border" : "TOFCASD.bmp",  "area" : "TZFCASD.bmp" },
-				{ "id" : 22, "animation" : "TBFREXT1.def", "x" : 349, "y" : 79,  "z" : -2, "border" : "TOFCASA.bmp",  "area" : "TZFCASA.bmp" },
-				{ "id" : 26, "animation" : "TBFRHOLY.def", "x" : 468, "y" : 260, "z" : 5,  "border" : "TOFHLYAA.bmp", "area" : "TZFHLYAA.bmp" },
-				{ "id" : 29, "animation" : "TBFRWTRW.def", "x" : 320, "y" : 141 },
-				{ "id" : 30, "animation" : "TBFRDW_0.def", "x" : 641, "y" : 168, "z" : 1,  "border" : "TOFGNL1.bmp",  "area" : "TZFGNL1.bmp" },
-				{ "id" : 31, "animation" : "TBFRDW_1.def", "x" : 141, "y" : 178, "border" : "TOFLIZ1.bmp",  "area" : "TZFLIZ1.bmp" },
-				{ "id" : 32, "animation" : "TBFRDW_3.def", "x" : 192, "y" : 85,  "border" : "TOFFLY1A.bmp", "area" : "TZFFLY1A.bmp" },
-				{ "id" : 33, "animation" : "TBFRDW_4.def", "x" : 0,   "y" : 292, "border" : "TOFBAS1.bmp",  "area" : "TZFBAS1.bmp" },
-				{ "id" : 34, "animation" : "TBFRDW_2.def", "x" : 15,  "y" : 127, "z" : -2, "border" : "TOFGOR1.bmp",  "area" : "TZFGOR1.bmp" },
-				{ "id" : 35, "animation" : "TBFRDW_5.def", "x" : 0,   "y" : 4,   "border" : "TOFWYV1.bmp",  "area" : "TZFWYV1.bmp" },
-				{ "id" : 36, "animation" : "TBFRDW_6.def", "x" : 612, "y" : 291, "z" : 5,  "border" : "TOFHYD1A.bmp", "area" : "TZFHYD1A.bmp" },
-				{ "id" : 37, "animation" : "TBFRUP_0.def", "x" : 641, "y" : 107, "z" : 1,  "border" : "TOFGNL2.bmp",  "area" : "TZFGNL2.bmp" },
-				{ "id" : 38, "animation" : "TBFRUP_1.def", "x" : 125, "y" : 163, "border" : "TOFLIZ2.bmp",  "area" : "TZFLIZ2.bmp" },
-				{ "id" : 39, "animation" : "TBFRUP_3.def", "x" : 159, "y" : 19,  "border" : "TOFFLY2A.bmp", "area" : "TZFFLY2A.bmp" },
-				{ "id" : 40, "animation" : "TBFRUP_4.def", "x" : 0,   "y" : 257, "border" : "TOFBAS2.bmp",  "area" : "TZFBAS2.bmp" },
-				{ "id" : 41, "animation" : "TBFRUP_2.def", "x" : 15,  "y" : 69,  "z" : -2, "border" : "TOFGOR2.bmp",  "area" : "TZFGOR2.bmp" },
-				{ "id" : 42, "animation" : "TBFRUP_5.def", "x" : 0,   "y" : 4,   "border" : "TOFWYV2.bmp",  "area" : "TZFWYV2.bmp" },
-				{ "id" : 43, "animation" : "TBFRUP_6.def", "x" : 587, "y" : 263, "z" : 5,  "border" : "TOFHYD2A.bmp", "area" : "TZFHYD2A.bmp" }
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 32, "built" : 33 },
-				"fort"    : {"normal" : 14, "built" : 15 }
-			},
-			"musicTheme" : "music/FortressTown",
-
-			"townBackground": "TBFRBACK.bmp",
-			"guildWindow": "TPMAGEFR.bmp",
-			"buildingsIcons": "HALLFORT.DEF",
-			"hallBackground": "TPTHBKFR.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2 ], [ 6 ] ],
-				[ [ 17 ], [ 21, 22 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Gnoll", "GnollMarauder"],
-				["PrimitiveLizardman", "AdvancedLizardman"],
-				["Dragonflies", "FireDragonFly"],
-				["Basilisk", "GreaterBasilisk"],
-				["CopperGorgon", "BronzeGorgon"],
-				["Wyvern", "WyvernMonarch"],
-				["Hydra", "ChaosHydra"]
-			],
-			"horde" : [ 0, -1 ],
-			"mageGuild" : 3,
-			"warMachine" : "FirstAidTent",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 6 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 11, 21 ] },
-				{ "id" : 18, "upgrades" : 30 },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 20, "upgrades" : 6 },
-				{ "id" : 21, "requires" : [ 7 ] },
-				{ "id" : 22, "requires" : [ 21 ] },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30 ] },
-				{ "id" : 32, "requires" : [ 30 ] },
-				{ "id" : 33, "requires" : [ 32 ] },
-				{ "id" : 34, "requires" : [ 31, 32 ] },
-				{ "id" : 35, "requires" : [ 31 ] },
-				{ "id" : 36, "requires" : [ 33, 35 ] },
-				{ "id" : 37, "upgrades" : 30, "requires" : [ 5 ] },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33 },
-				{ "id" : 41, "upgrades" : 34, "requires" : [ 15 ] },
-				{ "id" : 42, "upgrades" : 35 },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "PrimitiveLizardman",
-				"imagePrefix" : "SGFR",
-				"gate" :
-				{
-					"arch" : { "x" : 483, "y" : 236 },
-					"gate" : { "x" : 392, "y" : 253 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 376, "y" : 70 },
-					"moat" : { "x" : 383, "y" : 95 }
-				},
-				"shooterHeight" : 231,
-				"static" :
-				{
-					"background" : { "x" : 599, "y" : 62 },
-					"bottom" : { "x" : 522, "y" : 382 },
-					"top" : { "x" : 508, "y" : 130 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 599, "y" : 505 },
-						"creature" : { "x" : 372, "y" : 308 },
-						"tower" : { "x" : 599, "y" : 505 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 721, "y" : 178 },
-						"creature" : { "x" : 541, "y" : -37 },
-						"tower" : { "x" : 721, "y" : 178 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 548, "y" : 27 },
-						"creature" : { "x" : 326, "y" : -182 },
-						"tower" : { "x" : 548, "y" : 27 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 546, "y" : 441 },
-					"bottomMid" : { "x" : 486, "y" : 306 },
-					"upper" : { "x" : 526, "y" : 80 },
-					"upperMid" : { "x" : 498, "y" : 184 }
-				}
-			}
-		}
-	},
-	"conflux" :
-	{
-		"index" : 8,
-		"nativeTerrain": "grass",
-		"alignment" : "neutral",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASELE",
-			"130px" : "CRBKGELE"
-		},
-		"puzzleMap" :
-		{
-			"prefix" : "PUZELE",
-			"pieces" :
-			[
-				{ "x": 7, "y": 8, "index": 1 },
-				{ "x": 7, "y": 54, "index": 6 },
-				{ "x": 7, "y": 227, "index": 16 },
-				{ "x": 7, "y": 426, "index": 9 },
-				{ "x": 15, "y": 48, "index": 22 },
-				{ "x": 45, "y": 375, "index": 32 },
-				{ "x": 48, "y": 249, "index": 28 },
-				{ "x": 86, "y": 500, "index": 15 },
-				{ "x": 93, "y": 55, "index": 37 },
-				{ "x": 99, "y": 245, "index": 7 },
-				{ "x": 101, "y": 354, "index": 27 },
-				{ "x": 104, "y": 175, "index": 35 },
-				{ "x": 107, "y": 14, "index": 21 },
-				{ "x": 124, "y": 296, "index": 38 },
-				{ "x": 134, "y": 8, "index": 4 },
-				{ "x": 181, "y": 466, "index": 26 },
-				{ "x": 182, "y": 200, "index": 40 },
-				{ "x": 189, "y": 381, "index": 33 },
-				{ "x": 192, "y": 40, "index": 8 },
-				{ "x": 192, "y": 364, "index": 11 },
-				{ "x": 201, "y": 124, "index": 48 },
-				{ "x": 203, "y": 330, "index": 42 },
-				{ "x": 228, "y": 293, "index": 45 },
-				{ "x": 235, "y": 39, "index": 25 },
-				{ "x": 242, "y": 335, "index": 44 },
-				{ "x": 275, "y": 488, "index": 5 },
-				{ "x": 278, "y": 202, "index": 46 },
-				{ "x": 290, "y": 80, "index": 13 },
-				{ "x": 291, "y": 115, "index": 20 },
-				{ "x": 308, "y": 225, "index": 43 },
-				{ "x": 310, "y": 158, "index": 39 },
-				{ "x": 312, "y": 24, "index": 12 },
-				{ "x": 317, "y": 8, "index": 2 },
-				{ "x": 323, "y": 443, "index": 10 },
-				{ "x": 327, "y": 253, "index": 41 },
-				{ "x": 330, "y": 36, "index": 36 },
-				{ "x": 349, "y": 330, "index": 34 },
-				{ "x": 349, "y": 426, "index": 17 },
-				{ "x": 407, "y": 191, "index": 47 },
-				{ "x": 421, "y": 430, "index": 31 },
-				{ "x": 428, "y": 246, "index": 23 },
-				{ "x": 467, "y": 90, "index": 29 },
-				{ "x": 481, "y": 13, "index": 30 },
-				{ "x": 489, "y": 346, "index": 18 },
-				{ "x": 504, "y": 113, "index": 19 },
-				{ "x": 504, "y": 190, "index": 24 },
-				{ "x": 507, "y": 8, "index": 14 },
-				{ "x": 542, "y": 436, "index": 3 }
-			]
-		},
-		"town" :
-		{
-			"adventureMap" :
-			{
-				"castle" : "avchforx.def",
-				"village" : "AVCHFOR0.DEF",
-				"capitol" : "AVCHFORZ.DEF"
-			},
-			"structures" :
-			[
-				{ "animation" : "TBELEXT5.def", "x" : 682, "y" : 183,  "z" : -1, },
-				{ "animation" : "TBELEXT1.def", "x" : 23,  "y" : 218 },
-				{ "id" : 0,  "animation" : "TBELMAGE.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAGE.bmp", "area" : "TZELMAGE.bmp" },
-				{ "id" : 1,  "animation" : "TBELMAG2.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG2.bmp", "area" : "TZELMAG2.bmp" },
-				{ "id" : 2,  "animation" : "TBELMAG3.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG3.bmp", "area" : "TZELMAG3.bmp" },
-				{ "id" : 3,  "animation" : "TBELMAG4.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG4.bmp", "area" : "TZELMAG4.bmp" },
-				{ "id" : 4,  "animation" : "TBELMAG5.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG5.bmp", "area" : "TZELMAG5.bmp" },
-				{ "id" : 5,  "animation" : "TBELTVRN.def", "x" : 553, "y" : 203, "z" : 1,  "border" : "TOELTVRN.bmp", "area" : "TZELTVRN.bmp" },
-				{ "id" : 6,  "animation" : "TBELDOCK.def", "x" : 239, "y" : 215, "z" : 2,  "border" : "TOELDOCK.bmp", "area" : "TZELDOCK.bmp" },
-				{ "id" : 7,  "animation" : "TBELCSTL.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCSTL.bmp", "area" : "TZELCSTL.bmp" },
-				{ "id" : 8,  "animation" : "TBELCAS2.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCAS2.bmp", "area" : "TZELCAS2.bmp" },
-				{ "id" : 9,  "animation" : "TBELCAS3.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCAS3.bmp", "area" : "TZELCAS3.bmp" },
-				{ "id" : 10, "animation" : "TBELHALL.def", "x" : -1,  "y" : 164, "z" : 5,  "border" : "TOELHALL.bmp", "area" : "TZELHALL.bmp" },
-				{ "id" : 11, "animation" : "TBELHAL2.def", "x" : 0,   "y" : 165, "z" : 5,  "border" : "TOELHAL2.bmp", "area" : "TZELHAL2.bmp" },
-				{ "id" : 12, "animation" : "TBELHAL3.def", "x" : 0,   "y" : 165, "z" : 5,  "border" : "TOELHAL3.bmp", "area" : "TZELHAL3.bmp" },
-				{ "id" : 13, "animation" : "TBELHAL4.def", "x" : 0,   "y" : 164, "z" : 5,  "border" : "TOELHAL4.bmp", "area" : "TZELHAL4.bmp" },
-				{ "id" : 14, "animation" : "TBELMARK.def", "x" : 347, "y" : 216, "z" : 4,  "border" : "TOELMARK.bmp", "area" : "TZELMARK.bmp" },
-				{ "id" : 15, "animation" : "TBELSILO.def", "x" : 372, "y" : 171, "z" : 2,  "border" : "TOELSILO.bmp", "area" : "TZELSILO.bmp" },
-				{ "id" : 16, "animation" : "TBELBLAK.def", "x" : 449, "y" : 151, "z" : 1,  "border" : "TOELBLAK.bmp", "area" : "TZELBLAK.bmp" },
-				{ "id" : 17, "animation" : "TBELSPEC.def", "x" : 284, "y" : 246, "z" : 4,  "border" : "TOELSPEC.bmp", "area" : "TZELSPEC.bmp" },
-				{ "id" : 18, "animation" : "TBELHRD1.def", "x" : 689, "y" : 250, "border" : "TOELHRD1.bmp", "area" : "TZELHRD1.bmp", "hidden" : true },
-				{ "id" : 19, "animation" : "TBELHRD2.def", "x" : 689, "y" : 250, "border" : "TOELHRD2.bmp", "area" : "TZELHRD2.bmp", "hidden" : true, "builds" : 18 },
-				{ "id" : 20, "animation" : "TBELBOAT.def", "x" : 239, "y" : 215, "z" : 2,  "border" : "TOELBOAT.bmp", "area" : "TZELBOAT.bmp", "hidden" : true },
-				{ "id" : 21, "animation" : "TBELEXT6.def", "x" : 104, "y" : 170, "z" : 3,  "border" : "TOELEXT6.bmp", "area" : "TZELEXT6.bmp" },
-				{ "id" : 26, "animation" : "TBELHOLY.def", "x" : 307, "y" : 2,   "border" : "TOELHOLY.bmp", "area" : "TZELHOLY.bmp" },
-				{ "id" : 27, "animation" : "TBELEXT2.def", "x" : 232, "y" : 205 },
-				{ "id" : 28, "animation" : "TBELEXT3.def", "x" : 516, "y" : 223, "z" : 1 },
-				{ "id" : 29, "animation" : "TBELEXT4.def", "x" : 0,   "y" : 252, "z" : 6 },
-				{ "id" : 30, "animation" : "TBELDW_0.def", "x" : 689, "y" : 250, "border" : "TOELDW_0.bmp", "area" : "TZELDW_0.bmp" },
-				{ "id" : 31, "animation" : "TBELDW_1.def", "x" : 630, "y" : 50,  "border" : "TOELDW_1.bmp", "area" : "TZELDW_1.bmp" },
-				{ "id" : 32, "animation" : "TBELDW_2.def", "x" : 709, "y" : 210, "z" : -1, "border" : "TOELDW_2.bmp", "area" : "TZELDW_2.bmp" },
-				{ "id" : 33, "animation" : "TBELDW_3.def", "x" : 108, "y" : 131, "z" : -1, "border" : "TOELDW_3.bmp", "area" : "TZELDW_3.bmp" },
-				{ "id" : 34, "animation" : "TBELDW_4.def", "x" : 264, "y" : 168, "z" : -1, "border" : "TOELDW_4.bmp", "area" : "TZELDW_4.bmp" },
-				{ "id" : 35, "animation" : "TBELDW_5.def", "x" : 394, "y" : 283, "z" : 2,  "border" : "TOELDW_5.bmp", "area" : "TZELDW_5.bmp" },
-				{ "id" : 36, "animation" : "TBELDW_6.def", "x" : 43,  "y" : 16,  "z" : -2, "border" : "TOELDW_6.bmp", "area" : "TZELDW_6.bmp" },
-				{ "id" : 37, "animation" : "TBELUP_0.def", "x" : 689, "y" : 250, "border" : "TOELUP_0.bmp", "area" : "TZELUP_0.bmp" },
-				{ "id" : 38, "animation" : "TBELUP_1.def", "x" : 630, "y" : 50,  "border" : "TOELUP_1.bmp", "area" : "TZELUP_1.bmp" },
-				{ "id" : 39, "animation" : "TBELUP_2.def", "x" : 709, "y" : 210, "z" : -1, "border" : "TOELUP_2.bmp", "area" : "TZELUP_2.bmp" },
-				{ "id" : 40, "animation" : "TBELUP_3.def", "x" : 108, "y" : 131, "z" : -1, "border" : "TOELUP_3.bmp", "area" : "TZELUP_3.bmp" },
-				{ "id" : 41, "animation" : "TBELUP_4.def", "x" : 264, "y" : 168, "z" : -1, "border" : "TOELUP_4.bmp", "area" : "TZELUP_4.bmp" },
-				{ "id" : 42, "animation" : "TBELUP_5.def", "x" : 394, "y" : 283, "z" : 2,  "border" : "TOELUP_5.bmp", "area" : "TZELUP_5.bmp" },
-				{ "id" : 43, "animation" : "TBELUP_6.def", "x" : 43,  "y" : 0,   "z" : -2, "border" : "TOELUP_6.bmp", "area" : "TZELUP_6.bmp" },
-			],
-			"icons" :
-			{
-				"village" : {"normal" : 34, "built" : 35 },
-				"fort"    : {"normal" : 16, "built" : 17 }
-			},
-			"musicTheme" : "music/ElemTown",
-
-			"townBackground": "TBELBACK.bmp",
-			"guildWindow": "TPMAGEEL.bmp",
-			"buildingsIcons": "HALLELEM.DEF",
-			"hallBackground": "TPTHBKFR.BMP",
-			"hallSlots":
-			[
-				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
-				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 6 ] ],
-				[ [ 21 ], [ 17 ], [ 18, 19 ] ],
-				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
-				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
-			],
-			"creatures" :
-			[
-				["Pixie", "Sprite"],
-				["AirElemental", "StormElemental"],
-				["WaterElemental", "IceElemental"],
-				["FireElemental", "ElectricityElemental"],
-				["EarthElemental", "StoneElemental"],
-				["PsiElemental", "MagicElemental"],
-				["Firebird", "Pheonix"]
-			],
-			"horde" : [ 0, -1 ],
-			"mageGuild" : 5,
-			"primaryResource" : "mercury",
-			"warMachine" : "Ballista",
-
-			"buildings" :
-			[
-				{ "id" : 0 },
-				{ "id" : 1,  "upgrades" : 0 },
-				{ "id" : 2,  "upgrades" : 1 },
-				{ "id" : 3,  "upgrades" : 2 },
-				{ "id" : 4,  "upgrades" : 3 },
-				{ "id" : 5 },
-				{ "id" : 6 },
-				{ "id" : 7 },
-				{ "id" : 8,  "upgrades" : 7 },
-				{ "id" : 9,  "upgrades" : 8 },
-				{ "id" : 10, "mode" : "auto" },
-				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
-				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
-				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
-				{ "id" : 14 },
-				{ "id" : 15, "requires" : [ 14 ] },
-				{ "id" : 16 },
-				{ "id" : 17, "requires" : [ 14 ] },
-				{ "id" : 18, "upgrades" : 30 },
-				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
-				{ "id" : 20, "upgrades" : 6 },
-				{ "id" : 21, "requires" : [ 0 ] },
-				{ "id" : 26, "mode" : "grail"},
-				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
-				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
-				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
-				{ "id" : 30, "requires" : [ 7 ] },
-				{ "id" : 31, "requires" : [ 30, 0 ] },
-				{ "id" : 32, "requires" : [ 30, 0 ] },
-				{ "id" : 33, "requires" : [ 31 ] },
-				{ "id" : 34, "requires" : [ 32 ] },
-				{ "id" : 35, "requires" : [ 33, 34 ] },
-				{ "id" : 36, "requires" : [ 35 ] },
-				{ "id" : 37, "upgrades" : 30 },
-				{ "id" : 38, "upgrades" : 31 },
-				{ "id" : 39, "upgrades" : 32 },
-				{ "id" : 40, "upgrades" : 33, "requires" : [ 31 ] },
-				{ "id" : 41, "upgrades" : 34 },
-				{ "id" : 42, "upgrades" : 35, "requires" : [ 1 ] },
-				{ "id" : 43, "upgrades" : 36 }
-			],
-
-			"siege" :
-			{
-				"shooter" : "StormElemental",
-				"imagePrefix" : "SGEL",
-				"gate" :
-				{
-					"arch" : { "x" : 486, "y" : 232 },
-					"gate" : { "x" : 408, "y" : 254 }
-				},
-				"moat" :
-				{
-					"bank" : { "x" : 407, "y" : 80 },
-					"moat" : { "x" : 407, "y" : 80 }
-				},
-				"shooterHeight" : 229,
-				"static" :
-				{
-					"background" : { "x" : 600, "y" : 50 },
-					"bottom" : { "x" : 509, "y" : 346 },
-					"top" : { "x" : 490, "y" : 97 }
-				},
-				"towers" :
-				{
-					"bottom" :
-					{
-						"battlement" : { "x" : 608, "y" : 505 },
-						"creature" : { "x" : 382, "y" : 308 },
-						"tower" : { "x" : 608, "y" : 505 }
-					},
-					"keep" :
-					{
-						"battlement" : { "x" : 736, "y" : 159 },
-						"creature" : { "x" : 529, "y" : -42 },
-						"tower" : { "x" : 736, "y" : 159 }
-					},
-					"top" :
-					{
-						"battlement" : { "x" : 576, "y" : 28 },
-						"creature" : { "x" : 341, "y" : -162 },
-						"tower" : { "x" : 576, "y" : 28 }
-					}
-				},
-				"walls" :
-				{
-					"bottom" : { "x" : 509, "y" : 346 },
-					"bottomMid" : { "x" : 468, "y" : 299 },
-					"upper" : { "x" : 521, "y" : 41 },
-					"upperMid" : { "x" : 471, "y" : 147 }
-				}
-			}
-		}
-	},
-	"neutral" :
-	{
-		"index" : 9,
-		"alignment" : "neutral",
-		"creatureBackground" :
-		{
-			"120px" : "TPCASNEU",
-			"130px" : "CRBKGNEU"
-		}
-	}
-
-
-}

+ 248 - 0
config/factions/castle.json

@@ -0,0 +1,248 @@
+{
+	"castle" :
+	{
+		"index" : 0,
+		"nativeTerrain": "grass",
+		"alignment" : "good",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASCAS",
+			"130px" : "CRBKGCAS"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZCAS",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 39 },
+				{ "x": 7, "y": 30, "index": 41 },
+				{ "x": 7, "y": 102, "index": 1 },
+				{ "x": 7, "y": 156, "index": 23 },
+				{ "x": 7, "y": 202, "index": 6 },
+				{ "x": 7, "y": 320, "index": 13 },
+				{ "x": 16, "y": 8, "index": 39 },
+				{ "x": 22, "y": 406, "index": 2 },
+				{ "x": 70, "y": 301, "index": 22 },
+				{ "x": 72, "y": 194, "index": 11 },
+				{ "x": 101, "y": 332, "index": 8 },
+				{ "x": 106, "y": 8, "index": 9 },
+				{ "x": 106, "y": 31, "index": 29 },
+				{ "x": 114, "y": 60, "index": 7 },
+				{ "x": 126, "y": 329, "index": 17 },
+				{ "x": 128, "y": 191, "index": 21 },
+				{ "x": 152, "y": 347, "index": 27 },
+				{ "x": 154, "y": 239, "index": 31 },
+				{ "x": 157, "y": 429, "index": 34 },
+				{ "x": 166, "y": 470, "index": 4 },
+				{ "x": 185, "y": 127, "index": 30 },
+				{ "x": 212, "y": 335, "index": 36 },
+				{ "x": 214, "y": 191, "index": 48 },
+				{ "x": 217, "y": 226, "index": 43 },
+				{ "x": 235, "y": 147, "index": 35 },
+				{ "x": 245, "y": 77, "index": 16 },
+				{ "x": 266, "y": 384, "index": 42 },
+				{ "x": 288, "y": 288, "index": 45 },
+				{ "x": 298, "y": 8, "index": 26 },
+				{ "x": 321, "y": 177, "index": 46 },
+				{ "x": 346, "y": 67, "index": 38 },
+				{ "x": 354, "y": 459, "index": 20 },
+				{ "x": 355, "y": 397, "index": 25 },
+				{ "x": 375, "y": 162, "index": 28 },
+				{ "x": 382, "y": 255, "index": 32 },
+				{ "x": 408, "y": 32, "index": 37 },
+				{ "x": 408, "y": 111, "index": 14 },
+				{ "x": 421, "y": 147, "index": 19 },
+				{ "x": 422, "y": 466, "index": 12 },
+				{ "x": 426, "y": 8, "index": 15 },
+				{ "x": 436, "y": 238, "index": 24 },
+				{ "x": 458, "y": 336, "index": 44 },
+				{ "x": 486, "y": 8, "index": 40 },
+				{ "x": 487, "y": 144, "index": 33 },
+				{ "x": 517, "y": 145, "index": 18 },
+				{ "x": 520, "y": 68, "index": 5 },
+				{ "x": 524, "y": 234, "index": 10 },
+				{ "x": 525, "y": 327, "index": 3 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCcasx0.def",
+				"village" : "AVCCAST0.DEF",
+				"capitol" : "AVCCASZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBCSEXT2.def", "x" : 46,  "y" : 119 },
+				{ "id" : 0,  "animation" : "TBCSMAGE.def", "x" : 707, "y" : 166, "z" : 1, "border" : "TOCSMAG1.bmp", "area" : "TZCSMAG1.bmp" },
+				{ "id" : 1,  "animation" : "TBCSMAG2.def", "x" : 706, "y" : 135, "z" : 1, "border" : "TOCSMAG2.bmp", "area" : "TZCSMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBCSMAG3.def", "x" : 704, "y" : 107, "z" : 1, "border" : "TOCSM301.bmp", "area" : "TZCSM301.bmp" },
+				{ "id" : 3,  "animation" : "TBCSMAG4.def", "x" : 704, "y" : 76,  "z" : 1, "border" : "TOCSM401.bmp", "area" : "TZCSM401.bmp" },
+				{ "id" : 5,  "animation" : "TBCSTVRN.def", "x" : 0,   "y" : 230, "z" : 1, "border" : "TOCSTAV1.bmp", "area" : "TZCSTAV1.bmp" },
+				{ "id" : 6,  "animation" : "TBCSDOCK.def", "x" : 478, "y" : 134, "border" : "TOCSDKMS.bmp", "area" : "TZCSDKMS.bmp" },
+				{ "id" : 7,  "animation" : "TBCSCSTL.def", "x" : 595, "y" : 66,  "border" : "TOCSCAS1.bmp", "area" : "TZCSCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBCSCAS2.def", "x" : 478, "y" : 66,  "border" : "TOCSCAS2.bmp", "area" : "TZCSCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBCSCAS3.def", "x" : 478, "y" : 37,  "border" : "TOCSCAS3.bmp", "area" : "TZCSCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBCSHALL.def", "x" : 0,   "y" : 209, "border" : "TOCSH101.bmp", "area" : "TZCSH101.bmp" },
+				{ "id" : 11, "animation" : "TBCSHAL2.def", "x" : 0,   "y" : 176, "border" : "TOCSH201.bmp", "area" : "TZCSH201.bmp" },
+				{ "id" : 12, "animation" : "TBCSHAL3.def", "x" : 0,   "y" : 164, "border" : "TOCSH301.bmp", "area" : "TZCSH301.bmp" },
+				{ "id" : 13, "animation" : "TBCSHAL4.def", "x" : 0,   "y" : 154, "border" : "TOCSH401.bmp", "area" : "TZCSH401.bmp" },
+				{ "id" : 14, "animation" : "TBCSMARK.def", "x" : 413, "y" : 264, "border" : "TOCSMRK1.bmp", "area" : "TZCSMRK1.bmp" },
+				{ "id" : 15, "animation" : "TBCSSILO.def", "x" : 488, "y" : 228, "border" : "TOCSMRK2.bmp", "area" : "TZCSMRK2.bmp" },
+				{ "id" : 16, "animation" : "TBCSBLAK.def", "x" : 213, "y" : 251, "border" : "TOCSBLAK.bmp", "area" : "TZCSBLAK.bmp" },
+				{ "id" : 17, "animation" : "TBCSSPEC.def", "x" : 533, "y" : 71,  "border" : "TOCSLT01.bmp", "area" : "TZCSLT01.bmp" },
+				{ "id" : 18, "animation" : "TBCSHRD1.def", "x" : 76,  "y" : 53,  "border" : "TOCSGR1H.bmp", "area" : "TZCSGR1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBCSHRD2.def", "x" : 76,  "y" : 35,  "border" : "TOCSGR2H.bmp", "area" : "TZCSGR2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 20, "animation" : "TBCSBOAT.def", "x" : 478, "y" : 134, "border" : "TOCSDKMN.bmp", "area" : "TZCSDKMN.bmp", "hidden" : true },
+				{ "id" : 21, "animation" : "TBCSEXT0.def", "x" : 384, "y" : 193, "z" : -2, "border" : "TOCSCAVM.bmp", "area" : "TZCSCAVM.bmp" },
+				{ "id" : 22, "animation" : "TBCSEXT1.def", "x" : 0,   "y" : 198, "z" :  1, "border" : "TOCSTAV2.bmp", "area" : "TZCSTAV2.bmp" },
+				{ "id" : 26, "animation" : "TBCSHOLY.def", "x" : 456, "y" : 109, "z" : -1, "border" : "TOCSHOLY.bmp", "area" : "TZCSHOLY.bmp" },
+				{ "id" : 30, "animation" : "TBCSDW_0.def", "x" : 304, "y" : 92,  "border" : "TOCSPIK1.bmp", "area" : "TZCSPIK1.bmp" },
+				{ "id" : 31, "animation" : "TBCSDW_1.def", "x" : 360, "y" : 130, "border" : "TOCSCRS1.bmp", "area" : "TZCSCRS1.bmp" },
+				{ "id" : 32, "animation" : "TBCSDW_2.def", "x" : 76,  "y" : 57,  "border" : "TOCSGR1N.bmp", "area" : "TZCSGR1N.bmp" },
+				{ "id" : 33, "animation" : "TBCSDW_3.def", "x" : 176, "y" : 101, "border" : "TOCSSWD1.bmp", "area" : "TZCSSWD1.bmp" },
+				{ "id" : 34, "animation" : "TBCSDW_4.def", "x" : 563, "y" : 211, "z" : 1,  "border" : "TOCSMON1.bmp", "area" : "TZCSMON1.bmp" },
+				{ "id" : 35, "animation" : "TBCSDW_5.def", "x" : 174, "y" : 190, "z" : -1, "border" : "TOCSC101.bmp", "area" : "TZCSCAV1.bmp" },
+				{ "id" : 36, "animation" : "TBCSDW_6.def", "x" : 303, "y" : 0,   "z" : -1, "border" : "TOCSANG1.bmp", "area" : "TZCSANG1.bmp" },
+				{ "id" : 37, "animation" : "TBCSUP_0.def", "x" : 304, "y" : 65,  "border" : "TOCSPIK2.bmp", "area" : "TZCSPIK2.bmp" },
+				{ "id" : 38, "animation" : "TBCSUP_1.def", "x" : 360, "y" : 115, "border" : "TOCSCRS2.bmp", "area" : "TZCSCRS2.bmp" },
+				{ "id" : 39, "animation" : "TBCSUP_2.def", "x" : 76,  "y" : 35,  "border" : "TOCSGR2N.bmp", "area" : "TZCSGR2N.bmp" },
+				{ "id" : 40, "animation" : "TBCSUP_3.def", "x" : 176, "y" : 85,  "border" : "TOCSSWD2.bmp", "area" : "TZCSSWD2.bmp" },
+				{ "id" : 41, "animation" : "TBCSUP_4.def", "x" : 563, "y" : 173, "z" : 1,  "border" : "TOCSMON2.bmp", "area" : "TZCSMON2.bmp" },
+				{ "id" : 42, "animation" : "TBCSUP_5.def", "x" : 160, "y" : 190, "z" : -1, "border" : "TOCSCAV2.bmp", "area" : "TZCSCAV2.bmp" },
+				{ "id" : 43, "animation" : "TBCSUP_6.def", "x" : 303, "y" : 0,   "z" : -1, "border" : "TOCSANG2.bmp", "area" : "TZCSANG2.bmp" },
+
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 18, "built" : 19 },
+				"fort"    : {"normal" : 0,  "built" : 1 }
+			},
+
+			"musicTheme" : "music/CstleTown",
+
+			"townBackground": "TBCSBACK.bmp",
+			"guildWindow": "TPMAGECS.bmp",
+			"buildingsIcons": "HALLCSTL.DEF",
+			"hallBackground": "TPTHBKCS.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5, 22 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3 ], [ 6, 17 ] ],
+				[ [ 21 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Pikeman", "Halberdier"],
+				["Archer", "HeavyCrossbowman"],
+				["Griffin", "RoyalGriffin"],
+				["Swordsman", "Crusader"],
+				["Monk", "Zealot"],
+				["Cavalier", "Champion"],
+				["Angel", "Archangel"]
+			],
+			"horde" : [ 2, -1 ],
+			"mageGuild" : 4,
+			"warMachine" : "Ballista",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 6 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 6 ] },
+				{ "id" : 18, "upgrades" : 32 },
+				{ "id" : 19, "upgrades" : 39, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 20, "upgrades" : 6 },
+				{ "id" : 21, "requires" : [ 33 ] },
+				{ "id" : 22, "upgrades" : 5 },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 33 ] },
+				{ "id" : 33, "requires" : [ 16, 30 ] },
+				{ "id" : 34, "requires" : [ 0, 33 ] },
+				{ "id" : 35, "requires" : [ 21 ] },
+				{ "id" : 36, "requires" : [ 34 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33 },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Archer",
+				"imagePrefix" : "SGCS",
+				"gate" :
+				{
+					"arch" : { "x" : 477, "y" : 238 },
+					"gate" : { "x" : 399, "y" : 274 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 403, "y" : 80 },
+					"moat" : { "x" : 410, "y" : 90 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 600, "y" : 49 },
+					"bottom" : { "x" : 512, "y" : 347 },
+					"top" : { "x" : 489, "y" : 79 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 602, "y" : 500 },
+						"creature" : { "x" : 394, "y" : 299	},
+						"tower" : { "x" : 602, "y" : 500 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 720, "y" : 158 },
+						"creature" : { "x" : 526, "y" : -29 },
+						"tower" : { "x" : 720, "y" : 158 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 557, "y" : 24 },
+						"creature" : { "x" : 342, "y" : -187 },
+						"tower" : { "x" : 569, "y" : 35 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 528, "y" : 350 },
+					"bottomMid" : { "x" : 469, "y" : 291 },
+					"upper" : { "x" : 524, "y" : 32 },
+					"upperMid" : { "x" : 470, "y" : 127 }
+				}
+			}
+		}
+	}
+}

+ 250 - 0
config/factions/conflux.json

@@ -0,0 +1,250 @@
+{
+	"conflux" :
+	{
+		"index" : 8,
+		"nativeTerrain": "grass",
+		"alignment" : "neutral",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASELE",
+			"130px" : "CRBKGELE"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZELE",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 1 },
+				{ "x": 7, "y": 54, "index": 6 },
+				{ "x": 7, "y": 227, "index": 16 },
+				{ "x": 7, "y": 426, "index": 9 },
+				{ "x": 15, "y": 48, "index": 22 },
+				{ "x": 45, "y": 375, "index": 32 },
+				{ "x": 48, "y": 249, "index": 28 },
+				{ "x": 86, "y": 500, "index": 15 },
+				{ "x": 93, "y": 55, "index": 37 },
+				{ "x": 99, "y": 245, "index": 7 },
+				{ "x": 101, "y": 354, "index": 27 },
+				{ "x": 104, "y": 175, "index": 35 },
+				{ "x": 107, "y": 14, "index": 21 },
+				{ "x": 124, "y": 296, "index": 38 },
+				{ "x": 134, "y": 8, "index": 4 },
+				{ "x": 181, "y": 466, "index": 26 },
+				{ "x": 182, "y": 200, "index": 40 },
+				{ "x": 189, "y": 381, "index": 33 },
+				{ "x": 192, "y": 40, "index": 8 },
+				{ "x": 192, "y": 364, "index": 11 },
+				{ "x": 201, "y": 124, "index": 48 },
+				{ "x": 203, "y": 330, "index": 42 },
+				{ "x": 228, "y": 293, "index": 45 },
+				{ "x": 235, "y": 39, "index": 25 },
+				{ "x": 242, "y": 335, "index": 44 },
+				{ "x": 275, "y": 488, "index": 5 },
+				{ "x": 278, "y": 202, "index": 46 },
+				{ "x": 290, "y": 80, "index": 13 },
+				{ "x": 291, "y": 115, "index": 20 },
+				{ "x": 308, "y": 225, "index": 43 },
+				{ "x": 310, "y": 158, "index": 39 },
+				{ "x": 312, "y": 24, "index": 12 },
+				{ "x": 317, "y": 8, "index": 2 },
+				{ "x": 323, "y": 443, "index": 10 },
+				{ "x": 327, "y": 253, "index": 41 },
+				{ "x": 330, "y": 36, "index": 36 },
+				{ "x": 349, "y": 330, "index": 34 },
+				{ "x": 349, "y": 426, "index": 17 },
+				{ "x": 407, "y": 191, "index": 47 },
+				{ "x": 421, "y": 430, "index": 31 },
+				{ "x": 428, "y": 246, "index": 23 },
+				{ "x": 467, "y": 90, "index": 29 },
+				{ "x": 481, "y": 13, "index": 30 },
+				{ "x": 489, "y": 346, "index": 18 },
+				{ "x": 504, "y": 113, "index": 19 },
+				{ "x": 504, "y": 190, "index": 24 },
+				{ "x": 507, "y": 8, "index": 14 },
+				{ "x": 542, "y": 436, "index": 3 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "avchforx.def",
+				"village" : "AVCHFOR0.DEF",
+				"capitol" : "AVCHFORZ.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBELEXT5.def", "x" : 682, "y" : 183,  "z" : -1, },
+				{ "animation" : "TBELEXT1.def", "x" : 23,  "y" : 218 },
+				{ "id" : 0,  "animation" : "TBELMAGE.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAGE.bmp", "area" : "TZELMAGE.bmp" },
+				{ "id" : 1,  "animation" : "TBELMAG2.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG2.bmp", "area" : "TZELMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBELMAG3.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG3.bmp", "area" : "TZELMAG3.bmp" },
+				{ "id" : 3,  "animation" : "TBELMAG4.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG4.bmp", "area" : "TZELMAG4.bmp" },
+				{ "id" : 4,  "animation" : "TBELMAG5.def", "x" : 206, "y" : 58,  "z" : 4,  "border" : "TOELMAG5.bmp", "area" : "TZELMAG5.bmp" },
+				{ "id" : 5,  "animation" : "TBELTVRN.def", "x" : 553, "y" : 203, "z" : 1,  "border" : "TOELTVRN.bmp", "area" : "TZELTVRN.bmp" },
+				{ "id" : 6,  "animation" : "TBELDOCK.def", "x" : 239, "y" : 215, "z" : 2,  "border" : "TOELDOCK.bmp", "area" : "TZELDOCK.bmp" },
+				{ "id" : 7,  "animation" : "TBELCSTL.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCSTL.bmp", "area" : "TZELCSTL.bmp" },
+				{ "id" : 8,  "animation" : "TBELCAS2.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCAS2.bmp", "area" : "TZELCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBELCAS3.def", "x" : 349, "y" : 101, "z" : -1, "border" : "TOELCAS3.bmp", "area" : "TZELCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBELHALL.def", "x" : -1,  "y" : 164, "z" : 5,  "border" : "TOELHALL.bmp", "area" : "TZELHALL.bmp" },
+				{ "id" : 11, "animation" : "TBELHAL2.def", "x" : 0,   "y" : 165, "z" : 5,  "border" : "TOELHAL2.bmp", "area" : "TZELHAL2.bmp" },
+				{ "id" : 12, "animation" : "TBELHAL3.def", "x" : 0,   "y" : 165, "z" : 5,  "border" : "TOELHAL3.bmp", "area" : "TZELHAL3.bmp" },
+				{ "id" : 13, "animation" : "TBELHAL4.def", "x" : 0,   "y" : 164, "z" : 5,  "border" : "TOELHAL4.bmp", "area" : "TZELHAL4.bmp" },
+				{ "id" : 14, "animation" : "TBELMARK.def", "x" : 347, "y" : 216, "z" : 4,  "border" : "TOELMARK.bmp", "area" : "TZELMARK.bmp" },
+				{ "id" : 15, "animation" : "TBELSILO.def", "x" : 372, "y" : 171, "z" : 2,  "border" : "TOELSILO.bmp", "area" : "TZELSILO.bmp" },
+				{ "id" : 16, "animation" : "TBELBLAK.def", "x" : 449, "y" : 151, "z" : 1,  "border" : "TOELBLAK.bmp", "area" : "TZELBLAK.bmp" },
+				{ "id" : 17, "animation" : "TBELSPEC.def", "x" : 284, "y" : 246, "z" : 4,  "border" : "TOELSPEC.bmp", "area" : "TZELSPEC.bmp" },
+				{ "id" : 18, "animation" : "TBELHRD1.def", "x" : 689, "y" : 250, "border" : "TOELHRD1.bmp", "area" : "TZELHRD1.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBELHRD2.def", "x" : 689, "y" : 250, "border" : "TOELHRD2.bmp", "area" : "TZELHRD2.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 20, "animation" : "TBELBOAT.def", "x" : 239, "y" : 215, "z" : 2,  "border" : "TOELBOAT.bmp", "area" : "TZELBOAT.bmp", "hidden" : true },
+				{ "id" : 21, "animation" : "TBELEXT6.def", "x" : 104, "y" : 170, "z" : 3,  "border" : "TOELEXT6.bmp", "area" : "TZELEXT6.bmp" },
+				{ "id" : 26, "animation" : "TBELHOLY.def", "x" : 307, "y" : 2,   "border" : "TOELHOLY.bmp", "area" : "TZELHOLY.bmp" },
+				{ "id" : 27, "animation" : "TBELEXT2.def", "x" : 232, "y" : 205 },
+				{ "id" : 28, "animation" : "TBELEXT3.def", "x" : 516, "y" : 223, "z" : 1 },
+				{ "id" : 29, "animation" : "TBELEXT4.def", "x" : 0,   "y" : 252, "z" : 6 },
+				{ "id" : 30, "animation" : "TBELDW_0.def", "x" : 689, "y" : 250, "border" : "TOELDW_0.bmp", "area" : "TZELDW_0.bmp" },
+				{ "id" : 31, "animation" : "TBELDW_1.def", "x" : 630, "y" : 50,  "border" : "TOELDW_1.bmp", "area" : "TZELDW_1.bmp" },
+				{ "id" : 32, "animation" : "TBELDW_2.def", "x" : 709, "y" : 210, "z" : -1, "border" : "TOELDW_2.bmp", "area" : "TZELDW_2.bmp" },
+				{ "id" : 33, "animation" : "TBELDW_3.def", "x" : 108, "y" : 131, "z" : -1, "border" : "TOELDW_3.bmp", "area" : "TZELDW_3.bmp" },
+				{ "id" : 34, "animation" : "TBELDW_4.def", "x" : 264, "y" : 168, "z" : -1, "border" : "TOELDW_4.bmp", "area" : "TZELDW_4.bmp" },
+				{ "id" : 35, "animation" : "TBELDW_5.def", "x" : 394, "y" : 283, "z" : 2,  "border" : "TOELDW_5.bmp", "area" : "TZELDW_5.bmp" },
+				{ "id" : 36, "animation" : "TBELDW_6.def", "x" : 43,  "y" : 16,  "z" : -2, "border" : "TOELDW_6.bmp", "area" : "TZELDW_6.bmp" },
+				{ "id" : 37, "animation" : "TBELUP_0.def", "x" : 689, "y" : 250, "border" : "TOELUP_0.bmp", "area" : "TZELUP_0.bmp" },
+				{ "id" : 38, "animation" : "TBELUP_1.def", "x" : 630, "y" : 50,  "border" : "TOELUP_1.bmp", "area" : "TZELUP_1.bmp" },
+				{ "id" : 39, "animation" : "TBELUP_2.def", "x" : 709, "y" : 210, "z" : -1, "border" : "TOELUP_2.bmp", "area" : "TZELUP_2.bmp" },
+				{ "id" : 40, "animation" : "TBELUP_3.def", "x" : 108, "y" : 131, "z" : -1, "border" : "TOELUP_3.bmp", "area" : "TZELUP_3.bmp" },
+				{ "id" : 41, "animation" : "TBELUP_4.def", "x" : 264, "y" : 168, "z" : -1, "border" : "TOELUP_4.bmp", "area" : "TZELUP_4.bmp" },
+				{ "id" : 42, "animation" : "TBELUP_5.def", "x" : 394, "y" : 283, "z" : 2,  "border" : "TOELUP_5.bmp", "area" : "TZELUP_5.bmp" },
+				{ "id" : 43, "animation" : "TBELUP_6.def", "x" : 43,  "y" : 0,   "z" : -2, "border" : "TOELUP_6.bmp", "area" : "TZELUP_6.bmp" },
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 34, "built" : 35 },
+				"fort"    : {"normal" : 16, "built" : 17 }
+			},
+			"musicTheme" : "music/ElemTown",
+
+			"townBackground": "TBELBACK.bmp",
+			"guildWindow": "TPMAGEEL.bmp",
+			"buildingsIcons": "HALLELEM.DEF",
+			"hallBackground": "TPTHBKFR.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 6 ] ],
+				[ [ 21 ], [ 17 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Pixie", "Sprite"],
+				["AirElemental", "StormElemental"],
+				["WaterElemental", "IceElemental"],
+				["FireElemental", "ElectricityElemental"],
+				["EarthElemental", "StoneElemental"],
+				["PsiElemental", "MagicElemental"],
+				["Firebird", "Pheonix"]
+			],
+			"horde" : [ 0, -1 ],
+			"mageGuild" : 5,
+			"primaryResource" : "mercury",
+			"warMachine" : "Ballista",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 6 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 14 ] },
+				{ "id" : 18, "upgrades" : 30 },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 20, "upgrades" : 6 },
+				{ "id" : 21, "requires" : [ 0 ] },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30, 0 ] },
+				{ "id" : 32, "requires" : [ 30, 0 ] },
+				{ "id" : 33, "requires" : [ 31 ] },
+				{ "id" : 34, "requires" : [ 32 ] },
+				{ "id" : 35, "requires" : [ 33, 34 ] },
+				{ "id" : 36, "requires" : [ 35 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33, "requires" : [ 31 ] },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35, "requires" : [ 1 ] },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "StormElemental",
+				"imagePrefix" : "SGEL",
+				"gate" :
+				{
+					"arch" : { "x" : 486, "y" : 232 },
+					"gate" : { "x" : 408, "y" : 254 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 407, "y" : 80 },
+					"moat" : { "x" : 407, "y" : 80 }
+				},
+				"shooterHeight" : 229,
+				"static" :
+				{
+					"background" : { "x" : 600, "y" : 50 },
+					"bottom" : { "x" : 509, "y" : 346 },
+					"top" : { "x" : 490, "y" : 97 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 608, "y" : 505 },
+						"creature" : { "x" : 382, "y" : 308 },
+						"tower" : { "x" : 608, "y" : 505 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 736, "y" : 159 },
+						"creature" : { "x" : 529, "y" : -42 },
+						"tower" : { "x" : 736, "y" : 159 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 576, "y" : 28 },
+						"creature" : { "x" : 341, "y" : -162 },
+						"tower" : { "x" : 576, "y" : 28 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 509, "y" : 346 },
+					"bottomMid" : { "x" : 468, "y" : 299 },
+					"upper" : { "x" : 521, "y" : 41 },
+					"upperMid" : { "x" : 471, "y" : 147 }
+				}
+			}
+		}
+	}
+}

+ 245 - 0
config/factions/dungeon.json

@@ -0,0 +1,245 @@
+{
+	"dungeon" :
+	{
+		"index" : 5,
+		"nativeTerrain": "subterra",
+		"alignment" : "evil",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASDUN",
+			"130px" : "CRBKGDUN"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZDUN",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 31 },
+				{ "x": 7, "y": 125, "index": 1 },
+				{ "x": 7, "y": 353, "index": 33 },
+				{ "x": 7, "y": 394, "index": 6 },
+				{ "x": 30, "y": 101, "index": 36 },
+				{ "x": 33, "y": 219, "index": 16 },
+				{ "x": 57, "y": 171, "index": 13 },
+				{ "x": 62, "y": 8, "index": 47 },
+				{ "x": 63, "y": 90, "index": 41 },
+				{ "x": 83, "y": 471, "index": 10 },
+				{ "x": 94, "y": 117, "index": 21 },
+				{ "x": 99, "y": 8, "index": 5 },
+				{ "x": 113, "y": 258, "index": 32 },
+				{ "x": 156, "y": 146, "index": 28 },
+				{ "x": 165, "y": 288, "index": 42 },
+				{ "x": 172, "y": 388, "index": 44 },
+				{ "x": 177, "y": 36, "index": 39 },
+				{ "x": 194, "y": 235, "index": 46 },
+				{ "x": 204, "y": 502, "index": 3 },
+				{ "x": 236, "y": 320, "index": 23 },
+				{ "x": 238, "y": 8, "index": 20 },
+				{ "x": 245, "y": 75, "index": 25 },
+				{ "x": 247, "y": 396, "index": 29 },
+				{ "x": 247, "y": 459, "index": 14 },
+				{ "x": 253, "y": 152, "index": 48 },
+				{ "x": 301, "y": 233, "index": 43 },
+				{ "x": 323, "y": 8, "index": 12 },
+				{ "x": 323, "y": 178, "index": 45 },
+				{ "x": 328, "y": 342, "index": 30 },
+				{ "x": 329, "y": 428, "index": 19 },
+				{ "x": 339, "y": 8, "index": 26 },
+				{ "x": 357, "y": 141, "index": 27 },
+				{ "x": 374, "y": 8, "index": 15 },
+				{ "x": 374, "y": 236, "index": 34 },
+				{ "x": 392, "y": 439, "index": 35 },
+				{ "x": 400, "y": 291, "index": 40 },
+				{ "x": 401, "y": 103, "index": 18 },
+				{ "x": 422, "y": 381, "index": 37 },
+				{ "x": 436, "y": 8, "index": 17 },
+				{ "x": 438, "y": 336, "index": 24 },
+				{ "x": 449, "y": 131, "index": 9 },
+				{ "x": 453, "y": 161, "index": 11 },
+				{ "x": 471, "y": 267, "index": 38 },
+				{ "x": 477, "y": 64, "index": 22 },
+				{ "x": 480, "y": 456, "index": 8 },
+				{ "x": 485, "y": 8, "index": 2 },
+				{ "x": 536, "y": 197, "index": 4 },
+				{ "x": 541, "y": 22, "index": 7 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCdunx0.def",
+				"village" : "AVCDUNG0.DEF",
+				"capitol" : "AVCDUNZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "id" : 0,  "animation" : "TBDNMAGE.def", "x" : 164, "y" : 119, "z" : -1, "border" : "TODMAG1.bmp",  "area" : "TZDMAG1.bmp" },
+				{ "id" : 1,  "animation" : "TBDNMAG2.def", "x" : 164, "y" : 97,  "z" : -1, "border" : "TODMAG2.bmp",  "area" : "TZDMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBDNMAG3.def", "x" : 164, "y" : 77,  "z" : -1, "border" : "TODMAG3.bmp",  "area" : "TZDMAG3.bmp" },
+				{ "id" : 3,  "animation" : "TBDNMAG4.def", "x" : 164, "y" : 61,  "z" : -1, "border" : "TODMAG4.bmp",  "area" : "TZDMAG4.bmp" },
+				{ "id" : 4,  "animation" : "TBDNMAG5.def", "x" : 164, "y" : 15,  "z" : -1, "border" : "TODMAG5.bmp",  "area" : "TZDMAG5.bmp" },
+				{ "id" : 5,  "animation" : "TBDNTVRN.def", "x" : 211, "y" : 297, "border" : "TODTAV.bmp",   "area" : "TZDTAV.bmp" },
+				{ "id" : 7,  "animation" : "TBDNCSTL.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS1.bmp",  "area" : "TZDCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBDNCAS2.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS2.bmp",  "area" : "TZDCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBDNCAS3.def", "x" : 363, "y" : 87,  "z" : 2,  "border" : "TODCAS3.bmp",  "area" : "TZDCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBDNHALL.def", "x" : 0,   "y" : 234, "border" : "TODHALL1.bmp", "area" : "TZDHALL1.bmp" },
+				{ "id" : 11, "animation" : "TBDNHAL2.def", "x" : 0,   "y" : 223, "border" : "TODHALL2.bmp", "area" : "TZDHALL2.bmp" },
+				{ "id" : 12, "animation" : "TBDNHAL3.def", "x" : 0,   "y" : 223, "border" : "TODHALL3.bmp", "area" : "TZDHALL3.bmp" },
+				{ "id" : 13, "animation" : "TBDNHAL4.def", "x" : 0,   "y" : 203, "z" : -1, "border" : "TODHALL4.bmp", "area" : "TZDHALL4.bmp" },
+				{ "id" : 14, "animation" : "TBDNMARK.def", "x" : 590, "y" : 318, "z" : -2, "border" : "TODMARK.bmp",  "area" : "TZDMARK.bmp" },
+				{ "id" : 15, "animation" : "TBDNSILO.def", "x" : 624, "y" : 335, "z" : 1,  "border" : "TODSILO.bmp",  "area" : "TZDSILO.bmp" },
+				{ "id" : 16, "animation" : "TBDNBLAK.def", "x" : 544, "y" : 248, "z" : -3, "border" : "TODSMITH.bmp", "area" : "TZDSMITH.bmp" },
+				{ "id" : 17, "animation" : "TBDNSPEC.def", "x" : 746, "y" : 294, "z" : 1,  "border" : "TODART.bmp",   "area" : "TZDART.bmp" },
+				{ "id" : 18, "animation" : "TBDNHRD1.def", "x" : 0,   "y" : 326, "z" : 2,  "border" : "TODTR1HA.bmp", "area" : "TZDTR1HA.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBDNHRD2.def", "x" : 0,   "y" : 300, "z" : 2,  "border" : "TODTR2HA.bmp", "area" : "TZDTR2HA.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 21, "animation" : "TBDNEXT0.def", "x" : 131, "y" : 26 , "border" : "TODVOR1A.bmp", "area" : "TZDVOR1A.bmp" },
+				{ "id" : 22, "animation" : "TBDNEXT1.def", "x" : 687, "y" : 177, "border" : "TODPORTA.bmp", "area" : "TZDPORTA.bmp" },
+				{ "id" : 23, "animation" : "TBDNEXT2.def", "x" : 313, "y" : 298, "border" : "TODACAD.bmp",  "area" : "TZDACAD.bmp" },
+				{ "id" : 26, "animation" : "TBDNHOLY.def", "x" : 562, "y" : 24,  "z" : 1,  "border" : "TODHOLY.bmp",  "area" : "TZDHOLY.bmp" },
+				{ "id" : 30, "animation" : "TBDNDW_0.def", "x" : 0,   "y" : 326, "z" : 2,  "border" : "TODTRG1A.bmp", "area" : "TZDTRG1A.bmp" },
+				{ "id" : 31, "animation" : "TBDNDW_1.def", "x" : 0,   "y" : 26,  "border" : "TODHAR1.bmp",  "area" : "TZDHAR1.bmp" },
+				{ "id" : 32, "animation" : "TBDNDW_2.def", "x" : 118, "y" : 308, "z" : 1,  "border" : "TODBEH1A.bmp", "area" : "TZDBEH1A.bmp" },
+				{ "id" : 33, "animation" : "TBDNDW_3.def", "x" : 300, "y" : 29,  "z" : -1, "border" : "TODMED1.bmp",  "area" : "TZDMED1.bmp" },
+				{ "id" : 34, "animation" : "TBDNDW_4.def", "x" : 551, "y" : 186, "z" : 1,  "border" : "TODMIN1.bmp",  "area" : "TZDMIN1.bmp" },
+				{ "id" : 35, "animation" : "TBDNDW_5.def", "x" : 270, "y" : 253, "z" : -1, "border" : "TODMAN1.bmp",  "area" : "TZDMAN1.bmp" },
+				{ "id" : 36, "animation" : "TBDNDW_6.def", "x" : 550, "y" : 0,   "z" : -1, "border" : "TODDRA1A.bmp", "area" : "TZDDRA1A.bmp" },
+				{ "id" : 37, "animation" : "TBDNUP_0.def", "x" : 0,   "y" : 300, "z" : 2,  "border" : "TODTRG2A.bmp", "area" : "TZDTRG2A.bmp" },
+				{ "id" : 38, "animation" : "TBDNUP_1.def", "x" : 0,   "y" : 26,  "border" : "TODHAR2.bmp",  "area" : "TZDHAR2.bmp" },
+				{ "id" : 39, "animation" : "TBDNUP_2.def", "x" : 118, "y" : 256, "z" : 1,  "border" : "TODBEH2A.bmp", "area" : "TZDBEH2A.bmp" },
+				{ "id" : 40, "animation" : "TBDNUP_3.def", "x" : 300, "y" : 29,  "z" : -1, "border" : "TODMED2.bmp",  "area" : "TZDMED2.bmp" },
+				{ "id" : 41, "animation" : "TBDNUP_4.def", "x" : 519, "y" : 172, "z" : 1,  "border" : "TODMIN2.bmp",  "area" : "TZDMIN2.bmp" },
+				{ "id" : 42, "animation" : "TBDNUP_5.def", "x" : 270, "y" : 253, "z" : -1, "border" : "TODMAN2.bmp",  "area" : "TZDMAN2.bmp" },
+				{ "id" : 43, "animation" : "TBDNUP_6.def", "x" : 550, "y" : 0,   "z" : -1, "border" : "TODDRA2A.bmp", "area" : "TZDDRA2A.bmp" },
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 28, "built" : 29 },
+				"fort"    : {"normal" : 10, "built" : 11 }
+			},
+			"musicTheme" : "music/Dungeon",
+
+			"townBackground": "TBDNBACK.bmp",
+			"guildWindow": "TPMAGEDN.bmp",
+			"buildingsIcons": "HALLDUNG.DEF",
+			"hallBackground": "TPTHBKDG.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 22 ] ],
+				[ [ 17 ], [ 23 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Troglodyte", "InfernalTroglodyte"],
+				["Harpy", "HarpyHag"],
+				["Beholder", "EvilEye"],
+				["Medusa", "MedusaQueen"],
+				["Minotaur", "MinotaurKing"],
+				["Manticore", "Scorpicore"],
+				["RedDragon", "BlackDragon"]
+			],
+			"horde" : [ 0, -1 ],
+			"mageGuild" : 5,
+			"primaryResource" : "sulfur",
+			"warMachine" : "Ballista",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 14 ] },
+				{ "id" : 18, "upgrades" : 30 },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 21, "requires" : [ 0 ] },
+				{ "id" : 22 },
+				{ "id" : 23 },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 31, 32 ] },
+				{ "id" : 34, "requires" : [ 33 ] },
+				{ "id" : 35, "requires" : [ 33 ] },
+				{ "id" : 36, "requires" : [ 1, 34, 35 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33 },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36, "requires" : [ 2 ] }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Beholder",
+				"imagePrefix" : "SGDN",
+				"gate" :
+				{
+					"arch" : { "x" : 471, "y" : 164 },
+					"gate" : { "x" : 395, "y" : 260 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 283, "y" : 94 },
+					"moat" : { "x" : 283, "y" : 94 }
+				},
+				"shooterHeight" : 230,
+				"static" :
+				{
+					"background" : { "x" : 608, "y" : 50 },
+					"bottom" : { "x" : 522, "y" : 305 },
+					"top" : { "x" : 494, "y" : 53 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 600, "y" : 495 },
+						"creature" : { "x" : 410, "y" : 293 },
+						"tower" : { "x" : 560, "y" : 495 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 732, "y" : 162 },
+						"creature" : { "x" : 570, "y" : -50 },
+						"tower" : { "x" : 732, "y" : 162 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 565, "y" : 15 },
+						"creature" : { "x" : 381, "y" : -187 },
+						"tower" : { "x" : 565, "y" : 15 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 559, "y" : 448 },
+					"bottomMid" : { "x" : 471, "y" : 296 },
+					"upper" : { "x" : 523, "y" : 56 },
+					"upperMid" : { "x" : 477, "y" : 180 }
+				}
+			}
+		}
+	}
+}

+ 246 - 0
config/factions/fortress.json

@@ -0,0 +1,246 @@
+{
+	"fortress" :
+	{
+		"index" : 7,
+		"nativeTerrain": "swamp",
+		"alignment" : "neutral",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASFOR",
+			"130px" : "CRBKGFOR"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZFOR",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 36 },
+				{ "x": 7, "y": 152, "index": 25 },
+				{ "x": 7, "y": 306, "index": 34 },
+				{ "x": 7, "y": 388, "index": 23 },
+				{ "x": 7, "y": 434, "index": 15 },
+				{ "x": 23, "y": 417, "index": 37 },
+				{ "x": 32, "y": 232, "index": 38 },
+				{ "x": 42, "y": 137, "index": 39 },
+				{ "x": 47, "y": 440, "index": 8 },
+				{ "x": 56, "y": 19, "index": 47 },
+				{ "x": 71, "y": 8, "index": 1 },
+				{ "x": 87, "y": 219, "index": 30 },
+				{ "x": 90, "y": 26, "index": 41 },
+				{ "x": 104, "y": 397, "index": 33 },
+				{ "x": 116, "y": 345, "index": 40 },
+				{ "x": 134, "y": 215, "index": 11 },
+				{ "x": 175, "y": 168, "index": 19 },
+				{ "x": 191, "y": 428, "index": 13 },
+				{ "x": 200, "y": 326, "index": 24 },
+				{ "x": 216, "y": 98, "index": 18 },
+				{ "x": 221, "y": 398, "index": 20 },
+				{ "x": 225, "y": 235, "index": 46 },
+				{ "x": 239, "y": 8, "index": 9 },
+				{ "x": 245, "y": 40, "index": 7 },
+				{ "x": 248, "y": 208, "index": 48 },
+				{ "x": 261, "y": 439, "index": 5 },
+				{ "x": 262, "y": 134, "index": 26 },
+				{ "x": 297, "y": 352, "index": 22 },
+				{ "x": 309, "y": 99, "index": 16 },
+				{ "x": 320, "y": 262, "index": 43 },
+				{ "x": 323, "y": 404, "index": 10 },
+				{ "x": 326, "y": 200, "index": 45 },
+				{ "x": 331, "y": 20, "index": 17 },
+				{ "x": 345, "y": 178, "index": 21 },
+				{ "x": 353, "y": 8, "index": 3 },
+				{ "x": 358, "y": 290, "index": 42 },
+				{ "x": 381, "y": 399, "index": 14 },
+				{ "x": 400, "y": 65, "index": 12 },
+				{ "x": 428, "y": 160, "index": 35 },
+				{ "x": 448, "y": 293, "index": 29 },
+				{ "x": 451, "y": 94, "index": 27 },
+				{ "x": 453, "y": 424, "index": 2 },
+				{ "x": 462, "y": 397, "index": 32 },
+				{ "x": 465, "y": 8, "index": 4 },
+				{ "x": 486, "y": 163, "index": 44 },
+				{ "x": 492, "y": 184, "index": 31 },
+				{ "x": 517, "y": 304, "index": 6 },
+				{ "x": 549, "y": 8, "index": 28 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCftrx0.def",
+				"village" : "AVCFTRT0.DEF",
+				"capitol" : "AVCFORZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBFREXT2.def", "x" : 372, "y" : 227 },
+				{ "id" : 0,  "animation" : "TBFRMAGE.def", "x" : 0,   "y" : 200, "z" : -1, "border" : "TOFMAG1A.bmp", "area" : "TZFMAG1A.bmp" },
+				{ "id" : 1,  "animation" : "TBFRMAG2.def", "x" : 0,   "y" : 177, "z" : -1, "border" : "TOFMAG2A.bmp", "area" : "TZFMAG2A.bmp" },
+				{ "id" : 2,  "animation" : "TBFRMAG3.def", "x" : 0,   "y" : 135, "z" : -1, "border" : "TOFMAG3A.bmp", "area" : "TZFMAG3A.bmp" },
+				{ "id" : 5,  "animation" : "TBFRTVRN.def", "x" : 634, "y" : 219, "z" : 3,  "border" : "TOFTAVA.bmp",  "area" : "TZFTAVA.bmp" },
+				{ "id" : 6,  "animation" : "TBFRDOCK.def", "x" : 197, "y" : 294, "border" : "TOFDCK2.bmp",  "area" : "TZFDCK2.bmp" },
+				{ "id" : 7,  "animation" : "TBFRCSTL.def", "x" : 368, "y" : 118, "z" : -1, "border" : "TOFCAS1.bmp",  "area" : "TZFCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBFRCAS2.def", "x" : 368, "y" : 98,  "z" : -1, "border" : "TOFCAS2.bmp",  "area" : "TZFCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBFRCAS3.def", "x" : 368, "y" : 55,  "z" : -1, "border" : "TOFCAS3.bmp",  "area" : "TZFCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBFRHALL.def", "x" : 166, "y" : 128, "z" : 1,  "border" : "TOFHAL1.bmp",  "area" : "TZFHAL1.bmp" },
+				{ "id" : 11, "animation" : "TBFRHAL2.def", "x" : 166, "y" : 97,  "z" : 1,  "border" : "TOFHAL2.bmp",  "area" : "TZFHAL2.bmp" },
+				{ "id" : 12, "animation" : "TBFRHAL3.def", "x" : 166, "y" : 51,  "z" : 1,  "border" : "TOFHAL3.bmp",  "area" : "TZFHAL3.bmp" },
+				{ "id" : 13, "animation" : "TBFRHAL4.def", "x" : 166, "y" : 2,   "z" : 1,  "border" : "TOFHAL4.bmp",  "area" : "TZFHAL4.bmp" },
+				{ "id" : 14, "animation" : "TBFRMARK.def", "x" : 382, "y" : 219, "z" : 4,  "border" : "TOFMRKAA.bmp", "area" : "TZFMRKAA.bmp" },
+				{ "id" : 15, "animation" : "TBFRSILO.def", "x" : 448, "y" : 210, "z" : 2,  "border" : "TOFMRK2A.bmp", "area" : "TZFMRK2A.bmp" },
+				{ "id" : 16, "animation" : "TBFRBLAK.def", "x" : 360, "y" : 160, "border" : "TOFAIDA.bmp",  "area" : "TZFAIDA.bmp" },
+				{ "id" : 17, "animation" : "TBFRSPEC.def", "x" : 703, "y" : 36,  "border" : "TOFCAGE.bmp",  "area" : "TZFCAGE.bmp" },
+				{ "id" : 18, "animation" : "TBFRHRD1.def", "x" : 641, "y" : 121, "z" : 1,  "border" : "TOFGNL1H.bmp", "area" : "TZFGNL1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBFRHRD2.def", "x" : 641, "y" : 68,  "z" : 1,  "border" : "TOFGNL2H.bmp", "area" : "TZFGNL2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 20, "animation" : "TBFRBOAT.def", "x" : 197, "y" : 294, "z" : 1,  "border" : "TOFDCK1.bmp",  "area" : "TZFDCK1.bmp", "hidden" : true },
+				{ "id" : 21, "animation" : "TBFREXT0.def", "x" : 341, "y" : 174, "border" : "TOFCASD.bmp",  "area" : "TZFCASD.bmp" },
+				{ "id" : 22, "animation" : "TBFREXT1.def", "x" : 349, "y" : 79,  "z" : -2, "border" : "TOFCASA.bmp",  "area" : "TZFCASA.bmp" },
+				{ "id" : 26, "animation" : "TBFRHOLY.def", "x" : 468, "y" : 260, "z" : 5,  "border" : "TOFHLYAA.bmp", "area" : "TZFHLYAA.bmp" },
+				{ "id" : 29, "animation" : "TBFRWTRW.def", "x" : 320, "y" : 141 },
+				{ "id" : 30, "animation" : "TBFRDW_0.def", "x" : 641, "y" : 168, "z" : 1,  "border" : "TOFGNL1.bmp",  "area" : "TZFGNL1.bmp" },
+				{ "id" : 31, "animation" : "TBFRDW_1.def", "x" : 141, "y" : 178, "border" : "TOFLIZ1.bmp",  "area" : "TZFLIZ1.bmp" },
+				{ "id" : 32, "animation" : "TBFRDW_3.def", "x" : 192, "y" : 85,  "border" : "TOFFLY1A.bmp", "area" : "TZFFLY1A.bmp" },
+				{ "id" : 33, "animation" : "TBFRDW_4.def", "x" : 0,   "y" : 292, "border" : "TOFBAS1.bmp",  "area" : "TZFBAS1.bmp" },
+				{ "id" : 34, "animation" : "TBFRDW_2.def", "x" : 15,  "y" : 127, "z" : -2, "border" : "TOFGOR1.bmp",  "area" : "TZFGOR1.bmp" },
+				{ "id" : 35, "animation" : "TBFRDW_5.def", "x" : 0,   "y" : 4,   "border" : "TOFWYV1.bmp",  "area" : "TZFWYV1.bmp" },
+				{ "id" : 36, "animation" : "TBFRDW_6.def", "x" : 612, "y" : 291, "z" : 5,  "border" : "TOFHYD1A.bmp", "area" : "TZFHYD1A.bmp" },
+				{ "id" : 37, "animation" : "TBFRUP_0.def", "x" : 641, "y" : 107, "z" : 1,  "border" : "TOFGNL2.bmp",  "area" : "TZFGNL2.bmp" },
+				{ "id" : 38, "animation" : "TBFRUP_1.def", "x" : 125, "y" : 163, "border" : "TOFLIZ2.bmp",  "area" : "TZFLIZ2.bmp" },
+				{ "id" : 39, "animation" : "TBFRUP_3.def", "x" : 159, "y" : 19,  "border" : "TOFFLY2A.bmp", "area" : "TZFFLY2A.bmp" },
+				{ "id" : 40, "animation" : "TBFRUP_4.def", "x" : 0,   "y" : 257, "border" : "TOFBAS2.bmp",  "area" : "TZFBAS2.bmp" },
+				{ "id" : 41, "animation" : "TBFRUP_2.def", "x" : 15,  "y" : 69,  "z" : -2, "border" : "TOFGOR2.bmp",  "area" : "TZFGOR2.bmp" },
+				{ "id" : 42, "animation" : "TBFRUP_5.def", "x" : 0,   "y" : 4,   "border" : "TOFWYV2.bmp",  "area" : "TZFWYV2.bmp" },
+				{ "id" : 43, "animation" : "TBFRUP_6.def", "x" : 587, "y" : 263, "z" : 5,  "border" : "TOFHYD2A.bmp", "area" : "TZFHYD2A.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 32, "built" : 33 },
+				"fort"    : {"normal" : 14, "built" : 15 }
+			},
+			"musicTheme" : "music/FortressTown",
+
+			"townBackground": "TBFRBACK.bmp",
+			"guildWindow": "TPMAGEFR.bmp",
+			"buildingsIcons": "HALLFORT.DEF",
+			"hallBackground": "TPTHBKFR.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2 ], [ 6 ] ],
+				[ [ 17 ], [ 21, 22 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Gnoll", "GnollMarauder"],
+				["PrimitiveLizardman", "AdvancedLizardman"],
+				["Dragonflies", "FireDragonFly"],
+				["Basilisk", "GreaterBasilisk"],
+				["CopperGorgon", "BronzeGorgon"],
+				["Wyvern", "WyvernMonarch"],
+				["Hydra", "ChaosHydra"]
+			],
+			"horde" : [ 0, -1 ],
+			"mageGuild" : 3,
+			"warMachine" : "FirstAidTent",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 6 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 11, 21 ] },
+				{ "id" : 18, "upgrades" : 30 },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 20, "upgrades" : 6 },
+				{ "id" : 21, "requires" : [ 7 ] },
+				{ "id" : 22, "requires" : [ 21 ] },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 32 ] },
+				{ "id" : 34, "requires" : [ 31, 32 ] },
+				{ "id" : 35, "requires" : [ 31 ] },
+				{ "id" : 36, "requires" : [ 33, 35 ] },
+				{ "id" : 37, "upgrades" : 30, "requires" : [ 5 ] },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33 },
+				{ "id" : 41, "upgrades" : 34, "requires" : [ 15 ] },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "PrimitiveLizardman",
+				"imagePrefix" : "SGFR",
+				"gate" :
+				{
+					"arch" : { "x" : 483, "y" : 236 },
+					"gate" : { "x" : 392, "y" : 253 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 376, "y" : 70 },
+					"moat" : { "x" : 383, "y" : 95 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 599, "y" : 62 },
+					"bottom" : { "x" : 522, "y" : 382 },
+					"top" : { "x" : 508, "y" : 130 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 599, "y" : 505 },
+						"creature" : { "x" : 372, "y" : 308 },
+						"tower" : { "x" : 599, "y" : 505 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 721, "y" : 178 },
+						"creature" : { "x" : 541, "y" : -37 },
+						"tower" : { "x" : 721, "y" : 178 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 548, "y" : 27 },
+						"creature" : { "x" : 326, "y" : -182 },
+						"tower" : { "x" : 548, "y" : 27 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 546, "y" : 441 },
+					"bottomMid" : { "x" : 486, "y" : 306 },
+					"upper" : { "x" : 526, "y" : 80 },
+					"upperMid" : { "x" : 498, "y" : 184 }
+				}
+			}
+		}
+	}
+}

+ 248 - 0
config/factions/inferno.json

@@ -0,0 +1,248 @@
+{
+	"inferno" :
+	{
+		"index" : 3,
+		"nativeTerrain": "lava",
+		"alignment" : "evil",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASINF",
+			"130px" : "CRBKGINF"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZINF",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 30 },
+				{ "x": 7, "y": 16, "index": 2 },
+				{ "x": 7, "y": 95, "index": 12 },
+				{ "x": 7, "y": 271, "index": 27 },
+				{ "x": 7, "y": 308, "index": 8 },
+				{ "x": 7, "y": 464, "index": 1 },
+				{ "x": 16, "y": 164, "index": 26 },
+				{ "x": 41, "y": 378, "index": 39 },
+				{ "x": 50, "y": 471, "index": 13 },
+				{ "x": 51, "y": 101, "index": 17 },
+				{ "x": 80, "y": 260, "index": 35 },
+				{ "x": 81, "y": 48, "index": 4 },
+				{ "x": 91, "y": 143, "index": 47 },
+				{ "x": 115, "y": 8, "index": 25 },
+				{ "x": 141, "y": 360, "index": 28 },
+				{ "x": 153, "y": 269, "index": 41 },
+				{ "x": 164, "y": 55, "index": 44 },
+				{ "x": 173, "y": 101, "index": 36 },
+				{ "x": 173, "y": 492, "index": 6 },
+				{ "x": 187, "y": 160, "index": 48 },
+				{ "x": 194, "y": 388, "index": 19 },
+				{ "x": 200, "y": 373, "index": 20 },
+				{ "x": 204, "y": 282, "index": 45 },
+				{ "x": 239, "y": 469, "index": 11 },
+				{ "x": 240, "y": 8, "index": 32 },
+				{ "x": 271, "y": 163, "index": 43 },
+				{ "x": 276, "y": 255, "index": 46 },
+				{ "x": 296, "y": 428, "index": 3 },
+				{ "x": 297, "y": 281, "index": 16 },
+				{ "x": 306, "y": 8, "index": 10 },
+				{ "x": 317, "y": 17, "index": 15 },
+				{ "x": 327, "y": 84, "index": 29 },
+				{ "x": 348, "y": 142, "index": 40 },
+				{ "x": 348, "y": 342, "index": 21 },
+				{ "x": 370, "y": 405, "index": 22 },
+				{ "x": 401, "y": 103, "index": 18 },
+				{ "x": 407, "y": 40, "index": 31 },
+				{ "x": 421, "y": 508, "index": 7 },
+				{ "x": 453, "y": 215, "index": 33 },
+				{ "x": 455, "y": 377, "index": 34 },
+				{ "x": 460, "y": 170, "index": 38 },
+				{ "x": 475, "y": 319, "index": 42 },
+				{ "x": 488, "y": 412, "index": 37 },
+				{ "x": 504, "y": 8, "index": 24 },
+				{ "x": 515, "y": 67, "index": 5 },
+				{ "x": 517, "y": 211, "index": 14 },
+				{ "x": 532, "y": 305, "index": 23 },
+				{ "x": 556, "y": 335, "index": 9 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCinfx0.def",
+				"village" : "AVCINFT0.DEF",
+				"capitol" : "AVCINFZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "id" : 0,  "animation" : "TBINMAGE.def", "x" : 667, "y" : 127, "border" : "TOIMAG1A.bmp", "area" : "TZIMAG1A.bmp" },
+				{ "id" : 1,  "animation" : "TBINMAG2.def", "x" : 667, "y" : 101, "border" : "TOIMAG2A.bmp", "area" : "TZIMAG2A.bmp" },
+				{ "id" : 2,  "animation" : "TBINMAG3.def", "x" : 667, "y" : 83,  "border" : "TOIMAG3A.bmp", "area" : "TZIMAG3A.bmp" },
+				{ "id" : 3,  "animation" : "TBINMAG4.def", "x" : 667, "y" : 56,  "border" : "TOIMAG4A.bmp", "area" : "TZIMAG4A.bmp" },
+				{ "id" : 4,  "animation" : "TBINMAG5.def", "x" : 667, "y" : 35,  "border" : "TOIMAG5A.bmp", "area" : "TZIMAG5A.bmp" },
+				{ "id" : 5,  "animation" : "TBINTVRN.def", "x" : 105, "y" : 219, "z" : 1,  "border" : "TOITAV.bmp",   "area" : "TZITAV.bmp" },
+				{ "id" : 7,  "animation" : "TBINCSTL.def", "x" : 222, "y" : 44,  "border" : "TOICAS2A.bmp", "area" : "TZICAS2A.bmp" },
+				{ "id" : 8,  "animation" : "TBINCAS2.def", "x" : 222, "y" : 44,  "border" : "TOICAS1A.bmp", "area" : "TZICAS1A.bmp" },
+				{ "id" : 9,  "animation" : "TBINCAS3.def", "x" : 222, "y" : 18,  "border" : "TOICAS3A.bmp", "area" : "TZICAS3A.bmp" },
+				{ "id" : 10, "animation" : "TBINHALL.def", "x" : 0,   "y" : 174, "border" : "TOIHAL1.bmp",  "area" : "TZIHAL1.bmp"  },
+				{ "id" : 11, "animation" : "TBINHAL2.def", "x" : 0,   "y" : 174, "border" : "TOIHAL2.bmp",  "area" : "TZIHAL2.bmp"  },
+				{ "id" : 12, "animation" : "TBINHAL3.def", "x" : 0,   "y" : 174, "border" : "TOIHAL3.bmp",  "area" : "TZIHAL3.bmp"  },
+				{ "id" : 13, "animation" : "TBINHAL4.def", "x" : 0,   "y" : 131, "border" : "TOIHAL4.bmp",  "area" : "TZIHAL4.bmp"  },
+				{ "id" : 14, "animation" : "TBINMARK.def", "x" : 511, "y" : 301, "z" : 4,  "border" : "TOIMAR1.bmp",  "area" : "TZIMAR1.bmp" },
+				{ "id" : 15, "animation" : "TBINSILO.def", "x" : 497, "y" : 337, "z" : 5,  "border" : "TOIMAR2.bmp",  "area" : "TZIMAR2.bmp" },
+				{ "id" : 16, "animation" : "TBINBLAK.def", "x" : 684, "y" : 253, "z" : 1,  "border" : "TOIBLKA.bmp",  "area" : "TZIBLKA.bmp" },
+				{ "id" : 18, "animation" : "TBINHRD1.def", "x" : 614, "y" : 256, "border" : "TOIMP1HA.bmp", "area" : "TZIMP1HA.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBINHRD2.def", "x" : 614, "y" : 221, "border" : "TOIMP2HA.bmp", "area" : "TZIMP2HA.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 21, "animation" : "TBINEXT0.def", "x" : 297, "y" : 0,   "z" : -1, "border" : "TOICAB1A.bmp", "area" : "TZICAB1A.bmp" },
+				{ "id" : 22, "animation" : "TBINEXT1.def", "x" : 227, "y" : 174, "z" : 2,  "border" : "TOICASGA.bmp", "area" : "TZICASGA.bmp" },
+				{ "id" : 23, "animation" : "TBINEXT2.def", "x" : 593, "y" : 104, "border" : "TOIPAIN.bmp",  "area" : "TZIPAIN.bmp"  },
+				{ "id" : 24, "animation" : "TBINHRD3.def", "x" : 10,  "y" : 301, "border" : "TOIHND1H.bmp", "area" : "TZIHND1H.bmp", "hidden" : true },
+				{ "id" : 25, "animation" : "TBINHRD4.def", "x" : 9,   "y" : 273, "border" : "TOIHND2H.bmp", "area" : "TZIHND2H.bmp", "hidden" : true, "builds" : 24 },
+				{ "id" : 26, "animation" : "TBINHOLY.def", "x" : 24,  "y" : 10,  "z" : -1, "border" : "TOIHOLY.bmp",  "area" : "TZIHOLY.bmp" },
+				{ "id" : 30, "animation" : "TBINDW_0.def", "x" : 614, "y" : 256, "border" : "TOIMP1A.bmp",  "area" : "TZIMP1A.bmp"  },
+				{ "id" : 31, "animation" : "TBINDW_1.def", "x" : 187, "y" : 248, "z" : 4,  "border" : "TOIGOG1A.bmp", "area" : "TZIGOG1A.bmp" },
+				{ "id" : 32, "animation" : "TBINDW_2.def", "x" : 9,   "y" : 325, "border" : "TOIHND1.bmp",  "area" : "TZIHND1.bmp"  },
+				{ "id" : 33, "animation" : "TBINDW_3.def", "x" : 414, "y" : 204, "z" : 2,  "border" : "TOIDMN1.bmp",  "area" : "TZIDMN1.bmp" },
+				{ "id" : 34, "animation" : "TBINDW_4.def", "x" : 359, "y" : 296, "z" : 3,  "border" : "TOIPIT1.bmp",  "area" : "TZIPIT1.bmp" },
+				{ "id" : 35, "animation" : "TBINDW_5.def", "x" : 220, "y" : 350, "z" : 5,  "border" : "TOIEFR1.bmp",  "area" : "TZIEFR1.bmp" },
+				{ "id" : 36, "animation" : "TBINDW_6.def", "x" : 420, "y" : 153, "z" : -1, "border" : "TOIDVL1.bmp",  "area" : "TZIDVL1.bmp" },
+				{ "id" : 37, "animation" : "TBINUP_0.def", "x" : 614, "y" : 221, "border" : "TOIMP2A.bmp",  "area" : "TZIMP2A.bmp"  },
+				{ "id" : 38, "animation" : "TBINUP_1.def", "x" : 187, "y" : 212, "z" : 4,  "border" : "TOIGOG2A.bmp", "area" : "TZIGOG2A.bmp" },
+				{ "id" : 39, "animation" : "TBINUP_2.def", "x" : 9,   "y" : 273, "border" : "TOIHND2.bmp",  "area" : "TZIHND2.bmp"  },
+				{ "id" : 40, "animation" : "TBINUP_3.def", "x" : 412, "y" : 197, "z" : 2,  "border" : "TOIDMN2.bmp",  "area" : "TZIDMN2.bmp" },
+				{ "id" : 41, "animation" : "TBINUP_4.def", "x" : 359, "y" : 244, "z" : 3,  "border" : "TOIPIT2.bmp",  "area" : "TZIPIT2.bmp" },
+				{ "id" : 42, "animation" : "TBINUP_5.def", "x" : 220, "y" : 282, "z" : 5,  "border" : "TOIEFR2.bmp",  "area" : "TZIEFR2.bmp" },
+				{ "id" : 43, "animation" : "TBINUP_6.def", "x" : 420, "y" : 105, "z" : -1, "border" : "TOIDVL2.bmp",  "area" : "TZIDVL2.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 24, "built" : 25 },
+				"fort"    : {"normal" : 6,  "built" : 7 }
+			},
+			"musicTheme" : "music/InfernoTown",
+
+			"townBackground": "TBINBACK.bmp",
+			"guildWindow": "TPMAGEIN.bmp",
+			"buildingsIcons": "HALLINFR.DEF",
+			"hallBackground": "TPTHBKIN.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 23 ], [ 21 ] ],
+				[ [ 22 ], [ 18, 19 ], [ 24, 25 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Imp", "Familiar"],
+				["Gog", "Magog"],
+				["HellHound", "Cerberus"],
+				["Single-HornedDemon", "Dual-HornedDemon"],
+				["PitFiend", "PitFoe"],
+				["Efreet", "EfreetSultan"],
+				["Devil", "ArchDevil"]
+			],
+			"horde" : [ 0, 2 ],
+			"mageGuild" : 5,
+			"primaryResource" : "mercury",
+			"warMachine" : "Ballista",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 18, "upgrades" : 30 },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18, 19 ], "mode" : "auto" },
+				{ "id" : 21, "requires" : [ 7 ] },
+				{ "id" : 22, "requires" : [ 8 ] },
+				{ "id" : 23, "requires" : [ 0 ] },
+				{ "id" : 24, "upgrades" : 32 },
+				{ "id" : 25, "upgrades" : 39, "requires" : [ 24, 25 ], "mode" : "auto" },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 26 },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 31 ] },
+				{ "id" : 34, "requires" : [ 33 ] },
+				{ "id" : 35, "requires" : [ 0, 33 ] },
+				{ "id" : 36, "requires" : [ 34, 35 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33 },
+				{ "id" : 41, "upgrades" : 34, "requires" : [ 1 ] },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Gog",
+				"imagePrefix" : "SGIN",
+				"gate" :
+				{
+					"arch" : { "x" : 477, "y" : 221 },
+					"gate" : { "x" : 408, "y" : 254 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 403, "y" : 68 },
+					"moat" : { "x" : 403, "y" : 68 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 606, "y" : 52 },
+					"bottom" : { "x" : 522, "y" : 376 },
+					"top" : { "x" : 502, "y" : 92 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 595, "y" : 514 },
+						"creature" : { "x" : 369, "y" : 298 },
+						"tower" : { "x" : 595, "y" : 514 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 730, "y" : 179 },
+						"creature" : { "x" : 511, "y" : -37 },
+						"tower" : { "x" : 730, "y" : 179 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 569, "y" : 27 },
+						"creature" : { "x" : 341, "y" : -187 },
+						"tower" : { "x" : 569, "y" : 27 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 561, "y" : 451 },
+					"bottomMid" : { "x" : 485, "y" : 316 },
+					"upper" : { "x" : 532, "y" : 71 },
+					"upperMid" : { "x" : 480, "y" : 151 }
+				}
+			}
+		}
+	}
+}

+ 250 - 0
config/factions/necropolis.json

@@ -0,0 +1,250 @@
+{
+	"necropolis" :
+	{
+		"index" : 4,
+		"nativeTerrain": "dirt",
+		"alignment" : "evil",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASNEC",
+			"130px" : "CRBKGNEC"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZNEC",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 22 },
+				{ "x": 7, "y": 188, "index": 1 },
+				{ "x": 7, "y": 329, "index": 20 },
+				{ "x": 7, "y": 403, "index": 24 },
+				{ "x": 8, "y": 8, "index": 47 },
+				{ "x": 14, "y": 138, "index": 30 },
+				{ "x": 15, "y": 8, "index": 9 },
+				{ "x": 34, "y": 374, "index": 31 },
+				{ "x": 55, "y": 82, "index": 25 },
+				{ "x": 55, "y": 150, "index": 38 },
+				{ "x": 57, "y": 281, "index": 8 },
+				{ "x": 94, "y": 188, "index": 36 },
+				{ "x": 108, "y": 344, "index": 6 },
+				{ "x": 119, "y": 424, "index": 13 },
+				{ "x": 124, "y": 256, "index": 37 },
+				{ "x": 131, "y": 8, "index": 7 },
+				{ "x": 139, "y": 92, "index": 11 },
+				{ "x": 145, "y": 371, "index": 29 },
+				{ "x": 148, "y": 42, "index": 21 },
+				{ "x": 175, "y": 200, "index": 44 },
+				{ "x": 200, "y": 291, "index": 45 },
+				{ "x": 201, "y": 66, "index": 42 },
+				{ "x": 210, "y": 482, "index": 18 },
+				{ "x": 247, "y": 98, "index": 28 },
+				{ "x": 250, "y": 227, "index": 48 },
+				{ "x": 262, "y": 8, "index": 15 },
+				{ "x": 293, "y": 373, "index": 32 },
+				{ "x": 303, "y": 286, "index": 46 },
+				{ "x": 318, "y": 173, "index": 43 },
+				{ "x": 345, "y": 444, "index": 2 },
+				{ "x": 356, "y": 8, "index": 5 },
+				{ "x": 357, "y": 386, "index": 17 },
+				{ "x": 362, "y": 38, "index": 40 },
+				{ "x": 382, "y": 8, "index": 19 },
+				{ "x": 382, "y": 119, "index": 35 },
+				{ "x": 421, "y": 164, "index": 27 },
+				{ "x": 422, "y": 249, "index": 4 },
+				{ "x": 428, "y": 52, "index": 14 },
+				{ "x": 429, "y": 101, "index": 10 },
+				{ "x": 443, "y": 132, "index": 41 },
+				{ "x": 452, "y": 239, "index": 34 },
+				{ "x": 465, "y": 441, "index": 23 },
+				{ "x": 469, "y": 300, "index": 39 },
+				{ "x": 476, "y": 20, "index": 3 },
+				{ "x": 537, "y": 249, "index": 33 },
+				{ "x": 547, "y": 430, "index": 12 },
+				{ "x": 559, "y": 140, "index": 26 },
+				{ "x": 558, "y": 8, "index": 16 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCnecx0.def",
+				"village" : "AVCNECR0.DEF",
+				"capitol" : "AVCNECZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBNCEXT2.def", "x" : 25,  "y" : 279 },
+				{ "id" : 0,  "animation" : "TBNCMAGE.def", "x" : 341, "y" : 116, "z" : -1, "border" : "TONMAG1.bmp",  "area" : "TZNMAG1.bmp" },
+				{ "id" : 1,  "animation" : "TBNCMAG2.def", "x" : 341, "y" : 97,  "z" : -1, "border" : "TONMAG2.bmp",  "area" : "TZNMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBNCMAG3.def", "x" : 341, "y" : 78,  "z" : -1, "border" : "TONMAG3.bmp",  "area" : "TZNMAG3.bmp" },
+				{ "id" : 3,  "animation" : "TBNCMAG4.def", "x" : 340, "y" : 62,  "z" : -1, "border" : "TONMAG4.bmp",  "area" : "TZNMAG4.bmp" },
+				{ "id" : 4,  "animation" : "TBNCMAG5.def", "x" : 343, "y" : 35,  "z" : -1, "border" : "TONMAG5.bmp",  "area" : "TZNMAG5.bmp" },
+				{ "id" : 5,  "animation" : "TBNCTVRN.def", "x" : 508, "y" : 189, "border" : "TONTAV.bmp",   "area" : "TZNTAV.bmp"  },
+				{ "id" : 6,  "animation" : "TBNCDOCK.def", "x" : 617, "y" : 265, "z" : -2, "border" : "TONSHPBA.bmp", "area" : "TZNSHPBA.bmp" },
+				{ "id" : 7,  "animation" : "TBNCCSTL.def", "x" : 138, "y" : 66,  "border" : "TONCAS1.bmp",  "area" : "TZNCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBNCCAS2.def", "x" : 139, "y" : 66,  "border" : "TONCAS2.bmp",  "area" : "TZNCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBNCCAS3.def", "x" : 34,  "y" : 18,  "border" : "TONCAS3.bmp",  "area" : "TZNCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBNCHALL.def", "x" : 468, "y" : 76,  "z" : -1, "border" : "TONHAL1.bmp",  "area" : "TZNHAL1.bmp" },
+				{ "id" : 11, "animation" : "TBNCHAL2.def", "x" : 482, "y" : 56,  "z" : -1, "border" : "TONHAL2.bmp",  "area" : "TZNHAL2.bmp" },
+				{ "id" : 12, "animation" : "TBNCHAL3.def", "x" : 478, "y" : 26,  "z" : -1, "border" : "TONHAL3.bmp",  "area" : "TZNHAL3.bmp" },
+				{ "id" : 13, "animation" : "TBNCHAL4.def", "x" : 481, "y" : 26,  "z" : -1, "border" : "TONHAL4.bmp",  "area" : "TZNHAL4.bmp" },
+				{ "id" : 14, "animation" : "TBNCMARK.def", "x" : 347, "y" : 215, "z" : 2,  "border" : "TONMRK1.bmp",  "area" : "TZNMRK1.bmp" },
+				{ "id" : 15, "animation" : "TBNCSILO.def", "x" : 276, "y" : 185, "z" : 1,  "border" : "TONMRK2.bmp",  "area" : "TZNMRK2.bmp" },
+				{ "id" : 16, "animation" : "TBNCBLAK.def", "x" : 382, "y" : 252, "z" : 4,  "border" : "TONSMITA.bmp", "area" : "TZNSMITA.bmp" },
+				{ "id" : 17, "animation" : "TBNCSPEC.def", "x" : 18,  "y" : 0,   "z" : -1, "border" : "TONSHRDA.bmp", "area" : "TZNSHRDA.bmp" },
+				{ "id" : 18, "animation" : "TBNCHRD1.def", "x" : 80,  "y" : 222, "z" : 4, "border" : "TONSKE1H.bmp", "area" : "TZNSKE1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBNCHRD2.def", "x" : 64,  "y" : 222, "z" : 4, "border" : "TONSKE2H.bmp", "area" : "TZNSKE2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 20, "animation" : "TBNCBOAT.def", "x" : 617, "y" : 265, "z" : -2, "border" : "TONSHPNA.bmp", "area" : "TZNSHPNA.bmp", "hidden" : true },
+				{ "id" : 21, "animation" : "TBNCEXT0.def", "x" : 307, "y" : 61,  "z" : -2, "border" : "TONNECRA.bmp", "area" : "TZNNECRA.bmp" },
+				{ "id" : 22, "animation" : "TBNCEXT1.def", "x" : 247, "y" : 275, "z" : 4,  "border" : "TONSKELT.bmp", "area" : "TZNSKELT.bmp" },
+				{ "id" : 26, "animation" : "TBNCHOLY.def", "x" : 410, "y" : 88,  "border" : "TONHOLYA.bmp", "area" : "TZNHOLYA.bmp" },
+				{ "id" : 27, "animation" : "TBNCEXT3.def", "x" : 0,   "y" : 241 },
+				{ "id" : 28, "animation" : "TBNCEXT4.def", "x" : 321, "y" : 255 },
+				{ "id" : 29, "animation" : "TBNCEXT5.def", "x" : 475, "y" : 257 },
+				{ "id" : 30, "animation" : "TBNCDW_0.def", "x" : 80,  "y" : 222, "z" : 4, "border" : "TONSKEL1.bmp", "area" : "TZNSKEL1.bmp" },
+				{ "id" : 31, "animation" : "TBNCDW_1.def", "x" : 502, "y" : 223, "border" : "TONZOMB1.bmp", "area" : "TZNZOMB1.bmp" },
+				{ "id" : 32, "animation" : "TBNCDW_2.def", "x" : 0,   "y" : 187, "z" : 2, "border" : "TONWIGH1.bmp", "area" : "TZNWIGH1.bmp" },
+				{ "id" : 33, "animation" : "TBNCDW_3.def", "x" : 607, "y" : 212, "z" : 2, "border" : "TONVAM1.bmp",  "area" : "TZNVAM1.bmp" },
+				{ "id" : 34, "animation" : "TBNCDW_4.def", "x" : 206, "y" : 207, "z" : 3, "border" : "TONLICH1.bmp", "area" : "TZNLICH1.bmp" },
+				{ "id" : 35, "animation" : "TBNCDW_5.def", "x" : 0,   "y" : 31,  "border" : "TONBKN1.bmp",  "area" : "TZNBKN1.bmp" },
+				{ "id" : 36, "animation" : "TBNCDW_6.def", "x" : 663, "y" : 25,  "border" : "TONBON1.bmp",  "area" : "TZNBON1.bmp" },
+				{ "id" : 37, "animation" : "TBNCUP_0.def", "x" : 64,  "y" : 222, "z" : 4, "border" : "TONSKEL2.bmp", "area" : "TZNSKEL2.bmp" },
+				{ "id" : 38, "animation" : "TBNCUP_1.def", "x" : 498, "y" : 224, "border" : "TONZOMB2.bmp", "area" : "TZNZOMB2.bmp" },
+				{ "id" : 39, "animation" : "TBNCUP_2.def", "x" : 0,   "y" : 179, "z" : 2, "border" : "TONWIGH2.bmp", "area" : "TZNWIGH2.bmp" },
+				{ "id" : 40, "animation" : "TBNCUP_3.def", "x" : 615, "y" : 193, "z" : 2, "border" : "TONVAM2.bmp",  "area" : "TZNVAM2.bmp" },
+				{ "id" : 41, "animation" : "TBNCUP_4.def", "x" : 222, "y" : 171, "z" : 3, "border" : "TONLICH2.bmp", "area" : "TZNLICH2.bmp" },
+				{ "id" : 42, "animation" : "TBNCUP_5.def", "x" : 0,   "y" : 30,  "border" : "TONBKN2.bmp",  "area" : "TZNBKN2.bmp" },
+				{ "id" : 43, "animation" : "TBNCUP_6.def", "x" : 662, "y" : 23,  "border" : "TONBON2.bmp",  "area" : "TZNBON2.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 26, "built" : 27 },
+				"fort"    : {"normal" : 8,  "built" : 9 }
+			},
+			"musicTheme" : "music/NecroTown",
+
+			"townBackground": "TBNCBACK.bmp",
+			"guildWindow": "TPMAGENC.bmp",
+			"buildingsIcons": "HALLNECR.DEF",
+			"hallBackground": "TPTHBKNC.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 21 ], [ 6 ] ],
+				[ [ 17 ], [ 22 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Skeleton", "SkeletonWarrior"],
+				["Zombie", "ZombieLord"],
+				["Wight", "Wraith"],
+				["Vampire", "Nosferatu"],
+				["Lich", "PowerLich"],
+				["BlackKnight", "BlackLord"],
+				["BoneDragon", "GhostDragon"]
+			],
+			"horde" : [ 0, -1 ],
+			"mageGuild" : 5,
+			"warMachine" : "FirstAidTent",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 6 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 7 ] },
+				{ "id" : 18, "upgrades" : 30, "requires" : [ 22 ] },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 20, "upgrades" : 6 },
+				{ "id" : 21, "requires" : [ 0 ] },
+				{ "id" : 22, "requires" : [ 30 ] },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 31 ] },
+				{ "id" : 34, "requires" : [ 0, 31 ] },
+				{ "id" : 35, "requires" : [ 33, 34 ] },
+				{ "id" : 36, "requires" : [ 35 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33, "requires" : [ 21 ] },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Lich",
+				"imagePrefix" : "SGNC",
+				"gate" :
+				{
+					"arch" : { "x" : 474, "y" : 240 },
+					"gate" : { "x" : 401, "y" : 262 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : -1, "y" : -1 },
+					"moat" : { "x" : 406, "y" : 77 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 604, "y" : 58 },
+					"bottom" : { "x" : 509, "y" : 372 },
+					"top" : { "x" : 504, "y" : 97 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 592, "y" : 512 },
+						"creature" : { "x" : 371, "y" : 303 },
+						"tower" : { "x" : 592, "y" : 512 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 730, "y" : 164 },
+						"creature" : { "x" : 501, "y" : 98 },
+						"tower" : { "x" : 730, "y" : 164 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 561, "y" : 26 },
+						"creature" : { "x" : 339, "y" : -177 },
+						"tower" : { "x" : 561, "y" : 26 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 536, "y" : 445 },
+					"bottomMid" : { "x" : 478, "y" : 323 },
+					"upper" : { "x" : 543, "y" : 66 },
+					"upperMid" : { "x" : 487, "y" : 164 }
+				}
+			}
+		}
+	}
+}

+ 12 - 0
config/factions/neutral.json

@@ -0,0 +1,12 @@
+{
+	"neutral" :
+	{
+		"index" : 9,
+		"alignment" : "neutral",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASNEU",
+			"130px" : "CRBKGNEU"
+		}
+	}
+}

+ 253 - 0
config/factions/rampart.json

@@ -0,0 +1,253 @@
+{
+	"rampart" :
+	{
+		"index" : 1,
+		"nativeTerrain": "grass",
+		"alignment" : "good",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASRAM",
+			"130px" : "CRBKGRAM"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZRAM",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 2 },
+				{ "x": 7, "y": 101, "index": 13 },
+				{ "x": 7, "y": 195, "index": 20 },
+				{ "x": 7, "y": 310, "index": 6 },
+				{ "x": 7, "y": 378, "index": 22 },
+				{ "x": 7, "y": 449, "index": 21 },
+				{ "x": 61, "y": 8, "index": 19 },
+				{ "x": 97, "y": 42, "index": 8 },
+				{ "x": 98, "y": 201, "index": 24 },
+				{ "x": 108, "y": 308, "index": 36 },
+				{ "x": 115, "y": 461, "index": 1 },
+				{ "x": 129, "y": 366, "index": 7 },
+				{ "x": 134, "y": 8, "index": 4 },
+				{ "x": 157, "y": 188, "index": 25 },
+				{ "x": 160, "y": 309, "index": 39 },
+				{ "x": 162, "y": 441, "index": 11 },
+				{ "x": 164, "y": 126, "index": 28 },
+				{ "x": 174, "y": 390, "index": 33 },
+				{ "x": 178, "y": 188, "index": 46 },
+				{ "x": 187, "y": 258, "index": 41 },
+				{ "x": 190, "y": 24, "index": 38 },
+				{ "x": 215, "y": 272, "index": 45 },
+				{ "x": 255, "y": 443, "index": 9 },
+				{ "x": 265, "y": 323, "index": 40 },
+				{ "x": 277, "y": 45, "index": 47 },
+				{ "x": 278, "y": 383, "index": 27 },
+				{ "x": 292, "y": 196, "index": 43 },
+				{ "x": 294, "y": 266, "index": 48 },
+				{ "x": 310, "y": 8, "index": 17 },
+				{ "x": 330, "y": 493, "index": 16 },
+				{ "x": 339, "y": 8, "index": 12 },
+				{ "x": 339, "y": 167, "index": 29 },
+				{ "x": 344, "y": 108, "index": 35 },
+				{ "x": 361, "y": 239, "index": 31 },
+				{ "x": 363, "y": 385, "index": 44 },
+				{ "x": 398, "y": 310, "index": 42 },
+				{ "x": 400, "y": 130, "index": 23 },
+				{ "x": 404, "y": 436, "index": 32 },
+				{ "x": 421, "y": 127, "index": 26 },
+				{ "x": 429, "y": 8, "index": 37 },
+				{ "x": 430, "y": 106, "index": 30 },
+				{ "x": 462, "y": 393, "index": 14 },
+				{ "x": 469, "y": 270, "index": 10 },
+				{ "x": 486, "y": 8, "index": 3 },
+				{ "x": 499, "y": 481, "index": 15 },
+				{ "x": 511, "y": 255, "index": 34 },
+				{ "x": 516, "y": 48, "index": 18 },
+				{ "x": 525, "y": 169, "index": 5 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCramx0.def",
+				"village" : "AVCRAMP0.DEF",
+				"capitol" : "AVCRAMZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBRMEXT2.def", "x" : 327, "y" : 236 },
+				{ "id" : 0,  "animation" : "TBRMMAGE.def", "x" : 454, "y" : 200, "z" : -1, "border" : "TORMAG1.bmp",  "area" : "TZRMAG1.bmp" },
+				{ "id" : 1,  "animation" : "TBRMMAG2.def", "x" : 438, "y" : 178, "z" : -1, "border" : "TORMAG2.bmp",  "area" : "TZRMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBRMMAG3.def", "x" : 418, "y" : 153, "z" : -1, "border" : "TORMAG3.bmp",  "area" : "TZRMAG3.bmp" },
+				{ "id" : 3,  "animation" : "TBRMMAG4.def", "x" : 406, "y" : 129, "z" : -1, "border" : "TORMAG4.bmp",  "area" : "TZRMAG4.bmp" },
+				{ "id" : 4,  "animation" : "TBRMMAG5.def", "x" : 384, "y" : 104, "z" : -1, "border" : "TORMAG5.bmp",  "area" : "TZRMAG5.bmp" },
+				{ "id" : 5,  "animation" : "TBRMTVRN.def", "x" : 181, "y" : 229, "z" : 1,  "border" : "TORTAV.bmp",   "area" : "TZRTAV.bmp" },
+				{ "id" : 7,  "animation" : "TBRMCSTL.def", "x" : 63,  "y" : 25,  "z" : -2, "border" : "TORCAS1.bmp",  "area" : "TZRCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBRMCAS2.def", "x" : 79,  "y" : 18,  "z" : -2, "border" : "TORCAS3.bmp",  "area" : "TZRCAS3.bmp" },
+				{ "id" : 9,  "animation" : "TBRMCAS3.def", "x" : 79,  "y" : 18,  "z" : -2, "border" : "TORCAS2.bmp",  "area" : "TZRCAS2.bmp" },
+				{ "id" : 10, "animation" : "TBRMHALL.def", "x" : 565, "y" : 216, "border" : "TORHAL1.bmp",  "area" : "TZRHAL1.bmp" },
+				{ "id" : 11, "animation" : "TBRMHAL2.def", "x" : 538, "y" : 187, "border" : "TORHAL2.bmp",  "area" : "TZRHAL2.bmp" },
+				{ "id" : 12, "animation" : "TBRMHAL3.def", "x" : 538, "y" : 187, "border" : "TORHAL3.bmp",  "area" : "TZRHAL3.bmp" },
+				{ "id" : 13, "animation" : "TBRMHAL4.def", "x" : 534, "y" : 187, "border" : "TORHAL4.bmp",  "area" : "TZRHAL4.bmp" },
+				{ "id" : 14, "animation" : "TBRMMARK.def", "x" : 129, "y" : 301, "z" : 3,  "border" : "TORMRK1.bmp",  "area" : "TZRMRK1.bmp" },
+				{ "id" : 15, "animation" : "TBRMSILO.def", "x" : 245, "y" : 324, "z" : 4,  "border" : "TORMRK2.bmp",  "area" : "TZRMRK2.bmp" },
+				{ "id" : 16, "animation" : "TBRMBLAK.def", "x" : 558, "y" : 105, "z" : -3, "border" : "TORAID.bmp",   "area" : "TZRAID.bmp" },
+				{ "id" : 17, "animation" : "TBRMSPEC.def", "x" : 555, "y" : 297, "border" : "TORGAR1A.bmp", "area" : "TZRGAR1A.bmp" },
+				{ "id" : 18, "animation" : "TBRMHRD1.def", "x" : 0,   "y" : 154, "border" : "TORDWF1H.bmp", "area" : "TZRDWF1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBRMHRD2.def", "x" : 0,   "y" : 143, "border" : "TORDWF2H.bmp", "area" : "TZRDWF2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 21, "animation" : "TBRMEXT0.def", "x" : 555, "y" : 297, "z" : 2, "border" : "TORGAR2A.bmp", "area" : "TZRGAR2A.bmp" },
+				{ "id" : 22, "animation" : "TBRMEXT1.def", "x" : 0,   "y" : 181, "z" : 1, "border" : "TORDWFT.bmp",  "area" : "TZRDWFT.bmp" },
+				{ "id" : 24, "animation" : "TBRMHRD3.def", "x" : 47,  "y" : 142, "z" : -1, "border" : "TORTRE1H.bmp", "area" : "TZRTRE1H.bmp", "hidden" : true },
+				{ "id" : 25, "animation" : "TBRMHRD4.def", "x" : 47,  "y" : 142, "z" : -1, "border" : "TORTRE2H.bmp", "area" : "TZRTRE2H.bmp", "hidden" : true, "builds" : 24 },
+				{ "id" : 26, "animation" : "TBRMHOLY.def", "x" : 0,   "y" : 54,  "z" : -1, "border" : "TORHOLY.bmp",  "area" : "TZRHOLY.bmp" },
+				{ "id" : 27, "animation" : "TBRMEXT3.def", "x" : 293, "y" : 235 },
+				{ "id" : 28, "animation" : "TBRMEXT4.def", "x" : 295, "y" : 191 },
+				{ "id" : 29, "animation" : "TBRMEXT5.def", "x" : 260, "y" : 171 },
+				{ "id" : 30, "animation" : "TBRMDW_0.def", "x" : 0,   "y" : 236, "z" : 2,  "border" : "TORCEN1A.bmp", "area" : "TZRCEN1A.bmp" },
+				{ "id" : 31, "animation" : "TBRMDW_1.def", "x" : 0,   "y" : 154, "border" : "TORDWF1.bmp",  "area" : "TZRDWF1.bmp" },
+				{ "id" : 32, "animation" : "TBRMDW_2.def", "x" : 668, "y" : 101, "border" : "TORELF1.bmp",  "area" : "TZRELF1.bmp" },
+				{ "id" : 33, "animation" : "TBRMDW_3.def", "x" : 287, "y" : 73,  "z" : -1, "border" : "TORPEG1A.bmp", "area" : "TZRPEG1A.bmp" },
+				{ "id" : 34, "animation" : "TBRMDW_4.def", "x" : 68,  "y" : 146, "z" : -1, "border" : "TORTRE1.bmp",  "area" : "TZRTRE1.bmp" },
+				{ "id" : 35, "animation" : "TBRMDW_5.def", "x" : 362, "y" : 90,  "z" : -2, "border" : "TORUNI1.bmp",  "area" : "TZRUNI1.bmp" },
+				{ "id" : 36, "animation" : "TBRMDW_6.def", "x" : 502, "y" : 27,  "z" : -5, "border" : "TORDR1AA.bmp", "area" : "TZRDR1AA.bmp" },
+				{ "id" : 37, "animation" : "TBRMUP_0.def", "x" : 0,   "y" : 236, "z" : 2,  "border" : "TORCEN2A.bmp", "area" : "TZRCEN2A.bmp" },
+				{ "id" : 38, "animation" : "TBRMUP_1.def", "x" : 0,   "y" : 143, "border" : "TORDWF2.bmp",  "area" : "TZRDWF2.bmp" },
+				{ "id" : 39, "animation" : "TBRMUP_2.def", "x" : 665, "y" : 101, "border" : "TORELF2.bmp",  "area" : "TZRELF2.bmp" },
+				{ "id" : 40, "animation" : "TBRMUP_3.def", "x" : 287, "y" : 28,  "z" : -1, "border" : "TORPEG2A.bmp", "area" : "TZRPEG2A.bmp" },
+				{ "id" : 41, "animation" : "TBRMUP_4.def", "x" : 63,  "y" : 146, "z" : -1, "border" : "TORTRE2.bmp",  "area" : "TZRTRE2.bmp" },
+				{ "id" : 42, "animation" : "TBRMUP_5.def", "x" : 362, "y" : 90,  "z" : -2, "border" : "TORUNI2.bmp",  "area" : "TZRUNI2.bmp" },
+				{ "id" : 43, "animation" : "TBRMUP_6.def", "x" : 502, "y" : 5,   "z" : -5, "border" : "TORDR2AA.bmp", "area" : "TZRDR2AA.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 20, "built" : 21 },
+				"fort"    : {"normal" : 2,  "built" : 3 }
+			},
+
+			"musicTheme" : "music/Rampart",
+
+			"townBackground": "TBRMBACK.bmp",
+			"guildWindow": "TPMAGERM.bmp",
+			"buildingsIcons": "HALLRAMP.DEF",
+			"hallBackground": "TPTHBKRM.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 17, 21 ] ],
+				[ [ 22 ], [ 24, 25 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Centaur", "EliteCentaur"],
+				["Dwarf", "BattleDwarf"],
+				["WoodElf", "GrandElf"],
+				["Pegasus", "SilverPegasus"],
+				["Treefolk", "BriarTreefolk"],
+				["Unicorn", "WarUnicorn"],
+				["GreenDragon", "GoldDragon"]
+			],
+			"horde" : [ 1, 4 ],
+			"mageGuild" : 5,
+			"primaryResource" : "crystal",
+			"warMachine" : "FirstAidTent",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17 },
+				{ "id" : 18, "upgrades" : 31 },
+				{ "id" : 19, "upgrades" : 38, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 21, "requires" : [ 17 ] },
+				{ "id" : 22, "requires" : [ 18, 19 ] },
+				{ "id" : 24, "upgrades" : 34 },
+				{ "id" : 25, "upgrades" : 41, "requires" : [ 24 ], "mode" : "auto" },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 26 },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 32 ] },
+				{ "id" : 34, "requires" : [ 32 ] },
+				{ "id" : 35, "requires" : [ 33, 34 ] },
+				{ "id" : 36, "requires" : [ 35, 1 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33 },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36, "requires" : [ 2 ] }
+			],
+
+			"siege" :
+			{
+				"shooter" : "WoodElf",
+				"imagePrefix" : "SGRM",
+				"gate" :
+				{
+					"arch" : { "x" : 460, "y" : 220 },
+					"gate" : { "x" : 403, "y" : 271 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 410, "y" : 97 },
+					"moat" : { "x" : 410, "y" : 77 }
+				},
+				"shooterHeight" : 232,
+				"static" :
+				{
+					"background" : { "x" : 608, "y" : 46 },
+					"bottom" : { "x" : 510, "y" : 364 },
+					"top" : { "x" : 492, "y" : 103 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 594, "y" : 511 },
+						"creature" : { "x" : 371, "y" : 296 },
+						"tower" : { "x" : 594, "y" : 511 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 724, "y" : 189 },
+						"creature" : { "x" : 532, "y" : -27 },
+						"tower" : { "x" : 724, "y" : 189 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 566, "y" : 31 },
+						"creature" : { "x" : 341, "y" : -186 },
+						"tower" : { "x" : 565, "y" : 31 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 549, "y" : 451 },
+					"bottomMid" : { "x" : 469, "y" : 309 },
+					"upper" : { "x" : 530, "y" : 57 },
+					"upperMid" : { "x" : 469, "y" : 186 }
+				}
+			}
+		}
+	}
+}

+ 243 - 0
config/factions/stronghold.json

@@ -0,0 +1,243 @@
+{
+	"stronghold" :
+	{
+		"index" : 6,
+		"nativeTerrain": "rough",
+		"alignment" : "neutral",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASSTR",
+			"130px" : "CRBKGSTR"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZSTR",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 6 },
+				{ "x": 7, "y": 229, "index": 14 },
+				{ "x": 7, "y": 405, "index": 15 },
+				{ "x": 7, "y": 465, "index": 10 },
+				{ "x": 12, "y": 8, "index": 9 },
+				{ "x": 32, "y": 245, "index": 21 },
+				{ "x": 32, "y": 277, "index": 33 },
+				{ "x": 36, "y": 337, "index": 19 },
+				{ "x": 39, "y": 15, "index": 36 },
+				{ "x": 47, "y": 115, "index": 23 },
+				{ "x": 49, "y": 178, "index": 25 },
+				{ "x": 70, "y": 8, "index": 1 },
+				{ "x": 101, "y": 35, "index": 41 },
+				{ "x": 111, "y": 311, "index": 44 },
+				{ "x": 123, "y": 156, "index": 45 },
+				{ "x": 138, "y": 423, "index": 32 },
+				{ "x": 140, "y": 224, "index": 43 },
+				{ "x": 144, "y": 136, "index": 11 },
+				{ "x": 149, "y": 452, "index": 18 },
+				{ "x": 158, "y": 475, "index": 5 },
+				{ "x": 191, "y": 68, "index": 7 },
+				{ "x": 202, "y": 12, "index": 39 },
+				{ "x": 218, "y": 349, "index": 34 },
+				{ "x": 219, "y": 285, "index": 42 },
+				{ "x": 222, "y": 96, "index": 28 },
+				{ "x": 262, "y": 8, "index": 8 },
+				{ "x": 279, "y": 166, "index": 48 },
+				{ "x": 279, "y": 425, "index": 22 },
+				{ "x": 303, "y": 314, "index": 27 },
+				{ "x": 320, "y": 109, "index": 16 },
+				{ "x": 326, "y": 146, "index": 47 },
+				{ "x": 333, "y": 160, "index": 46 },
+				{ "x": 362, "y": 26, "index": 4 },
+				{ "x": 365, "y": 441, "index": 17 },
+				{ "x": 380, "y": 297, "index": 38 },
+				{ "x": 392, "y": 242, "index": 29 },
+				{ "x": 427, "y": 275, "index": 40 },
+				{ "x": 445, "y": 85, "index": 2 },
+				{ "x": 446, "y": 424, "index": 30 },
+				{ "x": 459, "y": 347, "index": 37 },
+				{ "x": 463, "y": 53, "index": 24 },
+				{ "x": 484, "y": 210, "index": 20 },
+				{ "x": 488, "y": 8, "index": 26 },
+				{ "x": 489, "y": 303, "index": 35 },
+				{ "x": 529, "y": 8, "index": 31 },
+				{ "x": 529, "y": 421, "index": 3 },
+				{ "x": 558, "y": 87, "index": 13 },
+				{ "x": 563, "y": 261, "index": 12 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCstrx0.def",
+				"village" : "AVCSTRO0.DEF",
+				"capitol" : "AVCSTRZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "animation" : "TBSTEXT3.def", "x" : 23,  "y" : 20 },
+				{ "id" : 0,  "animation" : "TBSTMAGE.def", "x" : 473, "y" : 67,  "z" : -1, "border" : "TOSMAG1.bmp",  "area" : "TZSMAG1.bmp" },
+				{ "id" : 1,  "animation" : "TBSTMAG2.def", "x" : 473, "y" : 37,  "z" : -1, "border" : "TOSMAG2.bmp",  "area" : "TZSMAG2.bmp" },
+				{ "id" : 2,  "animation" : "TBSTMAG3.def", "x" : 473, "y" : 1,   "z" : -1, "border" : "TOSMAG3.bmp",  "area" : "TZSMAG3.bmp" },
+				{ "id" : 5,  "animation" : "TBSTTVRN.def", "x" : 170, "y" : 280, "z" : 2,  "border" : "TOSTAV.bmp",   "area" : "TZSTAV.bmp" },
+				{ "id" : 7,  "animation" : "TBSTCSTL.def", "x" : 402, "y" : 148, "z" : -1, "border" : "TOSCA1.bmp",   "area" : "TZSCA1.bmp" },
+				{ "id" : 8,  "animation" : "TBSTCAS2.def", "x" : 402, "y" : 114, "z" : -1, "border" : "TOSCA2.bmp",   "area" : "TZSCA2.bmp" },
+				{ "id" : 9,  "animation" : "TBSTCAS3.def", "x" : 402, "y" : 114, "z" : -1, "border" : "TOSCA3.bmp",   "area" : "TZSCA3.bmp" },
+				{ "id" : 10, "animation" : "TBSTHALL.def", "x" : 0,   "y" : 259, "border" : "TOSHAL1A.bmp", "area" : "TZSHAL1A.bmp" },
+				{ "id" : 11, "animation" : "TBSTHAL2.def", "x" : 0,   "y" : 225, "border" : "TOSHAL2A.bmp", "area" : "TZSHAL2A.bmp" },
+				{ "id" : 12, "animation" : "TBSTHAL3.def", "x" : 0,   "y" : 201, "border" : "TOSHAL3A.bmp", "area" : "TZSHAL3A.bmp" },
+				{ "id" : 13, "animation" : "TBSTHAL4.def", "x" : 0,   "y" : 148, "border" : "TOSHAL4A.bmp", "area" : "TZSHAL4A.bmp" },
+				{ "id" : 14, "animation" : "TBSTMARK.def", "x" : 397, "y" : 308, "z" : 1,  "border" : "TOSMRK1.bmp",  "area" : "TZSMRK1.bmp" },
+				{ "id" : 15, "animation" : "TBSTSILO.def", "x" : 458, "y" : 248, "z" : 1,  "border" : "TOSMRK2.bmp",  "area" : "TZSMRK2.bmp" },
+				{ "id" : 16, "animation" : "TBSTBLAK.def", "x" : 660, "y" : 286, "border" : "TOSBLK1.bmp",  "area" : "TZSBLK1.bmp" },
+				{ "id" : 17, "animation" : "TBSTSPEC.def", "x" : 550, "y" : 229, "border" : "TOSCA1EA.bmp", "area" : "TZSCA1EA.bmp" },
+				{ "id" : 18, "animation" : "TBSTHRD1.def", "x" : 373, "y" : 239, "border" : "TOSGOB1H.bmp", "area" : "TZSGOB1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBSTHRD2.def", "x" : 373, "y" : 220, "border" : "TOSGOB2H.bmp", "area" : "TZSGOB2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 21, "animation" : "TBSTEXT0.def", "x" : 473, "y" : 282, "z" : 3,  "border" : "TOSMRK1C.bmp", "area" : "TZSMRK1C.bmp" },
+				{ "id" : 22, "animation" : "TBSTEXT1.def", "x" : 617, "y" : 286, "z" : 1,  "border" : "TOSBLK2.bmp",  "area" : "TZSBLK2.bmp" },
+				{ "id" : 23, "animation" : "TBSTEXT2.def", "x" : 313, "y" : 13,  "z" : -1, "border" : "TOSVAH.bmp",   "area" : "TZSVAH.bmp" },
+				{ "id" : 26, "animation" : "TBSTHOLY.def", "x" : 321, "y" : 105, "z" : 2,  "border" : "TOSHOLYA.bmp", "area" : "TZSHOLYA.bmp" },
+				{ "id" : 30, "animation" : "TBSTDW_0.def", "x" : 373, "y" : 239, "border" : "TOSGOB1.bmp",  "area" : "TZSGOB1.bmp" },
+				{ "id" : 31, "animation" : "TBSTDW_1.def", "x" : 266, "y" : 246, "z" : 1,  "border" : "TOSWOL1.bmp",  "area" : "TZSWOL1.bmp" },
+				{ "id" : 32, "animation" : "TBSTDW_2.def", "x" : 566, "y" : 232, "z" : 2,  "border" : "TOSORC1.bmp",  "area" : "TZSORC1.bmp" },
+				{ "id" : 33, "animation" : "TBSTDW_3.def", "x" : 197, "y" : 204, "border" : "TOSOGR1.bmp",  "area" : "TZSOGR1.bmp" },
+				{ "id" : 34, "animation" : "TBSTDW_4.def", "x" : 137, "y" : 30,  "z" : -1, "border" : "TOSROC1.bmp",  "area" : "TZSROC1.bmp" },
+				{ "id" : 35, "animation" : "TBSTDW_5.def", "x" : 622, "y" : 160, "z" : -2, "border" : "TOSCYC1.bmp",  "area" : "TZSCYC1.bmp" },
+				{ "id" : 36, "animation" : "TBSTDW_6.def", "x" : 604, "y" : 0,   "border" : "TOSBEH1A.bmp", "area" : "TZSBEH1A.bmp" },
+				{ "id" : 37, "animation" : "TBSTUP_0.def", "x" : 373, "y" : 220, "border" : "TOSGOB2.bmp",  "area" : "TZSGOB2.bmp" },
+				{ "id" : 38, "animation" : "TBSTUP_1.def", "x" : 266, "y" : 225, "z" : 1,  "border" : "TOSWOL2.bmp",  "area" : "TZSWOL2.bmp" },
+				{ "id" : 39, "animation" : "TBSTUP_2.def", "x" : 566, "y" : 158, "z" : 2,  "border" : "TOSORC2.bmp",  "area" : "TZSORC2.bmp" },
+				{ "id" : 40, "animation" : "TBSTUP_3.def", "x" : 197, "y" : 137, "border" : "TOSOGR2.bmp",  "area" : "TZSOGR2.bmp" },
+				{ "id" : 41, "animation" : "TBSTUP_4.def", "x" : 129, "y" : 15,  "z" : -1, "border" : "TOSROC2.bmp",  "area" : "TZSROC2.bmp" },
+				{ "id" : 42, "animation" : "TBSTUP_5.def", "x" : 616, "y" : 93,  "z" : -2, "border" : "TOSCYC2A.bmp", "area" : "TZSCYC2A.bmp" },
+				{ "id" : 43, "animation" : "TBSTUP_6.def", "x" : 604, "y" : 0,   "border" : "TOSBEH2A.bmp", "area" : "TZSBEH2A.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 30, "built" : 31 },
+				"fort"    : {"normal" : 12, "built" : 13 }
+			},
+			"musicTheme" : "music/Stronghold",
+
+			"townBackground": "TBSTBACK.bmp",
+			"guildWindow": "TPMAGEST.bmp",
+			"buildingsIcons": "HALLSTRN.DEF",
+			"hallBackground": "TPTHBKTW.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2 ], [ 23 ], [ 17 ] ],
+				[ [ 21 ], [ 22 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["Goblin", "Hobgoblin"],
+				["GoblinWolfRider", "HobgoblinWolfRider"],
+				["Orc", "OrcChieftain"],
+				["Ogre", "OgreMage"],
+				["Roc", "Thunderbird"],
+				["Cyclops", "CyclopsLord"],
+				["YoungBehemoth", "AncientBehemoth"]
+			],
+			"horde" : [ 0, -1 ],
+			"mageGuild" : 3,
+			"warMachine" : "AmmoCart",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 7 ] },
+				{ "id" : 18, "upgrades" : 30 },
+				{ "id" : 19, "upgrades" : 37, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 21, "requires" : [ 14 ] },
+				{ "id" : 22, "requires" : [ 16 ] },
+				{ "id" : 23, "requires" : [ 7 ] },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 32 ] },
+				{ "id" : 34, "requires" : [ 31 ] },
+				{ "id" : 35, "requires" : [ 33 ] },
+				{ "id" : 36, "requires" : [ 34 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31, "requires" : [ 37 ] },
+				{ "id" : 39, "upgrades" : 32, "requires" : [ 16 ] },
+				{ "id" : 40, "upgrades" : 33, "requires" : [ 0 ] },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Orc",
+				"imagePrefix" : "SGST",
+				"gate" :
+				{
+					"arch" : { "x" : 478, "y" : 235 },
+					"gate" : { "x" : 407, "y" : 266 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 410, "y" : 91 },
+					"moat" : { "x" : 410, "y" : 90 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 617, "y" : 62 },
+					"bottom" : { "x" : 511, "y" : 380 },
+					"top" : { "x" : 499, "y" : 107}
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 586, "y" : 508 },
+						"creature" : { "x" : 361, "y" : 290 },
+						"tower" : { "x" : 586, "y" : 508 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 731, "y" : 168 },
+						"creature" : { "x" : 531, "y" : -45 },
+						"tower" : { "x" : 731, "y" : 168 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 568, "y" : 30 },
+						"creature" : { "x" : 342, "y" : -187 },
+						"tower" : { "x" : 568, "y" : 30 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 553, "y" : 440 },
+					"bottomMid" : { "x" : 483, "y" : 304 },
+					"upper" : { "x" : 534, "y" : 69 },
+					"upperMid" : { "x" : 476, "y" : 189 }
+				}
+			}
+		}
+	}
+}

+ 246 - 0
config/factions/tower.json

@@ -0,0 +1,246 @@
+{
+	"tower" :
+	{
+		"index" : 2,
+		"nativeTerrain" : "snow",
+		"alignment" : "good",
+		"creatureBackground" :
+		{
+			"120px" : "TPCASTOW",
+			"130px" : "CRBKGTOW"
+		},
+		"puzzleMap" :
+		{
+			"prefix" : "PUZTOW",
+			"pieces" :
+			[
+				{ "x": 7, "y": 8, "index": 1 },
+				{ "x": 7, "y": 52, "index": 13 },
+				{ "x": 7, "y": 243, "index": 8 },
+				{ "x": 7, "y": 486, "index": 22 },
+				{ "x": 26, "y": 391, "index": 7 },
+				{ "x": 27, "y": 31, "index": 23 },
+				{ "x": 27, "y": 89, "index": 31 },
+				{ "x": 28, "y": 303, "index": 20 },
+				{ "x": 28, "y": 336, "index": 25 },
+				{ "x": 37, "y": 234, "index": 33 },
+				{ "x": 59, "y": 77, "index": 6 },
+				{ "x": 76, "y": 462, "index": 15 },
+				{ "x": 91, "y": 245, "index": 34 },
+				{ "x": 114, "y": 31, "index": 19 },
+				{ "x": 118, "y": 323, "index": 42 },
+				{ "x": 132, "y": 87, "index": 36 },
+				{ "x": 163, "y": 370, "index": 40 },
+				{ "x": 171, "y": 255, "index": 21 },
+				{ "x": 192, "y": 8, "index": 28 },
+				{ "x": 212, "y": 483, "index": 38 },
+				{ "x": 228, "y": 95, "index": 44 },
+				{ "x": 231, "y": 205, "index": 46 },
+				{ "x": 293, "y": 380, "index": 10 },
+				{ "x": 297, "y": 190, "index": 43 },
+				{ "x": 297, "y": 260, "index": 48 },
+				{ "x": 298, "y": 8, "index": 17 },
+				{ "x": 298, "y": 89, "index": 35 },
+				{ "x": 312, "y": 462, "index": 29 },
+				{ "x": 320, "y": 261, "index": 45 },
+				{ "x": 340, "y": 17, "index": 37 },
+				{ "x": 350, "y": 121, "index": 12 },
+				{ "x": 350, "y": 174, "index": 41 },
+				{ "x": 355, "y": 371, "index": 27 },
+				{ "x": 357, "y": 469, "index": 3 },
+				{ "x": 376, "y": 289, "index": 11 },
+				{ "x": 388, "y": 8, "index": 4 },
+				{ "x": 407, "y": 45, "index": 47 },
+				{ "x": 421, "y": 284, "index": 30 },
+				{ "x": 436, "y": 159, "index": 39 },
+				{ "x": 445, "y": 8, "index": 18 },
+				{ "x": 445, "y": 211, "index": 26 },
+				{ "x": 463, "y": 422, "index": 24 },
+				{ "x": 477, "y": 29, "index": 2 },
+				{ "x": 497, "y": 153, "index": 5 },
+				{ "x": 499, "y": 108, "index": 14 },
+				{ "x": 503, "y": 281, "index": 16 },
+				{ "x": 537, "y": 418, "index": 9 },
+				{ "x": 556, "y": 215, "index": 32 }
+			]
+		},
+		"town" :
+		{
+			"adventureMap" :
+			{
+				"castle" : "AVCtowx0.def",
+				"village" : "AVCTOWR0.DEF",
+				"capitol" : "AVCTOWZ0.DEF"
+			},
+			"structures" :
+			[
+				{ "id" : 0,  "animation" : "TBTWMAGE.def", "x" : 597, "y" : 82,  "border" : "TOTGLD1.bmp",  "area" : "TZTGLD1.bmp" },
+				{ "id" : 1,  "animation" : "TBTWMAG2.def", "x" : 593, "y" : 65,  "border" : "TOTGLD2.bmp",  "area" : "TZTGLD2.bmp" },
+				{ "id" : 2,  "animation" : "TBTWMAG3.def", "x" : 593, "y" : 48,  "border" : "TOTGLD3.bmp",  "area" : "TZTGLD3.bmp" },
+				{ "id" : 3,  "animation" : "TBTWMAG4.def", "x" : 593, "y" : 31,  "border" : "TOTGLD4.bmp",  "area" : "TZTGLD4.bmp" },
+				{ "id" : 4,  "animation" : "TBTWMAG5.def", "x" : 593, "y" : 14,  "border" : "TOTGLD5.bmp",  "area" : "TZTGLD5.bmp" },
+				{ "id" : 5,  "animation" : "TBTWTVRN.def", "x" : 375, "y" : 278, "z" : 1, "border" : "TOTTAV.bmp",   "area" : "TZTTAV.bmp" },
+				{ "id" : 7,  "animation" : "TBTWCSTL.def", "x" : 304, "y" : 0,   "border" : "TOTCAS1.bmp",  "area" : "TZTCAS1.bmp" },
+				{ "id" : 8,  "animation" : "TBTWCAS2.def", "x" : 301, "y" : 0,   "border" : "TOTCAS2.bmp",  "area" : "TZTCAS2.bmp" },
+				{ "id" : 9,  "animation" : "TBTWCAS3.def", "x" : 301, "y" : 0,   "border" : "TOTCAS3.bmp",  "area" : "TZTCAS3.bmp" },
+				{ "id" : 10, "animation" : "TBTWHALL.def", "x" : 0,   "y" : 259, "z" : 1,  "border" : "TOTHAL1.bmp",  "area" : "TZTHAL1.bmp" },
+				{ "id" : 11, "animation" : "TBTWHAL2.def", "x" : 0,   "y" : 220, "z" : 1,  "border" : "TOTHAL2.bmp",  "area" : "TZTHAL2.bmp" },
+				{ "id" : 12, "animation" : "TBTWHAL3.def", "x" : 0,   "y" : 82,  "z" : 1,  "border" : "TOTHAL3.bmp",  "area" : "TZTHAL3.bmp" },
+				{ "id" : 13, "animation" : "TBTWHAL4.def", "x" : 0,   "y" : 82,  "z" : 1,  "border" : "TOTHAL4.bmp",  "area" : "TZTHAL4.bmp" },
+				{ "id" : 14, "animation" : "TBTWMARK.def", "x" : 614, "y" : 292, "border" : "TOTMRK.bmp",   "area" : "TZTMRK.bmp" },
+				{ "id" : 15, "animation" : "TBTWSILO.def", "x" : 763, "y" : 214, "z" : 3, "border" : "TOTMRKS.bmp",  "area" : "TZTMRKS.bmp" },
+				{ "id" : 16, "animation" : "TBTWBLAK.def", "x" : 478, "y" : 211, "border" : "TOTBLKA.bmp",  "area" : "TZTBLKA.bmp" },
+				{ "id" : 17, "animation" : "TBTWSPEC.def", "x" : 674, "y" : 276, "z" : 2, "border" : "TOTMRKA.bmp",  "area" : "TZTMRKA.bmp" },
+				{ "id" : 18, "animation" : "TBTWHRD1.def", "x" : 0,   "y" : 47,  "border" : "TOTGAR1H.bmp", "area" : "TZTGAR1H.bmp", "hidden" : true },
+				{ "id" : 19, "animation" : "TBTWHRD2.def", "x" : 0,   "y" : 28,  "border" : "TOTGAR2H.bmp", "area" : "TZTGAR2H.bmp", "hidden" : true, "builds" : 18 },
+				{ "id" : 21, "animation" : "TBTWEXT0.def", "x" : 409, "y" : 82,  "border" : "TOTCASW.bmp",  "area" : "TZTCASW.bmp" },
+				{ "id" : 22, "animation" : "TBTWEXT1.def", "x" : 702, "y" : 115, "border" : "TOTGLDL.bmp",  "area" : "TZTGLDL.bmp" },
+				{ "id" : 23, "animation" : "TBTWEXT2.def", "x" : 592, "y" : 189, "z" : 1,  "border" : "TOTGLDW.bmp",  "area" : "TZTGLDW.bmp" },
+				{ "id" : 26, "animation" : "TBTWHOLY.def", "x" : 237, "y" : 14,  "z" : -1, "border" : "TOTHOLYA.bmp", "area" : "TZTHOLYA.bmp" },
+				{ "id" : 30, "animation" : "TBTWDW_0.def", "x" : 453, "y" : 221, "z" : 1,  "border" : "TOTGRM1A.bmp", "area" : "TZTGRM1A.bmp" },
+				{ "id" : 31, "animation" : "TBTWDW_1.def", "x" : 4,   "y" : 46,  "border" : "TOTGAR1.bmp",  "area" : "TZTGAR1.bmp" },
+				{ "id" : 32, "animation" : "TBTWDW_2.def", "x" : 209, "y" : 177, "z" : 1,  "border" : "TOTGOL1A.bmp", "area" : "TZTGOL1A.bmp" },
+				{ "id" : 33, "animation" : "TBTWDW_3.def", "x" : 613, "y" : 95,  "border" : "TOTMAG1.bmp",  "area" : "TZTMAG1.bmp" },
+				{ "id" : 34, "animation" : "TBTWDW_4.def", "x" : 511, "y" : 75,  "border" : "TOTGEN1.bmp",  "area" : "TZTGEN1.bmp" },
+				{ "id" : 35, "animation" : "TBTWDW_5.def", "x" : 681, "y" : 208, "z" : 2,  "border" : "TOTNAG1.bmp",  "area" : "TZTNAG1.bmp" },
+				{ "id" : 36, "animation" : "TBTWDW_6.def", "x" : 75,  "y" : 144, "z" : -1, "border" : "TOTTIT1.bmp",  "area" : "TZTTIT1.bmp" },
+				{ "id" : 37, "animation" : "TBTWUP_0.def", "x" : 446, "y" : 221, "z" : 1,  "border" : "TOTGRM2A.bmp", "area" : "TZTGRM2A.bmp" },
+				{ "id" : 38, "animation" : "TBTWUP_1.def", "x" : 4,   "y" : 28,  "border" : "TOTGAR2.bmp",  "area" : "TZTGAR2.bmp" },
+				{ "id" : 39, "animation" : "TBTWUP_2.def", "x" : 209, "y" : 177, "z" : 1,  "border" : "TOTGOL2A.bmp", "area" : "TZTGOL2A.bmp" },
+				{ "id" : 40, "animation" : "TBTWUP_3.def", "x" : 613, "y" : 74,  "border" : "TOTMAG2.bmp",  "area" : "TZTMAG2.bmp" },
+				{ "id" : 41, "animation" : "TBTWUP_4.def", "x" : 511, "y" : 8,   "border" : "TOTGEN2.bmp",  "area" : "TZTGEN2.bmp" },
+				{ "id" : 42, "animation" : "TBTWUP_5.def", "x" : 681, "y" : 157, "z" : 2,  "border" : "TOTNAG2.bmp",  "area" : "TZTNAG2.bmp" },
+				{ "id" : 43, "animation" : "TBTWUP_6.def", "x" : 75,  "y" : 91,  "z" : -1, "border" : "TOTTIT2.bmp",  "area" : "TZTTIT2.bmp" }
+			],
+			"icons" :
+			{
+				"village" : {"normal" : 22, "built" : 23 },
+				"fort"    : {"normal" : 4,  "built" : 5 }
+			},
+
+			"musicTheme" : "music/TowerTown",
+
+			"townBackground": "TBTWBACK.bmp",
+			"guildWindow": "TPMAGETW.bmp",
+			"buildingsIcons": "HALLTOWR.DEF",
+			"hallBackground": "TPTHBKTW.BMP",
+			"hallSlots":
+			[
+				[ [ 10, 11, 12, 13 ], [ 7, 8, 9 ], [ 5 ], [ 16 ] ],
+				[ [ 14, 15 ], [ 0, 1, 2, 3, 4 ], [ 22 ], [ 23 ] ],
+				[ [ 17 ], [ 21 ], [ 18, 19 ] ],
+				[ [ 30, 37 ], [ 31, 38 ], [ 32, 39 ], [ 33, 40 ] ],
+				[ [ 34, 41 ], [ 35, 42 ], [ 36, 43 ] ]
+			],
+			"creatures" :
+			[
+				["ApprenticeGremlin", "MasterGremlin"],
+				["StoneGargoyle", "ObsidianGargoyle"],
+				["IronGolem", "StoneGolem"],
+				["Mage", "ArchMage"],
+				["Genie", "Caliph"],
+				["NagaSentinel", "NagaGuardian"],
+				["LesserTitan", "GreaterTitan"]
+			],
+			"horde" : [ 1, -1 ],
+			"primaryResource" : "gems",
+			"mageGuild" : 5,
+			"warMachine" : "AmmoCart",
+
+			"buildings" :
+			[
+				{ "id" : 0 },
+				{ "id" : 1,  "upgrades" : 0 },
+				{ "id" : 2,  "upgrades" : 1 },
+				{ "id" : 3,  "upgrades" : 2 },
+				{ "id" : 4,  "upgrades" : 3 },
+				{ "id" : 5 },
+				{ "id" : 7 },
+				{ "id" : 8,  "upgrades" : 7 },
+				{ "id" : 9,  "upgrades" : 8 },
+				{ "id" : 10, "mode" : "auto" },
+				{ "id" : 11, "upgrades" : 10, "requires" : [ 5 ] },
+				{ "id" : 12, "upgrades" : 11, "requires" : [ 0, 14, 16 ] },
+				{ "id" : 13, "upgrades" : 12, "requires" : [ 9 ] },
+				{ "id" : 14 },
+				{ "id" : 15, "requires" : [ 14 ] },
+				{ "id" : 16 },
+				{ "id" : 17, "requires" : [ 14 ] },
+				{ "id" : 18, "upgrades" : 31 },
+				{ "id" : 19, "upgrades" : 38, "requires" : [ 18 ], "mode" : "auto" },
+				{ "id" : 21, "requires" : [ 7 ] },
+				{ "id" : 22, "requires" : [ 0 ] },
+				{ "id" : 23, "requires" : [ 0 ] },
+				{ "id" : 26, "mode" : "grail"},
+				{ "id" : 27, "requires" : [ 11 ], "mode" : "auto" },
+				{ "id" : 28, "requires" : [ 12 ], "mode" : "auto" },
+				{ "id" : 29, "requires" : [ 13 ], "mode" : "auto" },
+				{ "id" : 30, "requires" : [ 7 ] },
+				{ "id" : 31, "requires" : [ 30 ] },
+				{ "id" : 32, "requires" : [ 30 ] },
+				{ "id" : 33, "requires" : [ 0, 31, 32 ] },
+				{ "id" : 34, "requires" : [ 33 ] },
+				{ "id" : 35, "requires" : [ 33 ] },
+				{ "id" : 36, "requires" : [ 34, 35 ] },
+				{ "id" : 37, "upgrades" : 30 },
+				{ "id" : 38, "upgrades" : 31 },
+				{ "id" : 39, "upgrades" : 32 },
+				{ "id" : 40, "upgrades" : 33, "requires" : [ 22 ] },
+				{ "id" : 41, "upgrades" : 34 },
+				{ "id" : 42, "upgrades" : 35 },
+				{ "id" : 43, "upgrades" : 36 }
+			],
+
+			"siege" :
+			{
+				"shooter" : "Mage",
+				"imagePrefix" : "SGTW",
+				"gate" :
+				{
+					"arch" : { "x" : 471, "y" : 187 },
+					"gate" : { "x" : 400, "y" : 253 }
+				},
+				"moat" :
+				{
+					"bank" : { "x" : 410, "y" : 80 },
+					"moat" : { "x" : 410, "y" : 90 }
+				},
+				"shooterHeight" : 231,
+				"static" :
+				{
+					"background" : { "x" : 615, "y" : 57 },
+					"bottom" : { "x" : 517, "y" : 365 },
+					"top" : { "x" : 514, "y" : 79 }
+				},
+				"towers" :
+				{
+					"bottom" :
+					{
+						"battlement" : { "x" : 592, "y" : 516 },
+						"creature" : { "x" : 355, "y" : 311 },
+						"tower" : { "x" : 592, "y" : 516 }
+					},
+					"keep" :
+					{
+						"battlement" : { "x" : 726, "y" : 148 },
+						"creature" : { "x" : 499, "y" : -16 },
+						"tower" : { "x" : 726, "y" : 148 }
+					},
+					"top" :
+					{
+						"battlement" : { "x" : 580, "y" : 36 },
+						"creature" : { "x" : 346, "y" : -175 },
+						"tower" : { "x" : 580, "y" : 36 }
+					}
+				},
+				"walls" :
+				{
+					"bottom" : { "x" : 547, "y" : 452 },
+					"bottomMid" : { "x" : 475, "y" : 298 },
+					"upper" : { "x" : 547, "y" : 66 },
+					"upperMid" : { "x" : 488, "y" : 190 }
+				}
+			}
+		}
+	}
+}

+ 4 - 0
config/filesystem.json

@@ -49,6 +49,10 @@
 		[
 		[
 			{"type" : "dir",  "path" : "ALL/Maps"}
 			{"type" : "dir",  "path" : "ALL/Maps"}
 		],
 		],
+		"MODS/":
+		[
+			{"type" : "dir",  "path" : "ALL/Mods", "depth": 1}
+		],
 		"SAVES/":
 		"SAVES/":
 		[
 		[
 			{"type" : "dir",  "path" : "LOCAL/Games", "writeable": true},
 			{"type" : "dir",  "path" : "LOCAL/Games", "writeable": true},

+ 15 - 0
config/gameConfig.json

@@ -0,0 +1,15 @@
+{
+	"factions" :
+	[
+		"config/factions/castle.json",
+		"config/factions/rampart.json",
+		"config/factions/tower.json",
+		"config/factions/necropolis.json",
+		"config/factions/inferno.json",
+		"config/factions/dungeon.json",
+		"config/factions/stronghold.json",
+		"config/factions/fortress.json",
+		"config/factions/conflux.json",
+		"config/factions/neutral.json"
+	]
+}

+ 36 - 32
lib/CModHandler.cpp

@@ -71,10 +71,6 @@ CModHandler::CModHandler()
 	VLC->modh = this;
 	VLC->modh = this;
 
 
 	loadConfigFromFile ("defaultMods");
 	loadConfigFromFile ("defaultMods");
-	findAvailableMods();
-	//CResourceHandler::loadModsFilesystems(); //scan for all mods
-	//TODO: mod filesystem is already initialized at LibClasses launch
-	//TODO: load default (last?) config
 }
 }
 
 
 void CModHandler::loadConfigFromFile (std::string name)
 void CModHandler::loadConfigFromFile (std::string name)
@@ -94,51 +90,59 @@ void CModHandler::loadConfigFromFile (std::string name)
 	modules.STACK_ARTIFACT = gameModules["STACK_ARTIFACTS"].Bool();
 	modules.STACK_ARTIFACT = gameModules["STACK_ARTIFACTS"].Bool();
 	modules.COMMANDERS = gameModules["COMMANDERS"].Bool();
 	modules.COMMANDERS = gameModules["COMMANDERS"].Bool();
 	modules.MITHRIL = gameModules["MITHRIL"].Bool();
 	modules.MITHRIL = gameModules["MITHRIL"].Bool();
-
-	//TODO: load only mods from the list
 }
 }
 
 
-void CModHandler::saveConfigToFile (std::string name)
+void CModHandler::initialize(std::vector<std::string> availableMods)
 {
 {
-	//JsonNode savedConf = config;
-	//JsonNode schema(ResourceID("config/defaultSettings.json"));
+	BOOST_FOREACH(std::string &name, availableMods)
+	{
+		std::string modFileName = "mods/" + name + "/mod.json";
 
 
-	//savedConf.Struct().erase("session");
-	//savedConf.minimize(schema);
+		if (CResourceHandler::get()->existsResource(ResourceID(modFileName)))
+		{
+			const JsonNode config = JsonNode(ResourceID(modFileName));
 
 
-	CResourceHandler::get()->createResource("config/" + name +".json");
+			if (!config.isNull())
+			{
+				allMods[name].identifier = name;
+				allMods[name].name = config["name"].String();
+				allMods[name].description = config["description"].String();
+				allMods[name].loadPriority = config["priority"].Float();
+				activeMods.push_back(name);
+
+				tlog1 << "\t\tMod ";
+				tlog2 << allMods[name].name;
+				tlog1 << " enabled\n";
+			}
+		}
+		else
+			tlog1 << "\t\t Directory " << name << " does not contains VCMI mod\n";
+	}
 
 
-	std::ofstream file(CResourceHandler::get()->getResourceName(ResourceID("config/" + name +".json")), std::ofstream::trunc);
-	//file << savedConf;
+	std::sort(activeMods.begin(), activeMods.end(), [&](std::string a, std::string b)
+	{
+		return allMods[a].loadPriority < allMods[b].loadPriority;
+	});
 }
 }
 
 
 
 
-void CModHandler::findAvailableMods()
+std::vector<std::string> CModHandler::getActiveMods()
 {
 {
-	//TODO: read mods from Mods/ folder
-
-	auto & configList = CResourceHandler::get()->getResourcesWithName (ResourceID("CONFIG/mod.json"));
-
-	BOOST_FOREACH(auto & entry, configList)
-	{
-		auto stream = entry.getLoader()->load (entry.getResourceName());
-		std::unique_ptr<ui8[]> textData (new ui8[stream->getSize()]);
-		stream->read (textData.get(), stream->getSize());
-
-		tlog3 << "\t\tFound mod file: " << entry.getResourceName() << "\n";
-		allMods[allMods.size()].config.reset(new JsonNode((char*)textData.get(), stream->getSize()));
-	}
+	return activeMods;
 }
 }
 
 
 void CModHandler::loadActiveMods()
 void CModHandler::loadActiveMods()
 {
 {
-	BOOST_FOREACH(auto & mod, allMods)
+	BOOST_FOREACH(std::string & modName, activeMods)
 	{
 	{
-		const JsonNode & config = *mod.second.config;
+		std::string modFileName = "mods/" + modName + "/mod.json";
+
+		const JsonNode config = JsonNode(ResourceID(modFileName));
 
 
-		VLC->townh->load(config["factions"]);
-		VLC->creh->load(config["creatures"]);
+		VLC->townh->load(JsonUtils::assembleFromFiles(config ["factions"].convertTo<std::vector<std::string> >()));
+		VLC->creh->load( JsonUtils::assembleFromFiles(config["creatures"].convertTo<std::vector<std::string> >()));
 	}
 	}
+
 	VLC->creh->buildBonusTreeForTiers(); //do that after all new creatures are loaded
 	VLC->creh->buildBonusTreeForTiers(); //do that after all new creatures are loaded
 	identifiers.finalize();
 	identifiers.finalize();
 }
 }

+ 22 - 13
lib/CModHandler.h

@@ -40,39 +40,48 @@ public:
 	void finalize() const;
 	void finalize() const;
 };
 };
 
 
-typedef si32 TModID;
+typedef std::string TModID;
 
 
 class DLL_LINKAGE CModInfo
 class DLL_LINKAGE CModInfo
 {
 {
 public:
 public:
+	/// identifier, identical to name of folder with mod
+	std::string identifier;
+
+	/// human-readable strings
+	std::string name;
+	std::string description;
+
+	/// priority in which this mod should be loaded
+	/// may be somewhat ignored to load required mods first or overriden by user
+	double loadPriority;
+
 	/// TODO: list of mods that should be loaded before this one
 	/// TODO: list of mods that should be loaded before this one
-	std::vector <TModID> requirements;
+	std::set <TModID> requirements;
 
 
-	/// mod configuration (mod.json).
-	std::shared_ptr<JsonNode> config; //TODO: unique_ptr can't be serialized
+	// mod configuration (mod.json). (no need to store it right now)
+	// std::shared_ptr<JsonNode> config; //TODO: unique_ptr can't be serialized
 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 	{
-		h & requirements & config;
+		h & name & requirements;
 	}
 	}
 };
 };
 
 
 class DLL_LINKAGE CModHandler
 class DLL_LINKAGE CModHandler
 {
 {
-	//std::string currentConfig; //save settings in this file
-
 	std::map <TModID, CModInfo> allMods;
 	std::map <TModID, CModInfo> allMods;
-	std::set <TModID> activeMods;//TODO: use me
+	std::vector <TModID> activeMods;//active mods, in order in which they were loaded
 
 
+	void loadConfigFromFile (std::string name);
 public:
 public:
 	CIdentifierStorage identifiers;
 	CIdentifierStorage identifiers;
 
 
-	/// management of game settings config
-	void loadConfigFromFile (std::string name);	
-	void saveConfigToFile (std::string name);
+	/// receives list of available mods and trying to load mod.json from all of them
+	void initialize(std::vector<std::string> availableMods);
 
 
-	/// find all available mods and load them into FS
-	void findAvailableMods();
+	/// returns list of mods that should be active with order in which they shoud be loaded
+	std::vector<std::string> getActiveMods();
 
 
 	/// load content from all available mods
 	/// load content from all available mods
 	void loadActiveMods();
 	void loadActiveMods();

+ 2 - 1
lib/CTownHandler.cpp

@@ -502,7 +502,8 @@ void CTownHandler::load(const JsonNode &source)
 
 
 void CTownHandler::load()
 void CTownHandler::load()
 {
 {
-	JsonNode buildingsConf(ResourceID("config/buildings.json"));
+	JsonNode gameConf(ResourceID("config/gameConfig.json"));
+	JsonNode buildingsConf = JsonUtils::assembleFromFiles(gameConf["factions"].convertTo<std::vector<std::string> >());
 
 
 	JsonNode legacyConfig;
 	JsonNode legacyConfig;
 	loadLegacyData(legacyConfig);
 	loadLegacyData(legacyConfig);

+ 20 - 16
lib/Filesystem/CResourceLoader.cpp

@@ -330,8 +330,7 @@ void CResourceHandler::initialize()
 	//create "LOCAL" dir with current userDir (may be same as rootDir)
 	//create "LOCAL" dir with current userDir (may be same as rootDir)
 	initialLoader->addLoader("LOCAL/", userDir, false);
 	initialLoader->addLoader("LOCAL/", userDir, false);
 
 
-	//recurseInDir("ALL/CONFIG", 0);// look for configs
-	recurseInDir("ALL/CONFIG", 4);// look for mods (2) and mod files (3) in config folder
+	recurseInDir("ALL/CONFIG", 0);// look for configs
 	recurseInDir("ALL/DATA", 0); // look for archives
 	recurseInDir("ALL/DATA", 0); // look for archives
 	recurseInDir("ALL/MODS", 2); // look for mods. Depth 2 is required for now but won't cause issues if no mods present
 	recurseInDir("ALL/MODS", 2); // look for mods. Depth 2 is required for now but won't cause issues if no mods present
 }
 }
@@ -374,7 +373,7 @@ void CResourceHandler::loadFileSystem(const std::string &fsConfigURI)
 		BOOST_FOREACH(auto & entry, mountPoint.second.Vector())
 		BOOST_FOREACH(auto & entry, mountPoint.second.Vector())
 		{
 		{
 			CStopWatch timer;
 			CStopWatch timer;
-			tlog5 << "\t\tLoading resource at " << entry["path"].String();
+			tlog5 << "\t\tLoading resource at " << entry["path"].String() << "\n";
 
 
 			if (entry["type"].String() == "dir")
 			if (entry["type"].String() == "dir")
 				loadDirectory(mountPoint.first, entry);
 				loadDirectory(mountPoint.first, entry);
@@ -385,35 +384,40 @@ void CResourceHandler::loadFileSystem(const std::string &fsConfigURI)
 			if (entry["type"].String() == "vid")
 			if (entry["type"].String() == "vid")
 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_VID);
 				loadArchive(mountPoint.first, entry, EResType::ARCHIVE_VID);
 
 
-			tlog5 << " took " << timer.getDiff() << " ms.\n";
+			tlog5 << "Resource loaded in " << timer.getDiff() << " ms.\n";
 		}
 		}
 	}
 	}
 }
 }
 
 
-void CResourceHandler::loadModsFilesystems()
+std::vector<std::string> CResourceHandler::getAvailableMods()
 {
 {
 	auto iterator = initialLoader->getIterator([](const ResourceID & ident) ->  bool
 	auto iterator = initialLoader->getIterator([](const ResourceID & ident) ->  bool
 	{
 	{
 		std::string name = ident.getName();
 		std::string name = ident.getName();
 
 
-		return ident.getType() == EResType::TEXT
-		    && std::count(name.begin(), name.end(), '/') == 3
-		    && boost::algorithm::starts_with(name, "ALL/MODS/")
-		    && boost::algorithm::ends_with(name, "FILESYSTEM");
+		return ident.getType() == EResType::DIRECTORY
+		    && std::count(name.begin(), name.end(), '/') == 2
+		    && boost::algorithm::starts_with(name, "ALL/MODS/");
 	});
 	});
 
 
-	//sorted storage for found mods
-	//implements basic load order (entries in hashtable are basically random)
-	std::set<std::string> foundMods;
+	//storage for found mods
+	std::vector<std::string> foundMods;
 	while (iterator.hasNext())
 	while (iterator.hasNext())
 	{
 	{
-		foundMods.insert(iterator->getName());
+		std::string name = iterator->getName();
+
+		name.erase(0, name.find_last_of('/') + 1);        //Remove path prefix
+
+		foundMods.push_back(name);
 		++iterator;
 		++iterator;
 	}
 	}
+	return foundMods;
+}
 
 
-	BOOST_FOREACH(const std::string & entry, foundMods)
+void CResourceHandler::setActiveMods(std::vector<std::string> enabledMods)
+{
+	BOOST_FOREACH(std::string & modName, enabledMods)
 	{
 	{
-		tlog3 << "\t\tFound mod filesystem: " << entry << "\n";
-		loadFileSystem(entry);
+		loadFileSystem("all/mods/" + modName + "/mod.json");
 	}
 	}
 }
 }

+ 4 - 3
lib/Filesystem/CResourceLoader.h

@@ -380,10 +380,11 @@ public:
 	static void loadArchive(const std::string & mountPoint, const JsonNode & config, EResType::Type archiveType);
 	static void loadArchive(const std::string & mountPoint, const JsonNode & config, EResType::Type archiveType);
 
 
 	/**
 	/**
-	 * Experimental. Checks all subfolders of MODS directory for presence of ERA-style mods
-	 * If this directory has filesystem.json file it will be added to resources
+	 * Checks all subfolders of MODS directory for presence of mods
+	 * If this directory has mod.json file it will be added to resources
 	 */
 	 */
-	static void loadModsFilesystems();
+	static std::vector<std::string> getAvailableMods();
+	static void setActiveMods(std::vector<std::string> enabledMods); //WARNING: not reentrable. Do not call it twice!!!
 
 
 private:
 private:
 	/** Instance of resource loader */
 	/** Instance of resource loader */

+ 31 - 5
lib/JsonNode.cpp

@@ -1023,6 +1023,12 @@ void JsonUtils::validate(JsonNode & node, const JsonNode& schema)
 
 
 void JsonUtils::merge(JsonNode & dest, JsonNode & source)
 void JsonUtils::merge(JsonNode & dest, JsonNode & source)
 {
 {
+	if (dest.getType() == JsonNode::DATA_NULL)
+	{
+		std::swap(dest, source);
+		return;
+	}
+
 	switch (source.getType())
 	switch (source.getType())
 	{
 	{
 		break; case JsonNode::DATA_NULL:   dest.setType(JsonNode::DATA_NULL);
 		break; case JsonNode::DATA_NULL:   dest.setType(JsonNode::DATA_NULL);
@@ -1031,11 +1037,19 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source)
 		break; case JsonNode::DATA_STRING: std::swap(dest.String(), source.String());
 		break; case JsonNode::DATA_STRING: std::swap(dest.String(), source.String());
 		break; case JsonNode::DATA_VECTOR:
 		break; case JsonNode::DATA_VECTOR:
 		{
 		{
-			//reserve place and *move* data from source to dest
-			source.Vector().reserve(source.Vector().size() + dest.Vector().size());
+			size_t total = std::min(source.Vector().size(), dest.Vector().size());
 
 
-			std::move(source.Vector().begin(), source.Vector().end(),
-			          std::back_inserter(dest.Vector()));
+			for (size_t i=0; i< total; i++)
+				merge(dest.Vector()[i], source.Vector()[i]);
+
+			if (source.Vector().size() < dest.Vector().size())
+			{
+				//reserve place and *move* data from source to dest
+				source.Vector().reserve(source.Vector().size() + dest.Vector().size());
+
+				std::move(source.Vector().begin(), source.Vector().end(),
+				          std::back_inserter(dest.Vector()));
+			}
 		}
 		}
 		break; case JsonNode::DATA_STRUCT:
 		break; case JsonNode::DATA_STRUCT:
 		{
 		{
@@ -1050,4 +1064,16 @@ void JsonUtils::mergeCopy(JsonNode & dest, JsonNode source)
 {
 {
 	// uses copy created in stack to safely merge two nodes
 	// uses copy created in stack to safely merge two nodes
 	merge(dest, source);
 	merge(dest, source);
-}
+}
+
+JsonNode JsonUtils::assembleFromFiles(std::vector<std::string> files)
+{
+	JsonNode result;
+
+	BOOST_FOREACH(std::string file, files)
+	{
+		JsonNode section(ResourceID(file, EResType::TEXT));
+		merge(result, section);
+	}
+	return result;
+}

+ 7 - 2
lib/JsonNode.h

@@ -110,7 +110,7 @@ namespace JsonUtils
 
 
 	/// recursivly merges source into dest, replacing identical fields
 	/// recursivly merges source into dest, replacing identical fields
 	/// struct : recursively calls this function
 	/// struct : recursively calls this function
-	/// arrays : append array in dest with data from source
+	/// arrays : each entry will be merged recursively
 	/// values : value in source will replace value in dest
 	/// values : value in source will replace value in dest
 	/// null   : if value in source is present but set to null it will delete entry in dest
 	/// null   : if value in source is present but set to null it will delete entry in dest
 
 
@@ -119,6 +119,12 @@ namespace JsonUtils
 	/// this function will preserve data stored in source by creating copy
 	/// this function will preserve data stored in source by creating copy
 	DLL_LINKAGE void mergeCopy(JsonNode & dest, JsonNode source);
 	DLL_LINKAGE void mergeCopy(JsonNode & dest, JsonNode source);
 
 
+	/**
+	 * @brief generate one Json structure from multiple files
+	 * @param files - list of filenames with parts of json structure
+	 */
+	DLL_LINKAGE JsonNode assembleFromFiles(std::vector<std::string> files);
+
 	/// removes all nodes that are identical to default entry in schema
 	/// removes all nodes that are identical to default entry in schema
 	DLL_LINKAGE void minimize(JsonNode & node, const JsonNode& schema);
 	DLL_LINKAGE void minimize(JsonNode & node, const JsonNode& schema);
 
 
@@ -155,7 +161,6 @@ namespace JsonDetail
 				ret.insert(entry.first, entry.second.convertTo<Type>());
 				ret.insert(entry.first, entry.second.convertTo<Type>());
 			}
 			}
 			return ret;
 			return ret;
-
 		}
 		}
 	};
 	};
 
 

+ 16 - 7
lib/VCMI_Lib.cpp

@@ -31,12 +31,20 @@ LibClasses * VLC = NULL;
 
 
 DLL_LINKAGE VCMIDirs GVCMIDirs;
 DLL_LINKAGE VCMIDirs GVCMIDirs;
 
 
-
-DLL_LINKAGE void initDLL(CConsoleHandler *Console, std::ostream *Logfile)
+DLL_LINKAGE void preinitDLL(CConsoleHandler *Console, std::ostream *Logfile)
 {
 {
 	console = Console;
 	console = Console;
 	logfile = Logfile;
 	logfile = Logfile;
 	VLC = new LibClasses;
 	VLC = new LibClasses;
+	try
+	{
+		VLC->loadFilesystem();
+	}
+	HANDLE_EXCEPTION;
+}
+
+DLL_LINKAGE void loadDLLClasses()
+{
 	try
 	try
 	{
 	{
 		VLC->init();
 		VLC->init();
@@ -55,19 +63,20 @@ void LibClasses::loadFilesystem()
 	CResourceHandler::loadFileSystem("ALL/config/filesystem.json");
 	CResourceHandler::loadFileSystem("ALL/config/filesystem.json");
 	tlog0<<"\t Data loading: "<<loadTime.getDiff()<<std::endl;
 	tlog0<<"\t Data loading: "<<loadTime.getDiff()<<std::endl;
 
 
-	CResourceHandler::loadModsFilesystems();
+	modh = new CModHandler;
+	tlog0<<"\tMod handler: "<<loadTime.getDiff()<<std::endl;
+
+	modh->initialize(CResourceHandler::getAvailableMods());
+	CResourceHandler::setActiveMods(modh->getActiveMods());
 	tlog0<<"\t Mod filesystems: "<<loadTime.getDiff()<<std::endl;
 	tlog0<<"\t Mod filesystems: "<<loadTime.getDiff()<<std::endl;
 
 
-	tlog0<<"File system handler: "<<totalTime.getDiff()<<std::endl;
+	tlog0<<"Basic initialization: "<<totalTime.getDiff()<<std::endl;
 }
 }
 
 
 void LibClasses::init()
 void LibClasses::init()
 {
 {
 	CStopWatch pomtime;
 	CStopWatch pomtime;
 
 
-	modh = new CModHandler; //TODO: all handlers should use mod handler to manage objects
-	tlog0<<"\tMod handler: "<<pomtime.getDiff()<<std::endl;
-
 	generaltexth = new CGeneralTextHandler;
 	generaltexth = new CGeneralTextHandler;
 	generaltexth->load();
 	generaltexth->load();
 	tlog0<<"\tGeneral text handler: "<<pomtime.getDiff()<<std::endl;
 	tlog0<<"\tGeneral text handler: "<<pomtime.getDiff()<<std::endl;

+ 5 - 3
lib/VCMI_Lib.h

@@ -40,9 +40,9 @@ public:
 	~LibClasses();
 	~LibClasses();
 	void init(); //uses standard config file
 	void init(); //uses standard config file
 	void clear(); //deletes all handlers and its data
 	void clear(); //deletes all handlers and its data
-	void makeNull(); //sets all handler (except of lodhs) pointers to null
+	void makeNull(); //sets all handler pointers to null
 
 
-	static void loadFilesystem();
+	void loadFilesystem();// basic initialization. should be called before init()
 
 
 	void callWhenDeserializing(); //should be called only by serialize !!!
 	void callWhenDeserializing(); //should be called only by serialize !!!
 	template <typename Handler> void serialize(Handler &h, const int version)
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -57,4 +57,6 @@ public:
 
 
 extern DLL_LINKAGE LibClasses * VLC;
 extern DLL_LINKAGE LibClasses * VLC;
 
 
-DLL_LINKAGE void initDLL(CConsoleHandler *Console, std::ostream *Logfile);
+DLL_LINKAGE void preinitDLL(CConsoleHandler *Console, std::ostream *Logfile);
+DLL_LINKAGE void loadDLLClasses();
+

+ 2 - 2
server/CVCMIServer.cpp

@@ -509,9 +509,9 @@ int main(int argc, char** argv)
 		port = _ttoi(argv[1]);
 		port = _ttoi(argv[1]);
 #endif
 #endif
 	}
 	}
-	LibClasses::loadFilesystem();
+	preinitDLL(console,logfile);
 	tlog0 << "Port " << port << " will be used." << std::endl;
 	tlog0 << "Port " << port << " will be used." << std::endl;
-	initDLL(console,logfile);
+	loadDLLClasses();
 	srand ( (ui32)time(NULL) );
 	srand ( (ui32)time(NULL) );
 	try
 	try
 	{
 	{