mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Fix some more complex Sonar issues
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
Calendar::Calendar(const IGameSettings & settings, int day)
|
||||
: settings(&settings), day(day)
|
||||
: gameSettings(&settings), day(day)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ int Calendar::getMonth() const
|
||||
|
||||
int Calendar::getDaysInWeek() const
|
||||
{
|
||||
return settings->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK);
|
||||
return gameSettings->getInteger(EGameSettings::GENERAL_DAYS_PER_WEEK);
|
||||
}
|
||||
|
||||
int Calendar::getDaysInMonth() const
|
||||
@@ -63,12 +63,12 @@ int Calendar::getDaysInMonth() const
|
||||
|
||||
int Calendar::getWeeksInMonth() const
|
||||
{
|
||||
return settings->getInteger(EGameSettings::GENERAL_WEEKS_PER_MONTH);
|
||||
return gameSettings->getInteger(EGameSettings::GENERAL_WEEKS_PER_MONTH);
|
||||
}
|
||||
|
||||
Calendar Calendar::nextDay() const
|
||||
{
|
||||
return Calendar(*settings, day + 1);
|
||||
return Calendar(*gameSettings, day + 1);
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@@ -18,7 +18,7 @@ class IGameSettings;
|
||||
/// to the IGameSettings that provides week/month length.
|
||||
class DLL_LINKAGE Calendar final
|
||||
{
|
||||
const IGameSettings * settings;
|
||||
const IGameSettings * gameSettings;
|
||||
int day;
|
||||
|
||||
public:
|
||||
|
||||
+15
-15
@@ -65,15 +65,15 @@ bool CSpell::adventureCast(SpellCastEnvironment * env, const AdventureSpellCastP
|
||||
return adventureMechanics->adventureCast(env, parameters);
|
||||
}
|
||||
|
||||
const CSpell::LevelInfo & CSpell::getLevelInfo(const int32_t level) const
|
||||
const CSpell::LevelInfo & CSpell::getLevelInfo(const int32_t schoolLevel) const
|
||||
{
|
||||
if(level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
if(schoolLevel < 0 || schoolLevel >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
{
|
||||
logGlobal->error("CSpell::getLevelInfo: invalid school mastery level %d", level);
|
||||
logGlobal->error("CSpell::getLevelInfo: invalid school mastery level %d", schoolLevel);
|
||||
return levels.at(MasteryLevel::EXPERT);
|
||||
}
|
||||
|
||||
return levels.at(level);
|
||||
return levels.at(schoolLevel);
|
||||
}
|
||||
|
||||
int64_t CSpell::calculateDamage(const spells::Caster * caster) const
|
||||
@@ -132,8 +132,8 @@ SpellID CSpell::getId() const
|
||||
|
||||
std::string CSpell::getNameTextID() const
|
||||
{
|
||||
TextIdentifier id("spell", modScope, identifier, "name");
|
||||
return id.get();
|
||||
TextIdentifier textId("spell", modScope, identifier, "name");
|
||||
return textId.get();
|
||||
}
|
||||
|
||||
std::string CSpell::getNameTranslated() const
|
||||
@@ -141,15 +141,15 @@ std::string CSpell::getNameTranslated() const
|
||||
return LIBRARY->generaltexth->translate(getNameTextID());
|
||||
}
|
||||
|
||||
std::string CSpell::getDescriptionTextID(int32_t level) const
|
||||
std::string CSpell::getDescriptionTextID(int32_t schoolLevel) const
|
||||
{
|
||||
TextIdentifier textID("spell", modScope, identifier, "description", LEVEL_NAMES[level]);
|
||||
TextIdentifier textID("spell", modScope, identifier, "description", LEVEL_NAMES[schoolLevel]);
|
||||
return textID.get();
|
||||
}
|
||||
|
||||
std::string CSpell::getDescriptionTranslated(int32_t level) const
|
||||
std::string CSpell::getDescriptionTranslated(int32_t schoolLevel) const
|
||||
{
|
||||
return LIBRARY->generaltexth->translate(getDescriptionTextID(level));
|
||||
return LIBRARY->generaltexth->translate(getDescriptionTextID(schoolLevel));
|
||||
}
|
||||
|
||||
std::string CSpell::getAdventureEffectTextID(const std::string & effectType, const std::string & field) const
|
||||
@@ -330,21 +330,21 @@ si32 CSpell::getProbability(const FactionID & factionId) const
|
||||
return probabilities.at(factionId);
|
||||
}
|
||||
|
||||
void CSpell::getEffects(std::vector<Bonus> & lst, const int level, const bool cumulative, const si32 duration, std::optional<si32 *> maxDuration) const
|
||||
void CSpell::getEffects(std::vector<Bonus> & lst, const int schoolLevel, const bool cumulative, const si32 duration, std::optional<si32 *> maxDuration) const
|
||||
{
|
||||
if(level < 0 || level >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
if(schoolLevel < 0 || schoolLevel >= GameConstants::SPELL_SCHOOL_LEVELS)
|
||||
{
|
||||
logGlobal->error("invalid school level %d", level);
|
||||
logGlobal->error("invalid school level %d", schoolLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto & levelObject = levels.at(level);
|
||||
const auto & levelObject = levels.at(schoolLevel);
|
||||
|
||||
const auto & effectsJson = cumulative ? levelObject.cumulativeEffects : levelObject.effects;
|
||||
|
||||
if(effectsJson.Struct().empty())
|
||||
{
|
||||
logGlobal->error("This spell (%s) has no effects for level %d", getNameTranslated(), level);
|
||||
logGlobal->error("This spell (%s) has no effects for level %d", getNameTranslated(), schoolLevel);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,9 +86,9 @@ public:
|
||||
//to be used for spells configured with old format
|
||||
class FallbackMechanicsFactory : public CustomMechanicsFactory
|
||||
{
|
||||
JsonNode usePowerAsVal(const JsonNode & effects, si32 power) const
|
||||
JsonNode usePowerAsVal(const JsonNode & effectsNode, si32 power) const
|
||||
{
|
||||
JsonNode result = effects;
|
||||
JsonNode result = effectsNode;
|
||||
for(auto & [name, bonusNode] : result.Struct())
|
||||
if(bonusNode["val"].isNull())
|
||||
bonusNode["val"].Integer() = power;
|
||||
|
||||
@@ -28,7 +28,7 @@ const std::string AbilitiesWidget::V_CATEGORY="secondarySkill";
|
||||
const std::string AbilitiesWidget::V_NAME="gainedSkill";
|
||||
|
||||
AbilitiesWidget::AbilitiesWidget(CRewardableObject & hut, MapController & controller, QWidget * parent)
|
||||
: hut(hut), controller(controller), QDialog(parent), extractor(controller.getCallback()), ui(new Ui::AbilitiesWidget)
|
||||
: QDialog(parent), ui(new Ui::AbilitiesWidget), hut(hut), extractor(controller.getCallback()), controller(controller)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
@@ -176,7 +176,7 @@ bool AbilitiesWidget::isSetToDefault()
|
||||
return !ui->customize->isChecked();
|
||||
}
|
||||
|
||||
AbilitiesDelegate::AbilitiesDelegate(MapController & controller, CRewardableObject & hut) : BaseInspectorItemDelegate(), controller(controller), hut(hut) {}
|
||||
AbilitiesDelegate::AbilitiesDelegate(MapController & controller, CRewardableObject & hut) : BaseInspectorItemDelegate(), hut(hut), controller(controller) {}
|
||||
|
||||
QWidget * AbilitiesDelegate::createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
{
|
||||
|
||||
@@ -21,12 +21,8 @@
|
||||
#include "lib/modding/IdentifierStorage.h"
|
||||
#include "lib/spells/CSpellHandler.h"
|
||||
|
||||
const std::string ScholarWidget::presetNotFoundWarning =
|
||||
"<font color='red'>The scholar has %1 preset set to \"%2\", "
|
||||
"but the value is unknown. Maybe it is a mod configuration problem?</font color='red'>";
|
||||
|
||||
ScholarWidget::ScholarWidget(CRewardableObject & scholar, MapController & controller, QWidget * parent)
|
||||
: scholar(scholar), controller(controller), QDialog(parent), extractor(controller.getCallback()), ui(new Ui::ScholarWidget)
|
||||
: QDialog(parent), ui(new Ui::ScholarWidget), scholar(scholar), extractor(controller.getCallback()), controller(controller)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
rewardsData = {
|
||||
@@ -145,13 +141,13 @@ void ScholarWidget::changeComboBoxesAllowedState()
|
||||
|
||||
void ScholarWidget::showInvalidPresetWarning(std::string type, std::string name)
|
||||
{
|
||||
auto warning = tr(presetNotFoundWarning.c_str()).arg(type.c_str()).arg(name.c_str());
|
||||
auto warning = tr(presetNotFoundWarning).arg(type.c_str()).arg(name.c_str());
|
||||
ui->label->setText(warning);
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
ScholarDelegate::ScholarDelegate(MapController & controller, CRewardableObject & scholar)
|
||||
: BaseInspectorItemDelegate(), controller(controller), scholar(scholar)
|
||||
: BaseInspectorItemDelegate(), scholar(scholar), controller(controller)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,9 @@ private:
|
||||
MapController & controller;
|
||||
|
||||
std::vector<RewardData> rewardsData;
|
||||
static const std::string presetNotFoundWarning;
|
||||
static constexpr const char * presetNotFoundWarning =
|
||||
"<font color='red'>The scholar has %1 preset set to \"%2\", "
|
||||
"but the value is unknown. Maybe it is a mod configuration problem?</font color='red'>";
|
||||
};
|
||||
|
||||
class ScholarDelegate : public BaseInspectorItemDelegate
|
||||
|
||||
@@ -219,11 +219,11 @@ void CTeleportDialogQuery::notifyObjectAboutRemoval(const CGObjectInstance * vis
|
||||
logGlobal->error("Invalid instance in teleport query");
|
||||
}
|
||||
|
||||
CTeleportDialogQuery::CTeleportDialogQuery(CGameHandler * owner, const TeleportDialog & td) :
|
||||
CTeleportDialogQuery::CTeleportDialogQuery(CGameHandler * owner, const TeleportDialog & dialog) :
|
||||
CDialogQuery(owner, TYPE)
|
||||
{
|
||||
this->td = td;
|
||||
addPlayer(gh->gameInfo().getHero(td.hero)->getOwner());
|
||||
td = dialog;
|
||||
addPlayer(gh->gameInfo().getHero(dialog.hero)->getOwner());
|
||||
}
|
||||
|
||||
CHeroLevelUpDialogQuery::CHeroLevelUpDialogQuery(CGameHandler * owner, const HeroLevelUp & Hlu, const CGHeroInstance * Hero):
|
||||
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
TeleportDialog td; //copy of pack... debug purposes
|
||||
|
||||
CTeleportDialogQuery(CGameHandler * owner, const TeleportDialog &td);
|
||||
CTeleportDialogQuery(CGameHandler * owner, const TeleportDialog & dialog);
|
||||
|
||||
void notifyObjectAboutRemoval(const CGObjectInstance * visitedObject, const CGHeroInstance * visitingHero) const override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user