feat(CI): add cppcheck (#15211)

Co-authored-by: Skjalf <47818697+Nyeriah@users.noreply.github.com>
This commit is contained in:
Stefano Borzì
2023-03-05 18:47:18 +01:00
committed by GitHub
parent a5b4aecd52
commit 034b521501
22 changed files with 91 additions and 41 deletions

View File

@@ -110,7 +110,7 @@ bool TransactionTask::Execute()
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
std::lock_guard<std::mutex> lock(_deadlockLock);
for (Milliseconds loopDuration = 0s, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
for (Milliseconds loopDuration{}, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
{
if (!TryExecute())
return true;
@@ -157,7 +157,7 @@ bool TransactionWithResultTask::Execute()
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
std::lock_guard<std::mutex> lock(_deadlockLock);
for (Milliseconds loopDuration = 0s, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
for (Milliseconds loopDuration{}, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
{
if (!TryExecute())
{

View File

@@ -129,12 +129,12 @@ void AutobroadcastMgr::SendAutobroadcasts()
LOG_DEBUG("autobroadcast", "AutobroadcastMgr::SendAutobroadcasts: '{}'", msg);
}
void AutobroadcastMgr::SendWorldAnnouncement(std::string_view msg)
void AutobroadcastMgr::SendWorldAnnouncement(std::string msg)
{
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.data());
}
void AutobroadcastMgr::SendNotificationAnnouncement(std::string_view msg)
void AutobroadcastMgr::SendNotificationAnnouncement(std::string msg)
{
WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1));
data << msg.data();

View File

@@ -37,8 +37,8 @@ public:
void SendAutobroadcasts();
private:
void SendWorldAnnouncement(std::string_view msg);
void SendNotificationAnnouncement(std::string_view msg);
void SendWorldAnnouncement(std::string msg);
void SendNotificationAnnouncement(std::string msg);
typedef std::map<uint8, std::string> AutobroadcastsMap;
typedef std::map<uint8, uint8> AutobroadcastsWeightMap;

View File

@@ -895,8 +895,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
{
if (!(*itr3)->IsInvitedToBGInstanceGUID
&& (((*itr3)->ArenaMatchmakerRating >= arenaMinRating && (*itr3)->ArenaMatchmakerRating <= arenaMaxRating) || (int32)(*itr3)->JoinTime < discardTime)
&& ((*itr_teams[0])->ArenaTeamId != (*itr3)->PreviousOpponentsTeamId || ((int32)(*itr3)->JoinTime < discardOpponentsTime))
&& (*itr_teams[0])->ArenaTeamId != (*itr3)->ArenaTeamId)
&& ((*(itr_teams[0]))->ArenaTeamId != (*itr3)->PreviousOpponentsTeamId || ((int32)(*itr3)->JoinTime < discardOpponentsTime))
&& (*(itr_teams[0]))->ArenaTeamId != (*itr3)->ArenaTeamId)
{
itr_teams[found++] = itr3;
break;
@@ -907,8 +907,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId
//if we have 2 teams, then start new arena and invite players!
if (found == 2)
{
GroupQueueInfo* aTeam = *itr_teams[TEAM_ALLIANCE];
GroupQueueInfo* hTeam = *itr_teams[TEAM_HORDE];
GroupQueueInfo* aTeam = *(itr_teams[TEAM_ALLIANCE]);
GroupQueueInfo* hTeam = *(itr_teams[TEAM_HORDE]);
Battleground* arena = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, true);
if (!arena)

View File

@@ -1310,6 +1310,7 @@ bool Player::SatisfyQuestSeasonal(Quest const* qInfo, bool /*msg*/) const
if (!qInfo->IsSeasonal() || m_seasonalquests.empty())
return true;
// cppcheck-suppress mismatchingContainers
Player::SeasonalEventQuestMap::iterator itr = ((Player*)this)->m_seasonalquests.find(qInfo->GetEventIdForQuest());
if (itr == m_seasonalquests.end() || itr->second.empty())

View File

@@ -190,6 +190,7 @@ uint32 LootStore::LoadLootTable()
// Looking for the template of the entry
// often entries are put together
// cppcheck-suppress eraseDereference
if (m_LootTemplates.empty() || tab->first != entry)
{
// Searching the template (in case template Id changed)

View File

@@ -121,13 +121,13 @@ public:
};
};
struct Wave
struct WaveCreature
{
uint32 entry;
uint32 amount;
};
static Wave RingMobs[] = // different amounts based on the type
static WaveCreature RingMobs[] = // different amounts based on the type
{
{NPC_DREDGE_WORM, 3},
{NPC_DEEP_STINGER, 3},

View File

@@ -49,18 +49,18 @@ enum Rinji
GO_RINJI_CAGE = 142036
};
struct Location
struct LocationXYZ
{
float posX, posY, posZ;
float x, y, z;
};
Location AmbushSpawn[] =
LocationXYZ AmbushSpawn[] =
{
{ 191.296204f, -2839.329346f, 107.388f },
{ 70.972466f, -2848.674805f, 109.459f }
};
Location AmbushMoveTo[] =
LocationXYZ AmbushMoveTo[] =
{
{ 166.630386f, -2824.780273f, 108.153f },
{ 70.886589f, -2874.335449f, 116.675f }
@@ -118,12 +118,12 @@ public:
if (!_first)
spawnId = 1;
me->SummonCreature(NPC_RANGER, AmbushSpawn[spawnId].posX, AmbushSpawn[spawnId].posY, AmbushSpawn[spawnId].posZ, 0.0f,
me->SummonCreature(NPC_RANGER, AmbushSpawn[spawnId].x, AmbushSpawn[spawnId].y, AmbushSpawn[spawnId].z, 0.0f,
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
for (int i = 0; i < 2; ++i)
{
me->SummonCreature(NPC_OUTRUNNER, AmbushSpawn[spawnId].posX, AmbushSpawn[spawnId].posY, AmbushSpawn[spawnId].posZ, 0.0f,
me->SummonCreature(NPC_OUTRUNNER, AmbushSpawn[spawnId].x, AmbushSpawn[spawnId].y, AmbushSpawn[spawnId].z, 0.0f,
TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 60000);
}
}
@@ -131,7 +131,7 @@ public:
void JustSummoned(Creature* summoned) override
{
summoned->SetWalk(false);
summoned->GetMotionMaster()->MovePoint(0, AmbushMoveTo[spawnId].posX, AmbushMoveTo[spawnId].posY, AmbushMoveTo[spawnId].posZ);
summoned->GetMotionMaster()->MovePoint(0, AmbushMoveTo[spawnId].x, AmbushMoveTo[spawnId].y, AmbushMoveTo[spawnId].z);
}
void sQuestAccept(Player* player, Quest const* quest) override

View File

@@ -748,12 +748,11 @@ enum Worldstates
WORLD_STATE_FAIL_H = 3878
};
struct Location
{
struct LocationXYZO {
float x, y, z, o;
};
static Location AllianceSpawn[] =
static LocationXYZO AllianceSpawn[] =
{
{ 1603.97f, 718.02f, 65.10f, 0 }, // guardian // sewers
{ 1604.78f, 657.22f, 40.80f, 0 }, // wave 1
@@ -788,7 +787,7 @@ static Location AllianceSpawn[] =
{ 1307.92f, 395.53f, -63.24f, 4.472f },
};
static Location AllianceWP[] =
static LocationXYZO AllianceWP[] =
{
{ 1737.06f, 734.176f, 48.8f, 0 }, // Jaina sewers UNUSED
{ 1682.92f, 730.89f, 76.84f, 0 }, // UNUSED
@@ -802,12 +801,12 @@ static Location AllianceWP[] =
{ 1300.75f, 347.39f, -65.02f, 0 }, // jaina throne room
};
static Location HordeSpawn[] =
static LocationXYZO HordeSpawn[] =
{
{ 1581.94f, 383.22f, -62.22f, 0 } // Khanok
};
static Location ThrallSpawn[] =
static LocationXYZO ThrallSpawn[] =
{
// Vortex
{ 1880.0001f, 237.8242f, 59.472f, 3.060f },

View File

@@ -1078,7 +1078,7 @@ public:
bool GossipSelect(Player* player, uint32 sender, uint32 action) override
{
Seconds respawnTimer = 0s;
Seconds respawnTimer{};
player->PlayerTalkClass->SendCloseGossip();
Creature* lastSpawn = ObjectAccessor::GetCreature(*me, _creatureGuid);

View File

@@ -1008,9 +1008,12 @@ public:
break;
}
if (Aura* aura = target->GetAura(uint32(GetSpellInfo()->Effects[stage].CalcValue())))
if (aura->GetOwner() == target) // avoid assert(false) at any cost
aura->UpdateOwner(5000, target); // update whole aura so previous periodic ticks before refreshed by new one
if (target)
{
if (Aura* aura = target->GetAura(uint32(GetSpellInfo()->Effects[stage].CalcValue())))
if (aura->GetOwner() == target) // avoid assert(false) at any cost
aura->UpdateOwner(5000, target); // update whole aura so previous periodic ticks before refreshed by new one
}
GetCaster()->CastSpell(target, uint32(GetSpellInfo()->Effects[stage].CalcValue()), true, nullptr, nullptr, GetCaster()->GetGUID());
}

View File

@@ -870,13 +870,13 @@ static Location SpawnLocation[] =
{-4627.1240f, 1378.8752f, 139.9f, 2.544f} //Torloth The Magnificent
};
struct WaveData
struct WaveDataCreature
{
uint8 SpawnCount, UsedSpawnPoint;
uint32 CreatureId, SpawnTimer, YellTimer;
};
static WaveData WavesInfo[] =
static WaveDataCreature WavesInfo[] =
{
{9, 0, 22075, 10000, 7000}, //Illidari Soldier
{2, 9, 22074, 10000, 7000}, //Illidari Mind Breaker

View File

@@ -122,7 +122,10 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
// insert new records to index table
for (uint32 i = 0; i < newRecords; ++i)
{
// cppcheck-suppress autoVariables
indexTable[newIndexes[i]] = &dataTable[i * _recordSize];
}
records = indexTableSize;