Ivan Savenko 2 éve
szülő
commit
6f324216db

+ 6 - 14
config/objects/generic.json

@@ -230,7 +230,6 @@
 	"subterraneanGate" : {
 		"index" :103,
 		"handler" : "subterraneanGate",
-		"lastReservedIndex" : 1,
 		"base" : {
 			"sounds" : {
 				"ambient" : ["LOOPGATE"],
@@ -239,8 +238,8 @@
 		},
 		"types" : {
 			"object" : {
-				"index" : 0 },
-			"objectWoG" : { "index" : 1 } // WoG object? Present on VCMI Test 2011b
+				"index" : 0 
+			}
 		}
 	},
 
@@ -342,9 +341,6 @@
 					"value"		: 3000,
 					"rarity"	: 100
 				}
-			},
-			"object1":{ //WoG?
-				"index" :1
 			}
 		}
 	},
@@ -560,7 +556,6 @@
 	"witchHut" : {
 		"index" :113,
 		"handler" : "witch",
-		"lastReservedIndex" : 1,
 		"base" : {
 			"sounds" : {
 				"visit" : ["GAZEBO"]
@@ -575,9 +570,6 @@
 					"value"		: 1500,
 					"rarity"	: 80
 				}
-			},
-			"object1" : { //WoG?
-				"index" : 1
 			}
 		}
 	},
@@ -1044,10 +1036,10 @@
 	"grassHills"					: { "index" :208, "handler": "static", "types" : { "object" : { "index" : 0} } },
 	"roughHills"					: { "index" :209, "handler": "static", "types" : { "object" : { "index" : 0} } },
 	"subterraneanRocks"				: { "index" :210, "handler": "static", "types" : { "object" : { "index" : 0} } },
-	"swampFoliage" 					: { "index" :211, "handler": "static", "types" : { "object" : { "index" : 0} } },
+	"swampFoliage" 					: { "index" :211, "handler": "static", "types" : { "object" : { "index" : 0} } }
 
 	//These are WoG objects? They are not available in H3
-	"frozenLakeDUPLICATE"			: { "index" :172, "handler": "static", "types" : { "object" : { "index" : 0} } },
-	"oakTreesDUPLICATE"				: { "index" :186, "handler": "static", "types" : { "object" : { "index" : 0} } },
-	"plant"							: { "index" :189, "handler": "static", "types" : { "object" : { "index" : 0} } }
+	//"frozenLakeDUPLICATE"			: { "index" :172, "handler": "static", "types" : { "object" : { "index" : 0} } },
+	//"oakTreesDUPLICATE"				: { "index" :186, "handler": "static", "types" : { "object" : { "index" : 0} } },
+	//"plant"							: { "index" :189, "handler": "static", "types" : { "object" : { "index" : 0} } }
 }

+ 8 - 1
config/schemas/object.json

@@ -3,13 +3,20 @@
 	"$schema": "http://json-schema.org/draft-04/schema",
 	"title" : "VCMI map object format",
 	"description" : "Description of map object class",
-	"required": [ "handler", "name" ],
+	"required": [ "handler" ],
 	"additionalProperties" : false,
 
 	"properties":{
 		"index": {
 			"type":"number"
 		},
+		"lastReservedIndex" : {
+			"type":"number"
+		},
+		"subObjects" : {
+			"type" : "array",
+			"additionalItems" : true
+		},
 		"handler": {
 			"type":"string"
 		},

+ 1 - 2
config/schemas/objectType.json

@@ -3,7 +3,7 @@
 	"$schema": "http://json-schema.org/draft-04/schema",
 	"title" : "VCMI map object type format",
 	"description" : "Description of map object type, used only as sub-schema of object",
-	"required": [ ],
+	"required": [ "name" ],
 	"additionalProperties" : true, // may have type-dependant properties
 
 	"properties":{
@@ -16,7 +16,6 @@
 		"aiValue": {
 			"type":"number"
 		},
-
 		"sounds": {
 			"type":"object",
 			"additionalProperties" : false,

+ 14 - 6
lib/mapObjects/CObjectClassesHandler.cpp

@@ -112,6 +112,8 @@ std::vector<JsonNode> CObjectClassesHandler::loadLegacyData(size_t dataSize)
 		legacyTemplates.insert(std::make_pair(key, std::shared_ptr<const ObjectTemplate>(tmpl)));
 	}
 
+	objects.resize(256);
+
 	std::vector<JsonNode> ret(dataSize);// create storage for 256 objects
 	assert(dataSize == 256);
 
@@ -251,6 +253,9 @@ void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNo
 	assert(ID < objects.size());
 	assert(objects[ID]);
 
+	if ( subID >= objects[ID]->objects.size())
+		objects[ID]->objects.resize(subID+1);
+
 	JsonUtils::inherit(config, objects.at(ID)->base);
 	loadSubObject(config.meta, identifier, config, objects[ID], subID);
 }
@@ -343,6 +348,9 @@ void CObjectClassesHandler::afterLoadFinalization()
 
 		for(auto obj : entry->objects)
 		{
+			if (!obj)
+				continue;
+
 			obj->afterLoadFinalization();
 			if(obj->getTemplates().empty())
 				logGlobal->warn("No templates found for %s:%s", entry->getIdentifier(), obj->getIdentifier());
@@ -352,12 +360,9 @@ void CObjectClassesHandler::afterLoadFinalization()
 	//duplicate existing two-way portals to make reserve for RMG
 	auto& portalVec = objects[Obj::MONOLITH_TWO_WAY]->objects;
 	size_t portalCount = portalVec.size();
-	size_t currentIndex = portalCount;
-	while(portalVec.size() < 100)
-	{
-		portalVec[(si32)currentIndex] = portalVec[static_cast<si32>(currentIndex % portalCount)];
-		currentIndex++;
-	}
+
+	for (size_t i = portalCount; i < 100; ++i)
+		portalVec.push_back(portalVec[static_cast<si32>(i % portalCount)]);
 }
 
 std::string CObjectClassesHandler::getObjectName(si32 type, si32 subtype) const
@@ -367,6 +372,9 @@ std::string CObjectClassesHandler::getObjectName(si32 type, si32 subtype) const
 
 SObjectSounds CObjectClassesHandler::getObjectSounds(si32 type, si32 subtype) const
 {
+	if(type == Obj::PRISON || type == Obj::HERO)
+		subtype = 0;
+
 	assert(type < objects.size());
 	assert(objects[type]);
 	assert(subtype < objects[type]->objects.size());