diff --git a/src/engine/IMG_savepng.cpp b/src/engine/IMG_savepng.cpp index d8796c7..077f814 100644 --- a/src/engine/IMG_savepng.cpp +++ b/src/engine/IMG_savepng.cpp @@ -68,7 +68,7 @@ int IMG_SavePNG_RW(SDL_RWops* src, SDL_Surface* surf, int compression) png_colorp palette = nullptr; int ret = -1; int funky_format = 0; - SDL_PixelFormat* fmt{}; + SDL_PixelFormat* fmt{}; if (!src || !surf) { @@ -245,7 +245,7 @@ int IMG_SavePNG_RW(SDL_RWops* src, SDL_Surface* surf, int compression) 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); #else auto* tempsurf = SDL_CreateRGBSurface(SDL_SWSURFACE, surf->w, surf->h, 32, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); + 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); #endif if (!tempsurf) { diff --git a/src/engine/TimeUtills.cpp b/src/engine/TimeUtills.cpp index eeaec64..6c6ee96 100644 --- a/src/engine/TimeUtills.cpp +++ b/src/engine/TimeUtills.cpp @@ -5,18 +5,18 @@ namespace time_utils { - unsigned long long GetTickCount() - { - using namespace std::chrono; - return duration_cast(steady_clock::now().time_since_epoch()).count(); - } + unsigned long long GetTickCount() + { + using namespace std::chrono; + return duration_cast(steady_clock::now().time_since_epoch()).count(); + } - void TimeAction(const std::string& message, std::function& runAction) - { - const auto startTime = GetTickCount(); - runAction(); - const auto endTime = GetTickCount(); - const auto delta = endTime - startTime; - Message("", message + ": " + to_string(delta), Font::BIG, Dialog::YES); - } -} \ No newline at end of file + void TimeAction(const std::string& message, std::function& runAction) + { + const auto startTime = GetTickCount(); + runAction(); + const auto endTime = GetTickCount(); + const auto delta = endTime - startTime; + Message("", message + ": " + to_string(delta), Font::BIG, Dialog::YES); + } +} diff --git a/src/engine/display.cpp b/src/engine/display.cpp index 4fff47e..57304fc 100644 --- a/src/engine/display.cpp +++ b/src/engine/display.cpp @@ -112,7 +112,7 @@ Size Display::GetMaxMode(bool rotate) const modes == (SDL_Rect **)-1) { H2ERROR("GetMaxMode: " << "no modes available"); - return {}; + return {}; } int max = 0; int cur = 0; @@ -126,9 +126,9 @@ Size Display::GetMaxMode(bool rotate) const } } - Size result; - if (!modes[cur]) - return {}; + Size result; + if (!modes[cur]) + return {}; result.w = modes[cur]->w; result.h = modes[cur]->h; diff --git a/src/engine/sprites.cpp b/src/engine/sprites.cpp index f66c53b..dd4339a 100644 --- a/src/engine/sprites.cpp +++ b/src/engine/sprites.cpp @@ -37,7 +37,7 @@ const Point& SpritePos::GetPos() const Rect SpritePos::GetArea() const { - return { GetPos(), GetSize() }; + return {GetPos(), GetSize()}; } void SpritePos::SetSurface(const Surface& sf) diff --git a/src/engine/system.cpp b/src/engine/system.cpp index 86e2d0b..fdaeddb 100644 --- a/src/engine/system.cpp +++ b/src/engine/system.cpp @@ -299,7 +299,7 @@ std::string System::GetTime() char buf[13] = {0}; time(&raw); - struct tm * tmi = localtime(&raw); + struct tm* tmi = localtime(&raw); strftime(buf, sizeof buf - 1, "%X", tmi); diff --git a/src/engine/translations.cpp b/src/engine/translations.cpp index 8058e0c..016fcf9 100644 --- a/src/engine/translations.cpp +++ b/src/engine/translations.cpp @@ -29,13 +29,15 @@ #include "translations.h" using namespace std; + std::string _(const std::string& text) { - return Translation::gettext(text); + return Translation::gettext(text); } -std::string _n(const std::string &str, const std::string &plural, size_t n) + +std::string _n(const std::string& str, const std::string& plural, size_t n) { - return Translation::ngettext(str.c_str(), plural.c_str(), n); + return Translation::ngettext(str.c_str(), plural.c_str(), n); } namespace ModernTranslation diff --git a/src/engine/xmi2mid.cpp b/src/engine/xmi2mid.cpp index a65e6b1..b20bbe8 100644 --- a/src/engine/xmi2mid.cpp +++ b/src/engine/xmi2mid.cpp @@ -113,7 +113,7 @@ pack_t unpackValue(const u8* ptr) struct meta_t { - meta_t() + meta_t() { } @@ -145,7 +145,7 @@ struct IFFChunkHeader { } - IFFChunkHeader() = default; + IFFChunkHeader() = default; }; @@ -173,7 +173,7 @@ struct GroupChunkHeader { } - GroupChunkHeader() = default; + GroupChunkHeader() = default; }; ByteVectorWriter& operator<<(ByteVectorWriter& sb, const GroupChunkHeader& st) @@ -296,7 +296,7 @@ struct XMIData struct MidEvent { vector pack; - std::array data; // status, data1, data2, count + std::array data; // status, data1, data2, count //char status; //std::vector data; @@ -338,12 +338,13 @@ ByteVectorWriter& operator<<(ByteVectorWriter& sb, const MidEvent& st) return sb; } -struct MidEvents +struct MidEvents { - vector _items; + vector _items; + size_t count() const { - return _items.size(); + return _items.size(); } size_t size() const @@ -382,7 +383,7 @@ struct MidEvents if ((*it1).duration <= delta) { // note off - _items.emplace_back((*it1).duration - delta2, (*it1).command, (*it1).quantity, 0x7F); + _items.emplace_back((*it1).duration - delta2, (*it1).command, (*it1).quantity, 0x7F); delta2 += (*it1).duration - delta2; } } @@ -411,7 +412,7 @@ struct MidEvents // end if (0xFF == *ptr && 0x2F == *(ptr + 1)) { - _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); + _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); break; } switch (*ptr >> 4) @@ -432,7 +433,7 @@ struct MidEvents // pitch bend case 0x0E: { - _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); + _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); ptr += 3; delta = 0; } @@ -443,7 +444,7 @@ struct MidEvents // note on case 0x09: { - _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); + _items.emplace_back(delta, *ptr, *(ptr + 1), *(ptr + 2)); pack_t pack = unpackValue(ptr + 3); notesoff.emplace_back(*ptr - 0x10, *(ptr + 1), pack.first); ptr += 3 + pack.second; @@ -456,7 +457,7 @@ struct MidEvents // chanel pressure case 0x0D: { - _items.emplace_back(delta, *ptr, *(ptr + 1)); + _items.emplace_back(delta, *ptr, *(ptr + 1)); ptr += 2; delta = 0; } @@ -464,7 +465,7 @@ struct MidEvents // unused command default: - _items.emplace_back(0, 0xFF, 0x2F, 0); + _items.emplace_back(0, 0xFF, 0x2F, 0); H2ERROR("unknown st: 0x" << std::setw(2) << std::setfill('0') << std::hex << static_cast(*ptr) << ", ln: " << static_cast(&t.evnt[0] + t.evnt.size() - ptr)); @@ -509,9 +510,10 @@ ByteVectorWriter& operator<<(ByteVectorWriter& sb, const MidTrack& st) return sb; } -struct MidTracks +struct MidTracks { - vector _items; + vector _items; + size_t count() const { return _items.size(); @@ -530,7 +532,7 @@ struct MidTracks explicit MidTracks(const XMITracks& tracks) { for (const auto& track : tracks) - _items.emplace_back(track); + _items.emplace_back(track); } }; diff --git a/src/fheroes2/agg/agg.cpp b/src/fheroes2/agg/agg.cpp index e0458cd..dfd161e 100644 --- a/src/fheroes2/agg/agg.cpp +++ b/src/fheroes2/agg/agg.cpp @@ -57,7 +57,7 @@ namespace { - const int FATSIZENAME = 15; + const int FATSIZENAME = 15; std::vector pal_colors; std::vector pal_colors_u32; diff --git a/src/fheroes2/agg/icn.cpp b/src/fheroes2/agg/icn.cpp index cecde77..05dad5a 100644 --- a/src/fheroes2/agg/icn.cpp +++ b/src/fheroes2/agg/icn.cpp @@ -2012,8 +2012,8 @@ bool ICN::isBattleMonsterICN(int icn) int ICN::FromString(const std::string& str) { const icnmap_t* ptr = &icnmap[0]; - while (ptr->type != UNKNOWN && !str.empty() && str!= ptr->name) - ++ptr; + while (ptr->type != UNKNOWN && !str.empty() && str != ptr->name) + ++ptr; return ptr->type; } diff --git a/src/fheroes2/ai/simple/ai_heroes.cpp b/src/fheroes2/ai/simple/ai_heroes.cpp index 98b7f7e..9870a29 100644 --- a/src/fheroes2/ai/simple/ai_heroes.cpp +++ b/src/fheroes2/ai/simple/ai_heroes.cpp @@ -191,9 +191,9 @@ s32 FindUncharteredTerritory(Heroes& hero, uint32_t scoute) Maps::GetAroundIndexes(hero.GetIndex(), scoute, true, v); Maps::Indexes res; - v.resize(distance(v.begin(), - remove_if(v.begin(), v.end(), - [](s32 it) {return Maps::TileIsUnderProtection(it); }))); + v.resize(distance(v.begin(), + remove_if(v.begin(), v.end(), + [](s32 it) { return Maps::TileIsUnderProtection(it); }))); for (auto it = v.rbegin(); it != v.rend() && res.size() < 4; ++it) @@ -217,8 +217,8 @@ s32 GetRandomHeroesPosition(Heroes& hero, uint32_t scoute) Maps::Indexes res; v.resize(distance(v.begin(), - remove_if(v.begin(), v.end(), - [](s32 it) {return Maps::TileIsUnderProtection(it); }))); + remove_if(v.begin(), v.end(), + [](s32 it) { return Maps::TileIsUnderProtection(it); }))); for (auto it = v.rbegin(); it != v.rend() && res.size() < 4; ++it) @@ -402,8 +402,9 @@ bool AI::HeroesGetTask(Heroes& hero) // scan enemy hero if (hero.GetSquarePatrol()) { - const Maps::Indexes& indicesAround = Maps::ScanAroundObject(Maps::GetIndexFromAbsPoint(hero.GetCenterPatrol()), - hero.GetSquarePatrol(), MP2::OBJ_HEROES); + const Maps::Indexes& indicesAround = Maps::ScanAroundObject( + Maps::GetIndexFromAbsPoint(hero.GetCenterPatrol()), + hero.GetSquarePatrol(), MP2::OBJ_HEROES); for (int result : indicesAround) { const Heroes* enemy = world.GetTiles(result).GetHeroes(); @@ -419,7 +420,7 @@ bool AI::HeroesGetTask(Heroes& hero) if (conf.ExtHeroPatrolAllowPickup()) { const Maps::Indexes& indicesAround = Maps::ScanAroundObjects(hero.GetIndex(), - hero.GetSquarePatrol(), objs1); + hero.GetSquarePatrol(), objs1); for (auto result : indicesAround) { if (!HeroesValidObject(hero, result) || !hero.GetPath().Calculate(result)) @@ -543,11 +544,11 @@ bool AI::HeroesGetTask(Heroes& hero) } else { - // remove invalid task - task.remove_if([&](s32&it) - { - return !AIHeroesValidObject2(&hero, it); - }); + // remove invalid task + task.remove_if([&](s32& it) + { + return !AIHeroesValidObject2(&hero, it); + }); } // random shuffle diff --git a/src/fheroes2/army/army_bar.cpp b/src/fheroes2/army/army_bar.cpp index 9f97dd2..593a13c 100644 --- a/src/fheroes2/army/army_bar.cpp +++ b/src/fheroes2/army/army_bar.cpp @@ -41,7 +41,8 @@ bool CanUpgradeTroopButNoResources(Troop& troop, Army* army) bool candidate = false; if (troop._monster.isAllowUpgrade() && // allow upgrade - castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild(troop._monster.GetUpgrade().GetDwelling())) + castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild( + troop._monster.GetUpgrade().GetDwelling())) { candidate = true; } @@ -54,7 +55,8 @@ bool CanUpgradeTroop(Troop& troop, Army* army) bool candidate = false; if (troop._monster.isAllowUpgrade() && // allow upgrade - castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild(troop._monster.GetUpgrade().GetDwelling())) + castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild( + troop._monster.GetUpgrade().GetDwelling())) { candidate = true; } @@ -497,7 +499,8 @@ bool ArmyBar::ActionBarDoubleClick(const Point& cursor, ArmyTroop& troop, const if (troop._monster.isAllowUpgrade() && // allow upgrade - castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild(troop._monster.GetUpgrade().GetDwelling())) + castle && castle->GetRace() == troop._monster.GetRace() && castle->isBuild( + troop._monster.GetUpgrade().GetDwelling())) { flags |= Dialog::UPGRADE; diff --git a/src/fheroes2/army/army_troop.cpp b/src/fheroes2/army/army_troop.cpp index 14a1dc8..61876ae 100644 --- a/src/fheroes2/army/army_troop.cpp +++ b/src/fheroes2/army/army_troop.cpp @@ -68,7 +68,7 @@ void Troop::Set(const Monster& m, uint32_t c) void Troop::SetMonster(const Monster& m) { - _monster.id = m.GetID(); + _monster.id = m.GetID(); } void Troop::SetCount(uint32_t c) @@ -78,7 +78,7 @@ void Troop::SetCount(uint32_t c) void Troop::Reset() { - _monster.id = Monster::UNKNOWN; + _monster.id = Monster::UNKNOWN; count = 0; } diff --git a/src/fheroes2/battle/battle_action.cpp b/src/fheroes2/battle/battle_action.cpp index 842cb00..b82536c 100644 --- a/src/fheroes2/battle/battle_action.cpp +++ b/src/fheroes2/battle/battle_action.cpp @@ -581,8 +581,8 @@ Battle::TargetsInfo Battle::Arena::GetTargetsForSpells(const HeroBase* hero, con // unique targets._items.resize( - distance(targets._items.begin(), - unique(targets._items.begin(), targets._items.end()))); + distance(targets._items.begin(), + unique(targets._items.begin(), targets._items.end()))); } break; @@ -612,7 +612,8 @@ Battle::TargetsInfo Battle::Arena::GetTargetsForSpells(const HeroBase* hero, con } // unique - targets._items.resize(distance(targets._items.begin(), unique(targets._items.begin(), targets._items.end()))); + targets._items.resize(distance(targets._items.begin(), + unique(targets._items.begin(), targets._items.end()))); } break; @@ -769,11 +770,11 @@ void Battle::Arena::ApplyActionSpellMirrorImage(Command& cmd) auto center = b->GetHeadIndex(); return Board::GetDistance(center, index1) < Board::GetDistance(center, index2); }; - + sort(distances.begin(), distances.end(), SortingDistance); - const auto it = find_if(distances.begin(), distances.end(), - [&](s32 dist) {return Board::isValidMirrorImageIndex(dist, b); }); + const auto it = find_if(distances.begin(), distances.end(), + [&](s32 dist) { return Board::isValidMirrorImageIndex(dist, b); }); for (auto& distance : distances) { diff --git a/src/fheroes2/battle/battle_arena.cpp b/src/fheroes2/battle/battle_arena.cpp index 913b86d..f315514 100644 --- a/src/fheroes2/battle/battle_arena.cpp +++ b/src/fheroes2/battle/battle_arena.cpp @@ -227,10 +227,10 @@ Battle::Arena::Arena(Army& a1, Army& a2, s32 index, bool local) : interface = std::make_unique(*this, index); board.SetArea(interface->GetArea()); - for_each(army1->_items.begin(), army1->_items.end(), - [](Unit* it ) { it->InitContours(); }); + for_each(army1->_items.begin(), army1->_items.end(), + [](Unit* it) { it->InitContours(); }); for_each(army2->_items.begin(), army2->_items.end(), - [](Unit* it) { it->InitContours(); }); + [](Unit* it) { it->InitContours(); }); if (conf.Sound()) AGG::PlaySound(M82::PREBATTL); @@ -606,20 +606,19 @@ int Battle::Arena::GetOppositeColor(int col) const Battle::Unit* Battle::Arena::GetTroopUID(uint32_t uid) { auto it = find_if(army1->_items.begin(), army1->_items.end(), - [uid](const Unit *it) - { - return it->isUID(uid); - }); - + [uid](const Unit* it) + { + return it->isUID(uid); + }); + if (it != army1->_items.end()) return *it; it = find_if(army2->_items.begin(), army2->_items.end(), - [uid](const Unit *it) - { - return it->isUID(uid); - }); - + [uid](const Unit* it) + { + return it->isUID(uid); + }); return it != army2->_items.end() ? *it : nullptr; @@ -628,18 +627,18 @@ Battle::Unit* Battle::Arena::GetTroopUID(uint32_t uid) const Battle::Unit* Battle::Arena::GetTroopUID(uint32_t uid) const { auto it = find_if(army1->_items.begin(), army1->_items.end(), - [uid](const Unit *it) - { - return it->isUID(uid); - }); + [uid](const Unit* it) + { + return it->isUID(uid); + }); - if (it != army1->_items.end()) return *it; + if (it != army1->_items.end()) return *it; it = find_if(army2->_items.begin(), army2->_items.end(), - [uid](const Unit *it) - { - return it->isUID(uid); - }); + [uid](const Unit* it) + { + return it->isUID(uid); + }); return it != army2->_items.end() ? *it : nullptr; @@ -901,7 +900,7 @@ uint32_t Battle::Arena::GetCastleTargetValue(int target) const std::vector Battle::Arena::GetCastleTargets() const { - std::vector targets; + std::vector targets; targets.reserve(8); // check walls diff --git a/src/fheroes2/battle/battle_army.cpp b/src/fheroes2/battle/battle_army.cpp index a91fb14..5332e35 100644 --- a/src/fheroes2/battle/battle_army.cpp +++ b/src/fheroes2/battle/battle_army.cpp @@ -313,7 +313,7 @@ void Battle::Force::NewTurn() GetCommander()->ResetModes(Heroes::SPELLCASTED); for_each(_items.begin(), _items.end(), - [&](Unit* it) { it->NewTurn(); }); + [&](Unit* it) { it->NewTurn(); }); } bool isUnitFirst(const Battle::Unit* last, bool part1, int army2_color) diff --git a/src/fheroes2/battle/battle_board.cpp b/src/fheroes2/battle/battle_board.cpp index ebbf1dd..c7641bd 100644 --- a/src/fheroes2/battle/battle_board.cpp +++ b/src/fheroes2/battle/battle_board.cpp @@ -79,7 +79,7 @@ Rect Battle::Board::GetArea() const void Battle::Board::Reset() { - for_each(_items.begin(), _items.end(), [](Cell& it) { it.ResetQuality(); }); + for_each(_items.begin(), _items.end(), [](Cell& it) { it.ResetQuality(); }); for_each(_items.begin(), _items.end(), [](Cell& it) { it.ResetDirection(); }); } @@ -135,7 +135,7 @@ s32 Battle::Board::GetDistance(s32 index1, s32 index2) void Battle::Board::SetScanPassability(const Unit& b) { - for_each(_items.begin(), _items.end(), [](Cell& it) { it.ResetDirection(); }); + for_each(_items.begin(), _items.end(), [](Cell& it) { it.ResetDirection(); }); _items.at(b.GetHeadIndex()).SetDirection(CENTER); @@ -326,7 +326,7 @@ Battle::Indexes Battle::Board::GetPassableQualityPositions(const Unit& b) return result; } -bool IndexDistanceEqualDistance(const IndexDistance& id, uint32_t dist) +bool IndexDistanceEqualDistance(const IndexDistance& id, uint32_t dist) { return id.second == dist; } @@ -354,10 +354,10 @@ Battle::Indexes Battle::Board::GetNearestTroopIndexes(s32 pos, const Indexes* bl { sort(dists.begin(), dists.end(), IndexDistance::Shortest); dists.resize(count_if(dists.begin(), dists.end(), - [=](const IndexDistance&it) - { - return IndexDistanceEqualDistance(it, dists.front().second); - })); + [=](const IndexDistance& it) + { + return IndexDistanceEqualDistance(it, dists.front().second); + })); } if (!dists.empty()) diff --git a/src/fheroes2/battle/battle_cell.cpp b/src/fheroes2/battle/battle_cell.cpp index 64c0a9e..90dab94 100644 --- a/src/fheroes2/battle/battle_cell.cpp +++ b/src/fheroes2/battle/battle_cell.cpp @@ -115,9 +115,9 @@ bool Battle::Position::isValid() const Battle::Cell::Cell() : index(0), object(0), direction(UNKNOWN), quality(0), troop(nullptr) { - for(auto& cell:coord) + for (auto& cell : coord) { - cell = Point{}; + cell = Point{}; } } diff --git a/src/fheroes2/battle/battle_command.cpp b/src/fheroes2/battle/battle_command.cpp index 251bc83..db259e7 100644 --- a/src/fheroes2/battle/battle_command.cpp +++ b/src/fheroes2/battle/battle_command.cpp @@ -28,8 +28,8 @@ bool Battle::Actions::HaveCommand(uint32_t cmd) const { - return end() != find_if(begin(), end(), - [&](const Command& it) { return it.isType(cmd); }); + return end() != find_if(begin(), end(), + [&](const Command& it) { return it.isType(cmd); }); } Battle::Command::Command(int cmd) : type(cmd) @@ -38,7 +38,7 @@ Battle::Command::Command(int cmd) : type(cmd) Battle::Command& Battle::Command::operator<<(const int& val) { - _items.push_back(val); + _items.push_back(val); return *this; } @@ -47,7 +47,7 @@ Battle::Command& Battle::Command::operator>>(int& val) if (!_items.empty()) { val = _items.back(); - _items.pop_back(); + _items.pop_back(); } return *this; } diff --git a/src/fheroes2/battle/battle_dialogs.cpp b/src/fheroes2/battle/battle_dialogs.cpp index 6106b3e..4b02149 100644 --- a/src/fheroes2/battle/battle_dialogs.cpp +++ b/src/fheroes2/battle/battle_dialogs.cpp @@ -485,20 +485,22 @@ int Battle::Arena::DialogBattleHero(const HeroBase& hero, bool buttons) const if (le.MousePressRight(btnCast)) Message(_("Cast Spell"), - _("Cast a magical spell. You may only cast one spell per combat round. The round is reset when every creature has had a turn" - ), - Font::BIG); + _( + "Cast a magical spell. You may only cast one spell per combat round. The round is reset when every creature has had a turn" + ), + Font::BIG); else if (le.MousePressRight(btnRetreat)) Message(_("Retreat"), - _( - "Retreat your hero, abandoning your creatures. Your hero will be available for you to recruit again, however, the hero will have only a novice hero's forces." - ), - Font::BIG); + _( + "Retreat your hero, abandoning your creatures. Your hero will be available for you to recruit again, however, the hero will have only a novice hero's forces." + ), + Font::BIG); else if (le.MousePressRight(btnSurrender)) Message(_("Surrender"), - _("Surrendering costs gold. However if you pay the ransom, the hero and all of his or her surviving creatures will be available to recruit again." - ), - Font::BIG); + _( + "Surrendering costs gold. However if you pay the ransom, the hero and all of his or her surviving creatures will be available to recruit again." + ), + Font::BIG); else if (le.MousePressRight(btnClose)) Message(_("Cancel"), _("Return to the battle."), Font::BIG); diff --git a/src/fheroes2/battle/battle_interface.cpp b/src/fheroes2/battle/battle_interface.cpp index 2a38922..bc36d72 100644 --- a/src/fheroes2/battle/battle_interface.cpp +++ b/src/fheroes2/battle/battle_interface.cpp @@ -633,8 +633,8 @@ Battle::Status::Status() : back1(AGG::GetICN(ICN::TEXTBAR, 8)), back2(AGG::GetIC void Battle::Status::SetPosition(s32 cx, s32 cy) { - x = cx; - y = cy; + x = cx; + y = cy; } void Battle::Status::SetMessage(const string& str, bool top) @@ -742,7 +742,7 @@ void Battle::ArmiesOrder::Redraw(const Unit* current) const uint32_t ow = ARMYORDERW + 2; uint32_t ox = area.x + (area.w - ow * count_if(orders->_items.begin(), orders->_items.end(), - [&](const Unit* it) { return it->isValid(); })) / 2; + [&](const Unit* it) { return it->isValid(); })) / 2; uint32_t oy = area.y; x = ox; @@ -1270,7 +1270,7 @@ void Battle::Interface::RedrawCoverStatic(Surface& dst) const void Battle::Interface::RedrawCastle1(const Castle& castle, Surface& dst) const { - const Point& topleft = border.GetArea(); + const Point& topleft = border.GetArea(); const bool fortification = Race::KNGT == castle.GetRace() && castle.isBuild(BUILD_SPEC); int icn_castbkg; @@ -1446,8 +1446,8 @@ void Battle::Interface::RedrawCastle3(const Castle& castle) const void Battle::Interface::RedrawLowObjects(s32 cell_index, Surface& dst) { const Cell* cell = Board::GetCell(cell_index); - if (!cell) - return; + if (!cell) + return; Sprite sprite; switch (cell->GetObject()) @@ -1481,106 +1481,106 @@ void Battle::Interface::RedrawLowObjects(s32 cell_index, Surface& dst) void Battle::Interface::RedrawHighObjects(s32 cell_index) { - const Cell* cell = Board::GetCell(cell_index); - - if (!cell) - return; - - Sprite sprite; - - switch (cell->GetObject()) - { - case 0x80: - sprite = AGG::GetICN(ICN::COBJ0000, 0); - break; - case 0x81: - sprite = AGG::GetICN(ICN::COBJ0001, 0); - break; - case 0x82: - sprite = AGG::GetICN(ICN::COBJ0002, 0); - break; - case 0x83: - sprite = AGG::GetICN(ICN::COBJ0003, 0); - break; - case 0x85: - sprite = AGG::GetICN(ICN::COBJ0005, 0); - break; - case 0x86: - sprite = AGG::GetICN(ICN::COBJ0006, 0); - break; - case 0x88: - sprite = AGG::GetICN(ICN::COBJ0008, 0); - break; - case 0x89: - sprite = AGG::GetICN(ICN::COBJ0009, 0); - break; - case 0x8A: - sprite = AGG::GetICN(ICN::COBJ0010, 0); - break; - case 0x8B: - sprite = AGG::GetICN(ICN::COBJ0011, 0); - break; - case 0x8C: - sprite = AGG::GetICN(ICN::COBJ0012, 0); - break; - case 0x8D: - sprite = AGG::GetICN(ICN::COBJ0013, 0); - break; - case 0x8E: - sprite = AGG::GetICN(ICN::COBJ0014, 0); - break; - case 0x8F: - sprite = AGG::GetICN(ICN::COBJ0015, 0); - break; - case 0x91: - sprite = AGG::GetICN(ICN::COBJ0017, 0); - break; - case 0x92: - sprite = AGG::GetICN(ICN::COBJ0018, 0); - break; - case 0x93: - sprite = AGG::GetICN(ICN::COBJ0019, 0); - break; - case 0x94: - sprite = AGG::GetICN(ICN::COBJ0020, 0); - break; - case 0x95: - sprite = AGG::GetICN(ICN::COBJ0021, 0); - break; - case 0x96: - sprite = AGG::GetICN(ICN::COBJ0022, 0); - break; - case 0x97: - sprite = AGG::GetICN(ICN::COBJ0023, 0); - break; - case 0x98: - sprite = AGG::GetICN(ICN::COBJ0024, 0); - break; - case 0x99: - sprite = AGG::GetICN(ICN::COBJ0025, 0); - break; - case 0x9A: - sprite = AGG::GetICN(ICN::COBJ0026, 0); - break; - case 0x9B: - sprite = AGG::GetICN(ICN::COBJ0027, 0); - break; - case 0x9C: - sprite = AGG::GetICN(ICN::COBJ0028, 0); - break; - case 0x9D: - sprite = AGG::GetICN(ICN::COBJ0029, 0); - break; - default: - break; - } - - if (sprite.isValid()) - { - //const Point & topleft = border.GetArea(); - const Rect& pt = cell->GetPos(); - sprite.Blit(pt.x + pt.w / 2 + sprite.x(), pt.y + pt.h + sprite.y() - 10); - } + const Cell* cell = Board::GetCell(cell_index); + + if (!cell) + return; + + Sprite sprite; + + switch (cell->GetObject()) + { + case 0x80: + sprite = AGG::GetICN(ICN::COBJ0000, 0); + break; + case 0x81: + sprite = AGG::GetICN(ICN::COBJ0001, 0); + break; + case 0x82: + sprite = AGG::GetICN(ICN::COBJ0002, 0); + break; + case 0x83: + sprite = AGG::GetICN(ICN::COBJ0003, 0); + break; + case 0x85: + sprite = AGG::GetICN(ICN::COBJ0005, 0); + break; + case 0x86: + sprite = AGG::GetICN(ICN::COBJ0006, 0); + break; + case 0x88: + sprite = AGG::GetICN(ICN::COBJ0008, 0); + break; + case 0x89: + sprite = AGG::GetICN(ICN::COBJ0009, 0); + break; + case 0x8A: + sprite = AGG::GetICN(ICN::COBJ0010, 0); + break; + case 0x8B: + sprite = AGG::GetICN(ICN::COBJ0011, 0); + break; + case 0x8C: + sprite = AGG::GetICN(ICN::COBJ0012, 0); + break; + case 0x8D: + sprite = AGG::GetICN(ICN::COBJ0013, 0); + break; + case 0x8E: + sprite = AGG::GetICN(ICN::COBJ0014, 0); + break; + case 0x8F: + sprite = AGG::GetICN(ICN::COBJ0015, 0); + break; + case 0x91: + sprite = AGG::GetICN(ICN::COBJ0017, 0); + break; + case 0x92: + sprite = AGG::GetICN(ICN::COBJ0018, 0); + break; + case 0x93: + sprite = AGG::GetICN(ICN::COBJ0019, 0); + break; + case 0x94: + sprite = AGG::GetICN(ICN::COBJ0020, 0); + break; + case 0x95: + sprite = AGG::GetICN(ICN::COBJ0021, 0); + break; + case 0x96: + sprite = AGG::GetICN(ICN::COBJ0022, 0); + break; + case 0x97: + sprite = AGG::GetICN(ICN::COBJ0023, 0); + break; + case 0x98: + sprite = AGG::GetICN(ICN::COBJ0024, 0); + break; + case 0x99: + sprite = AGG::GetICN(ICN::COBJ0025, 0); + break; + case 0x9A: + sprite = AGG::GetICN(ICN::COBJ0026, 0); + break; + case 0x9B: + sprite = AGG::GetICN(ICN::COBJ0027, 0); + break; + case 0x9C: + sprite = AGG::GetICN(ICN::COBJ0028, 0); + break; + case 0x9D: + sprite = AGG::GetICN(ICN::COBJ0029, 0); + break; + default: + break; + } + + if (sprite.isValid()) + { + //const Point & topleft = border.GetArea(); + const Rect& pt = cell->GetPos(); + sprite.Blit(pt.x + pt.w / 2 + sprite.x(), pt.y + pt.h + sprite.y() - 10); + } } void Battle::Interface::RedrawKilled() const @@ -2635,8 +2635,8 @@ void Battle::Interface::RedrawActionWincesKills(TargetsInfo& targets) // targets damage animation loop while (le.HandleEvents() && finish != count_if(targets._items.begin(), targets._items.end(), - [](TargetInfo&it) {return it.isFinishAnimFrame(); } - )) + [](TargetInfo& it) { return it.isFinishAnimFrame(); } + )) { CheckGlobalEvents(le); @@ -4238,7 +4238,8 @@ void Battle::Interface::RedrawTargetsWithFrameAnimation(const TargetsInfo& targe } const Sprite& sprite = AGG::GetICN(icn, frame, reflect); - const Point offset = RedrawTroopWithFrameAnimationOffset(icn, pos, sprite, target.defender->_monster.isWide(), + const Point offset = RedrawTroopWithFrameAnimationOffset(icn, pos, sprite, + target.defender->_monster.isWide(), reflect, false); const Point sprite_pos(offset.x + (reflect ? 0 : pos.w / 2), offset.y); @@ -4531,12 +4532,12 @@ Battle::PopupDamageInfo::PopupDamageInfo() : FrameBorder(5), cell(nullptr), atta void Battle::PopupDamageInfo::SetInfo(const Cell* c, const Unit* a, const Unit* b) { - if(!c || cell==c) + if (!c || cell == c) + return; + if (!a || attacker == a) + return; + if (!b || defender == b) return; - if (!a || attacker == a) - return; - if (!b || defender == b) - return; if (!Settings::Get().ExtBattleShowDamage() || !Battle::AnimateInfrequentDelay(Game::BATTLE_POPUP_DELAY)) return; redraw = true; diff --git a/src/fheroes2/battle/battle_troop.cpp b/src/fheroes2/battle/battle_troop.cpp index 8020d41..2afe74f 100644 --- a/src/fheroes2/battle/battle_troop.cpp +++ b/src/fheroes2/battle/battle_troop.cpp @@ -384,22 +384,22 @@ void Battle::ModeDuration::DecreaseDuration() Battle::ModesAffected::ModesAffected() { - _items.reserve(3); + _items.reserve(3); } uint32_t Battle::ModesAffected::GetMode(uint32_t mode) const { - const auto it = find_if(_items.begin(), _items.end(), - [&](const ModeDuration& it) { return it.isMode(mode); }); + const auto it = find_if(_items.begin(), _items.end(), + [&](const ModeDuration& it) { return it.isMode(mode); }); return it == _items.end() ? 0 : (*it).second; } void Battle::ModesAffected::AddMode(uint32_t mode, uint32_t duration) { auto it = find_if(_items.begin(), _items.end(), - [&](const ModeDuration& it) { return it.isMode(mode); }); + [&](const ModeDuration& it) { return it.isMode(mode); }); if (it == _items.end()) - _items.emplace_back(mode, duration); + _items.emplace_back(mode, duration); else (*it).second = duration; } @@ -407,23 +407,23 @@ void Battle::ModesAffected::AddMode(uint32_t mode, uint32_t duration) void Battle::ModesAffected::RemoveMode(uint32_t mode) { auto it = find_if(_items.begin(), _items.end(), - [&](const ModeDuration& it) { return it.isMode(mode); }); + [&](const ModeDuration& it) { return it.isMode(mode); }); if (it != _items.end()) { // erase(it) if (it + 1 != _items.end()) std::swap(*it, _items.back()); - _items.pop_back(); + _items.pop_back(); } } void Battle::ModesAffected::DecreaseDuration() { - for_each(_items.begin(), _items.end(), [](ModeDuration&it) { it.DecreaseDuration(); }); + for_each(_items.begin(), _items.end(), [](ModeDuration& it) { it.DecreaseDuration(); }); } uint32_t Battle::ModesAffected::FindZeroDuration() const { - auto it = find_if(_items.begin(), _items.end(), [](const ModeDuration&it) {return it.isZeroDuration(); }); + auto it = find_if(_items.begin(), _items.end(), [](const ModeDuration& it) { return it.isZeroDuration(); }); return it == _items.end() ? 0 : (*it).first; } @@ -710,7 +710,7 @@ bool Battle::Unit::isReflect() const bool Battle::Unit::OutOfWalls() const { return Board::isOutOfWallsIndex(GetHeadIndex()) || - _monster.isWide() && Board::isOutOfWallsIndex(GetTailIndex()); + _monster.isWide() && Board::isOutOfWallsIndex(GetTailIndex()); } bool Battle::Unit::isHandFighting() const @@ -988,7 +988,7 @@ void Battle::Unit::PostKilledAction() uint32_t Battle::Unit::Resurrect(uint32_t points, bool allow_overflow, bool skip_dead) { - int resurrect = Monster::GetCountFromHitPoints(this->_monster, hp + points); + int resurrect = Monster::GetCountFromHitPoints(this->_monster, hp + points); SetCount(GetCount() + resurrect); hp += points; @@ -1839,7 +1839,7 @@ uint32_t Battle::Unit::GetMagicResist(const Spell& spell, uint32_t spower) const return 100; if (spell.isALiveOnly() && - _monster.isUndead()) + _monster.isUndead()) return 100; if (spell.isUndeadOnly() && diff --git a/src/fheroes2/castle/castle.cpp b/src/fheroes2/castle/castle.cpp index 236750a..f09d595 100644 --- a/src/fheroes2/castle/castle.cpp +++ b/src/fheroes2/castle/castle.cpp @@ -367,30 +367,31 @@ void Castle::ActionNewDay() uint32_t* Castle::GetDwelling(uint32_t dw) { - if (isBuild(dw)) - switch (dw) - { - case DWELLING_MONSTER1: - return &dwelling[0]; - case DWELLING_MONSTER2: - case DWELLING_UPGRADE2: - return &dwelling[1]; - case DWELLING_MONSTER3: - case DWELLING_UPGRADE3: - return &dwelling[2]; - case DWELLING_MONSTER4: - case DWELLING_UPGRADE4: - return &dwelling[3]; - case DWELLING_MONSTER5: - case DWELLING_UPGRADE5: - return &dwelling[4]; - case DWELLING_MONSTER6: - case DWELLING_UPGRADE6: - case DWELLING_UPGRADE7: - return &dwelling[5]; - default: - break; - } + if (!isBuild(dw)) + return nullptr; + switch (dw) + { + case DWELLING_MONSTER1: + return &dwelling[0]; + case DWELLING_MONSTER2: + case DWELLING_UPGRADE2: + return &dwelling[1]; + case DWELLING_MONSTER3: + case DWELLING_UPGRADE3: + return &dwelling[2]; + case DWELLING_MONSTER4: + case DWELLING_UPGRADE4: + return &dwelling[3]; + case DWELLING_MONSTER5: + case DWELLING_UPGRADE5: + return &dwelling[4]; + case DWELLING_MONSTER6: + case DWELLING_UPGRADE6: + case DWELLING_UPGRADE7: + return &dwelling[5]; + default: + break; + } return nullptr; } @@ -670,7 +671,8 @@ string Castle::GetStringBuilding(uint32_t build, int race) string Castle::GetDescriptionBuilding(uint32_t build, int race) { string desc_build[] = { - _("The Thieves' Guild provides information on enemy players. Thieves' Guilds can also provide scouting information on enemy towns." + _( + "The Thieves' Guild provides information on enemy players. Thieves' Guilds can also provide scouting information on enemy towns." ), _("The Tavern increases morale for troops defending the castle."), _("The Shipyard allows ships to be built."), @@ -678,9 +680,11 @@ string Castle::GetDescriptionBuilding(uint32_t build, int race) _("The Statue increases your town's income by %{count} per day."), _("The Left Turret provides extra firepower during castle combat."), _("The Right Turret provides extra firepower during castle combat."), - _("The Marketplace can be used to convert one type of resource into another. The more marketplaces you control, the better the exchange rate." + _( + "The Marketplace can be used to convert one type of resource into another. The more marketplaces you control, the better the exchange rate." ), - _("The Moat slows attacking units. Any unit entering the moat must end its turn there and becomes more vulnerable to attack." + _( + "The Moat slows attacking units. Any unit entering the moat must end its turn there and becomes more vulnerable to attack." ), _("The Castle improves town defense and increases income to %{count} gold per day."), _("The Tent provides workers to build a castle, provided the materials and the gold are available."), @@ -698,7 +702,8 @@ string Castle::GetDescriptionBuilding(uint32_t build, int race) }; string desc_spec[] = { - _("The Fortifications increase the toughness of the walls, increasing the number of turns it takes to knock them down." + _( + "The Fortifications increase the toughness of the walls, increasing the number of turns it takes to knock them down." ), _("The Coliseum provides inspiring spectacles to defending troops, raising their morale by two during combat."), _("The Rainbow increases the luck of the defending units by two."), @@ -2512,7 +2517,7 @@ void VecCastles::ChangeColors(int col1, int col2) AllCastles::AllCastles() { // reserve memory - _items.reserve(MAXCASTLES); + _items.reserve(MAXCASTLES); } AllCastles::~AllCastles() @@ -2530,7 +2535,7 @@ void AllCastles::clear() { for (auto& it : _items) delete it; - _items.clear(); + _items.clear(); } void AllCastles::Scoute(int colors) const diff --git a/src/fheroes2/castle/castle_building.cpp b/src/fheroes2/castle/castle_building.cpp index 3f86b66..0d6557f 100644 --- a/src/fheroes2/castle/castle_building.cpp +++ b/src/fheroes2/castle/castle_building.cpp @@ -64,7 +64,7 @@ CastleDialog::CacheBuildings::CacheBuildings(const Castle& castle, const Point& for (vector::const_iterator it = ordersBuildings.begin(); it != ordersBuildings.end(); ++it) { - _items.emplace_back(*it, CastleGetCoordBuilding(castle.GetRace(), *it, top)); + _items.emplace_back(*it, CastleGetCoordBuilding(castle.GetRace(), *it, top)); } } @@ -194,16 +194,16 @@ void CastleRedrawCurrentBuilding(const Castle& castle, const Point& dst_pt, for (const auto& order : orders._items) { if (!castle.isBuild(order.id)) - continue; - CastleRedrawBuilding(castle, dst_pt, order.id, frame, 0); - - if (flash == order.id) - { - CastleDialog::RedrawBuildingSpriteToArea(order.contour, - dst_pt.x + order.contour.x(), dst_pt.y + order.contour.y(), - max); - } - CastleRedrawBuildingExtended(castle, dst_pt, order.id, frame); + continue; + CastleRedrawBuilding(castle, dst_pt, order.id, frame, 0); + + if (flash == order.id) + { + CastleDialog::RedrawBuildingSpriteToArea(order.contour, + dst_pt.x + order.contour.x(), dst_pt.y + order.contour.y(), + max); + } + CastleRedrawBuildingExtended(castle, dst_pt, order.id, frame); } } // redraw build with alpha diff --git a/src/fheroes2/castle/castle_dialog.cpp b/src/fheroes2/castle/castle_dialog.cpp index 3d4e454..1f3a1ce 100644 --- a/src/fheroes2/castle/castle_dialog.cpp +++ b/src/fheroes2/castle/castle_dialog.cpp @@ -490,16 +490,16 @@ int Castle::OpenDialog(bool readonly, bool fade) for (auto it = cacheBuildings._items.rbegin(); it != cacheBuildings._items.rend(); ++it) { if ((*it).id != GetActualDwelling((*it).id) || !isBuild((*it).id)) - continue; - if (!readonly && le.MouseClickLeft((*it).coord) && - RecruitMonster(Dialog::RecruitMonster( - Monster(race, GetActualDwelling((*it).id)), GetDwellingLivedCount((*it).id), true))) - need_redraw = true; - else if (le.MousePressRight((*it).coord)) - Dialog::DwellingInfo(Monster(race, GetActualDwelling((*it).id)), GetDwellingLivedCount((*it).id)); - - if (le.MouseCursor((*it).coord)) - msg_status = Monster(race, (*it).id).GetName(); + continue; + if (!readonly && le.MouseClickLeft((*it).coord) && + RecruitMonster(Dialog::RecruitMonster( + Monster(race, GetActualDwelling((*it).id)), GetDwellingLivedCount((*it).id), true))) + need_redraw = true; + else if (le.MousePressRight((*it).coord)) + Dialog::DwellingInfo(Monster(race, GetActualDwelling((*it).id)), GetDwellingLivedCount((*it).id)); + + if (le.MouseCursor((*it).coord)) + msg_status = Monster(race, (*it).id).GetName(); } for (auto it = cacheBuildings._items.begin(); it != cacheBuildings._items.end(); ++it) diff --git a/src/fheroes2/castle/castle_town.cpp b/src/fheroes2/castle/castle_town.cpp index beb5912..9ca49fd 100644 --- a/src/fheroes2/castle/castle_town.cpp +++ b/src/fheroes2/castle/castle_town.cpp @@ -290,7 +290,8 @@ uint32_t Castle::OpenTown() const Rect rectGroupedArmyFormat(cur_pt.x + 585, cur_pt.y + 220, spriteGroupedArmyFormat.w(), spriteGroupedArmyFormat.h()); const string descriptionSpreadArmyFormat( - _("'Spread' combat formation spreads your armies from the top to the bottom of the battlefield, with at least one empty space between each army." + _( + "'Spread' combat formation spreads your armies from the top to the bottom of the battlefield, with at least one empty space between each army." )); const string descriptionGroupedArmyFormat( _("'Grouped' combat formation bunches your army toget her in the center of your side of the battlefield.")); diff --git a/src/fheroes2/castle/castle_well.cpp b/src/fheroes2/castle/castle_well.cpp index 791c848..46ae68d 100644 --- a/src/fheroes2/castle/castle_well.cpp +++ b/src/fheroes2/castle/castle_well.cpp @@ -45,12 +45,13 @@ struct dwelling_t : pair } }; -struct dwellings_t +struct dwellings_t { - vector _items; + vector _items; + dwellings_t() { - _items.reserve(6); + _items.reserve(6); } }; @@ -170,7 +171,7 @@ void Castle::OpenWell() { for (auto& dw : results._items) { - RecruitMonsterFromDwelling(dw.first, dw.second); + RecruitMonsterFromDwelling(dw.first, dw.second); } redraw = true; } diff --git a/src/fheroes2/dialog/dialog_levelup.cpp b/src/fheroes2/dialog/dialog_levelup.cpp index 7aca2d6..8cbed4d 100644 --- a/src/fheroes2/dialog/dialog_levelup.cpp +++ b/src/fheroes2/dialog/dialog_levelup.cpp @@ -70,7 +70,7 @@ Skill::SkillT DialogOneSecondary(const string& name, const string& primary, cons } Skill::SkillT DialogSelectSecondary(const string& name, const string& primary, const Skill::Secondary& sec1, - const Skill::Secondary& sec2, Heroes& hero) + const Skill::Secondary& sec2, Heroes& hero) { string header = _("%{name} has gained a level."); header.append("\n \n"); @@ -217,7 +217,7 @@ Skill::SkillT DialogSelectSecondary(const string& name, const string& primary, c } Skill::SkillT Dialog::LevelUpSelectSkill(const string& name, const string& primary, const Skill::Secondary& sec1, - const Skill::Secondary& sec2, Heroes& hero) + const Skill::Secondary& sec2, Heroes& hero) { Skill::SkillT result = Skill::SkillT::UNKNOWN; diff --git a/src/fheroes2/dialog/dialog_marketplace.cpp b/src/fheroes2/dialog/dialog_marketplace.cpp index dce5051..9e74f96 100644 --- a/src/fheroes2/dialog/dialog_marketplace.cpp +++ b/src/fheroes2/dialog/dialog_marketplace.cpp @@ -65,7 +65,8 @@ class TradeWindowGUI splitter.HideCursor(); TextBox( - _("Please inspect our fine wares. If you feel like offering a trade, click on the items you wish to trade with and for." + _( + "Please inspect our fine wares. If you feel like offering a trade, click on the items you wish to trade with and for." ), Font::BIG, Rect(pos_rt.x, pos_rt.y + 30, pos_rt.w, 100)); @@ -111,7 +112,8 @@ void TradeWindowGUI::ShowTradeArea(int resourceFrom, int resourceTo, uint32_t ma back.Restore(); Rect dst_rt(pos_rt.x, pos_rt.y + 30, pos_rt.w, 100); TextBox( - _("You have received quite a bargain. I expect to make no profit on the deal. Can I interest you in any of my other wares?" + _( + "You have received quite a bargain. I expect to make no profit on the deal. Can I interest you in any of my other wares?" ), Font::BIG, dst_rt); buttonGift.SetDisable(false); diff --git a/src/fheroes2/dialog/dialog_selectfile.cpp b/src/fheroes2/dialog/dialog_selectfile.cpp index 6ac3db5..ac38237 100644 --- a/src/fheroes2/dialog/dialog_selectfile.cpp +++ b/src/fheroes2/dialog/dialog_selectfile.cpp @@ -160,7 +160,7 @@ Maps::MapsFileInfoList GetSortedMapsFileInfoList() ListFiles list1; list1.ReadDir(Settings::GetSaveDir(), ".sav", false); - Maps::MapsFileInfoList list2(list1.size()); + Maps::MapsFileInfoList list2(list1.size()); int ii = 0; for (auto itd = list1.begin(); itd != list1.end(); ++itd, ++ii) if (!list2[ii].ReadSAV(*itd))--ii; @@ -213,7 +213,7 @@ string SelectFileListSimple(const string& header, const string& lastfile, bool e bool edit_mode = false; - Maps::MapsFileInfoList lists = GetSortedMapsFileInfoList(); + Maps::MapsFileInfoList lists = GetSortedMapsFileInfoList(); FileInfoListBox listbox(rt, edit_mode); listbox.RedrawBackground(rt); diff --git a/src/fheroes2/dialog/dialog_selectitems.cpp b/src/fheroes2/dialog/dialog_selectitems.cpp index ff89300..35778c3 100644 --- a/src/fheroes2/dialog/dialog_selectitems.cpp +++ b/src/fheroes2/dialog/dialog_selectitems.cpp @@ -207,7 +207,7 @@ class SelectEnumSecSkill : public SelectEnum void RedrawItem(const int& index, s32 dstx, s32 dsty, bool current) { - Skill::Secondary skill(static_cast < Skill::SkillT>(1 + index / 3), 1 + index % 3); + Skill::Secondary skill(static_cast(1 + index / 3), 1 + index % 3); AGG::GetICN(ICN::MINISS, skill.GetIndexSprite2()).Blit(dstx + 5, dsty + 3); string str = skill.GetName(); Text text(str, (current ? Font::YELLOW_BIG : Font::BIG)); diff --git a/src/fheroes2/dialog/dialog_selectscenario.cpp b/src/fheroes2/dialog/dialog_selectscenario.cpp index 0eb1fb6..7a5b7cf 100644 --- a/src/fheroes2/dialog/dialog_selectscenario.cpp +++ b/src/fheroes2/dialog/dialog_selectscenario.cpp @@ -306,7 +306,7 @@ const FileInfo* Dialog::SelectScenario(const MapsFileInfoList& all) cursor.Hide(); } else if ((le.MouseClickLeft(buttonSelectXLarge) || le.KeyPress(KEY_x)) && - buttonSelectXLarge.isEnable() ) + buttonSelectXLarge.isEnable()) { listbox.SetListContent(xlarge); cursor.Hide(); @@ -330,12 +330,14 @@ const FileInfo* Dialog::SelectScenario(const MapsFileInfoList& all) Message(_("All Maps"), _("View all maps, regardless of size."), Font::BIG); else if (le.MousePressRight(countPlayers) || le.MousePressRight(curCountPlayer)) Message(_("Players Icon"), - _("Indicates how many players total are in the EditScenario. Any positions not occupied by humans will be occupied by computer players." + _( + "Indicates how many players total are in the EditScenario. Any positions not occupied by humans will be occupied by computer players." ), Font::BIG); else if (le.MousePressRight(sizeMaps) || le.MousePressRight(curMapSize)) Message(_("Size Icon"), - _("Indicates whether the maps is small (36x36), medium (72x72), large (108x108), or extra large (144x144)." + _( + "Indicates whether the maps is small (36x36), medium (72x72), large (108x108), or extra large (144x144)." ), Font::BIG); else if (le.MousePressRight(curMapName)) diff --git a/src/fheroes2/dialog/dialog_thievesguild.cpp b/src/fheroes2/dialog/dialog_thievesguild.cpp index 8ad451f..79d192f 100644 --- a/src/fheroes2/dialog/dialog_thievesguild.cpp +++ b/src/fheroes2/dialog/dialog_thievesguild.cpp @@ -46,6 +46,7 @@ struct ValueColors : pair { return v == first; } + //bool IsColor(int c) const { return (c & second); }; static bool SortValueGreat(const ValueColors& v1, const ValueColors& v2) @@ -57,8 +58,8 @@ struct ValueColors : pair void UpdateValuesColors(vector& v, int value, int color) { const auto it = - find_if(v.begin(), v.end(), - [&](const ValueColors& it) { return it.IsValue(value); }); + find_if(v.begin(), v.end(), + [&](const ValueColors& it) { return it.IsValue(value); }); if (it == v.end()) v.emplace_back(value, color); @@ -289,7 +290,8 @@ void Dialog::ThievesGuild(bool oracle) break; } - dst_pt.x = cur_pt.x + startx + maxw / (colors._items.size() * 2) + ii * maxw / colors._items.size() - text.w() / 2; + dst_pt.x = cur_pt.x + startx + maxw / (colors._items.size() * 2) + ii * maxw / colors._items.size() - text.w() / + 2; dst_pt.y = cur_pt.y + 5; text.Blit(dst_pt); } @@ -397,7 +399,8 @@ void Dialog::ThievesGuild(bool oracle) color = colors._items.begin(); color != colors._items.end(); ++color) { text.Set(Color::String(*color)); - dst_pt.x = cur_pt.x + startx + maxw / (colors._items.size() * 2) + ii * maxw / colors._items.size() - text.w() / 2; + dst_pt.x = cur_pt.x + startx + maxw / (colors._items.size() * 2) + ii * maxw / colors._items.size() - text.w() / + 2; dst_pt.y = cur_pt.y + 270; text.Blit(dst_pt); ++ii; diff --git a/src/fheroes2/game/fheroes2.cpp b/src/fheroes2/game/fheroes2.cpp index d6a5426..57deb60 100644 --- a/src/fheroes2/game/fheroes2.cpp +++ b/src/fheroes2/game/fheroes2.cpp @@ -100,7 +100,11 @@ std::vector extractArgsVector(int argc, char** argv); int SDL_main(int argc, char **argv) { #elif WIN32 -struct HINSTANCE__ { int unused; }; +struct HINSTANCE__ +{ + int unused; +}; + int __stdcall wWinMain(HINSTANCE__* hInstance, HINSTANCE__* hPrevInstance, wchar_t* pCmdLine, int nCmdShow) { int argc = 0; @@ -412,5 +416,5 @@ void SetLangEnvPath(const Settings& conf) Translation::bindDomain(translations.back().c_str()); } else - H2ERROR("translation not found: " + mofile); + H2ERROR("translation not found: " + mofile); } diff --git a/src/fheroes2/game/game_delays.cpp b/src/fheroes2/game/game_delays.cpp index 3bf565a..025edf9 100644 --- a/src/fheroes2/game/game_delays.cpp +++ b/src/fheroes2/game/game_delays.cpp @@ -102,7 +102,7 @@ namespace Game void Game::AnimateDelaysInitialize() { - for_each(&delays[0], &delays[LAST_DELAY], [](TimeDelay&it) {it.Reset(); }); + for_each(&delays[0], &delays[LAST_DELAY], [](TimeDelay& it) { it.Reset(); }); UpdateHeroesMoveSpeed(); UpdateBattleSpeed(); } diff --git a/src/fheroes2/game/game_highscores.cpp b/src/fheroes2/game/game_highscores.cpp index d36c829..fd2f364 100644 --- a/src/fheroes2/game/game_highscores.cpp +++ b/src/fheroes2/game/game_highscores.cpp @@ -46,7 +46,7 @@ struct hgs_t { - hgs_t() = default; + hgs_t() = default; bool operator==(const hgs_t&) const; diff --git a/src/fheroes2/game/game_newgame.cpp b/src/fheroes2/game/game_newgame.cpp index b317b2a..7fe78f6 100644 --- a/src/fheroes2/game/game_newgame.cpp +++ b/src/fheroes2/game/game_newgame.cpp @@ -126,14 +126,19 @@ int Game::NewNetwork() if (HotKeyPressEvent(EVENT_DEFAULT_EXIT) || le.MouseClickLeft(buttonCancelGame)) return MAINMENU; // right info - if (le.MousePressRight(buttonHost)) Dialog::Message( - _("Host"), _("The host sets up the game options. There can only be one host per network game."), Font::BIG); - if (le.MousePressRight(buttonGuest)) Dialog::Message( - _("Guest"), - _("The guest waits for the host to set up the game, then is automatically added in. There can be multiple guests for TCP/IP games." - ), Font::BIG); - if (le.MousePressRight(buttonCancelGame)) Dialog::Message( - _("Cancel"), _("Cancel back to the main menu."), Font::BIG); + if (le.MousePressRight(buttonHost)) + Dialog::Message( + _("Host"), _("The host sets up the game options. There can only be one host per network game."), + Font::BIG); + if (le.MousePressRight(buttonGuest)) + Dialog::Message( + _("Guest"), + _( + "The guest waits for the host to set up the game, then is automatically added in. There can be multiple guests for TCP/IP games." + ), Font::BIG); + if (le.MousePressRight(buttonCancelGame)) + Dialog::Message( + _("Cancel"), _("Cancel back to the main menu."), Font::BIG); } return MAINMENU; @@ -225,7 +230,8 @@ int Game::NewGame() //if(le.MousePressRight(buttonCampainGame)) Dialog::Message(_("Campaign Game"), _("A single player game playing through a series of maps."), Font::BIG); if (le.MousePressRight(buttonMultiGame)) Dialog::Message(_("Multi-Player Game"), - _("A multi-player game, with several human players completing against each other on a single map." + _( + "A multi-player game, with several human players completing against each other on a single map." ), Font::BIG); if (le.MousePressRight(buttonSettings)) Dialog::Message(_("Settings"), _("FHeroes2 game settings."), Font::BIG); @@ -283,7 +289,8 @@ int Game::NewMulti() // right info if (le.MousePressRight(buttonHotSeat)) Dialog::Message(_("Hot Seat"), - _("Play a Hot Seat game, where 2 to 4 players play around the same computer, switching into the 'Hot Seat' when it is their turn." + _( + "Play a Hot Seat game, where 2 to 4 players play around the same computer, switching into the 'Hot Seat' when it is their turn." ), Font::BIG); if (le.MousePressRight(buttonCancelGame)) @@ -294,10 +301,12 @@ int Game::NewMulti() { le.MousePressLeft(buttonNetwork) ? buttonNetwork.PressDraw() : buttonNetwork.ReleaseDraw(); if (le.MouseClickLeft(buttonNetwork) || HotKeyPressEvent(EVENT_BUTTON_NETWORK)) return NEWNETWORK; - if (le.MousePressRight(buttonNetwork)) Dialog::Message( - _("Network"), - _("Play a network game, where 2 players use their own computers connected through a LAN (Local Area Network)." - ), Font::BIG); + if (le.MousePressRight(buttonNetwork)) + Dialog::Message( + _("Network"), + _( + "Play a network game, where 2 players use their own computers connected through a LAN (Local Area Network)." + ), Font::BIG); } #endif } diff --git a/src/fheroes2/game/game_scenarioinfo.cpp b/src/fheroes2/game/game_scenarioinfo.cpp index 395d128..e367037 100644 --- a/src/fheroes2/game/game_scenarioinfo.cpp +++ b/src/fheroes2/game/game_scenarioinfo.cpp @@ -56,7 +56,7 @@ int Game::ScenarioInfo() AGG::PlayMusic(MUS::MAINMENU); - Maps::MapsFileInfoList lists; + Maps::MapsFileInfoList lists; if (!PrepareMapsFileInfoList(lists, conf.GameType(TYPE_MULTI))) { Message(_("Warning"), _("No maps available!"), Font::BIG, Dialog::OK); @@ -264,7 +264,8 @@ int Game::ScenarioInfo() Font::BIG); else if (rating && le.MousePressRight(rating->GetRect())) Dialog::Message(_("Difficulty Rating"), - _("The difficulty rating reflects a combination of various settings for your game. This number will be applied to your final score." + _( + "The difficulty rating reflects a combination of various settings for your game. This number will be applied to your final score." ), Font::BIG); else if (le.MousePressRight(*buttonOk)) diff --git a/src/fheroes2/game/game_startgame.cpp b/src/fheroes2/game/game_startgame.cpp index d4dedca..429011c 100644 --- a/src/fheroes2/game/game_startgame.cpp +++ b/src/fheroes2/game/game_startgame.cpp @@ -250,11 +250,11 @@ void ShowNewWeekDialog() ? _( "After regular growth, population of %{monster} is doubled!") : _n("After regular growth, population of %{monter} increase on %{count} percent!", - "After regular growth, population of %{monter} increase on %{count} percent!", count + "After regular growth, population of %{monter} increase on %{count} percent!", count ); else message += _n("%{monster} population increases by +%{count}.", - "%{monster} population increases by +%{count}.", count); + "%{monster} population increases by +%{count}.", count); StringReplace(message, "%{monster}", monster.GetMultiName()); StringReplace(message, "%{count}", count); message += "\n"; @@ -299,7 +299,8 @@ int ShowWarningLostTownsDialog() if (1 == myKingdom.GetLostTownDays()) { Game::DialogPlayers(myKingdom.GetColor(), - _("%{color} player, this is your last day to capture a town, or you will be banished from this land." + _( + "%{color} player, this is your last day to capture a town, or you will be banished from this land." )); } else if (Game::GetLostTownDays() >= myKingdom.GetLostTownDays()) @@ -828,8 +829,9 @@ int Interface::Basic::HumanTurn(bool isload) else if (HotKeyPressEvent( Game:: EVENT_SCROLLRIGHT) - ) gameArea.SetScroll( - SCROLL_RIGHT); + ) + gameArea.SetScroll( + SCROLL_RIGHT); else if (HotKeyPressEvent( Game::EVENT_SCROLLUP)) gameArea.SetScroll( @@ -1029,10 +1031,12 @@ int Interface::Basic::HumanTurn(bool isload) if (Game::ENDTURN == res) { // warning lost all town - if (!myHeroes._items.empty() && myCastles._items.empty() && Game::GetLostTownDays() < myKingdom.GetLostTownDays()) + if (!myHeroes._items.empty() && myCastles._items.empty() && Game::GetLostTownDays() < myKingdom. + GetLostTownDays()) { Game::DialogPlayers(conf.CurrentColor(), - _("%{color} player, you have lost your last town. If you do not conquer another town in next week, you will be eliminated." + _( + "%{color} player, you have lost your last town. If you do not conquer another town in next week, you will be eliminated." )); } diff --git a/src/fheroes2/gui/interface_events.cpp b/src/fheroes2/gui/interface_events.cpp index 49896ef..06983d2 100644 --- a/src/fheroes2/gui/interface_events.cpp +++ b/src/fheroes2/gui/interface_events.cpp @@ -286,7 +286,7 @@ void Interface::Basic::EventNextTown() if (GetFocusCastle()) { auto it = find(myCastles._items.begin(), myCastles._items.end(), - GetFocusCastle()); + GetFocusCastle()); ++it; if (it == myCastles._items.end()) it = myCastles._items.begin(); SetFocus(*it); diff --git a/src/fheroes2/gui/interface_focus.cpp b/src/fheroes2/gui/interface_focus.cpp index 0ad0efc..33d3a24 100644 --- a/src/fheroes2/gui/interface_focus.cpp +++ b/src/fheroes2/gui/interface_focus.cpp @@ -98,8 +98,8 @@ void Interface::Basic::ResetFocus(int priority) { const KingdomHeroes& heroes = myKingdom.GetHeroes(); // skip sleeping - const auto it = find_if(heroes._items.begin(), heroes._items.end(), - [&](const Heroes* it) { return it->Modes(Heroes::SLEEPER); }); + const auto it = find_if(heroes._items.begin(), heroes._items.end(), + [&](const Heroes* it) { return it->Modes(Heroes::SLEEPER); }); if (it != heroes._items.end()) SetFocus(*it); diff --git a/src/fheroes2/gui/interface_gamearea.cpp b/src/fheroes2/gui/interface_gamearea.cpp index 4c21569..651caf6 100644 --- a/src/fheroes2/gui/interface_gamearea.cpp +++ b/src/fheroes2/gui/interface_gamearea.cpp @@ -174,7 +174,8 @@ void Interface::GameArea::DrawHeroRoute(Surface& dst, int flag, const Rect& rt) : Route::Path::GetIndexSprite((*it1).GetDirection(), (*it3).GetDirection(), Maps::Ground::GetPenalty(from, Direction::CENTER, hero->GetLevelSkill( - Skill::SkillT::PATHFINDING))); + Skill::SkillT:: + PATHFINDING))); Sprite sprite = AGG::GetICN(0 > green ? ICN::ROUTERED : ICN::ROUTE, index); sprite.SetAlphaMod(180); diff --git a/src/fheroes2/gui/interface_status.cpp b/src/fheroes2/gui/interface_status.cpp index 0f2f427..2ff5754 100644 --- a/src/fheroes2/gui/interface_status.cpp +++ b/src/fheroes2/gui/interface_status.cpp @@ -414,7 +414,8 @@ void Interface::StatusWindow::QueueEventProcessing() } if (le.MousePressRight(GetRect())) Dialog::Message(_("Status Window"), - _("This window provides information on the status of your hero or kingdom, and shows the date. Left click here to cycle throungh these windows." + _( + "This window provides information on the status of your hero or kingdom, and shows the date. Left click here to cycle throungh these windows." ), Font::BIG); } diff --git a/src/fheroes2/gui/text.cpp b/src/fheroes2/gui/text.cpp index 31f138c..164a7fb 100644 --- a/src/fheroes2/gui/text.cpp +++ b/src/fheroes2/gui/text.cpp @@ -345,9 +345,9 @@ void TextUnicode::Blit(s32 ax, s32 ay, int maxw, Surface& dst) if (!sprite.isValid()) return; const Surface& shaddow = AGG::GetUnicodeLetter(it, - font == 4 || font == 2 - ? Font::SHADDOW_BIG - : Font::SHADDOW); + font == 4 || font == 2 + ? Font::SHADDOW_BIG + : Font::SHADDOW); shaddow.Blit(ax + 1, ay + 1, dst); sprite.Blit(ax, ay, dst); ax += sprite.w(); diff --git a/src/fheroes2/heroes/heroes.cpp b/src/fheroes2/heroes/heroes.cpp index 183695d..b596bd2 100644 --- a/src/fheroes2/heroes/heroes.cpp +++ b/src/fheroes2/heroes/heroes.cpp @@ -105,8 +105,8 @@ Heroes::Heroes() : move_point_scale(-1), army(this), hid(UNKNOWN), portrait(UNKN { } -Heroes::Heroes(int heroid, int rc) : - HeroBase(HEROES, rc), ColorBase(Color::NONE), +Heroes::Heroes(int heroid, int rc) : + HeroBase(HEROES, rc), ColorBase(Color::NONE), experience(0), move_point_scale(-1), secondary_skills(rc), army(this), hid(heroid), portrait(heroid), race(rc), save_maps_object(MP2::OBJ_ZERO), path(*this), direction(Direction::RIGHT), @@ -885,7 +885,7 @@ bool Heroes::isVisited(int object, Visit::type_t type) const if (Visit::GLOBAL == type) return GetKingdom().isVisited(object); return visit_object.end() != find_if(visit_object.begin(), visit_object.end(), - [&](const IndexObject& it) { return it.isObject(object); }); + [&](const IndexObject& it) { return it.isObject(object); }); } /* set visited cell */ @@ -1812,7 +1812,7 @@ bool InCastleAndGuardian(const Castle* castle, Heroes* hero) } -bool InCastleNotGuardian(const Castle* castle, Heroes* hero) +bool InCastleNotGuardian(const Castle* castle, Heroes* hero) { return castle->GetCenter() == hero->GetCenter() && !hero->Modes(Heroes::GUARDIAN); } @@ -1913,19 +1913,19 @@ Heroes* VecHeroes::Get(const Point& center) const Heroes* AllHeroes::GetGuest(const Castle& castle) const { const auto it = find_if(_items.begin(), _items.end(), - [&](Heroes* hero) - { - return InCastleNotGuardian(&castle, hero); - }); + [&](Heroes* hero) + { + return InCastleNotGuardian(&castle, hero); + }); return _items.end() != it ? *it : nullptr; } Heroes* AllHeroes::GetGuard(const Castle& castle) const { auto it = Settings::Get().ExtCastleAllowGuardians() - ? find_if(_items.begin(), _items.end(), - [&](Heroes* hero) {return InCastleAndGuardian(&castle, hero); } - ) + ? find_if(_items.begin(), _items.end(), + [&](Heroes* hero) { return InCastleAndGuardian(&castle, hero); } + ) : _items.end(); return _items.end() != it ? *it : nullptr; } @@ -2016,17 +2016,17 @@ void AllHeroes::Scoute(int colors) const Heroes* AllHeroes::FromJail(s32 index) const { auto it = find_if(_items.begin(), _items.end(), - [=](Heroes* it) - { - return InJailMode(index, it); - }); + [=](Heroes* it) + { + return InJailMode(index, it); + }); return _items.end() != it ? *it : nullptr; } bool AllHeroes::HaveTwoFreemans() const { - return 2 <= count_if(_items.begin(), _items.end(), - [](Heroes*it) {return it->isFreeman(); }); + return 2 <= count_if(_items.begin(), _items.end(), + [](Heroes* it) { return it->isFreeman(); }); } ByteVectorWriter& operator<<(ByteVectorWriter& msg, const VecHeroes& heroes) diff --git a/src/fheroes2/heroes/heroes_action.cpp b/src/fheroes2/heroes/heroes_action.cpp index dfd0fda..9c31833 100644 --- a/src/fheroes2/heroes/heroes_action.cpp +++ b/src/fheroes2/heroes/heroes_action.cpp @@ -1468,7 +1468,8 @@ void ActionToWitchsHut(Heroes& hero, uint32_t obj, s32 dst_index) if (hero.HasMaxSecondarySkill()) { msg.append( - _("As you approach, she turns and focuses her one glass eye on you.\n\"You already know everything you deserve to learn!\" the witch screeches. \"NOW GET OUT OF MY HOUSE!\"" + _( + "As you approach, she turns and focuses her one glass eye on you.\n\"You already know everything you deserve to learn!\" the witch screeches. \"NOW GET OUT OF MY HOUSE!\"" )); Message(MP2::StringObject(obj), msg, Font::BIG, Dialog::OK); } @@ -1477,7 +1478,8 @@ void ActionToWitchsHut(Heroes& hero, uint32_t obj, s32 dst_index) if (hero.HasSecondarySkill(skill.Skill())) { msg.append( - _("As you approach, she turns and speaks.\n\"You already know that which I would teach you. I can help you no further.\"" + _( + "As you approach, she turns and speaks.\n\"You already know that which I would teach you. I can help you no further.\"" )); Message(MP2::StringObject(obj), msg, Font::BIG, Dialog::OK); } @@ -1486,7 +1488,8 @@ void ActionToWitchsHut(Heroes& hero, uint32_t obj, s32 dst_index) hero.LearnSkill(skill); msg.append( - _("An ancient and immortal witch living in a hut with bird's legs for stilts teaches you %{skill} for her own inscrutable purposes." + _( + "An ancient and immortal witch living in a hut with bird's legs for stilts teaches you %{skill} for her own inscrutable purposes." )); StringReplace(msg, "%{skill}", skill_name); Dialog::SecondarySkillInfo(MP2::StringObject(obj), msg, skill); @@ -2053,14 +2056,16 @@ void ActionToArtifact(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundFailure; Message("", - _("You try to pay the leprechaun, but realize that you can't afford it. The leprechaun stamps his foot and ignores you." + _( + "You try to pay the leprechaun, but realize that you can't afford it. The leprechaun stamps his foot and ignores you." ), Font::BIG, Dialog::OK); } } else Message("", - _("Insulted by your refusal of his generous offer, the leprechaun stamps his foot and ignores you." + _( + "Insulted by your refusal of his generous offer, the leprechaun stamps his foot and ignores you." ), Font::BIG, Dialog::OK); } @@ -2147,7 +2152,8 @@ void ActionToArtifact(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundFailure; Message("", - _("Discretion is the better part of valor, and you decide to avoid this fight for today." + _( + "Discretion is the better part of valor, and you decide to avoid this fight for today." ), Font::BIG, Dialog::OK); } @@ -2232,7 +2238,8 @@ void ActionToTreasureChest(Heroes& hero, uint32_t obj, s32 dst_index) else { Message(hdr, - _("After spending hours trying to fish the chest out of the sea, you open it, only to find it empty." + _( + "After spending hours trying to fish the chest out of the sea, you open it, only to find it empty." ), Font::BIG, Dialog::OK); } @@ -2289,7 +2296,8 @@ void ActionToAncientLamp(Heroes& hero, uint32_t obj, s32 dst_index) PlaySoundSuccess; if (troop.isValid() && Dialog::YES == Dialog::Message(MP2::StringObject(obj), - _("You stumble upon a dented and tarnished lamp lodged deep in the earth. Do you wish to rub the lamp?" + _( + "You stumble upon a dented and tarnished lamp lodged deep in the earth. Do you wish to rub the lamp?" ), Font::BIG, Dialog::YES | Dialog::NO)) RecruitMonsterFromTile(hero, tile, MP2::StringObject(obj), troop, true); @@ -2376,7 +2384,8 @@ void ActionToWhirlpools(Heroes& hero, uint32_t obj, s32 index_from) Message(_("A whirlpool engulfs your ship."), _("Some of your army has fallen overboard."), Font::BIG, Dialog::OK); troop->SetCount( - Monster::GetCountFromHitPoints(troop->_monster.GetID(), troop->GetHitPointsTroop() - troop->GetHitPointsTroop() * + Monster::GetCountFromHitPoints(troop->_monster.GetID(), + troop->GetHitPointsTroop() - troop->GetHitPointsTroop() * Game::GetWhirlpoolPercent() / 100)); } @@ -2390,7 +2399,8 @@ void ActionToAbandoneMine(Heroes& hero, uint32_t obj, s32 dst_index) PlaySoundWarning; if (Dialog::YES == Dialog::Message("", - _("You come upon an abandoned gold mine. The mine appears to be haunted. Do you wish to enter?" + _( + "You come upon an abandoned gold mine. The mine appears to be haunted. Do you wish to enter?" ), Font::BIG, Dialog::YES | Dialog::NO)) { @@ -2808,7 +2818,8 @@ void ActionToArtesianSpring(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundFailure; Message(name, - _("A drink at the spring is supposed to give you twice your normal spell points, but you are already at that level." + _( + "A drink at the spring is supposed to give you twice your normal spell points, but you are already at that level." ), Font::BIG, Dialog::OK); } @@ -2822,7 +2833,8 @@ void ActionToArtesianSpring(Heroes& hero, uint32_t obj, s32 dst_index) AGG::PlayMusic(MUS::WATERSPRING, false); hero.SetSpellPoints(max * 2); Message(name, - _("A drink from the spring fills your blood with magic! You have twice your normal spell points in reserve." + _( + "A drink from the spring fills your blood with magic! You have twice your normal spell points in reserve." ), Font::BIG, Dialog::OK); @@ -2842,7 +2854,8 @@ void ActionToXanadu(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundVisited; Message(MP2::StringObject(obj), - _("Recognizing you, the butler refuses to admit you. \"The master,\" he says, \"will not see the same student twice.\"" + _( + "Recognizing you, the butler refuses to admit you. \"The master,\" he says, \"will not see the same student twice.\"" ), Font::BIG, Dialog::OK); } @@ -2869,7 +2882,8 @@ void ActionToXanadu(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundSuccess; Message(MP2::StringObject(obj), - _("The butler admits you to see the master of the house. He trains you in the four skills a hero should know." + _( + "The butler admits you to see the master of the house. He trains you in the four skills a hero should know." ), Font::BIG, Dialog::OK); hero.IncreasePrimarySkill(Skill::Primary::ATTACK); @@ -3035,7 +3049,8 @@ void ActionToMagellanMaps(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundFailure; Message(MP2::StringObject(obj), - _("The captain sighs. \"You don't have enough money, eh? You can't expect me to give my maps away for free!\"" + _( + "The captain sighs. \"You don't have enough money, eh? You can't expect me to give my maps away for free!\"" ), Font::BIG, Dialog::OK); } @@ -3108,7 +3123,8 @@ void ActionToTreeKnowledge(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundVisited; Message(MP2::StringObject(obj), - _("Upon your approach, the tree opens its eyes in delight. \"It is good to see you, my student. I hope my teachings have helped you.\"" + _( + "Upon your approach, the tree opens its eyes in delight. \"It is good to see you, my student. I hope my teachings have helped you.\"" ), Font::BIG, Dialog::OK); } @@ -3136,7 +3152,8 @@ void ActionToTreeKnowledge(Heroes& hero, uint32_t obj, s32 dst_index) msg = _("Upon your approach, the tree opens its eyes in delight."); msg.append("\n"); msg.append( - _("\"Ahh, an adventurer! I will be happy to teach you a little of what I have learned over the ages for a mere %{count} %{res}.\"" + _( + "\"Ahh, an adventurer! I will be happy to teach you a little of what I have learned over the ages for a mere %{count} %{res}.\"" )); msg.append("\n"); msg.append(_("(Just bury it around my roots.)")); @@ -3180,7 +3197,8 @@ void ActionToDaemonCave(Heroes& hero, uint32_t obj, s32 dst_index) AGG::PlayMusic(MUS::DEMONCAVE, false); if (Dialog::YES == Dialog::Message(MP2::StringObject(obj), - _("The entrance to the cave is dark, and a foul, sulfurous smell issues from the cave mouth. Will you enter?" + _( + "The entrance to the cave is dark, and a foul, sulfurous smell issues from the cave mouth. Will you enter?" ), Font::BIG, Dialog::YES | Dialog::NO)) { @@ -3301,8 +3319,8 @@ void ActionToDaemonCave(Heroes& hero, uint32_t obj, s32 dst_index) void ActionToAlchemistsTower(Heroes& hero, uint32_t obj, s32 dst_index) { BagArtifacts& bag = hero.GetBagArtifacts(); - uint32_t cursed = count_if(bag._items.begin(), bag._items.end(), - [](const Artifact& it) {return it.isAlchemistRemove(); }); + uint32_t cursed = count_if(bag._items.begin(), bag._items.end(), + [](const Artifact& it) { return it.isAlchemistRemove(); }); if (cursed) { @@ -3314,7 +3332,7 @@ void ActionToAlchemistsTower(Heroes& hero, uint32_t obj, s32 dst_index) "As you enter the Alchemist's Tower, a hobbled, graying man in a brown cloak makes his way towards you."; msg.append("\n"); msg.append(_n("He checks your pack, and sees that you have 1 cursed item.", - "He checks your pack, and sees that you have %{count} cursed items.", cursed)); + "He checks your pack, and sees that you have %{count} cursed items.", cursed)); StringReplace(msg, "%{count}", cursed); msg.append("\n"); msg.append(_("For %{gold} gold, the alchemist will remove it for you. Do you pay?")); @@ -3324,13 +3342,14 @@ void ActionToAlchemistsTower(Heroes& hero, uint32_t obj, s32 dst_index) { hero.GetKingdom().OddFundsResource(payment); bag._items.resize(distance(bag._items.begin(), - remove_if(bag._items.begin(), bag._items.end(), - [](const Artifact& it) {return it.isAlchemistRemove(); }))); + remove_if(bag._items.begin(), bag._items.end(), + [](const Artifact& it) { return it.isAlchemistRemove(); }))); } } else Message("", - _("You hear a voice from behind the locked door, \"You don't have enough gold to pay for my services.\"" + _( + "You hear a voice from behind the locked door, \"You don't have enough gold to pay for my services.\"" ), Font::BIG, Dialog::OK); } @@ -3401,7 +3420,8 @@ void ActionToSirens(Heroes& hero, uint32_t obj, s32 dst_index) { PlaySoundVisited; Message(MP2::StringObject(obj), - _("As the sirens sing their eerie song, your small, determined army manages to overcome the urge to dive headlong into the sea." + _( + "As the sirens sing their eerie song, your small, determined army manages to overcome the urge to dive headlong into the sea." ), Font::BIG, Dialog::OK); } @@ -3429,7 +3449,8 @@ void ActionToJail(Heroes& hero, uint32_t obj, s32 dst_index) Maps::Tiles& tile = world.GetTiles(dst_index); PlaySoundSuccess; Message(MP2::StringObject(obj), - _("In a dazzling display of daring, you break into the local jail and free the hero imprisoned there, who, in return, pledges loyalty to your cause." + _( + "In a dazzling display of daring, you break into the local jail and free the hero imprisoned there, who, in return, pledges loyalty to your cause." ), Font::BIG, Dialog::OK); @@ -3459,7 +3480,8 @@ void ActionToJail(Heroes& hero, uint32_t obj, s32 dst_index) void ActionToHutMagi(Heroes& hero, uint32_t obj, s32 dst_index) { Message(MP2::StringObject(obj), - _("You enter a rickety hut and talk to the magician who lives there. He tells you of places near and far which may aid you in your journeys." + _( + "You enter a rickety hut and talk to the magician who lives there. He tells you of places near and far which may aid you in your journeys." ), Font::BIG, Dialog::OK); @@ -3564,7 +3586,8 @@ void ActionToBarrier(Heroes& hero, uint32_t obj, s32 dst_index) else { Message(MP2::StringObject(obj), - _("A magical barrier stands tall before you, blocking your way. Runes on the arch read,\n\"Speak the key and you may pass.\"\nYou speak, and nothing happens." + _( + "A magical barrier stands tall before you, blocking your way. Runes on the arch read,\n\"Speak the key and you may pass.\"\nYou speak, and nothing happens." ), Font::BIG, Dialog::OK); } diff --git a/src/fheroes2/heroes/skill.cpp b/src/fheroes2/heroes/skill.cpp index ec9aba6..9d00e6a 100644 --- a/src/fheroes2/heroes/skill.cpp +++ b/src/fheroes2/heroes/skill.cpp @@ -669,11 +669,11 @@ Skill::Secondary* Skill::SecSkills::FindSkill(SkillT skill) { const auto it = find_if(_items.begin(), _items.end(), [&](Secondary& it) - { - if (!it.isValid()) - return false; - return it.isSkill(skill); - }); + { + if (!it.isValid()) + return false; + return it.isSkill(skill); + }); return it != _items.end() ? &*it : nullptr; } @@ -743,7 +743,7 @@ Skill::SkillT Skill::SecondaryPriorityFromRace(int race, const std::vector& v = ss._items; sb.put32(static_cast(v.size())); - for(const Secondary& it:v) + for (const Secondary& it : v) { sb << ((int)it.first) << it.second; } diff --git a/src/fheroes2/kingdom/kingdom_overview.cpp b/src/fheroes2/kingdom/kingdom_overview.cpp index 8205f35..6309a60 100644 --- a/src/fheroes2/kingdom/kingdom_overview.cpp +++ b/src/fheroes2/kingdom/kingdom_overview.cpp @@ -44,7 +44,7 @@ struct HeroRow sp secskillsBar; sp primskillsBar; - HeroRow() = default; + HeroRow() = default; ~HeroRow() { diff --git a/src/fheroes2/system/fh2_win32.cpp b/src/fheroes2/system/fh2_win32.cpp index a42e100..1e6e03c 100644 --- a/src/fheroes2/system/fh2_win32.cpp +++ b/src/fheroes2/system/fh2_win32.cpp @@ -7,19 +7,19 @@ std::vector extractArgsVector(int argc, char** argv) { - int nArgs; - std::wstring commandLine = GetCommandLineW(); + int nArgs; + std::wstring commandLine = GetCommandLineW(); - LPWSTR* szArglist = CommandLineToArgvW(commandLine.c_str(), &nArgs); + LPWSTR* szArglist = CommandLineToArgvW(commandLine.c_str(), &nArgs); - std::vector vArgv; - vArgv.reserve(nArgs); - for (int i = 0; i < nArgs; i++) - { - vArgv.emplace_back(ws2s(szArglist[i])); - } - LocalFree(szArglist); - return vArgv; + std::vector vArgv; + vArgv.reserve(nArgs); + for (int i = 0; i < nArgs; i++) + { + vArgv.emplace_back(ws2s(szArglist[i])); + } + LocalFree(szArglist); + return vArgv; } #else