mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-22 22:13:35 +02:00
Fix several new issues detected by SonarCloud
This commit is contained in:
parent
80632cdf8b
commit
aef6b0cc00
@ -55,7 +55,7 @@ std::shared_ptr<CDefFile> RenderHandler::getAnimationFile(const AnimationPath &
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<ResourcePath> RenderHandler::getPathForScaleFactor(ResourcePath path, std::string factor)
|
std::optional<ResourcePath> RenderHandler::getPathForScaleFactor(const ResourcePath & path, const std::string & factor)
|
||||||
{
|
{
|
||||||
if(path.getType() == EResType::IMAGE)
|
if(path.getType() == EResType::IMAGE)
|
||||||
{
|
{
|
||||||
@ -80,7 +80,7 @@ std::optional<ResourcePath> RenderHandler::getPathForScaleFactor(ResourcePath pa
|
|||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<ResourcePath, int> RenderHandler::getScalePath(ResourcePath p)
|
std::pair<ResourcePath, int> RenderHandler::getScalePath(const ResourcePath & p)
|
||||||
{
|
{
|
||||||
auto path = p;
|
auto path = p;
|
||||||
int scaleFactor = 1;
|
int scaleFactor = 1;
|
||||||
|
@ -29,8 +29,8 @@ class RenderHandler : public IRenderHandler
|
|||||||
std::map<EFonts, std::shared_ptr<const IFont>> fonts;
|
std::map<EFonts, std::shared_ptr<const IFont>> fonts;
|
||||||
|
|
||||||
std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path);
|
std::shared_ptr<CDefFile> getAnimationFile(const AnimationPath & path);
|
||||||
std::optional<ResourcePath> getPathForScaleFactor(ResourcePath path, std::string factor);
|
std::optional<ResourcePath> getPathForScaleFactor(const ResourcePath & path, const std::string & factor);
|
||||||
std::pair<ResourcePath, int> getScalePath(ResourcePath p);
|
std::pair<ResourcePath, int> getScalePath(const ResourcePath & p);
|
||||||
AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
|
AnimationLayoutMap & getAnimationLayout(const AnimationPath & path);
|
||||||
void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);
|
void initFromJson(AnimationLayoutMap & layout, const JsonNode & config);
|
||||||
|
|
||||||
|
@ -283,7 +283,10 @@ std::shared_ptr<const ISharedImage> SDLImageShared::scaleInteger(int factor, SDL
|
|||||||
if (factor <= 0)
|
if (factor <= 0)
|
||||||
throw std::runtime_error("Unable to scale by integer value of " + std::to_string(factor));
|
throw std::runtime_error("Unable to scale by integer value of " + std::to_string(factor));
|
||||||
|
|
||||||
if (palette && surf && surf->format->palette)
|
if (!surf)
|
||||||
|
return shared_from_this();
|
||||||
|
|
||||||
|
if (palette && surf->format->palette)
|
||||||
SDL_SetSurfacePalette(surf, palette);
|
SDL_SetSurfacePalette(surf, palette);
|
||||||
|
|
||||||
SDL_Surface * scaled = nullptr;
|
SDL_Surface * scaled = nullptr;
|
||||||
@ -306,7 +309,7 @@ std::shared_ptr<const ISharedImage> SDLImageShared::scaleInteger(int factor, SDL
|
|||||||
// erase our own reference
|
// erase our own reference
|
||||||
SDL_FreeSurface(scaled);
|
SDL_FreeSurface(scaled);
|
||||||
|
|
||||||
if (surf && surf->format->palette)
|
if (surf->format->palette)
|
||||||
SDL_SetSurfacePalette(surf, originalPalette);
|
SDL_SetSurfacePalette(surf, originalPalette);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -314,8 +317,8 @@ std::shared_ptr<const ISharedImage> SDLImageShared::scaleInteger(int factor, SDL
|
|||||||
|
|
||||||
std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Palette * palette) const
|
std::shared_ptr<const ISharedImage> SDLImageShared::scaleTo(const Point & size, SDL_Palette * palette) const
|
||||||
{
|
{
|
||||||
float scaleX = float(size.x) / fullSize.x;
|
float scaleX = static_cast<float>(size.x) / fullSize.x;
|
||||||
float scaleY = float(size.y) / fullSize.y;
|
float scaleY = static_cast<float>(size.y) / fullSize.y;
|
||||||
|
|
||||||
if (palette && surf->format->palette)
|
if (palette && surf->format->palette)
|
||||||
SDL_SetSurfacePalette(surf, palette);
|
SDL_SetSurfacePalette(surf, palette);
|
||||||
|
@ -725,7 +725,7 @@ int CStackInstance::getExpRank() const
|
|||||||
|
|
||||||
int CStackInstance::getLevel() const
|
int CStackInstance::getLevel() const
|
||||||
{
|
{
|
||||||
return std::max(1, static_cast<int>(getType()->getLevel()));
|
return std::max(1, getType()->getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStackInstance::giveStackExp(TExpType exp)
|
void CStackInstance::giveStackExp(TExpType exp)
|
||||||
|
@ -544,8 +544,8 @@ void CSpell::serializeJson(JsonSerializeFormat & handler)
|
|||||||
///CSpell::AnimationInfo
|
///CSpell::AnimationInfo
|
||||||
CSpell::AnimationItem::AnimationItem() :
|
CSpell::AnimationItem::AnimationItem() :
|
||||||
verticalPosition(VerticalPosition::TOP),
|
verticalPosition(VerticalPosition::TOP),
|
||||||
pause(0),
|
transparency(1),
|
||||||
transparency(1)
|
pause(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -917,7 +917,7 @@ void BattleActionProcessor::makeAttack(const CBattleInfoCallback & battle, const
|
|||||||
handleAttackBeforeCasting(battle, ranged, attacker, defender);
|
handleAttackBeforeCasting(battle, ranged, attacker, defender);
|
||||||
|
|
||||||
// If the attacker or defender is not alive before the attack action, the action should be skipped.
|
// If the attacker or defender is not alive before the attack action, the action should be skipped.
|
||||||
if((attacker && !attacker->alive()) || (defender && !defender->alive()))
|
if((!attacker->alive()) || (defender && !defender->alive()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FireShieldInfo fireShield;
|
FireShieldInfo fireShield;
|
||||||
|
Loading…
Reference in New Issue
Block a user