1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-18 17:40:48 +02:00

Minor fixes

This commit is contained in:
nordsoft 2022-08-28 06:16:42 +04:00
parent c3276f2276
commit 108470471e
6 changed files with 145 additions and 138 deletions

View File

@ -362,7 +362,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
{ {
if(elem->obstacleType == CObstacleInstance::USUAL) if(elem->obstacleType == CObstacleInstance::USUAL)
{ {
std::string animationName = elem->getInfo().defName; std::string animationName = elem->getInfo().animation;
auto cached = animationsCache.find(animationName); auto cached = animationsCache.find(animationName);
@ -380,7 +380,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
} }
else if (elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE) else if (elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
{ {
std::string animationName = elem->getInfo().defName; std::string animationName = elem->getInfo().animation;
auto cached = animationsCache.find(animationName); auto cached = animationsCache.find(animationName);

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
"$schema": "http://json-schema.org/draft-04/schema", "$schema": "http://json-schema.org/draft-04/schema",
"title" : "VCMI obstacle format", "title" : "VCMI obstacle format",
"description" : "Format used to define new obstacles in VCMI", "description" : "Format used to define new obstacles in VCMI",
"required" : [ "defname" ], "required" : [ "animation" ],
"additionalProperties" : false, "additionalProperties" : false,
"properties":{ "properties":{
@ -30,7 +30,7 @@
"description": "Blocked hexes - absolute or relative hex id", "description": "Blocked hexes - absolute or relative hex id",
"items": { "type" : "number" } "items": { "type" : "number" }
}, },
"defname": { "animation": {
"type": "string", "type": "string",
"description": "Image resource" "description": "Image resource"
}, },

View File

@ -80,9 +80,9 @@ ObstacleInfo * ObstacleHandler::loadFromJson(const std::string & scope, const Js
{ {
auto * info = new ObstacleInfo(Obstacle(index), identifier); auto * info = new ObstacleInfo(Obstacle(index), identifier);
info->defName = json["defname"].String(); info->animation = json["animation"].String();
info->width = static_cast<si32>(json["width"].Float()); info->width = json["width"].Integer();
info->height = static_cast<si32>(json["height"].Float()); info->height = json["height"].Integer();
for(auto & t : json["allowedTerrain"].Vector()) for(auto & t : json["allowedTerrain"].Vector())
info->allowedTerrains.emplace_back(t.String()); info->allowedTerrains.emplace_back(t.String());
for(auto & t : json["specialBattlefields"].Vector()) for(auto & t : json["specialBattlefields"].Vector())

View File

@ -16,8 +16,9 @@
#include "Terrain.h" #include "Terrain.h"
#include "battle/BattleHex.h" #include "battle/BattleHex.h"
struct DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle> class DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle>
{ {
public:
ObstacleInfo(): obstacle(-1), width(0), height(0), isAbsoluteObstacle(false), iconIndex(0) ObstacleInfo(): obstacle(-1), width(0), height(0), isAbsoluteObstacle(false), iconIndex(0)
{} {}
@ -29,10 +30,13 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle>
Obstacle obstacle; Obstacle obstacle;
si32 iconIndex; si32 iconIndex;
std::string identifier; std::string identifier;
std::string defName; std::string appearAnimation, animation, dissapearAnimation;
std::vector<Terrain> allowedTerrains; std::vector<Terrain> allowedTerrains;
std::vector<std::string> allowedSpecialBfields; std::vector<std::string> allowedSpecialBfields;
//TODO: here is extra field to implement it's logic in the future but save backward compatibility
int obstacleType = -1;
ui8 isAbsoluteObstacle; //there may only one such obstacle in battle and its position is always the same ui8 isAbsoluteObstacle; //there may only one such obstacle in battle and its position is always the same
si32 width, height; //how much space to the right and up is needed to place obstacle (affects only placement algorithm) si32 width, height; //how much space to the right and up is needed to place obstacle (affects only placement algorithm)
std::vector<si16> blockedTiles; //offsets relative to obstacle position (that is its left bottom corner) std::vector<si16> blockedTiles; //offsets relative to obstacle position (that is its left bottom corner)
@ -51,9 +55,12 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle>
template <typename Handler> void serialize(Handler &h, const int version) template <typename Handler> void serialize(Handler &h, const int version)
{ {
h & obstacle; h & obstacle;
h & obstacleType;
h & iconIndex; h & iconIndex;
h & identifier; h & identifier;
h & defName; h & animation;
h & appearAnimation;
h & dissapearAnimation;
h & allowedTerrains; h & allowedTerrains;
h & allowedSpecialBfields; h & allowedSpecialBfields;
h & isAbsoluteObstacle; h & isAbsoluteObstacle;

View File

@ -12,8 +12,8 @@
#include "../ConstTransitivePtr.h" #include "../ConstTransitivePtr.h"
#include "../GameConstants.h" #include "../GameConstants.h"
const ui32 SERIALIZATION_VERSION = 803; const ui32 SERIALIZATION_VERSION = 804;
const ui32 MINIMAL_SERIALIZATION_VERSION = 803; const ui32 MINIMAL_SERIALIZATION_VERSION = 804;
const std::string SAVEGAME_MAGIC = "VCMISVG"; const std::string SAVEGAME_MAGIC = "VCMISVG";
class CHero; class CHero;