1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-10-31 00:07:39 +02:00

Merge pull request #3614 from IvanSavenko/sonarcloud_fixes_2

Sonarcloud fixes 2
This commit is contained in:
Ivan Savenko
2024-02-14 16:44:58 +02:00
committed by GitHub
26 changed files with 67 additions and 112 deletions

View File

@@ -845,8 +845,8 @@ void CCreatureHandler::loadUnitAnimInfo(JsonNode & graphics, CLegacyConfigParser
missile["attackClimaxFrame"].Float() = parser.readNumber();
// assume that creature is not a shooter and should not have whole missile field
if (missile["frameAngles"].Vector()[0].Float() == 0 &&
missile["attackClimaxFrame"].Float() == 0)
if (missile["frameAngles"].Vector()[0].Integer() == 0 &&
missile["attackClimaxFrame"].Integer() == 0)
graphics.Struct().erase("missile");
}
@@ -988,10 +988,10 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
int lastVal = 0;
for (const JsonNode &val : values)
{
if (val.Float() != lastVal)
if (val.Integer() != lastVal)
{
JsonNode bonusInput = exp["bonus"];
bonusInput["val"].Float() = static_cast<int>(val.Float()) - lastVal;
bonusInput["val"].Float() = val.Integer() - lastVal;
auto bonus = JsonUtils::parseBonus (bonusInput);
bonus->source = BonusSource::STACK_EXPERIENCE;

View File

@@ -1385,10 +1385,8 @@ bool CGameState::checkForVictory(const PlayerColor & player, const EventConditio
int total = 0; //creature counter
for(auto object : map->objects)
{
const CArmedInstance *ai = nullptr;
if(object
&& object->tempOwner == player //object controlled by player
&& (ai = dynamic_cast<const CArmedInstance *>(object.get()))) //contains army
const auto * ai = dynamic_cast<const CArmedInstance *>(object.get());
if(ai && ai->getOwner() == player)
{
for(const auto & elem : ai->Slots()) //iterate through army
if(elem.second->getId() == condition.objectType.as<CreatureID>()) //it's searched creature

View File

@@ -154,20 +154,6 @@ std::vector<TradeItemBuy> IMarket::availableItemsIds(EMarketMode mode) const
return ret;
}
const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose)
{
auto * imarket = dynamic_cast<const IMarket *>(obj);
if(verbose && !imarket)
{
logGlobal->error("Cannot cast to IMarket");
if(obj)
{
logGlobal->error("Object type %s", obj->typeName);
}
}
return imarket;
}
IMarket::IMarket()
{
}

View File

@@ -29,8 +29,6 @@ public:
bool getOffer(int id1, int id2, int &val1, int &val2, EMarketMode mode) const; //val1 - how many units of id1 player has to give to receive val2 units
std::vector<EMarketMode> availableModes() const;
static const IMarket *castFrom(const CGObjectInstance *obj, bool verbose = true);
};
VCMI_LIB_NAMESPACE_END

View File

@@ -156,9 +156,4 @@ void IShipyard::getBoatCost(TResources & cost) const
cost[EGameResID::GOLD] = 1000;
}
const IShipyard * IShipyard::castFrom( const CGObjectInstance *obj )
{
return dynamic_cast<const IShipyard *>(obj);
}
VCMI_LIB_NAMESPACE_END

View File

@@ -101,8 +101,6 @@ class DLL_LINKAGE IShipyard : public IBoatGenerator
{
public:
virtual void getBoatCost(ResourceSet & cost) const;
static const IShipyard *castFrom(const CGObjectInstance *obj);
};
VCMI_LIB_NAMESPACE_END

View File

@@ -28,12 +28,8 @@ public:
explicit rmgException(const std::string& _Message) : msg(_Message)
{
}
virtual ~rmgException() throw ()
{
};
const char *what() const throw () override
const char *what() const noexcept override
{
return msg.c_str();
}

View File

@@ -113,23 +113,6 @@ public:
return *this;
}
bool operator==(const float3 & i) const { return (x == i.x) && (y == i.y) && (z == i.z); }
bool operator!=(const float3 & i) const { return (x != i.x) || (y != i.y) || (z != i.z); }
bool operator<(const float3 & i) const
{
if (z<i.z)
return true;
if (z>i.z)
return false;
if (y<i.y)
return true;
if (y>i.y)
return false;
return x<i.x;
}
std::string toString() const
{
return "(" + std::to_string(x) +