1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-24 03:47:18 +02:00

Next batch of siege fixes

This commit is contained in:
Ivan Savenko 2022-11-27 22:50:18 +02:00
parent 35576834c9
commit 9f21569a79
10 changed files with 36 additions and 28 deletions

View File

@ -77,6 +77,10 @@ CBattleFieldController::CBattleFieldController(CBattleInterface * owner):
hex->myInterface = owner;
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)

View File

@ -91,7 +91,7 @@ std::string CBattleSiegeController::getWallPieceImageName(EWallVisual::EWallVisu
return prefix + "WA5.BMP";
case EWallVisual::MOAT:
return prefix + "MOAT.BMP";
case EWallVisual::BACKGROUND_MOAT:
case EWallVisual::MOAT_BANK:
return prefix + "MLIP.BMP";
case EWallVisual::KEEP_BATTLEMENT:
return prefix + "MANC.BMP";
@ -124,19 +124,15 @@ bool CBattleSiegeController::getWallPieceExistance(EWallVisual::EWallVisual what
//FIXME: use this instead of buildings test?
//ui8 siegeLevel = owner->curInt->cb->battleGetSiegeLevel();
bool isMoat = (what == EWallVisual::BACKGROUND_MOAT || what == EWallVisual::MOAT);
bool isKeep = what == EWallVisual::KEEP_BATTLEMENT;
bool isTower = (what == EWallVisual::UPPER_BATTLEMENT || what == EWallVisual::BOTTOM_BATTLEMENT);
bool hasMoat = town->hasBuilt(BuildingID::CITADEL) && town->town->faction->index != ETownType::TOWER;
bool hasKeep = town->hasBuilt(BuildingID::CITADEL);
bool hasTower = town->hasBuilt(BuildingID::CASTLE);
if ( isMoat ) return hasMoat;
if ( isKeep ) return hasKeep;
if ( isTower ) return hasTower;
return true;
switch (what)
{
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;
case EWallVisual::KEEP_BATTLEMENT: return town->hasBuilt(BuildingID::CITADEL);
case EWallVisual::UPPER_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE);
case EWallVisual::BOTTOM_BATTLEMENT: return town->hasBuilt(BuildingID::CASTLE);
default: return true;
}
}
BattleHex CBattleSiegeController::getWallPiecePosition(EWallVisual::EWallVisual what) const
@ -256,8 +252,8 @@ void CBattleSiegeController::showAbsoluteObstacles(std::shared_ptr<CCanvas> canv
if (getWallPieceExistance(EWallVisual::MOAT))
showWallPiece(canvas, EWallVisual::MOAT, owner->pos.topLeft());
if (getWallPieceExistance(EWallVisual::BACKGROUND_MOAT))
showWallPiece(canvas, EWallVisual::BACKGROUND_MOAT, owner->pos.topLeft());
if (getWallPieceExistance(EWallVisual::MOAT_BANK))
showWallPiece(canvas, EWallVisual::MOAT_BANK, owner->pos.topLeft());
}
void CBattleSiegeController::showBattlefieldObjects(std::shared_ptr<CCanvas> canvas, const BattleHex & location )

View File

@ -41,7 +41,7 @@ namespace EWallVisual
BOTTOM_STATIC_WALL,
UPPER_STATIC_WALL,
MOAT,
BACKGROUND_MOAT,
MOAT_BANK,
KEEP_BATTLEMENT,
BOTTOM_BATTLEMENT,
UPPER_BATTLEMENT,

View File

@ -498,8 +498,8 @@ void CBattleStacksController::startAction(const BattleAction* action)
if (creAnims[action->stackNumber]->framesInGroup(CCreatureAnim::MOVE_START))
addNewAnim(new CMovementStartAnimation(owner, stack));
if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
addNewAnim(new CReverseAnimation(owner, stack, stack->getPosition(), true));
//if(shouldRotate(stack, stack->getPosition(), actionTarget.at(0).hexValue))
// addNewAnim(new CReverseAnimation(owner, stack, stack->getPosition(), true));
}
}

View File

@ -314,7 +314,7 @@ void CCreatureAnimation::nextFrame(std::shared_ptr<CCanvas> canvas, bool facingR
image->setBorderPallete(borderPallete);
canvas->draw(image, pos.topLeft());
canvas->draw(image, pos.topLeft(), Rect(0, 0, pos.w, pos.h));
}
}

View File

@ -92,8 +92,8 @@ public:
// Keep the original palette, in order to do color switching operation
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, SDL_Rect * dest, SDL_Rect * src, 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, const SDL_Rect * dest, const SDL_Rect * src, ui8 alpha=255) const override;
std::shared_ptr<IImage> scaleFast(float scale) const override;
void exportBitmap(const boost::filesystem::path & path) const 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)
return;
@ -657,7 +657,7 @@ void SDLImage::draw(SDL_Surface *where, int posX, int posY, Rect *src, ui8 alpha
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)
return;

View File

@ -40,8 +40,8 @@ public:
using BorderPallete = std::array<SDL_Color, 3>;
//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, SDL_Rect * dest, SDL_Rect * src, 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, const SDL_Rect * dest, const SDL_Rect * src, ui8 alpha = 255) const = 0;
virtual std::shared_ptr<IImage> scaleFast(float scale) const = 0;

View File

@ -37,6 +37,11 @@ void CCanvas::draw(std::shared_ptr<IImage> image, const Point & pos)
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)
{
blitAt(image->surface, pos.x, pos.y, surface);

View File

@ -30,9 +30,12 @@ public:
~CCanvas();
/// renders image onto this canvas
/// renders image onto this canvas at specified position
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
void draw(std::shared_ptr<CCanvas> image, const Point & pos);

View File

@ -222,7 +222,7 @@
},
"moat" :
{
"bank" : { "x" : 406, "y" : 77 },
"bank" : { "x" : -1, "y" : -1 }, // Should not be present
"moat" : { "x" : 406, "y" : 77 }
},
"static" :