mirror of
https://github.com/vcmi/vcmi.git
synced 2026-06-19 22:57:37 +02:00
Merge pull request #6826 from IvanSavenko/sonar
[1.7.2] Fixes for issues reported by Sonar
This commit is contained in:
@@ -31,10 +31,10 @@
|
||||
#include "../../lib/networkPacks/PacksForClientBattle.h"
|
||||
#include "../../lib/callback/CCallback.h"
|
||||
|
||||
const std::string BattleSiegeController::getSiegePrefix() const
|
||||
const std::string & BattleSiegeController::getSiegePrefix() const
|
||||
{
|
||||
auto siegePrefixes = town->getTown()->clientInfo.siegePrefix;
|
||||
auto currentLayer = owner.curInt->cb->getMapHeader()->mapLayers.at(town->pos.z);
|
||||
const auto & siegePrefixes = town->getTown()->clientInfo.siegePrefix;
|
||||
const auto & currentLayer = owner.curInt->cb->getMapHeader()->mapLayers.at(town->pos.z);
|
||||
if(siegePrefixes.count(currentLayer))
|
||||
return siegePrefixes.at(currentLayer);
|
||||
else
|
||||
|
||||
@@ -90,7 +90,7 @@ class BattleSiegeController
|
||||
BattleHex getTurretBattleHex(EWallVisual::EWallVisual wallPiece) const;
|
||||
const CStack * getTurretStack(EWallVisual::EWallVisual wallPiece) const;
|
||||
|
||||
const std::string getSiegePrefix() const;
|
||||
const std::string & getSiegePrefix() const;
|
||||
|
||||
public:
|
||||
BattleSiegeController(BattleInterface & owner, const CGTownInstance *siegeTown);
|
||||
|
||||
@@ -387,7 +387,7 @@ void CBonusSelection::createBonusesIcons()
|
||||
|
||||
auto tooltip = useComponentPopup ? CButton::tooltip() : CButton::tooltip(desc.toString(), desc.toString());
|
||||
|
||||
std::shared_ptr<CToggleButton> bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), tooltip, nullptr, EShortcut::NONE, false, [this](){
|
||||
auto bonusButton = std::make_shared<CToggleButton>(Point(475 + i * 68, 455), AnimationPath::builtin("campaignBonusSelection"), tooltip, nullptr, EShortcut::NONE, false, [this](){
|
||||
if(buttonStart->isActive() && !buttonStart->isBlocked())
|
||||
CBonusSelection::startMap();
|
||||
});
|
||||
|
||||
@@ -312,7 +312,7 @@ void CHeroWindow::updateArtifacts()
|
||||
else
|
||||
{
|
||||
tacticsButton->block(false);
|
||||
tacticsButton->addCallback([&](bool on){ GAME->interface()->cb->setTactics(curHero, on); });
|
||||
tacticsButton->addCallback([this](bool on){ GAME->interface()->cb->setTactics(curHero, on); });
|
||||
}
|
||||
|
||||
formations->resetCallback();
|
||||
|
||||
@@ -378,7 +378,7 @@ int main(int argc, char * argv[])
|
||||
setThreadName("MainGUI");
|
||||
#endif
|
||||
|
||||
const auto & runMainLoop = [&]()
|
||||
const auto & runMainLoop = []()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -402,7 +402,7 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
};
|
||||
|
||||
const auto & cleanupEngine = [&]()
|
||||
const auto & cleanupEngine = [&logConfigurator]()
|
||||
{
|
||||
GAME->server().endNetwork();
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ std::string MapLayerType::getNameTranslated() const
|
||||
}
|
||||
|
||||
MapLayerType::MapLayerType():
|
||||
id(MapLayerId::UNKNOWN),
|
||||
identifier("empty"),
|
||||
modScope("core")
|
||||
modScope("core"),
|
||||
id(MapLayerId::UNKNOWN)
|
||||
{}
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@@ -42,7 +42,6 @@ public:
|
||||
|
||||
class DLL_LINKAGE MapLayerTypeService : public EntityServiceT<MapLayerId, MapLayerType>
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class DLL_LINKAGE MapLayerTypeHandler : public CHandlerBase<MapLayerId, MapLayerType, MapLayerType, MapLayerTypeService>
|
||||
|
||||
@@ -777,8 +777,8 @@ void GameStatePackVisitor::visitRebalanceStacks(RebalanceStacks & pack)
|
||||
assert(dstType == srcType);
|
||||
const auto srcHero = dynamic_cast<CGHeroInstance*>(srcObj);
|
||||
const auto dstHero = dynamic_cast<CGHeroInstance*>(dstObj);
|
||||
auto srcStack = const_cast<CStackInstance*>(srcObj->getStackPtr(src.slot));
|
||||
auto dstStack = const_cast<CStackInstance*>(dstObj->getStackPtr(dst.slot));
|
||||
auto srcStack = srcObj->getStackPtr(src.slot);
|
||||
auto dstStack = dstObj->getStackPtr(dst.slot);
|
||||
if(srcStack->getArt(ArtifactPosition::CREATURE_SLOT))
|
||||
{
|
||||
if(auto dstArt = dstStack->getArt(ArtifactPosition::CREATURE_SLOT))
|
||||
@@ -1339,7 +1339,10 @@ void GameStatePackVisitor::visitStartAction(StartAction & pack)
|
||||
case EActionType::MONSTER_SPELL:
|
||||
{
|
||||
auto * spell = pack.ba.spell.toSpell();
|
||||
if (spell && spell->canCastWithoutSkip()) {} //state does not change
|
||||
if (spell && spell->canCastWithoutSkip())
|
||||
{
|
||||
//state does not change
|
||||
}
|
||||
else
|
||||
{
|
||||
st->waiting = false;
|
||||
|
||||
@@ -193,7 +193,7 @@ void CStackInstance::setArmy(CArmedInstance * ArmyObj)
|
||||
|
||||
if(ArmyObj)
|
||||
{
|
||||
attachTo(const_cast<CArmedInstance &>(*ArmyObj));
|
||||
attachTo(*ArmyObj);
|
||||
armyInstance = ArmyObj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -919,8 +919,7 @@ void CMapLoaderJson::readHeader(const bool complete)
|
||||
// Fix TextIDs in JSON to include map name prefix before deserialization
|
||||
std::string actualMapName = TextOperations::convertMapName(mapName);
|
||||
std::string mapPrefix = "map." + actualMapName + ".";
|
||||
auto & headerData = const_cast<JsonNode &>(handler.getCurrent());
|
||||
fixStringsTextIDInJson(headerData, mapPrefix, false);
|
||||
fixStringsTextIDInJson(header, mapPrefix, false);
|
||||
|
||||
mapHeader->version = EMapFormat::VCMI;//todo: new version field
|
||||
|
||||
@@ -1402,8 +1401,7 @@ void CMapSaverJson::writeHeader()
|
||||
|
||||
writeTranslations();
|
||||
|
||||
auto & headerData = const_cast<JsonNode &>(handler.getCurrent());
|
||||
fixStringsTextIDInJson(headerData, "", true);
|
||||
fixStringsTextIDInJson(header, "", true);
|
||||
|
||||
addToArchive(header, HEADER_FILE_NAME);
|
||||
}
|
||||
|
||||
@@ -21,21 +21,11 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
struct DLL_LINKAGE GamePause : public CPackForServer
|
||||
{
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & static_cast<CPackForServer &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE EndTurn : public CPackForServer
|
||||
{
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & static_cast<CPackForServer &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE DismissHero : public CPackForServer
|
||||
@@ -766,11 +756,6 @@ struct DLL_LINKAGE CastAdvSpell : public CPackForServer
|
||||
struct DLL_LINKAGE RequestStatistic : public CPackForServer
|
||||
{
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & static_cast<CPackForServer &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
/***********************************************************************************************************/
|
||||
@@ -823,11 +808,6 @@ struct DLL_LINKAGE AdvInterfaceReady : public CPackForServer
|
||||
AdvInterfaceReady() = default;
|
||||
|
||||
void visitTyped(ICPackVisitor & cpackVisitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & static_cast<CPackForServer &>(*this);
|
||||
}
|
||||
};
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
||||
@@ -1397,7 +1397,7 @@ void MainWindow::on_actionMapLayer_triggered()
|
||||
int currentPos = 0;
|
||||
|
||||
QList<QPair<QString, MapLayerId>> layers;
|
||||
for(auto & layer : LIBRARY->mapLayerHandler->objects)
|
||||
for(const auto & layer : LIBRARY->mapLayerHandler->objects)
|
||||
{
|
||||
if(currentType == layer->getId())
|
||||
currentPos = layers.size();
|
||||
|
||||
@@ -92,7 +92,7 @@ WindowNewMap::~WindowNewMap()
|
||||
bool WindowNewMap::loadUserSettings()
|
||||
{
|
||||
bool ret = false;
|
||||
CRmgTemplate * templ = nullptr;
|
||||
const CRmgTemplate * templ = nullptr;
|
||||
|
||||
QSettings s = CLauncherDirs::getSettings(Ui::appName);
|
||||
|
||||
@@ -109,7 +109,7 @@ bool WindowNewMap::loadUserSettings()
|
||||
auto node = JsonUtils::toJson(settings);
|
||||
JsonDeserializer handler(nullptr, node);
|
||||
handler.serializeStruct("lastSettings", mapGenOptions);
|
||||
templ = const_cast<CRmgTemplate*>(mapGenOptions.getMapTemplate()); // Remember for later
|
||||
templ = mapGenOptions.getMapTemplate(); // Remember for later
|
||||
|
||||
ui->widthTxt->setValue(mapGenOptions.getWidth());
|
||||
ui->heightTxt->setValue(mapGenOptions.getHeight());
|
||||
|
||||
Reference in New Issue
Block a user