1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Fix sonar, fix build

This commit is contained in:
Ivan Savenko
2025-06-19 20:52:40 +03:00
parent 1ac8080cbf
commit e06c0e8de0
11 changed files with 21 additions and 18 deletions

View File

@ -94,7 +94,7 @@ std::vector<std::string> BattleConsole::getVisibleText() const
return {logEntries[scrollPosition - 1], logEntries[scrollPosition]}; return {logEntries[scrollPosition - 1], logEntries[scrollPosition]};
} }
std::vector<std::string> BattleConsole::splitText(const std::string & text) std::vector<std::string> BattleConsole::splitText(const std::string & text) const
{ {
std::vector<std::string> lines; std::vector<std::string> lines;
std::vector<std::string> output; std::vector<std::string> output;

View File

@ -53,7 +53,7 @@ private:
bool enteringText; bool enteringText;
/// splits text into individual strings for battle log /// splits text into individual strings for battle log
std::vector<std::string> splitText(const std::string & text); std::vector<std::string> splitText(const std::string & text) const;
/// select line(s) that will be visible in UI /// select line(s) that will be visible in UI
std::vector<std::string> getVisibleText() const; std::vector<std::string> getVisibleText() const;

View File

@ -31,7 +31,7 @@
#include "../../lib/gameState/InfoAboutArmy.h" #include "../../lib/gameState/InfoAboutArmy.h"
#include "../../lib/mapObjects/CGHeroInstance.h" #include "../../lib/mapObjects/CGHeroInstance.h"
const CGHeroInstance * BattleHero::instance() const CGHeroInstance * BattleHero::instance() const
{ {
return hero; return hero;
} }
@ -127,7 +127,7 @@ void BattleHero::heroLeftClicked()
} }
} }
void BattleHero::heroRightClicked() void BattleHero::heroRightClicked() const
{ {
if(settings["battle"]["stickyHeroInfoWindows"].Bool()) if(settings["battle"]["stickyHeroInfoWindows"].Bool())
return; return;

View File

@ -46,7 +46,7 @@ class BattleHero : public CIntObject
void render(Canvas & canvas); //prints next frame of animation to to void render(Canvas & canvas); //prints next frame of animation to to
public: public:
const CGHeroInstance * instance(); const CGHeroInstance * instance() const;
void setPhase(EHeroAnimType newPhase); //sets phase of hero animation void setPhase(EHeroAnimType newPhase); //sets phase of hero animation
@ -60,7 +60,7 @@ public:
void play(); void play();
void heroLeftClicked(); void heroLeftClicked();
void heroRightClicked(); void heroRightClicked() const;
BattleHero(const BattleInterface & owner, const CGHeroInstance * hero, bool defender); BattleHero(const BattleInterface & owner, const CGHeroInstance * hero, bool defender);
}; };

View File

