diff --git a/config/gameConfig.json b/config/gameConfig.json index 186029a94..a8e5bc71b 100644 --- a/config/gameConfig.json +++ b/config/gameConfig.json @@ -88,5 +88,9 @@ "battlefields": [ "config/battlefields.json" + ], + "obstacles": + [ + "config/obstacles.json" ] } diff --git a/config/schemas/battlefield.json b/config/schemas/battlefield.json index 02aa0dcfd..4abd729d2 100644 --- a/config/schemas/battlefield.json +++ b/config/schemas/battlefield.json @@ -2,7 +2,7 @@ "type":"object", "$schema": "http://json-schema.org/draft-04/schema", "title" : "VCMI battlefield format", - "description" : "Format used to define new artifacts in VCMI", + "description" : "Format used to define new battlefields in VCMI", "required" : [ "graphics" ], "additionalProperties" : false, diff --git a/config/schemas/obstacle.json b/config/schemas/obstacle.json new file mode 100644 index 000000000..f6a76f40b --- /dev/null +++ b/config/schemas/obstacle.json @@ -0,0 +1,46 @@ +{ + "type":"object", + "$schema": "http://json-schema.org/draft-04/schema", + "title" : "VCMI obstacle format", + "description" : "Format used to define new obstacles in VCMI", + "required" : [ "defname" ], + + "additionalProperties" : false, + "properties":{ + "allowedTerrains": { + "type": "array", + "description": "Obstacles can be place on specified terrains only", + "items": { "type" : "string" } + }, + "specialBattlefields": { + "type": "array", + "description": "Obstacles can be placed on specified specified battlefields", + "items": { "$ref" : "battlefield.json" } + }, + "width": { + "type": "number", + "description": "Width ob obstacle" + }, + "height": { + "type": "number", + "description": "height if obstacle" + }, + "blockedTiles": { + "type": "array", + "description": "Blocked hexes - absolute or relative hex id", + "items": { "type" : "number" } + }, + "defname": { + "type": "string", + "description": "Image resource" + }, + "unknown": { + "type": "number", + "description": "Unknown field" + }, + "absolute": { + "type": "boolean", + "description": "Should be used absulute or relative coordinates for obstacle. There is possible only one absolute obstacle" + } + } +} diff --git a/lib/BattleFieldHandler.h b/lib/BattleFieldHandler.h index ab5ab2742..b9023f3d0 100644 --- a/lib/BattleFieldHandler.h +++ b/lib/BattleFieldHandler.h @@ -10,6 +10,7 @@ #pragma once #include +#include #include "HeroBonus.h" #include "GameConstants.h" #include "IHandlerBase.h" diff --git a/lib/ObstacleHandler.cpp b/lib/ObstacleHandler.cpp index 38b2b283b..58052d730 100644 --- a/lib/ObstacleHandler.cpp +++ b/lib/ObstacleHandler.cpp @@ -23,7 +23,7 @@ int32_t ObstacleInfo::getIconIndex() const const std::string & ObstacleInfo::getName() const { - return name; + return identifier; } const std::string & ObstacleInfo::getJsonKey() const diff --git a/lib/ObstacleHandler.h b/lib/ObstacleHandler.h index e4b6fc5f4..8752c8bd0 100644 --- a/lib/ObstacleHandler.h +++ b/lib/ObstacleHandler.h @@ -22,13 +22,12 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT {} ObstacleInfo(Obstacle obstacle, std::string identifier) - : obstacle(obstacle), identifier(identifier), iconIndex(obstacle.getNum()), name(identifier), width(0), height(0), isAbsoluteObstacle(false) + : obstacle(obstacle), identifier(identifier), iconIndex(obstacle.getNum()), width(0), height(0), isAbsoluteObstacle(false) { } Obstacle obstacle; si32 iconIndex; - std::string name; std::string identifier; std::string defName; std::vector allowedTerrains; @@ -53,7 +52,6 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT { h & obstacle; h & iconIndex; - h & name; h & identifier; h & defName; h & allowedTerrains;