mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-03 00:46:55 +02:00
vcmi:towns now can choose if moat render is needed
Using invalid points. Also removed unused variable.
This commit is contained in:
@ -118,7 +118,7 @@ void BattleSiegeController::showWallPiece(Canvas & canvas, EWallVisual::EWallVis
|
|||||||
auto & ci = town->town->clientInfo;
|
auto & ci = town->town->clientInfo;
|
||||||
auto const & pos = ci.siegePositions[what];
|
auto const & pos = ci.siegePositions[what];
|
||||||
|
|
||||||
if ( wallPieceImages[what])
|
if ( wallPieceImages[what] && pos.isValid())
|
||||||
canvas.draw(wallPieceImages[what], Point(pos.x, pos.y));
|
canvas.draw(wallPieceImages[what], Point(pos.x, pos.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ bool BattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what)
|
|||||||
|
|
||||||
switch (what)
|
switch (what)
|
||||||
{
|
{
|
||||||
case EWallVisual::MOAT: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->getIndex() != ETownType::TOWER;
|
case EWallVisual::MOAT: return town->hasBuilt(BuildingID::CITADEL) && town->town->clientInfo.siegePositions.at(EWallVisual::MOAT).isValid();
|
||||||
case EWallVisual::MOAT_BANK: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->getIndex() != ETownType::TOWER && town->town->faction->getIndex() != ETownType::NECROPOLIS;
|
case EWallVisual::MOAT_BANK: return town->hasBuilt(BuildingID::CITADEL) && town->town->clientInfo.siegePositions.at(EWallVisual::MOAT_BANK).isValid();
|
||||||
case EWallVisual::KEEP_BATTLEMENT: return town->hasBuilt(BuildingID::CITADEL) && owner.curInt->cb->battleGetWallState(EWallPart::KEEP) != EWallState::DESTROYED;
|
case EWallVisual::KEEP_BATTLEMENT: return town->hasBuilt(BuildingID::CITADEL) && owner.curInt->cb->battleGetWallState(EWallPart::KEEP) != EWallState::DESTROYED;
|
||||||
case EWallVisual::UPPER_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && owner.curInt->cb->battleGetWallState(EWallPart::UPPER_TOWER) != EWallState::DESTROYED;
|
case EWallVisual::UPPER_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && owner.curInt->cb->battleGetWallState(EWallPart::UPPER_TOWER) != EWallState::DESTROYED;
|
||||||
case EWallVisual::BOTTOM_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && owner.curInt->cb->battleGetWallState(EWallPart::BOTTOM_TOWER) != EWallState::DESTROYED;
|
case EWallVisual::BOTTOM_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE) && owner.curInt->cb->battleGetWallState(EWallPart::BOTTOM_TOWER) != EWallState::DESTROYED;
|
||||||
|
@ -53,8 +53,6 @@ void CursorSoftware::createTexture(const Point & dimensions)
|
|||||||
|
|
||||||
void CursorSoftware::updateTexture()
|
void CursorSoftware::updateTexture()
|
||||||
{
|
{
|
||||||
Point dimensions(-1, -1);
|
|
||||||
|
|
||||||
if (!cursorSurface || Point(cursorSurface->w, cursorSurface->h) != cursorImage->dimensions())
|
if (!cursorSurface || Point(cursorSurface->w, cursorSurface->h) != cursorImage->dimensions())
|
||||||
createTexture(cursorImage->dimensions());
|
createTexture(cursorImage->dimensions());
|
||||||
|
|
||||||
|
@ -221,7 +221,6 @@
|
|||||||
},
|
},
|
||||||
"moat" :
|
"moat" :
|
||||||
{
|
{
|
||||||
"bank" : { "x" : -1, "y" : -1 }, // Should not be present
|
|
||||||
"moat" : { "x" : 406, "y" : 77 }
|
"moat" : { "x" : 406, "y" : 77 }
|
||||||
},
|
},
|
||||||
"static" :
|
"static" :
|
||||||
|
@ -209,8 +209,6 @@
|
|||||||
},
|
},
|
||||||
"moat" :
|
"moat" :
|
||||||
{
|
{
|
||||||
"bank" : { "x" : 410, "y" : 80 },
|
|
||||||
"moat" : { "x" : 410, "y" : 90 }
|
|
||||||
},
|
},
|
||||||
"static" :
|
"static" :
|
||||||
{
|
{
|
||||||
|
@ -778,6 +778,9 @@ void CTownHandler::loadTownHall(CTown &town, const JsonNode & source) const
|
|||||||
|
|
||||||
Point JsonToPoint(const JsonNode & node)
|
Point JsonToPoint(const JsonNode & node)
|
||||||
{
|
{
|
||||||
|
if(!node.isStruct())
|
||||||
|
return Point::makeInvalid();
|
||||||
|
|
||||||
Point ret;
|
Point ret;
|
||||||
ret.x = static_cast<si32>(node["x"].Float());
|
ret.x = static_cast<si32>(node["x"].Float());
|
||||||
ret.y = static_cast<si32>(node["y"].Float());
|
ret.y = static_cast<si32>(node["y"].Float());
|
||||||
|
35
lib/Point.h
35
lib/Point.h
@ -19,44 +19,48 @@ public:
|
|||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
//constructors
|
//constructors
|
||||||
Point()
|
constexpr Point() : x(0), y(0)
|
||||||
{
|
{
|
||||||
x = y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Point(int X, int Y)
|
constexpr Point(int X, int Y)
|
||||||
: x(X)
|
: x(X)
|
||||||
, y(Y)
|
, y(Y)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr static Point makeInvalid()
|
||||||
|
{
|
||||||
|
return Point(std::numeric_limits<int>::min(), std::numeric_limits<int>::min());
|
||||||
|
}
|
||||||
|
|
||||||
explicit DLL_LINKAGE Point(const int3 &a);
|
explicit DLL_LINKAGE Point(const int3 &a);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point operator+(const T &b) const
|
constexpr Point operator+(const T &b) const
|
||||||
{
|
{
|
||||||
return Point(x+b.x,y+b.y);
|
return Point(x+b.x,y+b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point operator/(const T &div) const
|
constexpr Point operator/(const T &div) const
|
||||||
{
|
{
|
||||||
return Point(x/div, y/div);
|
return Point(x/div, y/div);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point operator*(const T &mul) const
|
constexpr Point operator*(const T &mul) const
|
||||||
{
|
{
|
||||||
return Point(x*mul, y*mul);
|
return Point(x*mul, y*mul);
|
||||||
}
|
}
|
||||||
|
|
||||||
Point operator*(const Point &b) const
|
constexpr Point operator*(const Point &b) const
|
||||||
{
|
{
|
||||||
return Point(x*b.x,y*b.y);
|
return Point(x*b.x,y*b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point& operator+=(const T &b)
|
constexpr Point& operator+=(const T &b)
|
||||||
{
|
{
|
||||||
x += b.x;
|
x += b.x;
|
||||||
y += b.y;
|
y += b.y;
|
||||||
@ -64,34 +68,39 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point operator-(const T &b) const
|
constexpr Point operator-(const T &b) const
|
||||||
{
|
{
|
||||||
return Point(x - b.x, y - b.y);
|
return Point(x - b.x, y - b.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Point& operator-=(const T &b)
|
constexpr Point& operator-=(const T &b)
|
||||||
{
|
{
|
||||||
x -= b.x;
|
x -= b.x;
|
||||||
y -= b.y;
|
y -= b.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> Point& operator=(const T &t)
|
template<typename T> constexpr Point& operator=(const T &t)
|
||||||
{
|
{
|
||||||
x = t.x;
|
x = t.x;
|
||||||
y = t.y;
|
y = t.y;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<typename T> bool operator==(const T &t) const
|
template<typename T> constexpr bool operator==(const T &t) const
|
||||||
{
|
{
|
||||||
return x == t.x && y == t.y;
|
return x == t.x && y == t.y;
|
||||||
}
|
}
|
||||||
template<typename T> bool operator!=(const T &t) const
|
template<typename T> constexpr bool operator!=(const T &t) const
|
||||||
{
|
{
|
||||||
return !(*this == t);
|
return !(*this == t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr bool isValid() const
|
||||||
|
{
|
||||||
|
return x > std::numeric_limits<int>::min() && y > std::numeric_limits<int>::min();
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Handler>
|
template <typename Handler>
|
||||||
void serialize(Handler &h, const int version)
|
void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user