@ -42,12 +42,12 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
background->setPlayerColor(owner.playerID); background->setPlayerColor(owner.playerID);
pos = center(background->pos); pos = center(background->pos);
exit = std::make_shared<CButton>(Point(384, 505), AnimationPath::builtin("iok6432.def"), std::make_pair("", ""), [&](){ bExitf();}, EShortcut::GLOBAL_ACCEPT); exit = std::make_shared<CButton>(Point(384, 505), AnimationPath::builtin("iok6432.def"), std::make_pair("", ""), [this](){ bExitf();}, EShortcut::GLOBAL_ACCEPT);
exit->setBorderColor(Colors::METALLIC_GOLD); exit->setBorderColor(Colors::METALLIC_GOLD);
if(allowReplay || owner.cb->getStartInfo()->extraOptionsInfo.unlimitedReplay) if(allowReplay || owner.cb->getStartInfo()->extraOptionsInfo.unlimitedReplay)
{ {
repeat = std::make_shared<CButton>(Point(24, 505), AnimationPath::builtin("icn6432.def"), std::make_pair("", ""), [&](){ bRepeatf();}, EShortcut::GLOBAL_CANCEL); repeat = std::make_shared<CButton>(Point(24, 505), AnimationPath::builtin("icn6432.def"), std::make_pair("", ""), [this](){ bRepeatf();}, EShortcut::GLOBAL_CANCEL);
repeat->setBorderColor(Colors::METALLIC_GOLD); repeat->setBorderColor(Colors::METALLIC_GOLD);
labels.push_back(std::make_shared<CLabel>(232, 520, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->translate("vcmi.battleResultsWindow.applyResultsLabel"))); labels.push_back(std::make_shared<CLabel>(232, 520, FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, LIBRARY->generaltexth->translate("vcmi.battleResultsWindow.applyResultsLabel")));
} }
@ -79,7 +79,7 @@ BattleResultWindow::BattleResultWindow(const BattleResult & br, CPlayerInterface
for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER}) for(auto i : {BattleSide::ATTACKER, BattleSide::DEFENDER})
{ {
auto heroInfo = owner.cb->getBattle(br.battleID)->battleGetHeroInfo(i); auto heroInfo = owner.cb->getBattle(br.battleID)->battleGetHeroInfo(i);
const int xs[] = {21, 392}; const std::array xs = {21, 392};
if(heroInfo.portraitSource.isValid()) //attacking hero if(heroInfo.portraitSource.isValid()) //attacking hero
{ {

View File

@ -17,7 +17,7 @@
#include "../../lib/gameState/InfoAboutArmy.h" #include "../../lib/gameState/InfoAboutArmy.h"
#include "../../lib/texts/CGeneralTextHandler.h" #include "../../lib/texts/CGeneralTextHandler.h"
HeroInfoBasicPanel::HeroInfoBasicPanel(const InfoAboutHero & hero, Point * position, bool initializeBackground) HeroInfoBasicPanel::HeroInfoBasicPanel(const InfoAboutHero & hero, const Point * position, bool initializeBackground)
: CIntObject(0) : CIntObject(0)
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;
@ -84,7 +84,7 @@ void HeroInfoBasicPanel::show(Canvas & to)
CIntObject::show(to); CIntObject::show(to);
} }
HeroInfoWindow::HeroInfoWindow(const InfoAboutHero & hero, Point * position) HeroInfoWindow::HeroInfoWindow(const InfoAboutHero & hero, const Point * position)
: CWindowObject(RCLICK_POPUP | SHADOW_DISABLED, ImagePath::builtin("CHRPOP")) : CWindowObject(RCLICK_POPUP | SHADOW_DISABLED, ImagePath::builtin("CHRPOP"))
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;

View File

@ -13,7 +13,10 @@
class CLabel; class CLabel;
class CAnimImage; class CAnimImage;
VCMI_LIB_NAMESPACE_BEGIN
struct InfoAboutHero; struct InfoAboutHero;
VCMI_LIB_NAMESPACE_END
class HeroInfoBasicPanel : public CIntObject //extracted from InfoWindow to fit better as non-popup embed element class HeroInfoBasicPanel : public CIntObject //extracted from InfoWindow to fit better as non-popup embed element
{ {
@ -23,7 +26,7 @@ private:
std::vector<std::shared_ptr<CAnimImage>> icons; std::vector<std::shared_ptr<CAnimImage>> icons;
public: public:
HeroInfoBasicPanel(const InfoAboutHero & hero, Point * position, bool initializeBackground = true); HeroInfoBasicPanel(const InfoAboutHero & hero, const Point * position, bool initializeBackground = true);
void show(Canvas & to) override; void show(Canvas & to) override;
@ -37,5 +40,5 @@ private:
std::shared_ptr<HeroInfoBasicPanel> content; std::shared_ptr<HeroInfoBasicPanel> content;
public: public:
HeroInfoWindow(const InfoAboutHero & hero, Point * position); HeroInfoWindow(const InfoAboutHero & hero, const Point * position);
}; };

View File

@ -55,7 +55,7 @@ std::vector<std::tuple<SpellID, bool>> QuickSpellPanel::getSpells() const
{ {
id = SpellID::decode(spellIdentifier); id = SpellID::decode(spellIdentifier);
} }
catch(const IdentifierResolutionException & e) catch(const IdentifierResolutionException &)
{ {
id = SpellID::NONE; id = SpellID::NONE;
} }

View File

@ -31,8 +31,8 @@
#include "../../lib/texts/TextOperations.h" #include "../../lib/texts/TextOperations.h"
StackQueue::StackQueue(bool Embedded, BattleInterface & owner) StackQueue::StackQueue(bool Embedded, BattleInterface & owner)
: embedded(Embedded), : owner(owner)
owner(owner) , embedded(Embedded)
{ {
OBJECT_CONSTRUCTION; OBJECT_CONSTRUCTION;

View File

@ -121,7 +121,7 @@ void CIntObject::enable()
recActions = ALL_ACTIONS; recActions = ALL_ACTIONS;
} }
bool CIntObject::isDisabled() bool CIntObject::isDisabled() const
{ {
return recActions == NO_ACTIONS; return recActions == NO_ACTIONS;
} }

View File

@ -74,7 +74,7 @@ public:
/// activates if needed, all activity enabled (Warning: may not be symmetric with disable if recActions was limited!) /// activates if needed, all activity enabled (Warning: may not be symmetric with disable if recActions was limited!)
void enable(); void enable();
/// returns true if element was disabled via disable() call /// returns true if element was disabled via disable() call
bool isDisabled(); bool isDisabled() const;
/// deactivates or activates UI element based on flag /// deactivates or activates UI element based on flag
void setEnabled(bool on); void setEnabled(bool on);