Permalink
Browse files

Core/Misc: Define multiple functions const (+ code cleanup here and t…

…here)
  • Loading branch information...
Spp- committed Mar 20, 2013
1 parent af200bf commit 69e81d46b16ab9172c0a0999e387a0fb7f0f939c
@@ -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));
@@ -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
@@ -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)
@@ -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();
@@ -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();
}
}
}
@@ -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
-*/
@@ -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)
@@ -21,6 +21,8 @@
#include "SharedDefines.h"
#include "SpellMgr.h"
#include "DBCfmt.h"
+#include "Timer.h"
+#include "ObjectDefines.h"
#include <map>
@@ -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,15 +303,15 @@ 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;
}
uint32 displayID = ObjectMgr::ChooseDisplayId(GetCreatureTemplate(), 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;
@@ -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;}
@@ -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;
@@ -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();
@@ -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();
Oops, something went wrong.

0 comments on commit 69e81d4

Please sign in to comment.