From e59bc54a62d456ed783d0a29cadd12e440e1ae86 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 11 Mar 2021 19:47:07 +0100 Subject: [PATCH] Core/Misc: fixed more static analysis warnings --- .../game/Entities/Creature/Creature.cpp | 18 +++-------------- src/server/game/Entities/Creature/Creature.h | 1 - src/server/game/Server/Packets/QueryPackets.h | 20 +++++++++---------- 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 04811b706b0..86c76b509c5 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2168,7 +2168,7 @@ void Creature::LoadTemplateImmunities() } } -bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional effectMask /*= nullptr*/) const +bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Optional effectMask /*= {}*/) const { if (!spellInfo) return false; @@ -2179,7 +2179,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster, Option if (!spellInfo->Effects[i].IsEffect()) continue; - if (effectMask && !(effectMask.value() & (1 << i))) + if (effectMask && !(*effectMask & (1 << i))) continue; if (!IsImmunedToSpellEffect(spellInfo, i, caster)) @@ -2897,7 +2897,7 @@ uint32 Creature::UpdateVendorItemCurrentCount(VendorItem const* vItem, uint32 us if (itr == m_vendorItemCounts.end()) { uint32 new_count = vItem->maxcount > used_count ? vItem->maxcount-used_count : 0; - m_vendorItemCounts.push_back(VendorItemCount(vItem->item, new_count)); + m_vendorItemCounts.emplace_back(VendorItemCount(vItem->item, new_count)); return new_count; } @@ -3354,18 +3354,6 @@ bool Creature::IsEscorted() const return false; } -bool Creature::IsAllowedToRepostionAgainst(Unit* target) const -{ - // Exceptions for repositioning against a too close enemy: - return GetCombatReach() <= 10.0f // 1. Creature has a too big combat reach - && !IsMovementPreventedByCasting() // 2. Creature is currently casting - && CanFreeMove() // 3. Creature cannot move - && !GetVehicleBase() // 4. Creature is on a vehicle - && !target->GetVehicleBase() // 5. Chase target is on a vehicle - && !IsDungeonBoss() // 6. Creature is a dungeon boss - && !isWorldBoss(); // 7. Creature is a world boss -} - void Creature::MakeInterruptable(bool apply) { ApplySpellImmune(0, IMMUNITY_MECHANIC, MECHANIC_INTERRUPT, !apply); diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 2cca23d4fc7..28dd75dbce6 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -359,7 +359,6 @@ class TC_GAME_API Creature : public Unit, public GridObject, public Ma bool IsEscorted() const; bool CanGiveExperience() const; - bool IsAllowedToRepostionAgainst(Unit* target) const; void MakeInterruptable(bool apply); diff --git a/src/server/game/Server/Packets/QueryPackets.h b/src/server/game/Server/Packets/QueryPackets.h index 9fd81f6b210..06d5f5b0d30 100644 --- a/src/server/game/Server/Packets/QueryPackets.h +++ b/src/server/game/Server/Packets/QueryPackets.h @@ -45,20 +45,20 @@ namespace WorldPackets struct CreatureStats { - std::array Name; - std::array NameAlt; + std::array Name = {}; + std::array NameAlt = {}; std::string Title; std::string CursorName; - std::array Flags; + std::array Flags = {}; uint32 CreatureType = 0; uint32 CreatureFamily = 0; uint32 Classification = 0; - std::array ProxyCreatureID; - std::array CreatureDisplayID; + std::array ProxyCreatureID = {}; + std::array CreatureDisplayID = {}; float HpMulti = 0.0f; float EnergyMulti = 0.0f; bool Leader = false; - std::array QuestItems; + std::array QuestItems = {}; uint32 CreatureMovementInfoID = 0; uint32 RequiredExpansion = 0; }; @@ -88,15 +88,15 @@ namespace WorldPackets struct GameObjectStats { - std::array Name; + std::array Name = {}; std::string IconName; std::string CastBarCaption; std::string UnkString; uint32 Type = 0; uint32 DisplayID = 0; - std::array Data; + std::array Data = {}; float Size = 0.0f; - std::array QuestItems; + std::array QuestItems = {}; int32 RequiredLevel = 0; }; @@ -120,7 +120,7 @@ namespace WorldPackets void Read() override; uint32 MissingQuestCount = 0; - std::array MissingQuestPOIs; + std::array MissingQuestPOIs = {}; }; struct DBQueryRecord