Fix reliability issues from Sonar

This commit is contained in:
Ivan Savenko
2026-06-19 12:50:53 +03:00
parent 6c12efae5c
commit 4b57a168d5
11 changed files with 30 additions and 14 deletions
+3 -1
View File
@@ -24,7 +24,9 @@ jobs:
java-version: '11'
- name: Download & unpack archive
run: curl -L '${{ inputs.build_dir_xz_url }}' | tar -xf - --xz
env:
BUILD_DIR_XZ_URL: ${{ inputs.build_dir_xz_url }}
run: curl -L "$BUILD_DIR_XZ_URL" | tar -xf - --xz
- name: Build aab
run: |
@@ -139,7 +139,7 @@ void RecruitHeroBehavior::calculateFinalDecision(
const int treasureSourcesCount
)
{
if(!vstd::isAlmostZero(bestChoice.score))
if(bestChoice.hero != nullptr && !vstd::isAlmostZero(bestChoice.score))
{
if(ourHeroes.empty()
|| treasureSourcesCount > ourHeroes.size() * 5
@@ -71,6 +71,9 @@ bool needToRecruitHero(const Nullkiller * aiNk, const CGTownInstance * startupTo
for(auto obj : aiNk->objectClusterizer->getNearbyObjects())
{
if(!obj)
continue;
auto armed = dynamic_cast<const CArmedInstance *>(obj);
if(armed && armed->getArmyStrength() > 0)
+5 -5
View File
@@ -41,12 +41,12 @@ struct AIPathNode : public CGPathNode
const AIPathNode * chainOther = nullptr;
const ChainActor * actor = nullptr;
uint64_t danger;
uint64_t armyLoss;
uint32_t version;
uint64_t danger = 0;
uint64_t armyLoss = 0;
uint32_t version = 0;
int16_t manaCost;
DayFlags dayFlags;
int16_t manaCost = 0;
DayFlags dayFlags = DayFlags::NONE;
void addSpecialAction(std::shared_ptr<const SpecialAction> action);
+1 -1
View File
@@ -210,12 +210,12 @@ MusicEntry::MusicEntry(CMusicHandler * owner, std::string setName, const AudioPa
: owner(owner)
, music(nullptr)
, setName(std::move(setName))
, currentName()
, startTime(static_cast<uint32_t>(-1))
, startPosition(0)
, loop(looped ? -1 : 1)
, fromStart(fromStart)
, playing(false)
{
if(!musicURI.empty())
load(musicURI);
+3
View File
@@ -508,6 +508,9 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
std::map<int, OwnedObjectInfo> visibleObjects;
for(const CGObjectInstance * object : ownedObjects)
{
if(!object)
continue;
//Dwellings
if(auto * dwelling = dynamic_cast<const CGDwelling *>(object))
{
+1
View File
@@ -270,6 +270,7 @@ void CRClickPopupInt::mouseDraggedPopup(const Point & cursorPosition, const Poin
}
template<typename... Args>
requires (sizeof...(Args) != 1 || (!std::is_base_of_v<AdventureMapPopup, std::remove_cvref_t<Args>> && ...))
AdventureMapPopup::AdventureMapPopup(Args&&... args) :
CWindowObject(std::forward<Args>(args)...), dragDistance(Point(0, 0))
{
+1
View File
@@ -101,6 +101,7 @@ class AdventureMapPopup : public CWindowObject
public:
template<typename... Args>
requires (sizeof...(Args) != 1 || (!std::is_base_of_v<AdventureMapPopup, std::remove_cvref_t<Args>> && ...))
AdventureMapPopup(Args&&... args);
void mouseDraggedPopup(const Point & cursorPosition, const Point & lastUpdateDistance) override;
};
+4 -1
View File
@@ -128,7 +128,10 @@ float CLegacyConfigParser::readNumber()
std::istringstream stream(input);
if(input.find(',') != std::string::npos) // code to handle conversion with comma as decimal separator
stream.imbue(std::locale(std::locale(), new LocaleWithComma()));
{
static const std::locale commaLocale(std::locale(), new LocaleWithComma());
stream.imbue(commaLocale);
}
float result;
if ( !(stream >> result) )
+8 -2
View File
@@ -153,11 +153,17 @@ bool HeroPoolProcessor::hireHero(const ObjectInstanceID & objectID, const HeroTy
const CGTownInstance * town = gameHandler->gameInfo().getTown(objectID);
const auto & heroesPool = gameHandler->gameState().heroesPool;
if (!mapObject && gameHandler->complain("Invalid map object!"))
if (!mapObject)
{
gameHandler->complain("Invalid map object!");
return false;
}
if (!playerState && gameHandler->complain("Invalid player!"))
if (!playerState)
{
gameHandler->complain("Invalid player!");
return false;
}
if (playerState->resources[EGameResID::GOLD] < GameConstants::HERO_GOLD_COST && gameHandler->complain("Not enough gold for buying hero!"))
return false;
-3
View File
@@ -224,9 +224,6 @@ bool TurnOrderProcessor::mustActBefore(PlayerColor left, PlayerColor right) cons
if (leftInfo->isHuman() && !rightInfo->isHuman())
return true;
if (!leftInfo->isHuman() && rightInfo->isHuman())
return false;
return false;
}