1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-22 22:13:35 +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)
{
std::string animationName = elem->getInfo().defName;
std::string animationName = elem->getInfo().animation;
auto cached = animationsCache.find(animationName);
@ -380,7 +380,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet *army1, const CCreatureSet
}
else if (elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
{
std::string animationName = elem->getInfo().defName;
std::string animationName = elem->getInfo().animation;
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",
"title" : "VCMI obstacle format",
"description" : "Format used to define new obstacles in VCMI",
"required" : [ "defname" ],
"required" : [ "animation" ],
"additionalProperties" : false,
"properties":{
@ -30,7 +30,7 @@
"description": "Blocked hexes - absolute or relative hex id",
"items": { "type" : "number" }
},
"defname": {
"animation": {
"type": "string",
"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);
info->defName = json["defname"].String();
info->width = static_cast<si32>(json["width"].Float());
info->height = static_cast<si32>(json["height"].Float());
info->animation = json["animation"].String();
info->width = json["width"].Integer();
info->height = json["height"].Integer();
for(auto & t : json["allowedTerrain"].Vector())
info->allowedTerrains.emplace_back(t.String());
for(auto & t : json["specialBattlefields"].Vector())

View File

@ -16,8 +16,9 @@
#include "Terrain.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)
{}
@ -29,10 +30,13 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle>
Obstacle obstacle;
si32 iconIndex;
std::string identifier;
std::string defName;
std::string appearAnimation, animation, dissapearAnimation;
std::vector<Terrain> allowedTerrains;
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
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)
@ -51,9 +55,12 @@ struct DLL_LINKAGE ObstacleInfo : public EntityT<Obstacle>
template <typename Handler> void serialize(Handler &h, const int version)
{
h & obstacle;
h & obstacleType;
h & iconIndex;
h & identifier;
h & defName;
h & animation;
h & appearAnimation;
h & dissapearAnimation;
h & allowedTerrains;
h & allowedSpecialBfields;
h & isAbsoluteObstacle;

View File

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