diff --git a/lib/callback/Calendar.cpp b/lib/callback/Calendar.cpp index 086a15285..1ab5d8bdc 100644 --- a/lib/callback/Calendar.cpp +++ b/lib/callback/Calendar.cpp @@ -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 diff --git a/lib/callback/Calendar.h b/lib/callback/Calendar.h index 1c96bdaf7..72e9a8643 100644 --- a/lib/callback/Calendar.h +++ b/lib/callback/Calendar.h @@ -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: diff --git a/lib/spells/CSpell.cpp b/lib/spells/CSpell.cpp index 76033c8aa..2fdd652f5 100644 --- a/lib/spells/CSpell.cpp +++ b/lib/spells/CSpell.cpp @@ -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 & lst, const int level, const bool cumulative, const si32 duration, std::optional maxDuration) const +void CSpell::getEffects(std::vector & lst, const int schoolLevel, const bool cumulative, const si32 duration, std::optional 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; } diff --git a/lib/spells/ISpellMechanics.cpp b/lib/spells/ISpellMechanics.cpp index 9b29d30ee..14079522a 100644 --- a/lib/spells/ISpellMechanics.cpp +++ b/lib/spells/ISpellMechanics.cpp @@ -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; diff --git a/mapeditor/inspector/abilitieswidget.cpp b/mapeditor/inspector/abilitieswidget.cpp index 7ae4de6a0..c7e5be732 100644 --- a/mapeditor/inspector/abilitieswidget.cpp +++ b/mapeditor/inspector/abilitieswidget.cpp @@ -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 { diff --git a/mapeditor/inspector/scholarwidget.cpp b/mapeditor/inspector/scholarwidget.cpp index 474bc9450..3fdc9c523 100644 --- a/mapeditor/inspector/scholarwidget.cpp +++ b/mapeditor/inspector/scholarwidget.cpp @@ -21,12 +21,8 @@ #include "lib/modding/IdentifierStorage.h" #include "lib/spells/CSpellHandler.h" -const std::string ScholarWidget::presetNotFoundWarning = - "The scholar has %1 preset set to \"%2\", " - "but the value is unknown. Maybe it is a mod configuration problem?"; - 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) { } diff --git a/mapeditor/inspector/scholarwidget.h b/mapeditor/inspector/scholarwidget.h index 23eddc0bb..431d24de6 100644 --- a/mapeditor/inspector/scholarwidget.h +++ b/mapeditor/inspector/scholarwidget.h @@ -59,7 +59,9 @@ private: MapController & controller; std::vector rewardsData; - static const std::string presetNotFoundWarning; + static constexpr const char * presetNotFoundWarning = + "The scholar has %1 preset set to \"%2\", " + "but the value is unknown. Maybe it is a mod configuration problem?"; }; class ScholarDelegate : public BaseInspectorItemDelegate diff --git a/server/queries/MapQueries.cpp b/server/queries/MapQueries.cpp index c029610a0..b578dc159 100644 --- a/server/queries/MapQueries.cpp +++ b/server/queries/MapQueries.cpp @@ -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): diff --git a/server/queries/MapQueries.h b/server/queries/MapQueries.h index 207ce905a..b6639fae4 100644 --- a/server/queries/MapQueries.h +++ b/server/queries/MapQueries.h @@ -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; };