mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
allow json schema references to use relative file path
This commit is contained in:
parent
e5397c1e23
commit
8650a8eea8
@ -15,7 +15,7 @@
|
||||
"level" : {
|
||||
"type" : "number"
|
||||
},
|
||||
"bonus" : { "$ref" : "vcmi:bonus" }
|
||||
"bonus" : { "$ref" : "bonus.json" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@
|
||||
"bonuses": {
|
||||
"type":"array",
|
||||
"description": "Bonuses provided by this artifact using bonus system",
|
||||
"items": { "$ref" : "vcmi:bonus" }
|
||||
"items": { "$ref" : "bonus.json" }
|
||||
},
|
||||
"class": {
|
||||
"type":"string",
|
||||
|
@ -25,7 +25,7 @@
|
||||
"type" : "array",
|
||||
"description" : "parameters",
|
||||
"additionalItems" : true
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -135,7 +135,7 @@
|
||||
"description": "Creature abilities described using Bonus system",
|
||||
"type":"object",
|
||||
"additionalProperties": {
|
||||
"$ref" : "vcmi:bonus"
|
||||
"$ref" : "bonus.json"
|
||||
}
|
||||
},
|
||||
"stackExperience": {
|
||||
@ -147,7 +147,7 @@
|
||||
"required" : [ "bonus", "values" ],
|
||||
"description": "0",
|
||||
"properties":{
|
||||
"bonus": {"$ref" : "vcmi:bonus" },
|
||||
"bonus": {"$ref" : "bonus.json" },
|
||||
"values": {
|
||||
"type":"array",
|
||||
"minItems" : 10,
|
||||
|
@ -156,7 +156,7 @@
|
||||
"buildings": {
|
||||
"type" : "object",
|
||||
"additionalProperties" : {
|
||||
"$ref" : "vcmi:townBuilding"
|
||||
"$ref" : "townBuilding.json"
|
||||
}
|
||||
},
|
||||
"creatures": {
|
||||
@ -241,12 +241,12 @@
|
||||
"format" : "musicFile"
|
||||
},
|
||||
"siege": {
|
||||
"$ref" : "vcmi:townSiege"
|
||||
"$ref" : "townSiege.json"
|
||||
},
|
||||
"structures": {
|
||||
"type" : "object",
|
||||
"additionalProperties" : {
|
||||
"$ref" : "vcmi:townStructure"
|
||||
"$ref" : "townStructure.json"
|
||||
}
|
||||
},
|
||||
"townBackground": {
|
||||
|
@ -136,7 +136,7 @@
|
||||
"bonuses" : {
|
||||
"type" : "array",
|
||||
"description" : "List of bonuses",
|
||||
"items" : { "$ref" : "vcmi:bonus" }
|
||||
"items" : { "$ref" : "bonus.json" }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@
|
||||
"bonuses" : {
|
||||
"type" : "object",
|
||||
"description" : "Set of bonuses",
|
||||
"additionalProperties" : { "$ref" : "vcmi:bonus" }
|
||||
"additionalProperties" : { "$ref" : "bonus.json" }
|
||||
},
|
||||
"creature" : {
|
||||
"type" : "string",
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
"properties" : {
|
||||
"type" : { "type" : "string" },
|
||||
"messageToSend" : { "type" : "string" },
|
||||
"messageToSend" : { "type" : "string" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,17 @@
|
||||
|
||||
"properties":{
|
||||
"index": {
|
||||
"type":"number",
|
||||
"type":"number"
|
||||
},
|
||||
"name": {
|
||||
"type":"string",
|
||||
"type":"string"
|
||||
},
|
||||
"defaultAiValue": {
|
||||
"type":"number",
|
||||
"type":"number"
|
||||
},
|
||||
|
||||
"handler": {
|
||||
"type":"string",
|
||||
"type":"string"
|
||||
},
|
||||
|
||||
"sounds": {
|
||||
@ -56,7 +56,7 @@
|
||||
"types": {
|
||||
"type":"object",
|
||||
"additionalProperties": {
|
||||
"$ref" : "vcmi:objectType"
|
||||
"$ref" : "objectType.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@
|
||||
|
||||
"properties":{
|
||||
"index": {
|
||||
"type":"number",
|
||||
"type":"number"
|
||||
},
|
||||
"name": {
|
||||
"type":"string",
|
||||
"type":"string"
|
||||
},
|
||||
"aiValue": {
|
||||
"type":"number",
|
||||
"type":"number"
|
||||
},
|
||||
|
||||
"sounds": {
|
||||
@ -52,7 +52,7 @@
|
||||
"templates": {
|
||||
"type":"object",
|
||||
"additionalProperties": {
|
||||
"$ref" : "vcmi:objectTemplate"
|
||||
"$ref" : "objectTemplate.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@
|
||||
"effects" : {
|
||||
"type" : "object",
|
||||
"additionalProperties" : {
|
||||
"$ref" : "vcmi:bonus"
|
||||
"$ref" : "bonus.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,10 +73,10 @@
|
||||
"description":"Cost in mana points"
|
||||
},
|
||||
"power":{
|
||||
"type": "number",
|
||||
"type": "number"
|
||||
},
|
||||
"aiValue":{
|
||||
"type": "number",
|
||||
"type": "number"
|
||||
},
|
||||
|
||||
"range":{
|
||||
@ -87,14 +87,14 @@
|
||||
"type": "object",
|
||||
"description": "Timed effects (updated by prolongation)",
|
||||
"additionalProperties" : {
|
||||
"$ref" : "vcmi:bonus"
|
||||
"$ref" : "bonus.json"
|
||||
}
|
||||
},
|
||||
"cumulativeEffects":{
|
||||
"type": "object",
|
||||
"description": "Timed effects (updated by unique bonus)",
|
||||
"additionalProperties" : {
|
||||
"$ref" : "vcmi:bonus"
|
||||
"$ref" : "bonus.json"
|
||||
}
|
||||
},
|
||||
"battleEffects":{
|
||||
@ -175,7 +175,7 @@
|
||||
|
||||
"power":{
|
||||
"type": "number",
|
||||
"description": "Base power",
|
||||
"description": "Base power"
|
||||
},
|
||||
|
||||
"defaultGainChance":{
|
||||
|
@ -904,7 +904,7 @@ const JsonNode & getSchemaByName(std::string name)
|
||||
if (vstd::contains(loadedSchemas, name))
|
||||
return loadedSchemas[name];
|
||||
|
||||
std::string filename = "config/schemas/" + name + ".json";
|
||||
std::string filename = "config/schemas/" + name;
|
||||
|
||||
if (CResourceHandler::get()->existsResource(ResourceID(filename)))
|
||||
{
|
||||
@ -921,19 +921,20 @@ const JsonNode & JsonUtils::getSchema(std::string URI)
|
||||
{
|
||||
size_t posColon = URI.find(':');
|
||||
size_t posHash = URI.find('#');
|
||||
std::string filename;
|
||||
if(posColon == std::string::npos)
|
||||
{
|
||||
logMod->error("Invalid schema URI:%s", URI);
|
||||
return nullNode;
|
||||
filename = URI.substr(0, posHash);
|
||||
}
|
||||
|
||||
std::string protocolName = URI.substr(0, posColon);
|
||||
std::string filename = URI.substr(posColon + 1, posHash - posColon - 1);
|
||||
|
||||
if(protocolName != "vcmi")
|
||||
else
|
||||
{
|
||||
logMod->error("Error: unsupported URI protocol for schema: %s", URI);
|
||||
return nullNode;
|
||||
std::string protocolName = URI.substr(0, posColon);
|
||||
filename = URI.substr(posColon + 1, posHash - posColon - 1) + ".json";
|
||||
if(protocolName != "vcmi")
|
||||
{
|
||||
logMod->error("Error: unsupported URI protocol for schema: %s", URI);
|
||||
return nullNode;
|
||||
}
|
||||
}
|
||||
|
||||
// check if json pointer if present (section after hash in string)
|
||||
|
Loading…
Reference in New Issue
Block a user