mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Next batch of siege fixes
This commit is contained in:
parent
35576834c9
commit
9f21569a79
@ -77,6 +77,10 @@ CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
|
|||||||
hex->myInterface = owner;
|
hex->myInterface = owner;
|
||||||
bfield.push_back(hex);
|
bfield.push_back(hex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto accessibility = owner->curInt->cb->getAccesibility();
|
||||||
|
for(int i = 0; i < accessibility.size(); i++)
|
||||||
|
stackCountOutsideHexes[i] = (accessibility[i] == EAccessibility::ACCESSIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas)
|
void CBattleFieldController::showBackgroundImage(std::shared_ptr<CCanvas> canvas)
|
||||||
|
@ -91,7 +91,7 @@ std::string CBattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisu
|
|||||||
return prefix + "WA5.BMP";
|
return prefix + "WA5.BMP";
|
||||||
case EWallVisual::MOAT:
|
case EWallVisual::MOAT:
|
||||||
return prefix + "MOAT.BMP";
|
return prefix + "MOAT.BMP";
|
||||||
case EWallVisual::BACKGROUND_MOAT:
|
case EWallVisual::MOAT_BANK:
|
||||||
return prefix + "MLIP.BMP";
|
return prefix + "MLIP.BMP";
|
||||||
case EWallVisual::KEEP_BATTLEMENT:
|
case EWallVisual::KEEP_BATTLEMENT:
|
||||||
return prefix + "MANC.BMP";
|
return prefix + "MANC.BMP";
|
||||||
@ -124,19 +124,15 @@ bool CBattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what
|
|||||||
//FIXME: use this instead of buildings test?
|
//FIXME: use this instead of buildings test?
|
||||||
//ui8 siegeLevel = owner->curInt->cb->battleGetSiegeLevel();
|
//ui8 siegeLevel = owner->curInt->cb->battleGetSiegeLevel();
|
||||||
|
|
||||||
bool isMoat = (what == EWallVisual::BACKGROUND_MOAT || what == EWallVisual::MOAT);
|
switch (what)
|
||||||
bool isKeep = what == EWallVisual::KEEP_BATTLEMENT;
|
{
|
||||||
bool isTower = (what == EWallVisual::UPPER_BATTLEMENT || what == EWallVisual::BOTTOM_BATTLEMENT);
|
case EWallVisual::MOAT: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER;
|
||||||
|
case EWallVisual::MOAT_BANK: return town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER && town->town->faction->index != ETownType::NECROPOLIS;
|
||||||
bool hasMoat = town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER;
|
case EWallVisual::KEEP_BATTLEMENT: return town->hasBuilt(BuildingID::CITADEL);
|
||||||
bool hasKeep = town->hasBuilt(BuildingID::CITADEL);
|
case EWallVisual::UPPER_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE);
|
||||||
bool hasTower = town->hasBuilt(BuildingID::CASTLE);
|
case EWallVisual::BOTTOM_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE);
|
||||||
|
default: return true;
|
||||||
if ( isMoat ) return hasMoat;
|
}
|
||||||
if ( isKeep ) return hasKeep;
|
|
||||||
if ( isTower ) return hasTower;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BattleHex CBattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
|
BattleHex CBattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
|
||||||
@ -256,8 +252,8 @@ void CBattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canv
|
|||||||
if (getWallPieceExistance(EWallVisual::MOAT))
|
if (getWallPieceExistance(EWallVisual::MOAT))
|
||||||
showWallPiece(canvas, EWallVisual::MOAT, owner->pos.topLeft());
|
showWallPiece(canvas, EWallVisual::MOAT, owner->pos.topLeft());
|
||||||
|
|
||||||
if (getWallPieceExistance(EWallVisual::BACKGROUND_MOAT))
|
if (getWallPieceExistance(EWallVisual::MOAT_BANK))
|
||||||
showWallPiece(canvas, EWallVisual::BACKGROUND_MOAT, owner->pos.topLeft());
|
showWallPiece(canvas, EWallVisual::MOAT_BANK, owner->pos.topLeft());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBattleSiegeController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
|
void CBattleSiegeController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )
|
||||||
|
@ -41,7 +41,7 @@ namespace EWallVisual
|
|||||||
BOTTOM_STATIC_WALL,
|
BOTTOM_STATIC_WALL,
|
||||||
UPPER_STATIC_WALL,
|
UPPER_STATIC_WALL,
|
||||||
MOAT,
|
MOAT,
|
||||||
BACKGROUND_MOAT,
|
MOAT_BANK,
|
||||||
KEEP_BATTLEMENT,
|
KEEP_BATTLEMENT,
|
||||||
BOTTOM_BATTLEMENT,
|
BOTTOM_BATTLEMENT,
|
||||||
UPPER_BATTLEMENT,
|
UPPER_BATTLEMENT,
|
||||||
|
@ -498,8 +498,8 @@ void CBattleStacksController::startAction(const BattleAction* action)
|
|||||||
if (creAnims[action->stackNumber]->framesInGroup(CCreatureAnim::MOVE_START))
|
if (creAnims[action->stackNumber]->framesInGroup(CCreatureAnim::MOVE_START))
|
||||||
addNewAnim(new CMovementStartAnimation(owner, stack));
|
addNewAnim(new CMovementStartAnimation(owner, stack));
|
||||||
|
|
||||||
if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
|
//if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
|
||||||
addNewAnim(new CReverseAnimation(owner, stack, stack->getPosition(), true));
|
// addNewAnim(new CReverseAnimation(owner, stack, stack->getPosition(), true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ void CCreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool facingR
|
|||||||
|
|
||||||
image->setBorderPallete(borderPallete);
|
image->setBorderPallete(borderPallete);
|
||||||
|
|
||||||
canvas->draw(image, pos.topLeft());
|
canvas->draw(image, pos.topLeft(), Rect(0, 0, pos.w, pos.h));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ public:
|
|||||||
// Keep the original palette, in order to do color switching operation
|
// Keep the original palette, in order to do color switching operation
|
||||||
void savePalette();
|
void savePalette();
|
||||||
|
|
||||||
void draw(SDL_Surface * where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const override;
|
void draw(SDL_Surface * where, int posX=0, int posY=0, const Rect *src=nullptr, ui8 alpha=255) const override;
|
||||||
void draw(SDL_Surface * where, SDL_Rect * dest, SDL_Rect * src, ui8 alpha=255) const override;
|
void draw(SDL_Surface * where, const SDL_Rect * dest, const SDL_Rect * src, ui8 alpha=255) const override;
|
||||||
std::shared_ptr<IImage> scaleFast(float scale) const override;
|
std::shared_ptr<IImage> scaleFast(float scale) const override;
|
||||||
void exportBitmap(const boost::filesystem::path & path) const override;
|
void exportBitmap(const boost::filesystem::path & path) const override;
|
||||||
void playerColored(PlayerColor player) override;
|
void playerColored(PlayerColor player) override;
|
||||||
@ -647,7 +647,7 @@ SDLImage::SDLImage(std::string filename)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha) const
|
void SDLImage::draw(SDL_Surface *where, int posX, int posY, const Rect *src, ui8 alpha) const
|
||||||
{
|
{
|
||||||
if(!surf)
|
if(!surf)
|
||||||
return;
|
return;
|
||||||
@ -657,7 +657,7 @@ void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha
|
|||||||
draw(where, &destRect, src);
|
draw(where, &destRect, src);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLImage::draw(SDL_Surface* where, SDL_Rect* dest, SDL_Rect* src, ui8 alpha) const
|
void SDLImage::draw(SDL_Surface* where, const SDL_Rect* dest, const SDL_Rect* src, ui8 alpha) const
|
||||||
{
|
{
|
||||||
if (!surf)
|
if (!surf)
|
||||||
return;
|
return;
|
||||||
|
@ -40,8 +40,8 @@ public:
|
|||||||
using BorderPallete = std::array<SDL_Color, 3>;
|
using BorderPallete = std::array<SDL_Color, 3>;
|
||||||
|
|
||||||
//draws image on surface "where" at position
|
//draws image on surface "where" at position
|
||||||
virtual void draw(SDL_Surface * where, int posX = 0, int posY = 0, Rect * src = nullptr, ui8 alpha = 255) const=0;
|
virtual void draw(SDL_Surface * where, int posX = 0, int posY = 0, const Rect * src = nullptr, ui8 alpha = 255) const=0;
|
||||||
virtual void draw(SDL_Surface * where, SDL_Rect * dest, SDL_Rect * src, ui8 alpha = 255) const = 0;
|
virtual void draw(SDL_Surface * where, const SDL_Rect * dest, const SDL_Rect * src, ui8 alpha = 255) const = 0;
|
||||||
|
|
||||||
virtual std::shared_ptr<IImage> scaleFast(float scale) const = 0;
|
virtual std::shared_ptr<IImage> scaleFast(float scale) const = 0;
|
||||||
|
|
||||||
|
@ -37,6 +37,11 @@ void CCanvas::draw(std::shared_ptr<IImage> image, const Point & pos)
|
|||||||
image->draw(surface, pos.x, pos.y);
|
image->draw(surface, pos.x, pos.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCanvas::draw(std::shared_ptr<IImage> image, const Point & pos, const Rect & sourceRect)
|
||||||
|
{
|
||||||
|
image->draw(surface, pos.x, pos.y, &sourceRect);
|
||||||
|
}
|
||||||
|
|
||||||
void CCanvas::draw(std::shared_ptr<CCanvas> image, const Point & pos)
|
void CCanvas::draw(std::shared_ptr<CCanvas> image, const Point & pos)
|
||||||
{
|
{
|
||||||
blitAt(image->surface, pos.x, pos.y, surface);
|
blitAt(image->surface, pos.x, pos.y, surface);
|
||||||
|
@ -30,9 +30,12 @@ public:
|
|||||||
|
|
||||||
~CCanvas();
|
~CCanvas();
|
||||||
|
|
||||||
/// renders image onto this canvas
|
/// renders image onto this canvas at specified position
|
||||||
void draw(std::shared_ptr<IImage> image, const Point & pos);
|
void draw(std::shared_ptr<IImage> image, const Point & pos);
|
||||||
|
|
||||||
|
/// renders section of image bounded by sourceRect at specified position
|
||||||
|
void draw(std::shared_ptr<IImage> image, const Point & pos, const Rect & sourceRect);
|
||||||
|
|
||||||
/// renders another canvas onto this canvas
|
/// renders another canvas onto this canvas
|
||||||
void draw(std::shared_ptr<CCanvas> image, const Point & pos);
|
void draw(std::shared_ptr<CCanvas> image, const Point & pos);
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@
|
|||||||
},
|
},
|
||||||
"moat" :
|
"moat" :
|
||||||
{
|
{
|
||||||
"bank" : { "x" : 406, "y" : 77 },
|
"bank" : { "x" : -1, "y" : -1 }, // Should not be present
|
||||||
"moat" : { "x" : 406, "y" : 77 }
|
"moat" : { "x" : 406, "y" : 77 }
|
||||||
},
|
},
|
||||||
"static" :
|
"static" :
|
||||||
|
Loading…
x
Reference in New Issue
Block a user