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