diff options
author | Spp <spp@jorge.gr> | 2013-03-20 14:18:26 +0100 |
---|---|---|
committer | Spp <spp@jorge.gr> | 2013-03-20 14:20:17 +0100 |
commit | 69e81d46b16ab9172c0a0999e387a0fb7f0f939c (patch) | |
tree | 9749a7b1f5948863ba5d9e9d7163384f147a2692 /src | |
parent | af200bfaa5a84c8011c4c487fe4c5ea64bc17418 (diff) |
Core/Misc: Define multiple functions const (+ code cleanup here and there)
Diffstat (limited to 'src')
20 files changed, 192 insertions, 195 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 9883a7231b3..4c80d268c12 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -52,13 +52,13 @@ AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(uint32 factionTemplateId) if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) return &mNeutralAuctions; - // team have linked auction houses - FactionTemplateEntry const* u_entry = sFactionTemplateStore.LookupEntry(factionTemplateId); - if (!u_entry) + // teams have linked auction houses + FactionTemplateEntry const* uEntry = sFactionTemplateStore.LookupEntry(factionTemplateId); + if (!uEntry) return &mNeutralAuctions; - else if (u_entry->ourMask & FACTION_MASK_ALLIANCE) + else if (uEntry->ourMask & FACTION_MASK_ALLIANCE) return &mAllianceAuctions; - else if (u_entry->ourMask & FACTION_MASK_HORDE) + else if (uEntry->ourMask & FACTION_MASK_HORDE) return &mHordeAuctions; else return &mNeutralAuctions; @@ -326,7 +326,7 @@ void AuctionHouseMgr::LoadAuctions() } GetAuctionsMap(aItem->factionTemplateId)->AddAuction(aItem); - count++; + ++count; } while (result->NextRow()); CharacterDatabase.CommitTransaction(trans); @@ -365,7 +365,7 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(uint32 factionTem if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) { - //FIXME: found way for proper auctionhouse selection by another way + // FIXME: found way for proper auctionhouse selection by another way // AuctionHouse.dbc have faction field with _player_ factions associated with auction house races. // but no easy way convert creature faction to player race faction for specific city switch (factionTemplateId) @@ -777,7 +777,8 @@ void AuctionHouseMgr::DeleteExpiredAuctionsAtStartup() delete auction; ++expirecount; - } while (expAuctions->NextRow()); + } + while (expAuctions->NextRow()); sLog->outInfo(LOG_FILTER_SERVER_LOADING, ">> Deleted %u expired auctions in %u ms", expirecount, GetMSTimeDiffToNow(oldMSTime)); diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index eb35dc494ee..e0e972c5d40 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -95,8 +95,6 @@ struct AuctionEntry class AuctionHouseObject { public: - // Initialize storage - AuctionHouseObject() { next = AuctionsMap.begin(); } ~AuctionHouseObject() { for (AuctionEntryMap::iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr) @@ -131,9 +129,6 @@ class AuctionHouseObject private: AuctionEntryMap AuctionsMap; - - // storage for "next" auction item for next Update() - AuctionEntryMap::const_iterator next; }; class AuctionHouseMgr diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp index 9d17f6d6ec1..685cb4937a7 100644 --- a/src/server/game/Battlefield/Battlefield.cpp +++ b/src/server/game/Battlefield/Battlefield.cpp @@ -65,8 +65,6 @@ Battlefield::~Battlefield() for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr) delete *itr; - - m_capturePoints.clear(); } // Called when a player enters the zone @@ -681,7 +679,6 @@ BfGraveyard::BfGraveyard(Battlefield* battlefield) m_ControlTeam = TEAM_NEUTRAL; m_SpiritGuide[0] = 0; m_SpiritGuide[1] = 0; - m_ResurrectQueue.clear(); } void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId) diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index f60a7cca8d3..5828789e77b 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -270,7 +270,7 @@ void Battleground::Update(uint32 diff) // after 47 minutes without one team losing, the arena closes with no winner and no rating change if (isArena()) { - if (GetStartTime() >= 47*MINUTE*IN_MILLISECONDS) + if (GetStartTime() >= 47 * MINUTE*IN_MILLISECONDS) { UpdateArenaWorldState(); CheckArenaAfterTimerConditions(); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 6d5f3d07bae..65d3b9dc0b8 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -49,14 +49,12 @@ BattlegroundQueue::~BattlegroundQueue() { m_events.KillAllEvents(false); - m_QueuedPlayers.clear(); for (int i = 0; i < MAX_BATTLEGROUND_BRACKETS; ++i) { for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j) { for (GroupsQueueType::iterator itr = m_QueuedGroups[i][j].begin(); itr!= m_QueuedGroups[i][j].end(); ++itr) delete (*itr); - m_QueuedGroups[i][j].clear(); } } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp index b0ffc7855dd..9d1c12a8903 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundBE.cpp @@ -157,18 +157,3 @@ void BattlegroundBE::UpdatePlayerScore(Player* Source, uint32 type, uint32 value Battleground::UpdatePlayerScore(Source, type, value, doAddHonor); } - -/* -21:45:46 id:231310 [S2C] SMSG_INIT_WORLD_STATES (706 = 0x02C2) len: 86 -0000: 32 02 00 00 76 0e 00 00 00 00 00 00 09 00 f3 09 | 2...v........... -0010: 00 00 01 00 00 00 f1 09 00 00 01 00 00 00 f0 09 | ................ -0020: 00 00 02 00 00 00 d4 08 00 00 00 00 00 00 d8 08 | ................ -0030: 00 00 00 00 00 00 d7 08 00 00 00 00 00 00 d6 08 | ................ -0040: 00 00 00 00 00 00 d5 08 00 00 00 00 00 00 d3 08 | ................ -0050: 00 00 00 00 00 00 | ...... - -spell 32724 - Gold Team -spell 32725 - Green Team -35774 Gold Team -35775 Green Team -*/ diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index bb2a7e08b0f..62b3416f72e 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -24,8 +24,6 @@ ChannelMgr::~ChannelMgr() { for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr) delete itr->second; - - channels.clear(); } ChannelMgr* ChannelMgr::forTeam(uint32 team) diff --git a/src/server/game/DataStores/DBCStores.cpp b/src/server/game/DataStores/DBCStores.cpp index 8a2dad902fa..f382082761a 100644 --- a/src/server/game/DataStores/DBCStores.cpp +++ b/src/server/game/DataStores/DBCStores.cpp @@ -21,6 +21,8 @@ #include "SharedDefines.h" #include "SpellMgr.h" #include "DBCfmt.h" +#include "Timer.h" +#include "ObjectDefines.h" #include <map> diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ec97cacc64a..52ca60a4d1e 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -16,13 +16,13 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include "Creature.h" #include "BattlegroundMgr.h" #include "CellImpl.h" #include "Common.h" #include "CreatureAI.h" #include "CreatureAISelector.h" #include "CreatureGroups.h" -#include "Creature.h" #include "DatabaseEnv.h" #include "Formulas.h" #include "GameEventMgr.h" @@ -169,8 +169,6 @@ m_creatureInfo(NULL), m_creatureData(NULL), m_path_id(0), m_formation(NULL) Creature::~Creature() { - m_vendorItemCounts.clear(); - delete i_AI; i_AI = NULL; @@ -258,12 +256,12 @@ void Creature::RemoveCorpse(bool setSpawnTime) /** * change the entry of creature until respawn */ -bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data) +bool Creature::InitEntry(uint32 entry, uint32 /*team*/, const CreatureData* data) { - CreatureTemplate const* normalInfo = sObjectMgr->GetCreatureTemplate(Entry); + CreatureTemplate const* normalInfo = sObjectMgr->GetCreatureTemplate(entry); if (!normalInfo) { - sLog->outError(LOG_FILTER_SQL, "Creature::InitEntry creature entry %u does not exist.", Entry); + sLog->outError(LOG_FILTER_SQL, "Creature::InitEntry creature entry %u does not exist.", entry); return false; } @@ -293,7 +291,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data if (GetMap()->Is25ManRaid()) loot.maxDuplicates = 3; - SetEntry(Entry); // normal entry always + SetEntry(entry); // normal entry always m_creatureInfo = cinfo; // map mode related always // equal to player Race field, but creature does not have race @@ -305,7 +303,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data // Cancel load if no model defined if (!(cinfo->GetFirstValidModelId())) { - sLog->outError(LOG_FILTER_SQL, "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", Entry); + sLog->outError(LOG_FILTER_SQL, "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", entry); return false; } @@ -313,7 +311,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData* data CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID); if (!minfo) // Cancel load if no model defined { - sLog->outError(LOG_FILTER_SQL, "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", Entry); + sLog->outError(LOG_FILTER_SQL, "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", entry); return false; } @@ -1248,7 +1246,7 @@ float Creature::_GetDamageMod(int32 Rank) } } -float Creature::GetSpellDamageMod(int32 Rank) +float Creature::GetSpellDamageMod(int32 Rank) const { switch (Rank) // define rates for each elite rank { @@ -1708,7 +1706,7 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/) ForcedDespawn(msTimeToDespawn); } -bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) +bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const { if (!spellInfo) return false; diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index f4016043799..6e771d2761b 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -155,13 +155,18 @@ struct CreatureTemplate return SKILL_SKINNING; // normal case } - bool isTameable(bool exotic) const + bool isExotic() const + { + return (type_flags & CREATURE_TYPEFLAGS_EXOTIC) != 0; + } + + bool isTameable(bool canTameExotic) const { if (type != CREATURE_TYPE_BEAST || family == 0 || (type_flags & CREATURE_TYPEFLAGS_TAMEABLE) == 0) return false; - // if can tame exotic then can tame any temable - return exotic || (type_flags & CREATURE_TYPEFLAGS_EXOTIC) == 0; + // if can tame exotic then can tame any tameable + return canTameExotic || !isExotic(); } }; @@ -481,8 +486,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature bool isCanInteractWithBattleMaster(Player* player, bool msg) const; bool isCanTrainingAndResetTalentsOf(Player* player) const; bool canCreatureAttack(Unit const* victim, bool force = true) const; - bool IsImmunedToSpell(SpellInfo const* spellInfo); //override Unit::IsImmunedToSpell - bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; //override Unit::IsImmunedToSpellEffect + bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // override Unit::IsImmunedToSpell + bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; // override Unit::IsImmunedToSpellEffect bool isElite() const; bool isWorldBoss() const; @@ -530,7 +535,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature uint8 GetCurrentEquipmentId() { return m_equipmentId; } void SetCurrentEquipmentId(uint8 id) { m_equipmentId = id; } - float GetSpellDamageMod(int32 Rank); + float GetSpellDamageMod(int32 Rank) const; VendorItemData const* GetVendorItems() const; uint32 GetVendorItemCurrentCount(VendorItem const* vItem); @@ -659,8 +664,8 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature uint32 GetWaypointPath(){return m_path_id;} void LoadPath(uint32 pathid) { m_path_id = pathid; } - uint32 GetCurrentWaypointID(){return m_waypointID;} - void UpdateWaypointID(uint32 wpID){m_waypointID = wpID;} + uint32 GetCurrentWaypointID() const { return m_waypointID; } + void UpdateWaypointID(uint32 wpID) { m_waypointID = wpID; } void SearchFormation(); CreatureGroup* GetFormation() {return m_formation;} diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 5dd726044ee..a88fdac2349 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -737,7 +737,7 @@ void Item::RemoveFromUpdateQueueOf(Player* player) if (!IsInUpdateQueue()) return; - ASSERT(player != NULL) + ASSERT(player != NULL); if (player->GetGUID() != GetOwnerGUID()) { @@ -1018,27 +1018,27 @@ void Item::SendTimeUpdate(Player* owner) owner->GetSession()->SendPacket(&data); } -Item* Item::CreateItem(uint32 item, uint32 count, Player const* player) +Item* Item::CreateItem(uint32 itemEntry, uint32 count, Player const* player) { if (count < 1) return NULL; //don't create item at zero count - ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item); - if (pProto) + ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemEntry); + if (proto) { - if (count > pProto->GetMaxStackSize()) - count = pProto->GetMaxStackSize(); + if (count > proto->GetMaxStackSize()) + count = proto->GetMaxStackSize(); ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already"); - Item* pItem = NewItemOrBag(pProto); - if (pItem->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), item, player)) + Item* item = NewItemOrBag(proto); + if (item->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_ITEM), itemEntry, player)) { - pItem->SetCount(count); - return pItem; + item->SetCount(count); + return item; } else - delete pItem; + delete item; } else ASSERT(false); @@ -1176,7 +1176,7 @@ bool Item::IsRefundExpired() return (GetPlayedTime() > 2*HOUR); } -void Item::SetSoulboundTradeable(AllowedLooterSet& allowedLooters) +void Item::SetSoulboundTradeable(AllowedLooterSet const& allowedLooters) { SetFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_BOP_TRADEABLE); allowedGUIDs = allowedLooters; diff --git a/src/server/game/Entities/Item/Item.h b/src/server/game/Entities/Item/Item.h index 2f5ba02739d..0d34305d15c 100644 --- a/src/server/game/Entities/Item/Item.h +++ b/src/server/game/Entities/Item/Item.h @@ -208,7 +208,7 @@ bool ItemCanGoIntoBag(ItemTemplate const* proto, ItemTemplate const* pBagProto); class Item : public Object { public: - static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL); + static Item* CreateItem(uint32 itemEntry, uint32 count, Player const* player = NULL); Item* CloneItem(uint32 count, Player const* player = NULL) const; Item(); @@ -334,16 +334,17 @@ class Item : public Object void SetRefundRecipient(uint32 pGuidLow) { m_refundRecipient = pGuidLow; } void SetPaidMoney(uint32 money) { m_paidMoney = money; } void SetPaidExtendedCost(uint32 iece) { m_paidExtendedCost = iece; } - uint32 GetRefundRecipient() { return m_refundRecipient; } - uint32 GetPaidMoney() { return m_paidMoney; } - uint32 GetPaidExtendedCost() { return m_paidExtendedCost; } + + uint32 GetRefundRecipient() const { return m_refundRecipient; } + uint32 GetPaidMoney() const { return m_paidMoney; } + uint32 GetPaidExtendedCost() const { return m_paidExtendedCost; } void UpdatePlayedTime(Player* owner); uint32 GetPlayedTime(); bool IsRefundExpired(); // Soulbound trade system - void SetSoulboundTradeable(AllowedLooterSet& allowedLooters); + void SetSoulboundTradeable(AllowedLooterSet const& allowedLooters); void ClearSoulboundTradeable(Player* currentOwner); bool CheckSoulboundTradeExpire(); diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 7dc61c01d02..6c54ccfbdf7 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -211,19 +211,21 @@ class Object void ForceValuesUpdateAtIndex(uint32); Player* ToPlayer() { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player*>(this); else return NULL; } - Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return (Player const*)((Player*)this); else return NULL; } + Player const* ToPlayer() const { if (GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Player const*>(this); else return NULL; } + Creature* ToCreature() { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature*>(this); else return NULL; } - Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return (Creature const*)((Creature*)this); else return NULL; } + Creature const* ToCreature() const { if (GetTypeId() == TYPEID_UNIT) return reinterpret_cast<Creature const*>(this); else return NULL; } + + Unit* ToUnit() { if (isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit*>(this); else return NULL; } + Unit const* ToUnit() const { if (isType(TYPEMASK_UNIT)) return reinterpret_cast<Unit const*>(this); else return NULL; } - Unit* ToUnit() { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return reinterpret_cast<Unit*>(this); else return NULL; } - Unit const* ToUnit() const { if (GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) return (const Unit*)((Unit*)this); else return NULL; } GameObject* ToGameObject() { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject*>(this); else return NULL; } - GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return (const GameObject*)((GameObject*)this); else return NULL; } + GameObject const* ToGameObject() const { if (GetTypeId() == TYPEID_GAMEOBJECT) return reinterpret_cast<GameObject const*>(this); else return NULL; } Corpse* ToCorpse() { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse*>(this); else return NULL; } - Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return (const Corpse*)((Corpse*)this); else return NULL; } - protected: + Corpse const* ToCorpse() const { if (GetTypeId() == TYPEID_CORPSE) return reinterpret_cast<Corpse const*>(this); else return NULL; } + protected: Object(); void _InitValues(); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 6d83ea60dba..4b3adf6fba7 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -23326,7 +23326,7 @@ OutdoorPvP* Player::GetOutdoorPvP() const return sOutdoorPvPMgr->GetOutdoorPvPToZoneId(GetZoneId()); } -bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem) +bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem) const { if (spellInfo->EquippedItemClass < 0) return true; @@ -23337,7 +23337,7 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons { case ITEM_CLASS_WEAPON: { - for (uint8 i= EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) + for (uint8 i = EQUIPMENT_SLOT_MAINHAND; i < EQUIPMENT_SLOT_TABARD; ++i) if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; @@ -23346,7 +23346,7 @@ bool Player::HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item cons case ITEM_CLASS_ARMOR: { // tabard not have dependent spells - for (uint8 i= EQUIPMENT_SLOT_START; i< EQUIPMENT_SLOT_MAINHAND; ++i) + for (uint8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_MAINHAND; ++i) if (Item* item = GetUseableItemByPos(INVENTORY_SLOT_BAG_0, i)) if (item != ignoreItem && item->IsFitToSpellRequirements(spellInfo)) return true; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index bf38eba9d4c..6458de47378 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1213,7 +1213,7 @@ class Player : public Unit, public GridObject<Player> uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, 2); } void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, 2, count); } bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const; - bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = NULL); + bool HasItemFitToSpellRequirements(SpellInfo const* spellInfo, Item const* ignoreItem = NULL) const; bool CanNoReagentCast(SpellInfo const* spellInfo) const; bool HasItemOrGemWithIdEquipped(uint32 item, uint32 count, uint8 except_slot = NULL_SLOT) const; bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; @@ -1759,7 +1759,7 @@ class Player : public Unit, public GridObject<Player> float OCTRegenMPPerSpirit(); float GetRatingMultiplier(CombatRating cr) const; float GetRatingBonusValue(CombatRating cr) const; - uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; } + uint32 GetBaseSpellPowerBonus() const { return m_baseSpellPower; } int32 GetSpellPenetrationItemMod() const { return m_spellPenetrationItemMod; } float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index d76885591a5..87ca7a6c62b 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -4151,7 +4151,7 @@ AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 ico return NULL; } -AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) +AuraEffect* Unit::GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID) const { AuraEffectList const& auras = GetAuraEffectsByType(type); for (AuraEffectList::const_iterator i = auras.begin(); i != auras.end(); ++i) @@ -4467,7 +4467,7 @@ float Unit::GetTotalAuraMultiplier(AuraType auratype) const return multiplier; } -int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) +int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const { int32 modifier = 0; @@ -4493,7 +4493,7 @@ int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const return modifier; } -int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const +int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 miscMask) const { std::map<SpellGroup, int32> SameEffectSpellGroup; int32 modifier = 0; @@ -4501,7 +4501,7 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) - if ((*i)->GetMiscValue() & misc_mask) + if ((*i)->GetMiscValue() & miscMask) if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) modifier += (*i)->GetAmount(); @@ -4511,7 +4511,7 @@ int32 Unit::GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) return modifier; } -float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const +float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 miscMask) const { std::map<SpellGroup, int32> SameEffectSpellGroup; float multiplier = 1.0f; @@ -4519,7 +4519,7 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if (((*i)->GetMiscValue() & misc_mask)) + if (((*i)->GetMiscValue() & miscMask)) { // Check if the Aura Effect has a the Same Effect Stack Rule and if so, use the highest amount of that SpellGroup // If the Aura Effect does not have this Stack Rule, it returns false so we can add to the multiplier as usual @@ -4534,35 +4534,35 @@ float Unit::GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask return multiplier; } -int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask, const AuraEffect* except) const +int32 Unit::GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 miscMask, const AuraEffect* except) const { int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if (except != (*i) && (*i)->GetMiscValue()& misc_mask && (*i)->GetAmount() > modifier) + if (except != (*i) && (*i)->GetMiscValue()& miscMask && (*i)->GetAmount() > modifier) modifier = (*i)->GetAmount(); } return modifier; } -int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const +int32 Unit::GetMaxNegativeAuraModifierByMiscMask(AuraType auratype, uint32 miscMask) const { int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue()& misc_mask && (*i)->GetAmount() < modifier) + if ((*i)->GetMiscValue()& miscMask && (*i)->GetAmount() < modifier) modifier = (*i)->GetAmount(); } return modifier; } -int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const { std::map<SpellGroup, int32> SameEffectSpellGroup; int32 modifier = 0; @@ -4570,7 +4570,7 @@ int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue() == misc_value) + if ((*i)->GetMiscValue() == miscValue) if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) modifier += (*i)->GetAmount(); } @@ -4581,7 +4581,7 @@ int32 Unit::GetTotalAuraModifierByMiscValue(AuraType auratype, int32 misc_value) return modifier; } -float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_value) const +float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 miscValue) const { std::map<SpellGroup, int32> SameEffectSpellGroup; float multiplier = 1.0f; @@ -4589,7 +4589,7 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_valu AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue() == misc_value) + if ((*i)->GetMiscValue() == miscValue) if (!sSpellMgr->AddSameEffectStackRuleSpellGroups((*i)->GetSpellInfo(), (*i)->GetAmount(), SameEffectSpellGroup)) AddPct(multiplier, (*i)->GetAmount()); } @@ -4600,28 +4600,28 @@ float Unit::GetTotalAuraMultiplierByMiscValue(AuraType auratype, int32 misc_valu return multiplier; } -int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +int32 Unit::GetMaxPositiveAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const { int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue() == misc_value && (*i)->GetAmount() > modifier) + if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() > modifier) modifier = (*i)->GetAmount(); } return modifier; } -int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 misc_value) const +int32 Unit::GetMaxNegativeAuraModifierByMiscValue(AuraType auratype, int32 miscValue) const { int32 modifier = 0; AuraEffectList const& mTotalAuraList = GetAuraEffectsByType(auratype); for (AuraEffectList::const_iterator i = mTotalAuraList.begin(); i != mTotalAuraList.end(); ++i) { - if ((*i)->GetMiscValue() == misc_value && (*i)->GetAmount() < modifier) + if ((*i)->GetMiscValue() == miscValue && (*i)->GetAmount() < modifier) modifier = (*i)->GetAmount(); } @@ -9826,7 +9826,7 @@ void Unit::UnsummonAllTotems() void Unit::SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical) { // we guess size - WorldPacket data(SMSG_SPELLHEALLOG, (8+8+4+4+4+4+1+1)); + WorldPacket data(SMSG_SPELLHEALLOG, 8 + 8 + 4 + 4 + 4 + 4 + 1 + 1); data.append(victim->GetPackGUID()); data.append(GetPackGUID()); data << uint32(SpellID); @@ -9849,28 +9849,28 @@ int32 Unit::HealBySpell(Unit* victim, SpellInfo const* spellInfo, uint32 addHeal return gain; } -void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellID, uint32 damage, Powers powerType) +void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType) { WorldPacket data(SMSG_SPELLENERGIZELOG, (8+8+4+4+4+1)); data.append(victim->GetPackGUID()); data.append(GetPackGUID()); - data << uint32(spellID); + data << uint32(spellId); data << uint32(powerType); - data << uint32(damage); + data << int32(damage); SendMessageToSet(&data, true); } -void Unit::EnergizeBySpell(Unit* victim, uint32 spellID, uint32 damage, Powers powerType) +void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType) { - SendEnergizeSpellLog(victim, spellID, damage, powerType); + SendEnergizeSpellLog(victim, spellId, damage, powerType); // needs to be called after sending spell log victim->ModifyPower(powerType, damage); - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellID); + SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId); victim->getHostileRefManager().threatAssist(this, float(damage) * 0.5f, spellInfo); } -uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) const { if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) return pdamage; @@ -9934,7 +9934,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin AddPct(DoneTotalMod, (*i)->GetAmount()); // done scripted mod (take it from owner) - Unit* owner = GetOwner() ? GetOwner() : this; + Unit const * const owner = GetOwner() ? GetOwner() : this; AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { @@ -9967,8 +9967,8 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin for (AuraApplicationMap::const_iterator itr = victimAuras.begin(); itr != victimAuras.end(); ++itr) { Aura const* aura = itr->second->GetBase(); - SpellInfo const* m_spell = aura->GetSpellInfo(); - if (m_spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(m_spell->SpellFamilyFlags[1] & 0x0004071B || m_spell->SpellFamilyFlags[0] & 0x8044C402)) + SpellInfo const* spell = aura->GetSpellInfo(); + if (spell->SpellFamilyName != SPELLFAMILY_WARLOCK || !(spell->SpellFamilyFlags[1] & 0x0004071B || spell->SpellFamilyFlags[0] & 0x8044C402)) continue; modPercent += stepPercent * aura->GetStackAmount(); if (modPercent >= maxPercent) @@ -10288,7 +10288,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin return uint32(std::max(tmpDamage, 0.0f)); } -uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) const { if (!spellProto || damagetype == DIRECT_DAMAGE) return pdamage; @@ -10388,7 +10388,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui return uint32(std::max(tmpDamage, 0.0f)); } -int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) +int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const { int32 DoneAdvertisedBenefit = 0; @@ -10427,7 +10427,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) return DoneAdvertisedBenefit; } -int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) +int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const { int32 TakenAdvertisedBenefit = 0; @@ -10705,7 +10705,7 @@ uint32 Unit::SpellCriticalHealingBonus(SpellInfo const* spellProto, uint32 damag return damage; } -uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) const { // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && isTotem()) @@ -10725,7 +10725,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui AddPct(DoneTotalMod, (*i)->GetAmount()); // done scripted mod (take it from owner) - Unit* owner = GetOwner() ? GetOwner() : this; + Unit const* owner = GetOwner() ? GetOwner() : this; AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i) { @@ -10856,7 +10856,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui return uint32(std::max(heal, 0.0f)); } -uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack) const { float TakenTotalMod = 1.0f; @@ -10961,20 +10961,20 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u return uint32(std::max(heal, 0.0f)); } -int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) +int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const { - int32 AdvertisedBenefit = 0; + int32 advertisedBenefit = 0; AuraEffectList const& mHealingDone = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING_DONE); for (AuraEffectList::const_iterator i = mHealingDone.begin(); i != mHealingDone.end(); ++i) if (!(*i)->GetMiscValue() || ((*i)->GetMiscValue() & schoolMask) != 0) - AdvertisedBenefit += (*i)->GetAmount(); + advertisedBenefit += (*i)->GetAmount(); // Healing bonus of spirit, intellect and strength if (GetTypeId() == TYPEID_PLAYER) { // Base value - AdvertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus(); + advertisedBenefit += ToPlayer()->GetBaseSpellPowerBonus(); // Healing bonus from stats AuraEffectList const& mHealingDoneOfStatPercent = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_HEALING_OF_STAT_PERCENT); @@ -10982,31 +10982,31 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) { // stat used dependent from misc value (stat index) Stats usedStat = Stats((*i)->GetSpellInfo()->Effects[(*i)->GetEffIndex()].MiscValue); - AdvertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount())); + advertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount())); } // ... and attack power AuraEffectList const& mHealingDonebyAP = GetAuraEffectsByType(SPELL_AURA_MOD_SPELL_HEALING_OF_ATTACK_POWER); for (AuraEffectList::const_iterator i = mHealingDonebyAP.begin(); i != mHealingDonebyAP.end(); ++i) if ((*i)->GetMiscValue() & schoolMask) - AdvertisedBenefit += int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount())); + advertisedBenefit += int32(CalculatePct(GetTotalAttackPowerValue(BASE_ATTACK), (*i)->GetAmount())); } - return AdvertisedBenefit; + return advertisedBenefit; } -int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) +int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const { - int32 AdvertisedBenefit = 0; + int32 advertisedBenefit = 0; AuraEffectList const& mDamageTaken = GetAuraEffectsByType(SPELL_AURA_MOD_HEALING); for (AuraEffectList::const_iterator i = mDamageTaken.begin(); i != mDamageTaken.end(); ++i) if (((*i)->GetMiscValue() & schoolMask) != 0) - AdvertisedBenefit += (*i)->GetAmount(); + advertisedBenefit += (*i)->GetAmount(); - return AdvertisedBenefit; + return advertisedBenefit; } -bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) +bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) const { // If m_immuneToSchool type contain this school type, IMMUNE damage. SpellImmuneList const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; @@ -11023,7 +11023,7 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask shoolMask) return false; } -bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) +bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const { if (spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY) return false; @@ -11047,7 +11047,7 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) return false; } -bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) +bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const { if (!spellInfo) return false; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index dc4c89198db..49df2659433 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -759,16 +759,6 @@ namespace Movement{ class MoveSpline; } -enum DiminishingLevels -{ - DIMINISHING_LEVEL_1 = 0, - DIMINISHING_LEVEL_2 = 1, - DIMINISHING_LEVEL_3 = 2, - DIMINISHING_LEVEL_IMMUNE = 3, - DIMINISHING_LEVEL_4 = 3, - DIMINISHING_LEVEL_TAUNT_IMMUNE = 4 -}; - struct DiminishingReturn { DiminishingReturn(DiminishingGroup group, uint32 t, uint32 count) @@ -842,16 +832,16 @@ public: void ResistDamage(uint32 amount); void BlockDamage(uint32 amount); - Unit* GetAttacker() const { return m_attacker; }; - Unit* GetVictim() const { return m_victim; }; - SpellInfo const* GetSpellInfo() const { return m_spellInfo; }; - SpellSchoolMask GetSchoolMask() const { return m_schoolMask; }; - DamageEffectType GetDamageType() const { return m_damageType; }; - WeaponAttackType GetAttackType() const { return m_attackType; }; - uint32 GetDamage() const { return m_damage; }; - uint32 GetAbsorb() const { return m_absorb; }; - uint32 GetResist() const { return m_resist; }; - uint32 GetBlock() const { return m_block; }; + Unit* GetAttacker() const { return m_attacker; } + Unit* GetVictim() const { return m_victim; } + SpellInfo const* GetSpellInfo() const { return m_spellInfo; } + SpellSchoolMask GetSchoolMask() const { return m_schoolMask; } + DamageEffectType GetDamageType() const { return m_damageType; } + WeaponAttackType GetAttackType() const { return m_attackType; } + uint32 GetDamage() const { return m_damage; } + uint32 GetAbsorb() const { return m_absorb; } + uint32 GetResist() const { return m_resist; } + uint32 GetBlock() const { return m_block; } }; class HealInfo @@ -876,35 +866,42 @@ public: m_heal -= amount; } - uint32 GetHeal() const { return m_heal; }; + uint32 GetHeal() const { return m_heal; } }; class ProcEventInfo { -private: - Unit* const _actor; - Unit* const _actionTarget; - Unit* const _procTarget; - uint32 _typeMask; - uint32 _spellTypeMask; - uint32 _spellPhaseMask; - uint32 _hitMask; - Spell* _spell; - DamageInfo* _damageInfo; - HealInfo* _healInfo; public: - explicit ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo); - Unit* GetActor() { return _actor; }; + ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget, uint32 typeMask, + uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, + Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo); + + Unit* GetActor() { return _actor; } Unit* GetActionTarget() const { return _actionTarget; } Unit* GetProcTarget() const { return _procTarget; } + uint32 GetTypeMask() const { return _typeMask; } uint32 GetSpellTypeMask() const { return _spellTypeMask; } uint32 GetSpellPhaseMask() const { return _spellPhaseMask; } uint32 GetHitMask() const { return _hitMask; } + SpellInfo const* GetSpellInfo() const { return NULL; } SpellSchoolMask GetSchoolMask() const { return SPELL_SCHOOL_MASK_NONE; } + DamageInfo* GetDamageInfo() const { return _damageInfo; } HealInfo* GetHealInfo() const { return _healInfo; } + +private: + Unit* const _actor; + Unit* const _actionTarget; + Unit* const _procTarget; + uint32 _typeMask; + uint32 _spellTypeMask; + uint32 _spellPhaseMask; + uint32 _hitMask; + Spell* _spell; + DamageInfo* _damageInfo; + HealInfo* _healInfo; }; // Struct for use in Unit::CalculateMeleeDamage @@ -1523,8 +1520,8 @@ class Unit : public WorldObject void SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical = false); int32 HealBySpell(Unit* victim, SpellInfo const* spellInfo, uint32 addHealth, bool critical = false); - void SendEnergizeSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype); - void EnergizeBySpell(Unit* victim, uint32 SpellID, uint32 Damage, Powers powertype); + void SendEnergizeSpellLog(Unit* victim, uint32 spellID, int32 damage, Powers powerType); + void EnergizeBySpell(Unit* victim, uint32 SpellID, int32 Damage, Powers powertype); uint32 SpellNonMeleeDamageLog(Unit* victim, uint32 spellID, uint32 damage); void CastSpell(SpellCastTargets const& targets, SpellInfo const* spellInfo, CustomSpellValues const* value, TriggerCastFlags triggerFlags = TRIGGERED_NONE, Item* castItem = NULL, AuraEffect const* triggeredByAura = NULL, uint64 originalCaster = 0); @@ -1602,10 +1599,10 @@ class Unit : public WorldObject void BuildHeartBeatMsg(WorldPacket* data) const; - bool isAlive() const { return (m_deathState == ALIVE); }; - bool isDying() const { return (m_deathState == JUST_DIED); }; - bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); }; - DeathState getDeathState() { return m_deathState; }; + bool isAlive() const { return (m_deathState == ALIVE); } + bool isDying() const { return (m_deathState == JUST_DIED); } + bool isDead() const { return (m_deathState == DEAD || m_deathState == CORPSE); } + DeathState getDeathState() const { return m_deathState; } virtual void setDeathState(DeathState s); // overwrited in Creature/Player/Pet uint64 GetOwnerGUID() const { return GetUInt64Value(UNIT_FIELD_SUMMONEDBY); } @@ -1738,7 +1735,7 @@ class Unit : public WorldObject AuraEffect* GetAuraEffect(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const; AuraEffect* GetAuraEffectOfRankedSpell(uint32 spellId, uint8 effIndex, uint64 casterGUID = 0) const; AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; // spell mustn't have familyflags - AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID =0); + AuraEffect* GetAuraEffect(AuraType type, SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID =0) const; AuraEffect* GetDummyAuraEffect(SpellFamilyNames name, uint32 iconId, uint8 effIndex) const; AuraApplication * GetAuraApplication(uint32 spellId, uint64 casterGUID = 0, uint64 itemCasterGUID = 0, uint8 reqEffMask = 0, AuraApplication * except = NULL) const; @@ -1767,7 +1764,7 @@ class Unit : public WorldObject int32 GetTotalAuraModifier(AuraType auratype) const; float GetTotalAuraMultiplier(AuraType auratype) const; - int32 GetMaxPositiveAuraModifier(AuraType auratype); + int32 GetMaxPositiveAuraModifier(AuraType auratype) const; int32 GetMaxNegativeAuraModifier(AuraType auratype) const; int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const; @@ -1931,14 +1928,14 @@ class Unit : public WorldObject Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo); Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = NULL); - int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask); - int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask); - uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); - int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask); - int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask); - uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1); + int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask) const; + int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const; + uint32 SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1) const; + uint32 SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1) const; + int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask) const; + int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; + uint32 SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; + uint32 SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, uint32 healamount, DamageEffectType damagetype, uint32 stack = 1) const; uint32 MeleeDamageBonusDone(Unit* pVictim, uint32 damage, WeaponAttackType attType, SpellInfo const* spellProto = NULL); uint32 MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackType attType, SpellInfo const* spellProto = NULL); @@ -1962,10 +1959,10 @@ class Unit : public WorldObject void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply); void ApplySpellDispelImmunity(const SpellInfo* spellProto, DispelType type, bool apply); - virtual bool IsImmunedToSpell(SpellInfo const* spellInfo); + virtual bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // redefined in Creature - bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask); - bool IsImmunedToDamage(SpellInfo const* spellInfo); + bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const; + bool IsImmunedToDamage(SpellInfo const* spellInfo) const; virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; // redefined in Creature static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = NULL, uint8 effIndex = MAX_SPELL_EFFECTS); @@ -2103,10 +2100,14 @@ class Unit : public WorldObject virtual bool isBeingLoaded() const { return false;} bool IsDuringRemoveFromWorld() const {return m_duringRemoveFromWorld;} - Pet* ToPet(){ if (isPet()) return reinterpret_cast<Pet*>(this); else return NULL; } - Totem* ToTotem(){ if (isTotem()) return reinterpret_cast<Totem*>(this); else return NULL; } + Pet* ToPet() { if (isPet()) return reinterpret_cast<Pet*>(this); else return NULL; } + Pet const* ToPet() const { if (isPet()) return reinterpret_cast<Pet const*>(this); else return NULL; } + + Totem* ToTotem() { if (isTotem()) return reinterpret_cast<Totem*>(this); else return NULL; } + Totem const* ToTotem() const { if (isTotem()) return reinterpret_cast<Totem const*>(this); else return NULL; } + TempSummon* ToTempSummon() { if (isSummon()) return reinterpret_cast<TempSummon*>(this); else return NULL; } - const TempSummon* ToTempSummon() const { if (isSummon()) return reinterpret_cast<const TempSummon*>(this); else return NULL; } + TempSummon const* ToTempSummon() const { if (isSummon()) return reinterpret_cast<TempSummon const*>(this); else return NULL; } void SetTarget(uint64 guid); diff --git a/src/server/game/Miscellaneous/SharedDefines.h b/src/server/game/Miscellaneous/SharedDefines.h index c6e58e9cb3a..caf504944c6 100644 --- a/src/server/game/Miscellaneous/SharedDefines.h +++ b/src/server/game/Miscellaneous/SharedDefines.h @@ -3568,4 +3568,14 @@ enum NavTerrain // we only have 8 bits }; +enum DiminishingLevels +{ + DIMINISHING_LEVEL_1 = 0, + DIMINISHING_LEVEL_2 = 1, + DIMINISHING_LEVEL_3 = 2, + DIMINISHING_LEVEL_IMMUNE = 3, + DIMINISHING_LEVEL_4 = 3, + DIMINISHING_LEVEL_TAUNT_IMMUNE = 4 +}; + #endif diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index cc0a0101597..3e6ba0023b1 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -22,6 +22,7 @@ #include "Util.h" #include "DBCStructure.h" #include "Object.h" +#include "SpellAuraDefines.h" class Unit; class Player; diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h index a717a0544f2..c1b64e76a41 100644 --- a/src/server/game/Spells/SpellMgr.h +++ b/src/server/game/Spells/SpellMgr.h @@ -22,9 +22,15 @@ // For static or at-server-startup loaded spell data #include <ace/Singleton.h> -#include "Common.h" + +#include "DBCStructure.h" #include "SharedDefines.h" -#include "Unit.h" +#include "UnorderedMap.h" +#include "Util.h" + +#include <map> +#include <set> +#include <vector> class SpellInfo; class Player; @@ -442,10 +448,7 @@ class PetAura typedef UNORDERED_MAP<uint32, uint32> PetAuraMap; public: - PetAura() : removeOnChangePet(false), damage(0) - { - auras.clear(); - } + PetAura() : removeOnChangePet(false), damage(0) { } PetAura(uint32 petEntry, uint32 aura, bool _removeOnChangePet, int _damage) : removeOnChangePet(_removeOnChangePet), damage(_damage) |