diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 22a0ab4a5..c23475c4f 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -995,7 +995,7 @@ void CBattleInterface::newStack(const CStack * stack) coords.x = siegeH->town->town->clientInfo.siegePositions[posID].x + this->pos.x; coords.y = siegeH->town->town->clientInfo.siegePositions[posID].y + this->pos.y; } - creAnims[stack->ID]->pos.h = siegeH->town->town->clientInfo.siegeShooterCropHeight; + creAnims[stack->ID]->pos.h = 225; } else { @@ -2945,13 +2945,18 @@ std::string CBattleInterface::SiegeHelper::getSiegeName(ui16 what, ui16 additInf void CBattleInterface::SiegeHelper::printPartOfWall(SDL_Surface * to, int what) { Point pos = Point(-1, -1); + auto & ci = owner->siegeH->town->town->clientInfo; if (what >= 1 && what <= 17) { - pos.x = owner->siegeH->town->town->clientInfo.siegePositions[what].x + owner->pos.x; - pos.y = owner->siegeH->town->town->clientInfo.siegePositions[what].y + owner->pos.y; + pos.x = ci.siegePositions[what].x + owner->pos.x; + pos.y = ci.siegePositions[what].y + owner->pos.y; } + if (town->town->faction->index == ETownType::TOWER + && (what == 13 || what == 14)) + return; // no moat in Tower. TODO: remove hardcode somehow? + if(pos.x != -1) { blitAt(walls[what], pos.x, pos.y, to); @@ -3054,6 +3059,8 @@ void CBattleInterface::showAbsoluteObstacles(SDL_Surface * to) if(oi->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE) blitAt(getObstacleImage(*oi), pos.x + oi->getInfo().width, pos.y + oi->getInfo().height, to); + if (siegeH && siegeH->town->hasBuilt(BuildingID::CITADEL)) + siegeH->printPartOfWall(to, 14); // show moat background } void CBattleInterface::showHighlightedHexes(SDL_Surface * to) @@ -3463,22 +3470,28 @@ BattleObjectsByHex CBattleInterface::sortObjectsByHex() if (siegeH) { sorted.beforeAll.walls.push_back(1); // 1. background wall - sorted.hex[135].walls.push_back(2); // 2. keep sorted.afterAll.walls.push_back(3); // 3. bottom tower sorted.hex[182].walls.push_back(4); // 4. bottom wall sorted.hex[130].walls.push_back(5); // 5. wall below gate, sorted.hex[62].walls.push_back(6); // 6. wall over gate sorted.hex[12].walls.push_back(7); // 7. upper wall sorted.beforeAll.walls.push_back(8); // 8. upper tower - //sorted.hex[94].walls.push_back(9); // 9. gate // Not implemented it seems + //sorted.hex[94].walls.push_back(9); // 9. gate // Not implemented it seems sorted.hex[112].walls.push_back(10); // 10. gate arch sorted.hex[165].walls.push_back(11); // 11. bottom static wall - sorted.beforeAll.walls.push_back(12); // 12. upper static wall - sorted.beforeAll.walls.push_back(13); // 13. moat - sorted.beforeAll.walls.push_back(14); // 14. mlip - sorted.hex[135].walls.push_back(15); // 15. keep turret cover - sorted.afterAll.walls.push_back(16); // 16. lower turret cover - sorted.beforeAll.walls.push_back(17); // 17. upper turret cover + sorted.hex[45].walls.push_back(12); // 12. upper static wall + if (siegeH && siegeH->town->hasBuilt(BuildingID::CITADEL)) + { + sorted.beforeAll.walls.push_back(13); // 13. moat + //sorted.beforeAll.walls.push_back(14); // 14. mlip (moat background terrain), blit as absolute obstacle + sorted.hex[135].walls.push_back(2); // 2. keep + sorted.hex[135].walls.push_back(15); // 15. keep turret cover + } + if (siegeH && siegeH->town->hasBuilt(BuildingID::CASTLE)) + { + sorted.afterAll.walls.push_back(16); // 16. lower turret cover + sorted.beforeAll.walls.push_back(17); // 17. upper turret cover + } } return sorted; } diff --git a/client/battle/CCreatureAnimation.cpp b/client/battle/CCreatureAnimation.cpp index c1708c001..ba4be6826 100644 --- a/client/battle/CCreatureAnimation.cpp +++ b/client/battle/CCreatureAnimation.cpp @@ -401,7 +401,8 @@ ui8 * CCreatureAnimation::getPixelAddr(SDL_Surface * dest, int X, int Y) const template inline void CCreatureAnimation::putPixelAt(SDL_Surface * dest, int X, int Y, size_t index, const std::array & special) const { - putPixel(getPixelAddr(dest, X, Y), palette[index], index, special); + if ( X < pos.x + pos.w && Y < pos.y + pos.h) + putPixel(getPixelAddr(dest, X, Y), palette[index], index, special); } template diff --git a/config/factions/castle.json b/config/factions/castle.json index 5aaaff9ec..8672bcc86 100644 --- a/config/factions/castle.json +++ b/config/factions/castle.json @@ -204,7 +204,6 @@ "bank" : { "x" : 403, "y" : 80 }, "moat" : { "x" : 410, "y" : 90 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 600, "y" : 49 }, diff --git a/config/factions/conflux.json b/config/factions/conflux.json index bd645afd6..3278fa7f8 100644 --- a/config/factions/conflux.json +++ b/config/factions/conflux.json @@ -212,7 +212,6 @@ "bank" : { "x" : 407, "y" : 80 }, "moat" : { "x" : 407, "y" : 80 } }, - "shooterHeight" : 229, "static" : { "background" : { "x" : 600, "y" : 50 }, diff --git a/config/factions/dungeon.json b/config/factions/dungeon.json index db4dea77a..081d01dfe 100644 --- a/config/factions/dungeon.json +++ b/config/factions/dungeon.json @@ -196,28 +196,27 @@ "imagePrefix" : "SGDN", "gate" : { - "arch" : { "x" : 471, "y" : 164 }, + "arch" : { "x" : 471, "y" : 165 }, "gate" : { "x" : 395, "y" : 260 } }, "moat" : { - "bank" : { "x" : 283, "y" : 94 }, - "moat" : { "x" : 283, "y" : 94 } + "bank" : { "x" : 284, "y" : 94 }, + "moat" : { "x" : 284, "y" : 94 } }, - "shooterHeight" : 230, "static" : { "background" : { "x" : 608, "y" : 50 }, - "bottom" : { "x" : 522, "y" : 305 }, + "bottom" : { "x" : 522, "y" : 306 }, "top" : { "x" : 494, "y" : 53 } }, "towers" : { "bottom" : { - "battlement" : { "x" : 600, "y" : 495 }, + "battlement" : { "x" : 595, "y" : 496 }, "creature" : { "x" : 410, "y" : 293 }, - "tower" : { "x" : 560, "y" : 495 } + "tower" : { "x" : 595, "y" : 496 } }, "keep" : { @@ -227,9 +226,9 @@ }, "top" : { - "battlement" : { "x" : 565, "y" : 15 }, + "battlement" : { "x" : 562, "y" : 15 }, "creature" : { "x" : 381, "y" : -187 }, - "tower" : { "x" : 565, "y" : 15 } + "tower" : { "x" : 562, "y" : 15 } } }, "walls" : @@ -237,7 +236,7 @@ "bottom" : { "x" : 559, "y" : 448 }, "bottomMid" : { "x" : 471, "y" : 296 }, "upper" : { "x" : 523, "y" : 56 }, - "upperMid" : { "x" : 477, "y" : 180 } + "upperMid" : { "x" : 478, "y" : 181 } } } } diff --git a/config/factions/fortress.json b/config/factions/fortress.json index 214f09592..53a6e5ca5 100644 --- a/config/factions/fortress.json +++ b/config/factions/fortress.json @@ -205,7 +205,6 @@ "bank" : { "x" : 376, "y" : 70 }, "moat" : { "x" : 383, "y" : 95 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 599, "y" : 62 }, diff --git a/config/factions/inferno.json b/config/factions/inferno.json index afdf05c52..138082125 100644 --- a/config/factions/inferno.json +++ b/config/factions/inferno.json @@ -205,7 +205,6 @@ "bank" : { "x" : 403, "y" : 68 }, "moat" : { "x" : 403, "y" : 68 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 606, "y" : 52 }, diff --git a/config/factions/necropolis.json b/config/factions/necropolis.json index 0b39e1f6a..4c39c5e05 100644 --- a/config/factions/necropolis.json +++ b/config/factions/necropolis.json @@ -211,7 +211,6 @@ "bank" : { "x" : -1, "y" : -1 }, "moat" : { "x" : 406, "y" : 77 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 604, "y" : 58 }, diff --git a/config/factions/rampart.json b/config/factions/rampart.json index 6ee0c7160..e7a64fedc 100644 --- a/config/factions/rampart.json +++ b/config/factions/rampart.json @@ -212,7 +212,6 @@ "bank" : { "x" : 410, "y" : 97 }, "moat" : { "x" : 410, "y" : 77 } }, - "shooterHeight" : 232, "static" : { "background" : { "x" : 608, "y" : 46 }, diff --git a/config/factions/stronghold.json b/config/factions/stronghold.json index 2d91ae010..0097b5afa 100644 --- a/config/factions/stronghold.json +++ b/config/factions/stronghold.json @@ -202,7 +202,6 @@ "bank" : { "x" : 410, "y" : 91 }, "moat" : { "x" : 410, "y" : 90 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 617, "y" : 62 }, diff --git a/config/factions/tower.json b/config/factions/tower.json index 029789ec5..b89c103cc 100644 --- a/config/factions/tower.json +++ b/config/factions/tower.json @@ -142,7 +142,7 @@ "primaryResource" : "gems", "mageGuild" : 5, "warMachine" : "ammoCart", - "moatDamage" : -1, + "moatDamage" : 0, //TODO: minefield "buildings" : { @@ -204,7 +204,6 @@ "bank" : { "x" : 410, "y" : 80 }, "moat" : { "x" : 410, "y" : 90 } }, - "shooterHeight" : 231, "static" : { "background" : { "x" : 615, "y" : 57 }, diff --git a/config/schemas/townSiege.json b/config/schemas/townSiege.json index 35236e22f..c04f652b4 100644 --- a/config/schemas/townSiege.json +++ b/config/schemas/townSiege.json @@ -76,10 +76,6 @@ } } }, - "shooterHeight": { - "type":"number", - "description" : "Height at which shooter image will be cropped" - }, "shooter": { "type":"string", "description" : "Identifier of creature that will be used as tower shooter" diff --git a/lib/CTownHandler.cpp b/lib/CTownHandler.cpp index 0d1040431..86b8cad79 100644 --- a/lib/CTownHandler.cpp +++ b/lib/CTownHandler.cpp @@ -395,8 +395,6 @@ void CTownHandler::loadSiegeScreen(CTown &town, const JsonNode & source) town.clientInfo.siegeShooter = CreatureID(creature); }); - town.clientInfo.siegeShooterCropHeight = source["shooterHeight"].Float(); - auto & pos = town.clientInfo.siegePositions; pos.resize(21); diff --git a/lib/CTownHandler.h b/lib/CTownHandler.h index 26550e77d..b5e9bbf9e 100644 --- a/lib/CTownHandler.h +++ b/lib/CTownHandler.h @@ -185,13 +185,12 @@ public: std::string siegePrefix; std::vector siegePositions; CreatureID siegeShooter; // shooter creature ID - si32 siegeShooterCropHeight; //trim height for shooters in turrets template void serialize(Handler &h, const int version) { h & icons & iconSmall & iconLarge & musicTheme & townBackground & guildWindow & buildingsIcons & hallBackground; h & advMapVillage & advMapCastle & advMapCapitol & hallSlots & structures; - h & siegePrefix & siegePositions & siegeShooter & siegeShooterCropHeight; + h & siegePrefix & siegePositions & siegeShooter; } } clientInfo;