Apply style fix

This commit is contained in:
Antz 2020-01-10 23:13:44 +00:00
parent 5531a0087d
commit 35405dd549
155 changed files with 10968 additions and 3660 deletions

View file

@ -34,7 +34,9 @@ int AggressorAI::Permissible(const Creature* creature)
{
// have some hostile factions, it will be selected by IsHostileTo check at MoveInLineOfSight
if (!creature->IsCivilian() && !creature->IsNeutralToAll())
{ return PERMIT_BASE_PROACTIVE; }
{
return PERMIT_BASE_PROACTIVE;
}
return PERMIT_BASE_NO;
}
@ -47,7 +49,9 @@ void AggressorAI::MoveInLineOfSight(Unit* u)
{
// Ignore Z for flying creatures
if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE)
{ return; }
{
return;
}
if (m_creature->CanInitiateAttack() && u->IsTargetableForAttack() &&
m_creature->IsHostileTo(u) && u->isInAccessablePlaceFor(m_creature))
@ -111,7 +115,9 @@ void AggressorAI::EnterEvadeMode()
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
{ m_creature->GetMotionMaster()->MoveTargetedHome(); }
{
m_creature->GetMotionMaster()->MoveTargetedHome();
}
}
m_creature->DeleteThreatList();
@ -124,7 +130,9 @@ void AggressorAI::UpdateAI(const uint32 /*diff*/)
{
// update i_victimGuid if m_creature->getVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
{ return; }
{
return;
}
i_victimGuid = m_creature->getVictim()->GetObjectGuid();
@ -140,7 +148,9 @@ bool AggressorAI::IsVisible(Unit* pl) const
void AggressorAI::AttackStart(Unit* u)
{
if (!u || !m_creature->CanAttackByItself())
{ return; }
{
return;
}
if (m_creature->Attack(u, true))
{

View file

@ -62,7 +62,9 @@ AuctionHouseMgr::~AuctionHouseMgr()
AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house)
{
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
{ return &mAuctions[AUCTION_HOUSE_NEUTRAL]; }
{
return &mAuctions[AUCTION_HOUSE_NEUTRAL];
}
// team have linked auction houses
switch (GetAuctionHouseTeam(house))
@ -84,7 +86,9 @@ uint64 AuctionHouseMgr::GetAuctionDeposit(AuctionHouseEntry const* entry, uint32
float min_deposit = float(sWorld.getConfig(CONFIG_UINT32_AUCTION_DEPOSIT_MIN));
if (deposit < min_deposit)
{ deposit = min_deposit; }
{
deposit = min_deposit;
}
return uint64(deposit * sWorld.getConfig(CONFIG_FLOAT_RATE_AUCTION_DEPOSIT));
}
@ -94,7 +98,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction)
{
Item* pItem = GetAItem(auction->itemGuidLow);
if (!pItem)
{ return; }
{
return;
}
ObjectGuid bidder_guid = ObjectGuid(HIGHGUID_PLAYER, auction->bidder);
Player* bidder = sObjectMgr.GetPlayer(bidder_guid);
@ -123,7 +129,9 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction)
if (bidder_security > SEC_PLAYER) // not do redundant DB requests
{
if (!sObjectMgr.GetPlayerNameByGUID(bidder_guid, bidder_name))
{ bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN); }
{
bidder_name = sObjectMgr.GetMangosStringForDBCLocale(LANG_UNKNOWN);
}
}
}
@ -196,7 +204,9 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction)
uint32 owner_accId = 0;
if (!owner)
{ owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); }
{
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
}
// owner exist
if (owner || owner_accId)
@ -245,7 +255,9 @@ void AuctionHouseMgr::SendAuctionExpiredMail(AuctionEntry* auction)
uint32 owner_accId = 0;
if (!owner)
{ owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid); }
{
owner_accId = sObjectMgr.GetPlayerAccountIdByGUID(owner_guid);
}
// owner exist
if (owner || owner_accId)
@ -561,7 +573,9 @@ AuctionHouseEntry const* AuctionHouseMgr::GetAuctionHouseEntry(Unit* unit)
{
Player* player = (Player*)unit;
if (player->GetAuctionAccessMode() > 0)
{ houseid = 7; }
{
houseid = 7;
}
else
{
switch (((Player*)unit)->GetTeam())
@ -630,7 +644,9 @@ void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player,
if (Aentry->bidder == player->GetGUIDLow())
{
if (itr->second->BuildAuctionInfo(data))
{ ++count; }
{
++count;
}
++totalcount;
}
}
@ -646,7 +662,9 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player,
if (Aentry->owner == player->GetGUIDLow())
{
if (Aentry->BuildAuctionInfo(data))
{ ++count; }
{
++count;
}
++totalcount;
}
}
@ -818,7 +836,9 @@ void WorldSession::BuildListAuctionItems(std::vector<AuctionEntry*> const& aucti
continue;
Item* item = sAuctionMgr.GetAItem(Aentry->itemGuidLow);
if (!item)
{ continue; }
{
continue;
}
if (isFull)
{
@ -830,19 +850,29 @@ void WorldSession::BuildListAuctionItems(std::vector<AuctionEntry*> const& aucti
ItemPrototype const* proto = item->GetProto();
if (itemClass != 0xffffffff && proto->Class != itemClass)
{ continue; }
{
continue;
}
if (itemSubClass != 0xffffffff && proto->SubClass != itemSubClass)
{ continue; }
{
continue;
}
if (inventoryType != 0xffffffff && proto->InventoryType != inventoryType)
{ continue; }
{
continue;
}
if (quality != 0xffffffff && proto->Quality < quality)
{ continue; }
{
continue;
}
if (levelmin != 0x00 && (proto->RequiredLevel < levelmin || (levelmax != 0x00 && proto->RequiredLevel > levelmax)))
{ continue; }
{
continue;
}
if (usable != 0x00)
{
@ -867,7 +897,9 @@ void WorldSession::BuildListAuctionItems(std::vector<AuctionEntry*> const& aucti
sObjectMgr.GetItemLocaleStrings(proto->ItemId, loc_idx, &name);
if (!wsearchedname.empty() && !Utf8FitTo(name, wsearchedname))
{ continue; }
{
continue;
}
if (count < 50 && totalcount >= listfrom)
{
@ -942,7 +974,9 @@ AuctionEntry* AuctionHouseObject::AddAuction(AuctionHouseEntry const* auctionHou
AH->SaveToDB();
if (pl)
{ pl->SaveInventoryAndGoldToDB(); }
{
pl->SaveInventoryAndGoldToDB();
}
CharacterDatabase.CommitTransaction();
@ -993,7 +1027,9 @@ uint64 AuctionEntry::GetAuctionOutBid() const
{
uint64 outbid = (bid / 100) * 5;
if (!outbid)
{ outbid = 1; }
{
outbid = 1;
}
return outbid;
}
@ -1018,7 +1054,9 @@ void AuctionEntry::AuctionBidWinning(Player* newbidder)
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("UPDATE auction SET itemguid = 0, moneyTime = '" UI64FMTD "', buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", (uint64)moneyDeliveryTime, bidder, bid, Id);
if (newbidder)
{ newbidder->SaveInventoryAndGoldToDB(); }
{
newbidder->SaveInventoryAndGoldToDB();
}
CharacterDatabase.CommitTransaction();
sAuctionMgr.SendAuctionWonMail(this);
@ -1030,7 +1068,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/)
// bid can't be greater buyout
if (buyout && newbid > buyout)
{ newbid = buyout; }
{
newbid = buyout;
}
if (newbidder && newbidder->GetGUIDLow() == bidder)
{
@ -1042,7 +1082,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/)
newbidder->ModifyMoney(-int64(newbid));
if (bidder) // return money to old bidder if present
{ WorldSession::SendAuctionOutbiddedMail(this); }
{
WorldSession::SendAuctionOutbiddedMail(this);
}
}
bidder = newbidder ? newbidder->GetGUIDLow() : 0;
@ -1057,7 +1099,9 @@ bool AuctionEntry::UpdateBid(uint64 newbid, Player* newbidder /*=NULL*/)
CharacterDatabase.BeginTransaction();
CharacterDatabase.PExecute("UPDATE auction SET buyguid = '%u', lastbid = '" UI64FMTD "' WHERE id = '%u'", bidder, bid, Id);
if (newbidder)
{ newbidder->SaveInventoryAndGoldToDB(); }
{
newbidder->SaveInventoryAndGoldToDB();
}
CharacterDatabase.CommitTransaction();
return true;
}

View file

@ -49,14 +49,18 @@ void Bag::AddToWorld()
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
{ m_bagslot[i]->AddToWorld(); }
{
m_bagslot[i]->AddToWorld();
}
}
void Bag::RemoveFromWorld()
{
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
{ m_bagslot[i]->RemoveFromWorld(); }
{
m_bagslot[i]->RemoveFromWorld();
}
Item::RemoveFromWorld();
}
@ -66,7 +70,9 @@ bool Bag::Create(uint32 guidlow, uint32 itemid, Player const* owner)
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
if (!itemProto || itemProto->ContainerSlots > MAX_BAG_SIZE)
{ return false; }
{
return false;
}
Object::_Create(guidlow, 0, HIGHGUID_CONTAINER);
@ -101,7 +107,9 @@ void Bag::SaveToDB()
bool Bag::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
{
if (!Item::LoadFromDB(guidLow, fields, ownerGuid))
{ return false; }
{
return false;
}
// cleanup bag content related item value fields (its will be filled correctly from `character_inventory`)
for (int i = 0; i < MAX_BAG_SIZE; ++i)
@ -119,7 +127,9 @@ void Bag::DeleteFromDB()
{
for (int i = 0; i < MAX_BAG_SIZE; ++i)
if (m_bagslot[i])
{ m_bagslot[i]->DeleteFromDB(); }
{
m_bagslot[i]->DeleteFromDB();
}
Item::DeleteFromDB();
}
@ -129,7 +139,9 @@ uint32 Bag::GetFreeSlots() const
uint32 slots = 0;
for (uint32 i = 0; i < GetBagSize(); ++i)
if (!m_bagslot[i])
{ ++slots; }
{
++slots;
}
return slots;
}
@ -139,7 +151,9 @@ void Bag::RemoveItem(uint8 slot, bool /*update*/)
MANGOS_ASSERT(slot < MAX_BAG_SIZE);
if (m_bagslot[slot])
{ m_bagslot[slot]->SetContainer(NULL); }
{
m_bagslot[slot]->SetContainer(NULL);
}
m_bagslot[slot] = NULL;
SetGuidValue(CONTAINER_FIELD_SLOT_1 + (slot * 2), ObjectGuid());
@ -166,7 +180,9 @@ void Bag::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) cons
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
{ m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target); }
{
m_bagslot[i]->BuildCreateUpdateBlockForPlayer(data, target);
}
}
// If the bag is empty returns true
@ -174,7 +190,9 @@ bool Bag::IsEmpty() const
{
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
{ return false; }
{
return false;
}
return true;
}
@ -183,7 +201,9 @@ Item* Bag::GetItemByEntry(uint32 item) const
{
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] && m_bagslot[i]->GetEntry() == item)
{ return m_bagslot[i]; }
{
return m_bagslot[i];
}
return NULL;
}
@ -204,7 +224,9 @@ uint32 Bag::GetItemCount(uint32 item, Item* eItem) const
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i])
if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)
{ count += m_bagslot[i]->GetCount(); }
{
count += m_bagslot[i]->GetCount();
}
if (eItem && eItem->GetProto()->GemProperties)
for (uint32 i = 0; i < GetBagSize(); ++i)
@ -232,7 +254,9 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
for (uint32 i = 0; i < GetBagSize(); ++i)
if (m_bagslot[i] != 0)
if (m_bagslot[i]->GetObjectGuid() == guid)
{ return i; }
{
return i;
}
return NULL_SLOT;
}
@ -240,7 +264,9 @@ uint8 Bag::GetSlotByItemGUID(ObjectGuid guid) const
Item* Bag::GetItemByPos(uint8 slot) const
{
if (slot < GetBagSize())
{ return m_bagslot[slot]; }
{
return m_bagslot[slot];
}
return NULL;
}

View file

@ -78,7 +78,9 @@ class Bag : public Item
inline Item* NewItemOrBag(ItemPrototype const* proto)
{
if (proto->InventoryType == INVTYPE_BAG)
{ return new Bag; }
{
return new Bag;
}
return new Item;
}

View file

@ -53,7 +53,9 @@ void Camera::UpdateForCurrentViewPoint()
m_gridRef.unlink();
if (GridType* grid = m_source->GetViewPoint().m_grid)
{ grid->AddWorldObject(this); }
{
grid->AddWorldObject(this);
}
UpdateVisibilityForOwner();
}
@ -63,7 +65,9 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
MANGOS_ASSERT(obj);
if (m_source == obj)
{ return; }
{
return;
}
if (!m_owner.IsInMap(obj))
{
@ -80,17 +84,23 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
// detach and deregister from active objects if there are no more reasons to be active
m_source->GetViewPoint().Detach(this);
if (!m_source->IsActiveObject())
{ m_source->GetMap()->RemoveFromActive(m_source); }
{
m_source->GetMap()->RemoveFromActive(m_source);
}
m_source = obj;
if (!m_source->IsActiveObject())
{ m_source->GetMap()->AddToActive(m_source); }
{
m_source->GetMap()->AddToActive(m_source);
}
m_source->GetViewPoint().Attach(this);
if (update_far_sight_field)
{ m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); }
{
m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid()));
}
UpdateForCurrentViewPoint();
}
@ -98,7 +108,9 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/)
void Camera::Event_ViewPointVisibilityChanged()
{
if (!m_owner.HaveAtClient(m_source))
{ ResetView(); }
{
ResetView();
}
}
void Camera::ResetView(bool update_far_sight_field /*= true*/)

View file

@ -55,7 +55,9 @@ void Corpse::AddToWorld()
{
///- Register the corpse for guid lookup
if (!IsInWorld())
{ sObjectAccessor.AddObject(this); }
{
sObjectAccessor.AddObject(this);
}
Object::AddToWorld();
}
@ -64,7 +66,9 @@ void Corpse::RemoveFromWorld()
{
///- Remove the corpse from the accessor
if (IsInWorld())
{ sObjectAccessor.RemoveObject(this); }
{
sObjectAccessor.RemoveObject(this);
}
Object::RemoveFromWorld();
}
@ -232,9 +236,13 @@ bool Corpse::LoadFromDB(uint32 lowguid, Field* fields)
uint32 flags = CORPSE_FLAG_UNK2;
if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
{ flags |= CORPSE_FLAG_HIDE_HELM; }
{
flags |= CORPSE_FLAG_HIDE_HELM;
}
if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
{ flags |= CORPSE_FLAG_HIDE_CLOAK; }
{
flags |= CORPSE_FLAG_HIDE_CLOAK;
}
SetUInt32Value(CORPSE_FIELD_FLAGS, flags);
// no need to mark corpse as lootable, because corpses are not saved in battle grounds
@ -265,7 +273,9 @@ bool Corpse::isVisibleForInState(Player const* u, WorldObject const* viewPoint,
bool Corpse::IsHostileTo(Unit const* unit) const
{
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
{ return owner->IsHostileTo(unit); }
{
return owner->IsHostileTo(unit);
}
else
{ return false; }
}
@ -273,7 +283,9 @@ bool Corpse::IsHostileTo(Unit const* unit) const
bool Corpse::IsFriendlyTo(Unit const* unit) const
{
if (Player* owner = sObjectMgr.GetPlayer(GetOwnerGuid()))
{ return owner->IsFriendlyTo(unit); }
{
return owner->IsFriendlyTo(unit);
}
else
{ return true; }
}
@ -281,7 +293,9 @@ bool Corpse::IsFriendlyTo(Unit const* unit) const
bool Corpse::IsExpired(time_t t) const
{
if (m_type == CORPSE_BONES)
{ return m_time < t - 60 * MINUTE; }
{
return m_time < t - 60 * MINUTE;
}
else
{ return m_time < t - 3 * DAY; }
}

File diff suppressed because it is too large Load diff

View file

@ -166,7 +166,9 @@ struct CreatureInfo
SkillType GetRequiredLootSkill() const
{
if (CreatureTypeFlags & CREATURE_TYPEFLAGS_HERBLOOT)
{ return SKILL_HERBALISM; }
{
return SKILL_HERBALISM;
}
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_MININGLOOT)
{ return SKILL_MINING; }
else if (CreatureTypeFlags & CREATURE_TYPEFLAGS_ENGINEERLOOT)
@ -565,7 +567,9 @@ class Creature : public Unit
bool IsElite() const
{
if (IsPet())
{ return false; }
{
return false;
}
uint32 Rank = GetCreatureInfo()->Rank;
return Rank != CREATURE_ELITE_NORMAL && Rank != CREATURE_ELITE_RARE;
@ -574,7 +578,9 @@ class Creature : public Unit
bool IsWorldBoss() const
{
if (IsPet())
{ return false; }
{
return false;
}
return GetCreatureInfo()->Rank == CREATURE_ELITE_WORLDBOSS;
}
@ -785,7 +791,9 @@ class Creature : public Unit
virtual uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= CREATURE_MAX_SPELLS || m_charmInfo->GetCharmSpell(pos)->GetType() != ACT_ENABLED)
{ return 0; }
{
return 0;
}
else
{ return m_charmInfo->GetCharmSpell(pos)->GetAction(); }
}

View file

@ -40,7 +40,9 @@ CreatureAI::~CreatureAI()
void CreatureAI::AttackedBy(Unit* attacker)
{
if (!m_creature->getVictim())
{ AttackStart(attacker); }
{
AttackStart(attacker);
}
}
CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell, bool isTriggered)
@ -50,17 +52,25 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
{
// State does not allow
if (m_creature->hasUnitState(UNIT_STAT_CAN_NOT_REACT_OR_LOST_CONTROL))
{ return CAST_FAIL_STATE; }
{
return CAST_FAIL_STATE;
}
if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_SILENCE && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SILENCED))
{ return CAST_FAIL_STATE; }
{
return CAST_FAIL_STATE;
}
if (pSpell->GetPreventionType() == SPELL_PREVENTION_TYPE_PACIFY && m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
{ return CAST_FAIL_STATE; }
{
return CAST_FAIL_STATE;
}
// Check for power (also done by Spell::CheckCast())
if (m_creature->GetPower((Powers)pSpell->powerType) < Spell::CalculatePowerCost(pSpell, m_creature))
{ return CAST_FAIL_POWER; }
{
return CAST_FAIL_POWER;
}
if (!pSpell->HasAttribute(SPELL_ATTR_EX2_IGNORE_LOS) && !m_creature->IsWithinLOSInMap(pTarget) && m_creature != pTarget)
return CAST_FAIL_NOT_IN_LOS;
@ -74,12 +84,16 @@ CanCastResult CreatureAI::CanCastSpell(Unit* pTarget, const SpellEntry* pSpell,
float fDistance = m_creature->GetCombatDistance(pTarget, pSpell->rangeIndex == SPELL_RANGE_IDX_COMBAT);
if (fDistance > (m_creature->IsHostileTo(pTarget) ? pSpellRange->maxRange : pSpellRange->maxRangeFriendly))
{ return CAST_FAIL_TOO_FAR; }
{
return CAST_FAIL_TOO_FAR;
}
float fMinRange = m_creature->IsHostileTo(pTarget) ? pSpellRange->minRange : pSpellRange->minRangeFriendly;
if (fMinRange && fDistance < fMinRange)
{ return CAST_FAIL_TOO_CLOSE; }
{
return CAST_FAIL_TOO_CLOSE;
}
}
return CAST_OK;
@ -93,7 +107,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
Unit* pCaster = m_creature;
if (uiCastFlags & CAST_FORCE_TARGET_SELF)
{ pCaster = pTarget; }
{
pCaster = pTarget;
}
// Allowed to cast only if not casting (unless we interrupt ourself) or if spell is triggered
if (!pCaster->IsNonMeleeSpellCasted(false) || (uiCastFlags & (CAST_TRIGGERED | CAST_INTERRUPT_PREVIOUS)))
@ -104,7 +120,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
if (uiCastFlags & CAST_AURA_NOT_PRESENT)
{
if (pTarget->HasAura(uiSpell))
{ return CAST_FAIL_TARGET_AURA; }
{
return CAST_FAIL_TARGET_AURA;
}
}
// Check if can not cast spell
@ -120,7 +138,9 @@ CanCastResult CreatureAI::DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32
// Interrupt any previous spell
if ((uiCastFlags & CAST_INTERRUPT_PREVIOUS) && pCaster->IsNonMeleeSpellCasted(false))
{ pCaster->InterruptNonMeleeSpells(false); }
{
pCaster->InterruptNonMeleeSpells(false);
}
// Creature should always stop before it will cast a non-instant spell
if (GetSpellCastTime(pSpell))
@ -155,14 +175,18 @@ void CreatureAI::SetCombatMovement(bool enable, bool stopOrStartMovement /*=fals
m_isCombatMovement = enable;
if (enable)
{ m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); }
{
m_creature->clearUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT);
}
else
{ m_creature->addUnitState(UNIT_STAT_NO_COMBAT_MOVEMENT); }
if (stopOrStartMovement && m_creature->getVictim()) // Only change current movement while in combat
{
if (enable)
{ m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle); }
{
m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim(), m_attackDistance, m_attackAngle);
}
else if (!enable && m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
{ m_creature->StopMoving(); }
}

View file

@ -48,7 +48,9 @@ namespace FactorySelector
// Allow scripting AI for normal creatures and not controlled pets (guardians and mini-pets)
if (!creature->IsPet() || !static_cast<Pet*>(creature)->isControlled())
{ return scriptedAI; }
{
return scriptedAI;
}
}
CreatureAIRegistry& ai_registry(CreatureAIRepository::Instance());
@ -64,17 +66,23 @@ namespace FactorySelector
{
Unit* controler = creature->GetOwner() ? creature->GetOwner() : creature->GetCharmer();
if (controler && controler->GetTypeId() == TYPEID_PLAYER && controler->IsAlive())
{ ai_factory = ai_registry.GetRegistryItem("PetAI"); }
{
ai_factory = ai_registry.GetRegistryItem("PetAI");
}
}
else if (creature->IsTotem())
{ ai_factory = ai_registry.GetRegistryItem("TotemAI"); }
// select by script name
if (!ai_factory && !ainame.empty())
{ ai_factory = ai_registry.GetRegistryItem(ainame.c_str()); }
{
ai_factory = ai_registry.GetRegistryItem(ainame.c_str());
}
if (!ai_factory && creature->IsGuard())
{ ai_factory = ai_registry.GetRegistryItem("GuardAI"); }
{
ai_factory = ai_registry.GetRegistryItem("GuardAI");
}
// select by permit check
if (!ai_factory)

File diff suppressed because it is too large Load diff

View file

@ -44,13 +44,17 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Texts(bool check_entry_use)
sObjectMgr.LoadMangosStrings(WorldDatabase, "creature_ai_texts", MIN_CREATURE_AI_TEXT_STRING_ID, MAX_CREATURE_AI_TEXT_STRING_ID, true);
if (check_entry_use)
{ CheckUnusedAITexts(); }
{
CheckUnusedAITexts();
}
}
void CreatureEventAIMgr::CheckUnusedAITexts()
{
if (m_usedTextsAmount == sObjectMgr.GetLoadedStringsCount(MIN_CREATURE_AI_TEXT_STRING_ID))
{ return; }
{
return;
}
sLog.outString("Checking EventAI for unused texts, this might take a while");
@ -58,7 +62,9 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
// check not used strings this is negative range
for (int32 i = MAX_CREATURE_AI_TEXT_STRING_ID + 1; i <= MIN_CREATURE_AI_TEXT_STRING_ID; ++i)
if (sObjectMgr.GetMangosStringLocale(i))
{ idx_set.insert(i); }
{
idx_set.insert(i);
}
for (CreatureEventAI_Event_Map::const_iterator itr = m_CreatureEventAI_Event_Map.begin(); itr != m_CreatureEventAI_Event_Map.end(); ++itr)
{
@ -78,7 +84,9 @@ void CreatureEventAIMgr::CheckUnusedAITexts()
int k = action.type == ACTION_T_TEXT ? 0 : 1;
for (; k < 3; ++k)
if (action.text.TextId[k])
{ idx_set.erase(action.text.TextId[k]); }
{
idx_set.erase(action.text.TextId[k]);
}
break;
}
default: break;
@ -106,7 +114,9 @@ bool IsValidTargetType(EventAI_Type eventType, EventAI_ActionType actionType, ui
case TARGET_T_HOSTILE_RANDOM:
case TARGET_T_HOSTILE_RANDOM_NOT_TOP:
if (actionType == ACTION_T_QUEST_EVENT || actionType == ACTION_T_CAST_EVENT || actionType == ACTION_T_QUEST_EVENT_ALL || actionType == ACTION_T_KILLED_MONSTER)
{ sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType); }
{
sLog.outErrorEventAI("Event %u Action%u uses LIKELY bad Target type %u for event-type %u (must target player)", eventId, action, targetType, eventType);
}
// no break, check if valid at all
case TARGET_T_HOSTILE:
case TARGET_T_HOSTILE_SECOND_AGGRO:
@ -305,7 +315,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// No chance of this event occuring
if (temp.event_chance == 0)
{ sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i); }
{
sLog.outErrorEventAI("Event %u has 0 percent chance. Event will never trigger!", i);
}
// Chance above 100, force it to be 100
else if (temp.event_chance > 100)
{
@ -320,9 +332,13 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case EVENT_T_TIMER_OOC:
case EVENT_T_TIMER_GENERIC:
if (temp.timer.initialMax < temp.timer.initialMin)
{ sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using timed event(%u) with param2 < param1 (InitialMax < InitialMin). Event will never repeat.", temp.creature_id, i);
}
if (temp.timer.repeatMax < temp.timer.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_HP:
case EVENT_T_MANA:
@ -330,10 +346,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case EVENT_T_TARGET_MANA:
case EVENT_T_ENERGY:
if (temp.percent_range.percentMax > 100)
{ sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param2 (MinPercent) > 100. Event will never trigger! ", temp.creature_id, i);
}
if (temp.percent_range.percentMax <= temp.percent_range.percentMin)
{ sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using percentage event(%u) with param1 <= param2 (MaxPercent <= MinPercent). Event will never trigger! ", temp.creature_id, i);
}
if (temp.event_flags & EFLAG_REPEATABLE && !temp.percent_range.repeatMin && !temp.percent_range.repeatMax)
{
@ -352,24 +372,36 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
}
if ((temp.spell_hit.schoolMask & pSpell->SchoolMask) != pSpell->SchoolMask)
{ sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i); }
{
sLog.outErrorEventAI("Creature %u has param1(spellId %u) but param2 is not -1 and not equal to spell's school mask. Event %u can never trigger.", temp.creature_id, temp.spell_hit.schoolMask, i);
}
}
if (!temp.spell_hit.schoolMask)
{ sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i); }
{
sLog.outErrorEventAI("Creature %u is using invalid SpellSchoolMask(%u) defined in event %u.", temp.creature_id, temp.spell_hit.schoolMask, i);
}
if (temp.spell_hit.repeatMax < temp.spell_hit.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_RANGE:
if (temp.range.maxDist < temp.range.minDist)
{ sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (MaxDist < MinDist). Event will never repeat.", temp.creature_id, i);
}
if (temp.range.repeatMax < temp.range.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_OOC_LOS:
if (temp.ooc_los.repeatMax < temp.ooc_los.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_SPAWNED:
switch (temp.spawned.condition)
@ -378,11 +410,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case SPAWNED_EVENT_MAP:
if (!sMapStore.LookupEntry(temp.spawned.conditionValue1))
{ sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); }
{
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'map specific' but map (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
}
break;
case SPAWNED_EVENT_ZONE:
if (!GetAreaEntryByAreaID(temp.spawned.conditionValue1))
{ sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1); }
{
sLog.outErrorEventAI("Creature %u are using spawned event(%u) with param1 = %u 'area specific' but area (param2: %u) does not exist. Event will never repeat.", temp.creature_id, i, temp.spawned.condition, temp.spawned.conditionValue1);
}
break;
default:
sLog.outErrorEventAI("Creature %u are using invalid spawned event %u mode (%u) in param1", temp.creature_id, i, temp.spawned.condition);
@ -391,11 +427,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case EVENT_T_FRIENDLY_HP:
if (temp.friendly_hp.repeatMax < temp.friendly_hp.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_FRIENDLY_IS_CC:
if (temp.friendly_is_cc.repeatMax < temp.friendly_is_cc.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_FRIENDLY_MISSING_BUFF:
{
@ -411,29 +451,41 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue;
}
if (temp.friendly_buff.repeatMax < temp.friendly_buff.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
}
case EVENT_T_KILL:
if (temp.kill.repeatMax < temp.kill.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_TARGET_CASTING:
if (temp.target_casting.repeatMax < temp.target_casting.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_SUMMONED_UNIT:
case EVENT_T_SUMMONED_JUST_DIED:
case EVENT_T_SUMMONED_JUST_DESPAWN:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(temp.summoned.creatureId))
{ sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent creature template id (%u) in param1, skipped.", temp.creature_id, i, temp.summoned.creatureId);
}
if (temp.summoned.repeatMax < temp.summoned.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with param2 < param1 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
case EVENT_T_QUEST_ACCEPT:
case EVENT_T_QUEST_COMPLETE:
if (!sObjectMgr.GetQuestTemplate(temp.quest.questId))
{ sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId); }
{
sLog.outErrorEventAI("Creature %u are using event(%u) with nonexistent quest id (%u) in param1, skipped.", temp.creature_id, i, temp.quest.questId);
}
sLog.outErrorEventAI("Creature %u using not implemented event (%u) in event %u.", temp.creature_id, temp.event_id, i);
continue;
@ -491,7 +543,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue;
}
if (temp.buffed.repeatMax < temp.buffed.repeatMin)
{ sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i); }
{
sLog.outErrorEventAI("Creature %u are using repeatable event(%u) with param4 < param3 (RepeatMax < RepeatMin). Event will never repeat.", temp.creature_id, i);
}
break;
}
case EVENT_T_RECEIVE_AI_EVENT:
@ -540,7 +594,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
case ACTION_T_CHANCED_TEXT:
// Check first param as chance
if (!action.chanced_text.chance)
{ sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1); }
{
sLog.outErrorEventAI("Event %u Action %u has not set chance param1. Text will not be displayed", i, j + 1);
}
else if (action.chanced_text.chance >= 100)
{ sLog.outErrorEventAI("Event %u Action %u has set chance param1 >= 100. Text will always be displayed", i, j + 1); }
// no break here to check texts
@ -553,10 +609,14 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
if (action.text.TextId[k])
{
if (k > firstTextParam && not_set)
{ sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1); }
{
sLog.outErrorEventAI("Event %u Action %u has param%d, but it follow after not set param. Required for randomized text.", i, j + 1, k + 1);
}
if (!action.text.TextId[k])
{ not_set = true; }
{
not_set = true;
}
// range negative
else if (action.text.TextId[k] > MIN_CREATURE_AI_TEXT_STRING_ID || action.text.TextId[k] <= MAX_CREATURE_AI_TEXT_STRING_ID)
{
@ -607,33 +667,51 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_SOUND:
if (!sSoundEntriesStore.LookupEntry(action.sound.soundId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SoundID %u.", i, j + 1, action.sound.soundId);
}
break;
case ACTION_T_EMOTE:
if (!sEmotesStore.LookupEntry(action.emote.emoteId))
{ sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId); }
{
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.emote.emoteId);
}
break;
case ACTION_T_RANDOM_SOUND:
if (!sSoundEntriesStore.LookupEntry(action.random_sound.soundId1))
{ sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1); }
{
sLog.outErrorEventAI("Event %u Action %u param1 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId1);
}
if (action.random_sound.soundId2 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId2))
{ sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2); }
{
sLog.outErrorEventAI("Event %u Action %u param2 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId2);
}
if (action.random_sound.soundId3 >= 0 && !sSoundEntriesStore.LookupEntry(action.random_sound.soundId3))
{ sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3); }
{
sLog.outErrorEventAI("Event %u Action %u param3 uses nonexistent SoundID %u.", i, j + 1, action.random_sound.soundId3);
}
break;
case ACTION_T_RANDOM_EMOTE:
if (!sEmotesStore.LookupEntry(action.random_emote.emoteId1))
{ sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1); }
{
sLog.outErrorEventAI("Event %u Action %u param1 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId1);
}
if (action.random_emote.emoteId2 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId2))
{ sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2); }
{
sLog.outErrorEventAI("Event %u Action %u param2 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId2);
}
if (action.random_emote.emoteId3 >= 0 && !sEmotesStore.LookupEntry(action.random_emote.emoteId3))
{ sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3); }
{
sLog.outErrorEventAI("Event %u Action %u param3 (EmoteId: %u) are not valid.", i, j + 1, action.random_emote.emoteId3);
}
break;
case ACTION_T_CAST:
{
const SpellEntry* spell = sSpellStore.LookupEntry(action.cast.spellId);
if (!spell)
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast.spellId);
}
/* FIXME: temp.raw.param3 not have event tipes with recovery time in it....
else
{
@ -648,7 +726,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
// Cast is always triggered if target is forced to cast on self
if (action.cast.castFlags & CAST_FORCE_TARGET_SELF)
{ action.cast.castFlags |= CAST_TRIGGERED; }
{
action.cast.castFlags |= CAST_TRIGGERED;
}
IsValidTargetType(temp.event_type, action.type, action.cast.target, i, j + 1);
@ -657,7 +737,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
{
// spell must be cast on self, but is not
if ((IsOnlySelfTargeting(spell) || spell->rangeIndex == SPELL_RANGE_IDX_SELF_ONLY) && action.cast.target != TARGET_T_SELF && !(action.cast.castFlags & CAST_FORCE_TARGET_SELF))
{ sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target); }
{
sLog.outErrorEventAI("Event %u Action %u uses SpellID %u that must be self cast (target is %u)", i, j + 1, action.cast.spellId, action.cast.target);
}
// TODO: spell must be cast on enemy, but is not
@ -676,24 +758,32 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
}
case ACTION_T_SUMMON:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon.creatureId);
}
IsValidTargetType(temp.event_type, action.type, action.summon.target, i, j + 1);
break;
case ACTION_T_THREAT_SINGLE_PCT:
if (std::abs(action.threat_single_pct.percent) > 100)
{ sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent); }
{
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_single_pct.percent);
}
IsValidTargetType(temp.event_type, action.type, action.threat_single_pct.target, i, j + 1);
break;
case ACTION_T_THREAT_ALL_PCT:
if (std::abs(action.threat_all_pct.percent) > 100)
{ sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent); }
{
sLog.outErrorEventAI("Event %u Action %u uses invalid percent value %u.", i, j + 1, action.threat_all_pct.percent);
}
break;
case ACTION_T_QUEST_EVENT:
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event.questId))
{
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
{ sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId); }
{
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event.questId);
}
}
else
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event.questId); }
@ -702,14 +792,20 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_CAST_EVENT:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event.creatureId);
}
if (!sSpellStore.LookupEntry(action.cast_event.spellId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event.spellId);
}
IsValidTargetType(temp.event_type, action.type, action.cast_event.target, i, j + 1);
break;
case ACTION_T_SET_UNIT_FIELD:
if (action.set_unit_field.field < OBJECT_END || action.set_unit_field.field >= UNIT_END)
{ sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1); }
{
sLog.outErrorEventAI("Event %u Action %u param1 (UNIT_FIELD*). Index out of range for intended use.", i, j + 1);
}
IsValidTargetType(temp.event_type, action.type, action.set_unit_field.target, i, j + 1);
break;
case ACTION_T_SET_UNIT_FLAG:
@ -718,11 +814,15 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_SET_PHASE:
if (action.set_phase.phase >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phase >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
break;
case ACTION_T_INC_PHASE:
if (action.set_inc_phase.step == 0)
{ sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1); }
{
sLog.outErrorEventAI("Event %u Action %u is incrementing phase by 0. Was this intended?", i, j + 1);
}
else if (std::abs(action.set_inc_phase.step) > MAX_PHASE - 1)
{ sLog.outErrorEventAI("Event %u Action %u is change phase by too large for any use %i.", i, j + 1, action.set_inc_phase.step); }
break;
@ -730,35 +830,53 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
if (Quest const* qid = sObjectMgr.GetQuestTemplate(action.quest_event_all.questId))
{
if (!qid->HasSpecialFlag(QUEST_SPECIAL_FLAG_EXPLORATION_OR_EVENT))
{ sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId); }
{
sLog.outErrorEventAI("Event %u Action %u. SpecialFlags for quest entry %u does not include |2, Action will not have any effect.", i, j + 1, action.quest_event_all.questId);
}
}
else
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent Quest entry %u.", i, j + 1, action.quest_event_all.questId); }
break;
case ACTION_T_CAST_EVENT_ALL:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.cast_event_all.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.cast_event_all.creatureId);
}
if (!sSpellStore.LookupEntry(action.cast_event_all.spellId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.cast_event_all.spellId);
}
break;
case ACTION_T_REMOVEAURASFROMSPELL:
if (!sSpellStore.LookupEntry(action.remove_aura.spellId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent SpellID %u.", i, j + 1, action.remove_aura.spellId);
}
IsValidTargetType(temp.event_type, action.type, action.remove_aura.target, i, j + 1);
break;
case ACTION_T_RANDOM_PHASE: // PhaseId1, PhaseId2, PhaseId3
if (action.random_phase.phase1 >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phase1 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
if (action.random_phase.phase2 >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phase2 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
if (action.random_phase.phase3 >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phase3 >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
break;
case ACTION_T_RANDOM_PHASE_RANGE: // PhaseMin, PhaseMax
if (action.random_phase_range.phaseMin >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMin >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
if (action.random_phase_range.phaseMin >= MAX_PHASE)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax >= %u. Phase mask can not be used past phase %u.", i, j + 1, MAX_PHASE, MAX_PHASE - 1);
}
if (action.random_phase_range.phaseMin >= action.random_phase_range.phaseMax)
{
sLog.outErrorEventAI("Event %u Action %u attempts to set phaseMax <= phaseMin.", i, j + 1);
@ -768,21 +886,29 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_SUMMON_ID:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.summon_id.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.summon_id.creatureId);
}
IsValidTargetType(temp.event_type, action.type, action.summon_id.target, i, j + 1);
if (m_CreatureEventAI_Summon_Map.find(action.summon_id.spawnId) == m_CreatureEventAI_Summon_Map.end())
{ sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId); }
{
sLog.outErrorEventAI("Event %u Action %u summons missing CreatureEventAI_Summon %u", i, j + 1, action.summon_id.spawnId);
}
break;
case ACTION_T_KILLED_MONSTER:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.killed_monster.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.killed_monster.creatureId);
}
IsValidTargetType(temp.event_type, action.type, action.killed_monster.target, i, j + 1);
break;
case ACTION_T_SET_INST_DATA:
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
sLog.outErrorEventAI("Event %u Action %u. Cannot set instance data without difficulty event flags.", i, j + 1);
if (action.set_inst_data.value > 4/*SPECIAL*/)
{ sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1); }
{
sLog.outErrorEventAI("Event %u Action %u attempts to set instance data above encounter state 4. Custom case?", i, j + 1);
}
break;
case ACTION_T_SET_INST_DATA64:
if (!(temp.event_flags & EFLAG_DIFFICULTY_ALL))
@ -791,7 +917,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
break;
case ACTION_T_UPDATE_TEMPLATE:
if (!sCreatureStorage.LookupEntry<CreatureInfo>(action.update_template.creatureId))
{ sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId); }
{
sLog.outErrorEventAI("Event %u Action %u uses nonexistent creature entry %u.", i, j + 1, action.update_template.creatureId);
}
break;
case ACTION_T_SET_SHEATH:
if (action.set_sheath.sheath >= MAX_SHEATH_STATE)
@ -859,7 +987,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
continue;
}
if (action.throwEvent.radius > SIZE_OF_GRIDS)
{ sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS); }
{
sLog.outErrorEventAI("Event %u Action %u uses unexpectedly huge radius %u (expected to be less than %f)", i, j + 1, action.throwEvent.radius, SIZE_OF_GRIDS);
}
if (action.throwEvent.radius == 0)
{
@ -913,7 +1043,9 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
bool ainame = strcmp(cInfo->AIName, "EventAI") == 0;
bool hasevent = m_CreatureEventAI_Event_Map.find(i) != m_CreatureEventAI_Event_Map.end();
if (ainame && !hasevent)
{ sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName); }
{
sLog.outErrorEventAI("EventAI not has script for creature entry (%u), but AIName = '%s'.", i, cInfo->AIName);
}
else if (!ainame && hasevent)
{ sLog.outErrorEventAI("EventAI has script for creature entry (%u), but AIName = '%s' instead 'EventAI'.", i, cInfo->AIName); }
}

View file

@ -48,7 +48,9 @@ void DynamicObject::AddToWorld()
{
///- Register the dynamicObject for guid lookup
if (!IsInWorld())
{ GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this); }
{
GetMap()->GetObjectsStore().insert<DynamicObject>(GetObjectGuid(), (DynamicObject*)this);
}
Object::AddToWorld();
}
@ -134,7 +136,9 @@ void DynamicObject::Update(uint32 /*update_diff*/, uint32 p_time)
bool deleteThis = false;
if (m_aliveDuration > int32(p_time))
{ m_aliveDuration -= p_time; }
{
m_aliveDuration -= p_time;
}
else
{ deleteThis = true; }
@ -204,11 +208,15 @@ void DynamicObject::Delay(int32 delaytime)
bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* viewPoint, bool inVisibleList) const
{
if (!IsInWorld() || !u->IsInWorld())
{ return false; }
{
return false;
}
// always seen by owner
if (GetCasterGuid() == u->GetObjectGuid())
{ return true; }
{
return true;
}
// normal case
return IsWithinDistInMap(viewPoint, GetMap()->GetVisibilityDistance() + (inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f), false);
@ -217,7 +225,9 @@ bool DynamicObject::isVisibleForInState(Player const* u, WorldObject const* view
bool DynamicObject::IsHostileTo(Unit const* unit) const
{
if (Unit* owner = GetCaster())
{ return owner->IsHostileTo(unit); }
{
return owner->IsHostileTo(unit);
}
else
{ return false; }
}
@ -225,7 +235,9 @@ bool DynamicObject::IsHostileTo(Unit const* unit) const
bool DynamicObject::IsFriendlyTo(Unit const* unit) const
{
if (Unit* owner = GetCaster())
{ return owner->IsFriendlyTo(unit); }
{
return owner->IsFriendlyTo(unit);
}
else
{ return true; }
}

View file

@ -45,7 +45,9 @@ namespace MaNGOS
inline uint32 GetGrayLevel(uint32 pl_level)
{
if (pl_level <= 5)
{ return 0; }
{
return 0;
}
else if (pl_level <= 39)
{ return pl_level - 5 - pl_level / 10; }
else if (pl_level <= 59)
@ -57,7 +59,9 @@ namespace MaNGOS
inline XPColorChar GetColorCode(uint32 pl_level, uint32 mob_level)
{
if (mob_level >= pl_level + 5)
{ return RED; }
{
return RED;
}
else if (mob_level >= pl_level + 3)
{ return ORANGE; }
else if (mob_level >= pl_level - 2)
@ -102,7 +106,9 @@ namespace MaNGOS
{
uint32 nLevelDiff = mob_level - pl_level;
if (nLevelDiff > 4)
{ nLevelDiff = 4; }
{
nLevelDiff = 4;
}
return ((pl_level * 5 + nBaseExp) * (20 + nLevelDiff) / 10 + 1) / 2;
}
else
@ -126,10 +132,14 @@ namespace MaNGOS
uint32 xp_gain = BaseGain(pl->getLevel(), u->getLevel(), GetContentLevelsForMapAndZone(pl->GetMapId(), pl->GetZoneId()));
if (xp_gain == 0)
{ return 0; }
{
return 0;
}
if (u->GetTypeId() == TYPEID_UNIT && ((Creature*)u)->IsElite())
{ xp_gain *= 2; }
{
xp_gain *= 2;
}
return (uint32)(xp_gain * sWorld.getConfig(CONFIG_FLOAT_RATE_XP_KILL));
}

View file

@ -63,7 +63,9 @@ void GMTicketMgr::LoadGMTickets()
uint32 guidlow = fields[0].GetUInt32();
if (!guidlow)
{ continue; }
{
continue;
}
ObjectGuid guid = ObjectGuid(HIGHGUID_PLAYER, guidlow);
GMTicket& ticket = m_GMTicketMap[guid];
@ -89,7 +91,9 @@ void GMTicketMgr::DeleteAll()
for (GMTicketMap::const_iterator itr = m_GMTicketMap.begin(); itr != m_GMTicketMap.end(); ++itr)
{
if (Player* owner = sObjectMgr.GetPlayer(itr->first))
{ owner->GetSession()->SendGMTicketGetTicket(0x0A); }
{
owner->GetSession()->SendGMTicketGetTicket(0x0A);
}
}
CharacterDatabase.Execute("DELETE FROM character_ticket");
m_GMTicketListByCreatingOrder.clear();

View file

@ -187,7 +187,9 @@ class GMTicketMgr
{
GMTicketMap::iterator itr = m_GMTicketMap.find(guid);
if (itr == m_GMTicketMap.end())
{ return NULL; }
{
return NULL;
}
return &(itr->second);
}
@ -199,12 +201,16 @@ class GMTicketMgr
GMTicket* GetGMTicketByOrderPos(uint32 pos)
{
if (pos >= GetTicketCount())
{ return NULL; }
{
return NULL;
}
GMTicketList::iterator itr = m_GMTicketListByCreatingOrder.begin();
std::advance(itr, pos);
if (itr == m_GMTicketListByCreatingOrder.end())
{ return NULL; }
{
return NULL;
}
return *itr;
}
@ -220,7 +226,9 @@ class GMTicketMgr
{
GMTicketMap::iterator itr = m_GMTicketMap.find(guid);
if (itr == m_GMTicketMap.end())
{ return; }
{
return;
}
itr->second.DeleteFromDB();
m_GMTicketListByCreatingOrder.remove(&itr->second);
m_GMTicketMap.erase(itr);

File diff suppressed because it is too large Load diff

View file

@ -690,7 +690,9 @@ class GameObject : public WorldObject
{
time_t now = time(NULL);
if (m_respawnTime > now)
{ return m_respawnTime; }
{
return m_respawnTime;
}
else
{ return now; }
}

View file

@ -31,7 +31,9 @@
int GuardAI::Permissible(const Creature* creature)
{
if (creature->IsGuard())
{ return PERMIT_BASE_SPECIAL; }
{
return PERMIT_BASE_SPECIAL;
}
return PERMIT_BASE_NO;
}
@ -44,7 +46,9 @@ void GuardAI::MoveInLineOfSight(Unit* u)
{
// Ignore Z for flying creatures
if (!m_creature->CanFly() && m_creature->GetDistanceZ(u) > CREATURE_Z_ATTACK_RANGE)
{ return; }
{
return;
}
if (!m_creature->getVictim() && u->IsTargetableForAttack() &&
(u->IsHostileToPlayers() || m_creature->IsHostileTo(u) /*|| u->getVictim() && m_creature->IsFriendlyTo(u->getVictim())*/) &&
@ -107,14 +111,18 @@ void GuardAI::EnterEvadeMode()
// Remove ChaseMovementGenerator from MotionMaster stack list, and add HomeMovementGenerator instead
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == CHASE_MOTION_TYPE)
{ m_creature->GetMotionMaster()->MoveTargetedHome(); }
{
m_creature->GetMotionMaster()->MoveTargetedHome();
}
}
void GuardAI::UpdateAI(const uint32 /*diff*/)
{
// update i_victimGuid if i_creature.getVictim() !=0 and changed
if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
{ return; }
{
return;
}
i_victimGuid = m_creature->getVictim()->GetObjectGuid();
@ -130,7 +138,9 @@ bool GuardAI::IsVisible(Unit* pl) const
void GuardAI::AttackStart(Unit* u)
{
if (!u)
{ return; }
{
return;
}
if (m_creature->Attack(u, true))
{
@ -146,5 +156,7 @@ void GuardAI::AttackStart(Unit* u)
void GuardAI::JustDied(Unit* killer)
{
if (Player* pkiller = killer->GetCharmerOrOwnerPlayerOrPlayerItself())
{ m_creature->SendZoneUnderAttackMessage(pkiller); }
{
m_creature->SendZoneUnderAttackMessage(pkiller);
}
}

View file

@ -79,7 +79,9 @@ void MemberSlot::ChangeRank(uint32 newRank)
Player* player = sObjectMgr.GetPlayer(guid);
// If player not online data in data field will be loaded from guild tabs no need to update it !!
if (player)
{ player->SetRank(newRank); }
{
player->SetRank(newRank);
}
CharacterDatabase.PExecute("UPDATE guild_member SET rank='%u' WHERE guid='%u'", newRank, guid.GetCounter());
}
@ -117,11 +119,15 @@ Guild::~Guild()
bool Guild::Create(Player* leader, std::string gname)
{
if (sGuildMgr.GetGuildByName(gname))
{ return false; }
{
return false;
}
WorldSession* lSession = leader->GetSession();
if (!lSession)
{ return false; }
{
return false;
}
m_LeaderGuid = leader->GetObjectGuid();
m_Name = gname;
@ -179,12 +185,16 @@ bool Guild::AddMember(ObjectGuid plGuid, uint32 plRank)
if (pl)
{
if (pl->GetGuildId() != 0)
{ return false; }
{
return false;
}
}
else
{
if (Player::GetGuildIdFromDB(plGuid) != 0) // player already in guild
{ return false; }
{
return false;
}
}
// remove all player signs from another petitions
@ -296,7 +306,9 @@ void Guild::SetGINFO(std::string ginfo)
bool Guild::LoadGuildFromDB(QueryResult* guildDataResult)
{
if (!guildDataResult)
{ return false; }
{
return false;
}
Field* fields = guildDataResult->Fetch();
@ -345,7 +357,9 @@ bool Guild::CheckGuildStructure()
{
MemberSlot &member = itr->second;
if (member.RankId == GR_GUILDMASTER && m_LeaderGuid != member.guid)
{ member.ChangeRank(GR_OFFICER); }
{
member.ChangeRank(GR_OFFICER);
}
}
return true;
@ -373,7 +387,9 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
fields = guildRanksResult->Fetch();
// condition that would be true when all ranks in QueryResult will be processed and guild without ranks is being processed
if (!fields)
{ break; }
{
break;
}
uint32 guildId = fields[0].GetUInt32();
if (guildId < m_Id)
@ -385,7 +401,9 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
}
if (guildId > m_Id) // we loaded all ranks for this guild already, break cycle
{ break; }
{
break;
}
uint32 rankID = fields[1].GetUInt32();
std::string rankName = fields[2].GetCppString();
@ -393,11 +411,15 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
uint32 rankMoney = fields[4].GetUInt32();
if (rankID != m_Ranks.size()) // guild_rank.ids are sequence 0,1,2,3..
{ broken_ranks = true; }
{
broken_ranks = true;
}
// first rank is guildmaster, prevent loss leader rights
if (m_Ranks.empty())
{ rankRights |= GR_RIGHT_ALL; }
{
rankRights |= GR_RIGHT_ALL;
}
AddRank(rankName, rankRights, rankMoney);
}
@ -432,14 +454,18 @@ bool Guild::LoadRanksFromDB(QueryResult* guildRanksResult)
bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
{
if (!guildMembersResult)
{ return false; }
{
return false;
}
do
{
Field* fields = guildMembersResult->Fetch();
// this condition will be true when all rows in QueryResult are processed and new guild without members is going to be loaded - prevent crash
if (!fields)
{ break; }
{
break;
}
uint32 guildId = fields[0].GetUInt32();
if (guildId < m_Id)
{
@ -459,7 +485,9 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
newmember.RankId = fields[2].GetUInt32();
// don't allow member to have not existing rank!
if (newmember.RankId >= m_Ranks.size())
{ newmember.RankId = GetLowestRank(); }
{
newmember.RankId = GetLowestRank();
}
newmember.Pnote = fields[3].GetCppString();
newmember.OFFnote = fields[4].GetCppString();
@ -504,7 +532,9 @@ bool Guild::LoadMembersFromDB(QueryResult* guildMembersResult)
while (guildMembersResult->NextRow());
if (members.empty())
{ return false; }
{
return false;
}
UpdateAccountsNumber();
@ -515,7 +545,9 @@ void Guild::SetLeader(ObjectGuid guid)
{
MemberSlot* slot = GetMemberSlot(guid);
if (!slot)
{ return; }
{
return;
}
m_LeaderGuid = guid;
slot->ChangeRank(GR_GUILDMASTER);
@ -558,13 +590,17 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
}
if (!best)
{ return true; }
{
return true;
}
SetLeader(newLeaderGUID);
// If player not online data in data field will be loaded from guild tabs no need to update it !!
if (Player* newLeader = sObjectMgr.GetPlayer(newLeaderGUID))
{ newLeader->SetRank(GR_GUILDMASTER); }
{
newLeader->SetRank(GR_GUILDMASTER);
}
// when leader non-exist (at guild load with deleted leader only) not send broadcasts
if (oldLeader)
@ -588,7 +624,9 @@ bool Guild::DelMember(ObjectGuid guid, bool isDisbanding)
CharacterDatabase.PExecute("DELETE FROM guild_member WHERE guid = '%u'", lowguid);
if (!isDisbanding)
{ UpdateAccountsNumber(); }
{
UpdateAccountsNumber();
}
// Used by Eluna
#ifdef ENABLE_ELUNA
@ -612,11 +650,15 @@ bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint32 language)
{
if (!session)
{ return; }
{
return;
}
Player* player = session->GetPlayer();
if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_GCHATSPEAK))
{ return; }
{
return;
}
WorldPacket data;
ChatHandler::BuildChatPacket(data, CHAT_MSG_GUILD, msg.c_str(), Language(language), player->GetChatTag(), player->GetObjectGuid(), player->GetName());
@ -626,7 +668,9 @@ void Guild::BroadcastToGuild(WorldSession* session, const std::string& msg, uint
Player* pl = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(player->GetObjectGuid()))
{ pl->GetSession()->SendPacket(&data); }
{
pl->GetSession()->SendPacket(&data);
}
}
}
@ -650,11 +694,15 @@ void Guild::BroadcastAddonToGuild(WorldSession* session, const std::string& msg,
void Guild::BroadcastToOfficers(WorldSession* session, const std::string& msg, uint32 language)
{
if (!session)
{ return; }
{
return;
}
Player* player = session->GetPlayer();
if (!player || !HasRankRight(player->GetRank(), GR_RIGHT_OFFCHATSPEAK))
{ return; }
{
return;
}
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
@ -691,7 +739,9 @@ void Guild::BroadcastPacket(WorldPacket* packet)
{
Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (player)
{ player->GetSession()->SendPacket(packet); }
{
player->GetSession()->SendPacket(packet);
}
}
}
@ -703,7 +753,9 @@ void Guild::BroadcastPacketToRank(WorldPacket* packet, uint32 rankId)
{
Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
if (player)
{ player->GetSession()->SendPacket(packet); }
{
player->GetSession()->SendPacket(packet);
}
}
}
}
@ -744,7 +796,9 @@ void Guild::MassInviteToEvent(WorldSession* session, uint32 minLevel, uint32 max
void Guild::CreateRank(std::string name_, uint32 rights)
{
if (m_Ranks.size() >= GUILD_RANKS_MAX_COUNT)
{ return; }
{
return;
}
// ranks are sequence 0,1,2,... where 0 means guildmaster
uint32 new_rank_id = m_Ranks.size();
@ -775,7 +829,9 @@ void Guild::DelRank(uint32 rankId)
// client won't allow to have less than GUILD_RANKS_MIN_COUNT ranks in guild
if (m_Ranks.size() <= GUILD_RANKS_MIN_COUNT || rankId < GUILD_RANKS_MIN_COUNT)
{ return; }
{
return;
}
RankList::iterator itr = m_Ranks.erase(m_Ranks.begin() + rankId);
// delete lowest guild_rank
@ -826,7 +882,9 @@ void Guild::SwitchRank(uint32 rankId, bool up)
std::string Guild::GetRankName(uint32 rankId)
{
if (rankId >= m_Ranks.size())
{ return "<unknown>"; }
{
return "<unknown>";
}
return m_Ranks[rankId].Name;
}
@ -834,7 +892,9 @@ std::string Guild::GetRankName(uint32 rankId)
uint32 Guild::GetRankRights(uint32 rankId)
{
if (rankId >= m_Ranks.size())
{ return 0; }
{
return 0;
}
return m_Ranks[rankId].Rights;
}
@ -842,7 +902,9 @@ uint32 Guild::GetRankRights(uint32 rankId)
void Guild::SetRankName(uint32 rankId, std::string name_)
{
if (rankId >= m_Ranks.size())
{ return; }
{
return;
}
m_Ranks[rankId].Name = name_;
@ -854,7 +916,9 @@ void Guild::SetRankName(uint32 rankId, std::string name_)
void Guild::SetRankRights(uint32 rankId, uint32 rights)
{
if (rankId >= m_Ranks.size())
{ return; }
{
return;
}
m_Ranks[rankId].Rights = rights;
@ -980,7 +1044,9 @@ void Guild::Roster(WorldSession* session /*= NULL*/)
data << uint32(0);
if (session)
{ session->SendPacket(&data); }
{
session->SendPacket(&data);
}
else
{ BroadcastPacket(&data); }
DEBUG_LOG("WORLD: Sent (SMSG_GUILD_ROSTER)");
@ -996,7 +1062,9 @@ void Guild::Query(WorldSession* session)
for (size_t i = 0 ; i < GUILD_RANKS_MAX_COUNT; ++i) // show always 10 ranks
{
if (i < m_Ranks.size())
{ data << m_Ranks[i].Name; }
{
data << m_Ranks[i].Name;
}
else
{ data << uint8(0); } // null string
}
@ -1079,7 +1147,9 @@ uint32 Guild::GetAccountsNumber()
{
// not need recalculation
if (m_accountsNumber)
{ return m_accountsNumber; }
{
return m_accountsNumber;
}
// We use a set to be sure each element will be unique
std::set<uint32> accountsIdSet;
@ -1119,7 +1189,9 @@ void Guild::LoadGuildEventLogFromDB()
// 0 1 2 3 4 5
QueryResult* result = CharacterDatabase.PQuery("SELECT LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog WHERE guildid=%u ORDER BY TimeStamp DESC,LogGuid DESC LIMIT %u", m_Id, GUILD_EVENTLOG_MAX_RECORDS);
if (!result)
{ return; }
{
return;
}
bool isNextLogGuidSet = false;
// uint32 configCount = sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT);
// First event in list will be the oldest and the latest event is last event in list
@ -1164,7 +1236,9 @@ void Guild::LogGuildEvent(uint8 EventType, ObjectGuid playerGuid1, ObjectGuid pl
m_GuildEventLogNextGuid = (m_GuildEventLogNextGuid + 1) % sWorld.getConfig(CONFIG_UINT32_GUILD_EVENT_LOG_COUNT);
// Check max records limit
if (m_GuildEventLog.size() >= GUILD_EVENTLOG_MAX_RECORDS)
{ m_GuildEventLog.pop_front(); }
{
m_GuildEventLog.pop_front();
}
// Add event to list
m_GuildEventLog.push_back(NewEvent);
// Save event to DB

View file

@ -401,7 +401,9 @@ class Guild
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first)))
if (player != except)
{ _do(player); }
{
_do(player);
}
}
void CreateRank(std::string name, uint32 rights);
@ -443,7 +445,9 @@ class Guild
{
for (MemberList::iterator itr = members.begin(); itr != members.end(); ++itr)
if (itr->second.Name == name)
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}

View file

@ -47,7 +47,9 @@ void AddItemsSetItem(Player* player, Item* item)
}
if (set->required_skill_id && player->GetSkillValue(set->required_skill_id) < set->required_skill_value)
{ return; }
{
return;
}
ItemSetEffect* eff = NULL;
@ -69,10 +71,14 @@ void AddItemsSetItem(Player* player, Item* item)
size_t x = 0;
for (; x < player->ItemSetEff.size(); ++x)
if (!player->ItemSetEff[x])
{ break; }
{
break;
}
if (x < player->ItemSetEff.size())
{ player->ItemSetEff[x] = eff; }
{
player->ItemSetEff[x] = eff;
}
else
{ player->ItemSetEff.push_back(eff); }
}
@ -82,18 +88,26 @@ void AddItemsSetItem(Player* player, Item* item)
for (uint32 x = 0; x < 8; ++x)
{
if (!set->spells[x])
{ continue; }
{
continue;
}
// not enough for spell
if (set->items_to_triggerspell[x] > eff->item_count)
{ continue; }
{
continue;
}
uint32 z = 0;
for (; z < 8; ++z)
if (eff->spells[z] && eff->spells[z]->Id == set->spells[x])
{ break; }
{
break;
}
if (z < 8)
{ continue; }
{
continue;
}
// new spell
for (uint32 y = 0; y < 8; ++y)
@ -141,18 +155,24 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
// can be in case now enough skill requirement for set appling but set has been appliend when skill requirement not enough
if (!eff)
{ return; }
{
return;
}
--eff->item_count;
for (uint32 x = 0; x < 8; ++x)
{
if (!set->spells[x])
{ continue; }
{
continue;
}
// enough for spell
if (set->items_to_triggerspell[x] <= eff->item_count)
{ continue; }
{
continue;
}
for (uint32 z = 0; z < 8; ++z)
{
@ -177,7 +197,9 @@ void RemoveItemsSetItem(Player* player, ItemPrototype const* proto)
bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProto)
{
if (!pProto || !pBagProto)
{ return false; }
{
return false;
}
switch (pBagProto->Class)
{
@ -188,15 +210,21 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
return true;
case ITEM_SUBCLASS_SOUL_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_SOUL_SHARDS))
{ return false; }
{
return false;
}
return true;
case ITEM_SUBCLASS_HERB_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_HERBS))
{ return false; }
{
return false;
}
return true;
case ITEM_SUBCLASS_ENCHANTING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_ENCHANTING_SUPP))
{ return false; }
{
return false;
}
return true;
case ITEM_SUBCLASS_MINING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_MINING_SUPP))
@ -204,7 +232,9 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
return true;
case ITEM_SUBCLASS_ENGINEERING_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_ENGINEERING_SUPP))
{ return false; }
{
return false;
}
return true;
case ITEM_SUBCLASS_GEM_CONTAINER:
if (!(pProto->BagFamily & BAG_FAMILY_GEMS))
@ -230,11 +260,15 @@ bool ItemCanGoIntoBag(ItemPrototype const* pProto, ItemPrototype const* pBagProt
{
case ITEM_SUBCLASS_QUIVER:
if (!(pProto->BagFamily & BAG_FAMILY_ARROWS))
{ return false; }
{
return false;
}
return true;
case ITEM_SUBCLASS_AMMO_POUCH:
if (!(pProto->BagFamily & BAG_FAMILY_BULLETS))
{ return false; }
{
return false;
}
return true;
default:
return false;
@ -402,7 +436,9 @@ bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner)
ItemPrototype const* itemProto = ObjectMgr::GetItemPrototype(itemid);
if (!itemProto)
{ return false; }
{
return false;
}
SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, itemProto->MaxDurability);
@ -426,7 +462,9 @@ bool Item::IsNotEmptyBag() const
void Item::UpdateDuration(Player* owner, uint32 diff)
{
if (!GetUInt32Value(ITEM_FIELD_DURATION))
{ return; }
{
return;
}
// DEBUG_LOG("Item::UpdateDuration Item (Entry: %u Duration %u Diff %u)", GetEntry(), GetUInt32Value(ITEM_FIELD_DURATION), diff);
@ -546,11 +584,15 @@ void Item::SaveToDB()
LootItem* item = loot.LootItemInSlot(i, owner, &qitem);
if (!item)
{ continue; }
{
continue;
}
// questitems use the blocked field for other purposes
if (!qitem && item->is_blocked)
{ continue; }
{
continue;
}
stmt.addUInt32(GetGUIDLow());
stmt.addUInt32(owner->GetGUIDLow());
@ -565,7 +607,9 @@ void Item::SaveToDB()
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_TEMPORARY)
{ SetLootState(ITEM_LOOT_UNCHANGED); }
{
SetLootState(ITEM_LOOT_UNCHANGED);
}
SetState(ITEM_UNCHANGED);
}
@ -596,14 +640,18 @@ bool Item::LoadFromDB(uint32 guidLow, Field* fields, ObjectGuid ownerGuid)
ItemPrototype const* proto = GetProto();
if (!proto)
{ return false; }
{
return false;
}
// update max durability (and durability) if need
if (proto->MaxDurability != GetUInt32Value(ITEM_FIELD_MAXDURABILITY))
{
SetUInt32Value(ITEM_FIELD_MAXDURABILITY, proto->MaxDurability);
if (GetUInt32Value(ITEM_FIELD_DURABILITY) > proto->MaxDurability)
{ SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability); }
{
SetUInt32Value(ITEM_FIELD_DURABILITY, proto->MaxDurability);
}
need_save = true;
}
@ -768,13 +816,17 @@ uint32 Item::GetSkill()
{
case ITEM_CLASS_WEAPON:
if (proto->SubClass >= MAX_ITEM_SUBCLASS_WEAPON)
{ return 0; }
{
return 0;
}
else
{ return item_weapon_skills[proto->SubClass]; }
case ITEM_CLASS_ARMOR:
if (proto->SubClass >= MAX_ITEM_SUBCLASS_ARMOR)
{ return 0; }
{
return 0;
}
else
{ return item_armor_skills[proto->SubClass]; }
@ -788,7 +840,9 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
ItemPrototype const* itemProto = sItemStorage.LookupEntry<ItemPrototype>(item_id);
if (!itemProto)
{ return 0; }
{
return 0;
}
// item must have one from this field values not null if it can have random enchantments
if ((!itemProto->RandomProperty) && (!itemProto->RandomSuffix))
@ -825,7 +879,9 @@ int32 Item::GenerateItemRandomPropertyId(uint32 item_id)
void Item::SetItemRandomProperties(int32 randomPropId)
{
if (!randomPropId)
{ return; }
{
return;
}
if (randomPropId > 0)
{
@ -875,7 +931,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
{
// pretend the item never existed
if (forplayer || GetOwnerGuid())
{ RemoveFromUpdateQueueOf(forplayer); }
{
RemoveFromUpdateQueueOf(forplayer);
}
delete this;
return;
}
@ -886,7 +944,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
if (uState != ITEM_NEW) { uState = state; }
if (forplayer || GetOwnerGuid())
{ AddToUpdateQueueOf(forplayer); }
{
AddToUpdateQueueOf(forplayer);
}
}
else
{
@ -900,7 +960,9 @@ void Item::SetState(ItemUpdateState state, Player* forplayer)
void Item::AddToUpdateQueueOf(Player* player)
{
if (IsInUpdateQueue())
{ return; }
{
return;
}
if (!player)
{
@ -921,7 +983,9 @@ void Item::AddToUpdateQueueOf(Player* player)
}
if (player->m_itemUpdateQueueBlocked)
{ return; }
{
return;
}
player->m_itemUpdateQueue.push_back(this);
uQueuePos = player->m_itemUpdateQueue.size() - 1;
@ -930,7 +994,9 @@ void Item::AddToUpdateQueueOf(Player* player)
void Item::RemoveFromUpdateQueueOf(Player* player)
{
if (!IsInUpdateQueue())
{ return; }
{
return;
}
if (!player)
{
@ -951,7 +1017,9 @@ void Item::RemoveFromUpdateQueueOf(Player* player)
}
if (player->m_itemUpdateQueueBlocked)
{ return; }
{
return;
}
player->m_itemUpdateQueue[uQueuePos] = NULL;
uQueuePos = -1;
@ -970,23 +1038,35 @@ bool Item::IsEquipped() const
bool Item::CanBeTraded(bool mail) const
{
if ((!mail || !IsBoundAccountWide()) && IsSoulBound())
{ return false; }
{
return false;
}
if (IsBag() && (Player::IsBagPos(GetPos()) || !((Bag const*)this)->IsEmpty()))
{ return false; }
{
return false;
}
if (Player* owner = GetOwner())
{
if (owner->CanUnequipItem(GetPos(), false) != EQUIP_ERR_OK)
{ return false; }
{
return false;
}
if (owner->GetLootGuid() == GetObjectGuid())
{ return false; }
{
return false;
}
}
if (HasGeneratedLoot())
{ return false; }
{
return false;
}
if (IsBoundByEnchant())
{ return false; }
{
return false;
}
return true;
}
@ -998,7 +1078,9 @@ bool Item::IsBoundByEnchant() const
{
uint32 enchant_id = GetEnchantmentId(EnchantmentSlot(enchant_slot));
if (!enchant_id)
{ continue; }
{
continue;
}
if (enchant_slot == TRANSMOGRIFY_ENCHANTMENT_SLOT)
return true;
@ -1008,10 +1090,14 @@ bool Item::IsBoundByEnchant() const
SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(enchant_id);
if (!enchantEntry)
{ continue; }
{
continue;
}
if (enchantEntry->slot & ENCHANTMENT_CAN_SOULBOUND)
{ return true; }
{
return true;
}
}
return false;
}
@ -1069,14 +1155,20 @@ bool Item::IsTargetValidForItemUse(Unit* pUnitTarget)
ItemRequiredTargetMapBounds bounds = sObjectMgr.GetItemRequiredTargetMapBounds(GetProto()->ItemId);
if (bounds.first == bounds.second)
{ return true; }
{
return true;
}
if (!pUnitTarget)
{ return false; }
{
return false;
}
for (ItemRequiredTargetMap::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
if (itr->second.IsFitToRequirements(pUnitTarget))
{ return true; }
{
return true;
}
return false;
}
@ -1085,7 +1177,9 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
{
// Better lost small time at check in comparison lost time at item save to DB.
if ((GetEnchantmentId(slot) == id) && (GetEnchantmentDuration(slot) == duration) && (GetEnchantmentCharges(slot) == charges))
{ return; }
{
return;
}
if (slot < MAX_INSPECTED_ENCHANTMENT_SLOT)
{
@ -1106,7 +1200,9 @@ void Item::SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint
void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
{
if (GetEnchantmentDuration(slot) == duration)
{ return; }
{
return;
}
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_DURATION_OFFSET, duration);
SetState(ITEM_CHANGED);
@ -1115,7 +1211,9 @@ void Item::SetEnchantmentDuration(EnchantmentSlot slot, uint32 duration)
void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
{
if (GetEnchantmentCharges(slot) == charges)
{ return; }
{
return;
}
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + ENCHANTMENT_CHARGES_OFFSET, charges);
SetState(ITEM_CHANGED);
@ -1124,7 +1222,9 @@ void Item::SetEnchantmentCharges(EnchantmentSlot slot, uint32 charges)
void Item::ClearEnchantment(EnchantmentSlot slot)
{
if (!GetEnchantmentId(slot))
{ return; }
{
return;
}
for (uint8 x = 0; x < 3; ++x)
SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1 + slot * MAX_ENCHANTMENT_OFFSET + x, 0);
@ -1241,7 +1341,9 @@ void Item::SendTimeUpdate(Player* owner)
uint32 duration = GetUInt32Value(ITEM_FIELD_DURATION);
if (!duration)
{ return; }
{
return;
}
WorldPacket data(SMSG_ITEM_TIME_UPDATE, (8 + 4));
data << ObjectGuid(GetObjectGuid());
@ -1257,7 +1359,9 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r
if (ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(item))
{
if (count > pProto->GetMaxStackSize())
{ count = pProto->GetMaxStackSize(); }
{
count = pProto->GetMaxStackSize();
}
MANGOS_ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
@ -1266,7 +1370,9 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, uint32 r
{
pItem->SetCount(count);
if (uint32 randId = randomPropertyId ? randomPropertyId : Item::GenerateItemRandomPropertyId(item))
{ pItem->SetItemRandomProperties(randId); }
{
pItem->SetItemRandomProperties(randId);
}
return pItem;
}
@ -1280,7 +1386,9 @@ Item* Item::CloneItem(uint32 count, Player const* player) const
{
Item* newItem = CreateItem(GetEntry(), count, player, GetItemRandomPropertyId());
if (!newItem)
{ return NULL; }
{
return NULL;
}
newItem->SetGuidValue(ITEM_FIELD_CREATOR, GetGuidValue(ITEM_FIELD_CREATOR));
newItem->SetGuidValue(ITEM_FIELD_GIFTCREATOR, GetGuidValue(ITEM_FIELD_GIFTCREATOR));
@ -1293,15 +1401,21 @@ bool Item::IsBindedNotWith(Player const* player) const
{
// own item
if (GetOwnerGuid() == player->GetObjectGuid())
{ return false; }
{
return false;
}
// has loot with diff owner
if (HasGeneratedLoot())
{ return true; }
{
return true;
}
// not binded item
if (!IsSoulBound())
{ return false; }
{
return false;
}
// not BOA item case
if (!IsBoundAccountWide())
@ -1322,19 +1436,25 @@ bool Item::IsBindedNotWith(Player const* player) const
void Item::AddToClientUpdateList()
{
if (Player* pl = GetOwner())
{ pl->GetMap()->AddUpdateObject(this); }
{
pl->GetMap()->AddUpdateObject(this);
}
}
void Item::RemoveFromClientUpdateList()
{
if (Player* pl = GetOwner())
{ pl->GetMap()->RemoveUpdateObject(this); }
{
pl->GetMap()->RemoveUpdateObject(this);
}
}
void Item::BuildUpdateData(UpdateDataMapType& update_players)
{
if (Player* pl = GetOwner())
{ BuildUpdateDataForPlayer(pl, update_players); }
{
BuildUpdateDataForPlayer(pl, update_players);
}
ClearUpdateMask(false);
}
@ -1343,15 +1463,21 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
{
// check item type
if (GetEntry() != proto->ItemId)
{ return EQUIP_ERR_ITEM_CANT_STACK; }
{
return EQUIP_ERR_ITEM_CANT_STACK;
}
// check free space (full stacks can't be target of merge
if (GetCount() >= proto->GetMaxStackSize())
{ return EQUIP_ERR_ITEM_CANT_STACK; }
{
return EQUIP_ERR_ITEM_CANT_STACK;
}
// not allow merge looting currently items
if (HasGeneratedLoot())
{ return EQUIP_ERR_ALREADY_LOOTED; }
{
return EQUIP_ERR_ALREADY_LOOTED;
}
return EQUIP_ERR_OK;
}
@ -1359,10 +1485,14 @@ InventoryResult Item::CanBeMergedPartlyWith(ItemPrototype const* proto) const
bool ItemRequiredTarget::IsFitToRequirements(Unit* pUnitTarget) const
{
if (pUnitTarget->GetTypeId() != TYPEID_UNIT)
{ return false; }
{
return false;
}
if (pUnitTarget->GetEntry() != m_uiTargetEntry)
{ return false; }
{
return false;
}
switch (m_uiType)
{
@ -1418,12 +1548,16 @@ void Item::SetLootState(ItemLootUpdateState state)
case ITEM_LOOT_CHANGED:
// new loot must stay in new state until saved, temporary must stay until remove
if (m_lootState != ITEM_LOOT_NEW && m_lootState != ITEM_LOOT_TEMPORARY)
{ m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state; }
{
m_lootState = m_lootState == ITEM_LOOT_NONE ? ITEM_LOOT_NEW : state;
}
break;
case ITEM_LOOT_UNCHANGED:
// expected that called after DB update or load
if (m_lootState == ITEM_LOOT_REMOVED)
{ m_lootState = ITEM_LOOT_NONE; }
{
m_lootState = ITEM_LOOT_NONE;
}
// temporary must stay until remove (ignore any changes)
else if (m_lootState != ITEM_LOOT_TEMPORARY)
{ m_lootState = ITEM_LOOT_UNCHANGED; }
@ -1441,7 +1575,9 @@ void Item::SetLootState(ItemLootUpdateState state)
}
if (m_lootState != ITEM_LOOT_NONE && m_lootState != ITEM_LOOT_UNCHANGED && m_lootState != ITEM_LOOT_TEMPORARY)
{ SetState(ITEM_CHANGED); }
{
SetState(ITEM_CHANGED);
}
}
uint32 Item::GetScriptId() const

View file

@ -150,7 +150,9 @@ void LootStore::LoadLootTable()
LootStoreItem storeitem = LootStoreItem(item, type, chanceOrQuestChance, group, conditionId, mincountOrRef, maxcount);
if (!storeitem.IsValid(*this, entry)) // Validity checks
{ continue; }
{
continue;
}
// Looking for the template of the entry
// often entries are put together
@ -191,7 +193,9 @@ bool LootStore::HaveQuestLootFor(uint32 loot_id) const
{
LootTemplateMap::const_iterator itr = m_LootTemplates.find(loot_id);
if (itr == m_LootTemplates.end())
{ return false; }
{
return false;
}
// scan loot for quest items
return itr->second->HasQuestDrop(m_LootTemplates);
@ -202,7 +206,9 @@ bool LootStore::HaveQuestLootForPlayer(uint32 loot_id, Player* player) const
LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id);
if (tab != m_LootTemplates.end())
if (tab->second->HasQuestDropForPlayer(m_LootTemplates, player))
{ return true; }
{
return true;
}
return false;
}
@ -212,7 +218,9 @@ LootTemplate const* LootStore::GetLootFor(uint32 loot_id) const
LootTemplateMap::const_iterator tab = m_LootTemplates.find(loot_id);
if (tab == m_LootTemplates.end())
{ return NULL; }
{
return NULL;
}
return tab->second;
}
@ -256,10 +264,14 @@ void LootStore::ReportNotExistedId(uint32 id) const
bool LootStoreItem::Roll(bool rate) const
{
if (chance >= 100.0f)
{ return true; }
{
return true;
}
if (mincountOrRef < 0) // reference case
{ return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f)); }
{
return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_ITEM_REFERENCED) : 1.0f));
}
if (type == LOOTITEM_TYPE_CURRENCY)
return roll_chance_f(chance * (rate ? sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_CURRENCY) : 1.0f));
@ -430,41 +442,57 @@ bool LootItem::AllowedForPlayer(Player const* player, WorldObject const* lootTar
{
ItemPrototype const* pProto = ObjectMgr::GetItemPrototype(itemid);
if (!pProto)
{ return false; }
{
return false;
}
// not show loot for not own team
if ((pProto->Flags2 & ITEM_FLAG2_HORDE_ONLY) && player->GetTeam() != HORDE)
{ return false; }
{
return false;
}
if ((pProto->Flags2 & ITEM_FLAG2_ALLIANCE_ONLY) && player->GetTeam() != ALLIANCE)
{ return false; }
{
return false;
}
if (needs_quest)
{
// Checking quests for quest-only drop (check only quests requirements in this case)
if (!player->HasQuestForItem(itemid))
{ return false; }
{
return false;
}
}
else
{
// Not quest only drop (check quest starting items for already accepted non-repeatable quests)
if (pProto->StartQuest && player->GetQuestStatus(pProto->StartQuest) != QUEST_STATUS_NONE && !player->HasQuestForItem(itemid))
{ return false; }
{
return false;
}
}
}
else if (type == LOOT_ITEM_TYPE_CURRENCY)
{
CurrencyTypesEntry const * currency = sCurrencyTypesStore.LookupEntry(itemid);
if (!itemid)
{ return false; }
{
return false;
}
if (!player->isGameMaster())
{
if (currency->Category == CURRENCY_CATEGORY_META)
{ return false; }
{
return false;
}
if (currency->Category == CURRENCY_CATEGORY_ARCHAEOLOGY && !player->HasSkill(SKILL_ARCHAEOLOGY))
{ return false; }
{
return false;
}
}
}
@ -475,7 +503,9 @@ LootSlotType LootItem::GetSlotTypeForSharedLoot(PermissionTypes permission, Play
{
// ignore currencies, looted items, FFA (each player get own copy) and not allowed items
if (currency || is_looted || freeforall || (conditionId && !condition_ok) || !AllowedForPlayer(viewer, lootTarget))
{ return MAX_LOOT_SLOT_TYPE; }
{
return MAX_LOOT_SLOT_TYPE;
}
switch (permission)
{
@ -502,7 +532,9 @@ void Loot::AddItem(LootStoreItem const& item)
if (item.needs_quest) // Quest drop
{
if (m_questItems.size() < MAX_NR_QUEST_ITEMS)
{ m_questItems.push_back(LootItem(item)); }
{
m_questItems.push_back(LootItem(item));
}
}
else if (items.size() < MAX_NR_LOOT_ITEMS) // Non-quest drop
{
@ -516,7 +548,9 @@ void Loot::AddItem(LootStoreItem const& item)
{
ItemPrototype const* proto = ObjectMgr::GetItemPrototype(item.itemid);
if (!proto || !(proto->Flags & ITEM_FLAG_PARTY_LOOT))
{ ++unlootedCount; }
{
++unlootedCount;
}
}
}
}
@ -526,14 +560,18 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
{
// Must be provided
if (!loot_owner)
{ return false; }
{
return false;
}
LootTemplate const* tab = store.GetLootFor(loot_id);
if (!tab)
{
if (!noEmptyError)
{ sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id); }
{
sLog.outErrorDb("Table '%s' loot id #%u used but it doesn't have records.", store.GetName(), loot_id);
}
return false;
}
@ -548,7 +586,9 @@ bool Loot::FillLoot(uint32 loot_id, LootStore const& store, Player* loot_owner,
{
for (GroupReference* itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* pl = itr->getSource())
{ FillNotNormalLootFor(pl); }
{
FillNotNormalLootFor(pl);
}
}
// ... for personal loot
else
@ -567,11 +607,15 @@ void Loot::FillNotNormalLootFor(Player* pl)
qmapitr = m_playerQuestItems.find(plguid);
if (qmapitr == m_playerQuestItems.end())
{ FillQuestLoot(pl); }
{
FillQuestLoot(pl);
}
qmapitr = m_playerFFAItems.find(plguid);
if (qmapitr == m_playerFFAItems.end())
{ FillFFALoot(pl); }
{
FillFFALoot(pl);
}
qmapitr = m_playerNonQuestNonFFANonCurrencyConditionalItems.find(plguid);
if (qmapitr == m_playerNonQuestNonFFANonCurrencyConditionalItems.end())
@ -641,12 +685,16 @@ QuestItemList* Loot::FillQuestLoot(Player* player)
//
// increase once if one looter only, looter-times if free for all
if (item.freeforall || !item.is_blocked)
{ ++unlootedCount; }
{
++unlootedCount;
}
item.is_blocked = true;
if (items.size() + ql->size() == MAX_NR_LOOT_ITEMS)
{ break; }
{
break;
}
}
}
if (ql->empty())
@ -698,7 +746,9 @@ void Loot::NotifyItemRemoved(uint8 lootIndex)
i_next = i;
++i_next;
if (Player* pl = ObjectAccessor::FindPlayer(*i))
{ pl->SendNotifyLootItemRemoved(lootIndex); }
{
pl->SendNotifyLootItemRemoved(lootIndex);
}
else
{ m_playersLooting.erase(i); }
}
@ -713,7 +763,9 @@ void Loot::NotifyMoneyRemoved()
i_next = i;
++i_next;
if (Player* pl = ObjectAccessor::FindPlayer(*i))
{ pl->SendNotifyLootMoneyRemoved(); }
{
pl->SendNotifyLootMoneyRemoved();
}
else
{ m_playersLooting.erase(i); }
}
@ -742,10 +794,14 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
uint8 j;
for (j = 0; j < pql.size(); ++j)
if (pql[j].index == questIndex)
{ break; }
{
break;
}
if (j < pql.size())
{ pl->SendNotifyLootItemRemoved(items.size() + j); }
{
pl->SendNotifyLootItemRemoved(items.size() + j);
}
}
}
else
@ -758,7 +814,9 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
if (maxAmount > 0)
{
if (maxAmount <= minAmount)
{ gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); }
{
gold = uint32(maxAmount * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY));
}
else if ((maxAmount - minAmount) < 32700)
{ gold = uint32(urand(minAmount, maxAmount) * sWorld.getConfig(CONFIG_FLOAT_RATE_DROP_MONEY)); }
else
@ -778,7 +836,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{
QuestItem* qitem2 = &itr->second->at(questSlot);
if (qitem)
{ *qitem = qitem2; }
{
*qitem = qitem2;
}
item = &m_questItems[qitem2->index];
is_looted = qitem2->is_looted;
}
@ -815,7 +875,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{
QuestItem* ffaitem2 = (QuestItem*) & (*iter);
if (ffaitem)
{ *ffaitem = ffaitem2; }
{
*ffaitem = ffaitem2;
}
is_looted = ffaitem2->is_looted;
break;
}
@ -832,7 +894,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
{
QuestItem* conditem2 = (QuestItem*) & (*iter);
if (conditem)
{ *conditem = conditem2; }
{
*conditem = conditem2;
}
is_looted = conditem2->is_looted;
break;
}
@ -842,7 +906,9 @@ LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem** qite
}
if (is_looted)
{ return NULL; }
{
return NULL;
}
return item;
}
@ -899,7 +965,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
{
LootSlotType slot_type = l.items[i].GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget());
if (slot_type >= MAX_LOOT_SLOT_TYPE)
{ continue; }
{
continue;
}
b << uint8(i) << l.items[i];
b << uint8(slot_type); // 0 - get 1 - look only 2 - master selection
@ -917,7 +985,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
LootSlotType slot_type = item.GetSlotTypeForSharedLoot(lv.permission, lv.viewer, l.GetLootTarget(), !ci->is_looted);
if (slot_type >= MAX_LOOT_SLOT_TYPE)
{ continue; }
{
continue;
}
b << uint8(ci->index) << item;
b << uint8(slot_type); // allow loot
@ -994,7 +1064,9 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv)
void LootTemplate::LootGroup::AddEntry(LootStoreItem& item)
{
if (item.chance != 0)
{ ExplicitlyChanced.push_back(item); }
{
ExplicitlyChanced.push_back(item);
}
else
{ EqualChanced.push_back(item); }
}
@ -1009,15 +1081,21 @@ LootStoreItem const* LootTemplate::LootGroup::Roll() const
for (uint32 i = 0; i < ExplicitlyChanced.size(); ++i) // check each explicitly chanced entry in the template and modify its chance based on quality.
{
if (ExplicitlyChanced[i].chance >= 100.0f)
{ return &ExplicitlyChanced[i]; }
{
return &ExplicitlyChanced[i];
}
Roll -= ExplicitlyChanced[i].chance;
if (Roll < 0)
{ return &ExplicitlyChanced[i]; }
{
return &ExplicitlyChanced[i];
}
}
}
if (!EqualChanced.empty()) // If nothing selected yet - an item is taken from equal-chanced part
{ return &EqualChanced[irand(0, EqualChanced.size() - 1)]; }
{
return &EqualChanced[irand(0, EqualChanced.size() - 1)];
}
return NULL; // Empty drop from the group
}
@ -1027,10 +1105,14 @@ bool LootTemplate::LootGroup::HasQuestDrop() const
{
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (i->needs_quest)
{ return true; }
{
return true;
}
for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i)
if (i->needs_quest)
{ return true; }
{
return true;
}
return false;
}
@ -1039,10 +1121,14 @@ bool LootTemplate::LootGroup::HasQuestDropForPlayer(Player const* player) const
{
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid))
{ return true; }
{
return true;
}
for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i)
if (player->HasQuestForItem(i->itemid))
{ return true; }
{
return true;
}
return false;
}
@ -1051,7 +1137,9 @@ void LootTemplate::LootGroup::Process(Loot& loot) const
{
LootStoreItem const* item = Roll();
if (item != NULL)
{ loot.AddItem(*item); }
{
loot.AddItem(*item);
}
}
// Overall chance for the group without equal chanced items
@ -1061,7 +1149,9 @@ float LootTemplate::LootGroup::RawTotalChance() const
for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)
if (!i->needs_quest)
{ result += i->chance; }
{
result += i->chance;
}
return result;
}
@ -1072,7 +1162,9 @@ float LootTemplate::LootGroup::TotalChance() const
float result = RawTotalChance();
if (!EqualChanced.empty() && result < 100.0f)
{ return 100.0f; }
{
return 100.0f;
}
return result;
}
@ -1098,7 +1190,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0)
{
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
{ LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
{
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
}
else if (ref_set)
{ ref_set->erase(-ieItr->mincountOrRef); }
}
@ -1109,7 +1203,9 @@ void LootTemplate::LootGroup::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0)
{
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
{ LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
{
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
}
else if (ref_set)
{ ref_set->erase(-ieItr->mincountOrRef); }
}
@ -1160,7 +1256,9 @@ void LootTemplate::Process(Loot& loot, LootStore const& store, bool rate, uint8
// Check condition
if (i->conditionId && !sObjectMgr.IsPlayerMeetToCondition(i->conditionId, NULL, NULL, loot.GetLootTarget(), CONDITION_FROM_REFERING_LOOT))
{ continue; }
{
continue;
}
for (uint32 loop = 0; loop < i->maxcount; ++loop) // Ref multiplicator
{ Referenced->Process(loot, store, rate, i->group); }
@ -1192,7 +1290,9 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
if (Referenced == store.end())
{ continue; } // Error message [should be] already printed at loading stage
if (Referenced->second->HasQuestDrop(store, i->group))
{ return true; }
{
return true;
}
}
else if (i->needs_quest)
{ return true; } // quest drop found
@ -1201,7 +1301,9 @@ bool LootTemplate::HasQuestDrop(LootTemplateMap const& store, uint8 groupId) con
// Now processing groups
for (LootGroups::const_iterator i = Groups.begin() ; i != Groups.end() ; ++i)
if (i->HasQuestDrop())
{ return true; }
{
return true;
}
return false;
}
@ -1225,7 +1327,9 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
if (Referenced == store.end())
{ continue; } // Error message already printed at loading stage
if (Referenced->second->HasQuestDropForPlayer(store, player, i->group))
{ return true; }
{
return true;
}
}
else if (player->HasQuestForItem(i->itemid))
{ return true; } // active quest drop found
@ -1234,7 +1338,9 @@ bool LootTemplate::HasQuestDropForPlayer(LootTemplateMap const& store, Player co
// Now checking groups
for (LootGroups::const_iterator i = Groups.begin(); i != Groups.end(); ++i)
if (i->HasQuestDropForPlayer(player))
{ return true; }
{
return true;
}
return false;
}
@ -1256,7 +1362,9 @@ void LootTemplate::CheckLootRefs(LootIdSet* ref_set) const
if (ieItr->mincountOrRef < 0)
{
if (!LootTemplates_Reference.GetLootFor(-ieItr->mincountOrRef))
{ LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef); }
{
LootTemplates_Reference.ReportNotExistedId(-ieItr->mincountOrRef);
}
else if (ref_set)
{ ref_set->erase(-ieItr->mincountOrRef); }
}
@ -1279,7 +1387,9 @@ void LoadLootTemplates_Creature()
if (uint32 lootid = cInfo->LootId)
{
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Creature.ReportNotExistedId(lootid); }
{
LootTemplates_Creature.ReportNotExistedId(lootid);
}
else
{ ids_setUsed.insert(lootid); }
}
@ -1309,7 +1419,9 @@ void LoadLootTemplates_Disenchant()
if (uint32 lootid = proto->DisenchantID)
{
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Disenchant.ReportNotExistedId(lootid); }
{
LootTemplates_Disenchant.ReportNotExistedId(lootid);
}
else
{ ids_setUsed.insert(lootid); }
}
@ -1331,7 +1443,9 @@ void LoadLootTemplates_Fishing()
{
if (AreaTableEntry const* areaEntry = sAreaStore.LookupEntry(i))
if (ids_set.find(areaEntry->ID) != ids_set.end())
{ ids_set.erase(areaEntry->ID); }
{
ids_set.erase(areaEntry->ID);
}
}
// by default (look config options) fishing at fail provide junk loot, entry 0 use for store this loot
@ -1352,7 +1466,9 @@ void LoadLootTemplates_Gameobject()
if (uint32 lootid = itr->GetLootId())
{
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Gameobject.ReportNotExistedId(lootid); }
{
LootTemplates_Gameobject.ReportNotExistedId(lootid);
}
else
{ ids_setUsed.insert(lootid); }
}
@ -1375,10 +1491,14 @@ void LoadLootTemplates_Item()
if (ItemPrototype const* proto = sItemStorage.LookupEntry<ItemPrototype>(i))
{
if (!(proto->Flags & ITEM_FLAG_LOOTABLE))
{ continue; }
{
continue;
}
if (ids_set.find(proto->ItemId) != ids_set.end() || proto->MaxMoneyLoot > 0)
{ ids_set.erase(proto->ItemId); }
{
ids_set.erase(proto->ItemId);
}
// wdb have wrong data cases, so skip by default
else if (!sLog.HasLogFilter(LOG_FILTER_DB_STRICTED_CHECK))
{ LootTemplates_Item.ReportNotExistedId(proto->ItemId); }
@ -1427,7 +1547,9 @@ void LoadLootTemplates_Pickpocketing()
if (uint32 lootid = cInfo->PickpocketLootId)
{
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Pickpocketing.ReportNotExistedId(lootid); }
{
LootTemplates_Pickpocketing.ReportNotExistedId(lootid);
}
else
{ ids_setUsed.insert(lootid); }
}
@ -1474,7 +1596,9 @@ void LoadLootTemplates_Mail()
for (uint32 i = 1; i < sMailTemplateStore.GetNumRows(); ++i)
if (sMailTemplateStore.LookupEntry(i))
if (ids_set.find(i) != ids_set.end())
{ ids_set.erase(i); }
{
ids_set.erase(i);
}
// output error for any still listed (not referenced from appropriate table) ids
LootTemplates_Mail.ReportUnusedIds(ids_set);
@ -1493,7 +1617,9 @@ void LoadLootTemplates_Skinning()
if (uint32 lootid = cInfo->SkinningLootId)
{
if (ids_set.find(lootid) == ids_set.end())
{ LootTemplates_Skinning.ReportNotExistedId(lootid); }
{
LootTemplates_Skinning.ReportNotExistedId(lootid);
}
else
{ ids_setUsed.insert(lootid); }
}

View file

@ -98,7 +98,9 @@ void Object::_InitValues()
void Object::_Create(uint32 guidlow, uint32 entry, HighGuid guidhigh)
{
if (!m_uint32Values)
{ _InitValues(); }
{
_InitValues();
}
ObjectGuid guid = ObjectGuid(guidhigh, entry, guidlow);
SetGuidValue(OBJECT_FIELD_GUID, guid);
@ -114,7 +116,9 @@ void Object::SetObjectScale(float newScale)
void Object::SendForcedObjectUpdate()
{
if (!m_inWorld || !m_objectUpdated)
{ return; }
{
return;
}
UpdateDataMapType update_players;
@ -133,14 +137,18 @@ void Object::SendForcedObjectUpdate()
void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const
{
if (!target)
{ return; }
{
return;
}
uint8 updatetype = UPDATETYPE_CREATE_OBJECT;
uint16 updateFlags = m_updateFlag;
/** lower flag1 **/
if (target == this) // building packet for yourself
{ updateFlags |= UPDATEFLAG_SELF; }
{
updateFlags |= UPDATEFLAG_SELF;
}
if (m_itsNewObject)
{
@ -518,7 +526,9 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint16 updateFlags) const
void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const
{
if (!target)
{ return; }
{
return;
}
uint32 valuesCount = m_valuesCount;
if(GetTypeId() == TYPEID_PLAYER && target != this)
@ -532,7 +542,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
{
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
{ IsActivateToQuest = true; }
{
IsActivateToQuest = true;
}
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
}
@ -550,7 +562,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
{
if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
{ IsActivateToQuest = true; }
{
IsActivateToQuest = true;
}
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
updateMask->SetBit(GAMEOBJECT_BYTES_1); // why do we need this here?
@ -595,7 +609,9 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
if (appendValue & UNIT_NPC_FLAG_STABLEMASTER)
{
if (target->getClass() != CLASS_HUNTER)
{ appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER; }
{
appendValue &= ~UNIT_NPC_FLAG_STABLEMASTER;
}
}
}
@ -656,14 +672,18 @@ void Object::BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* u
/* If we're not allowed to loot the target, destroy the lootable flag */
if (!target->isAllowedToLoot((Creature*)this))
if (send_value & UNIT_DYNFLAG_LOOTABLE)
{ send_value = send_value & ~UNIT_DYNFLAG_LOOTABLE; }
{
send_value = send_value & ~UNIT_DYNFLAG_LOOTABLE;
}
/* If we are allowed to loot it and mob is tapped by us, destroy the tapped flag */
bool is_tapped = target->IsTappedByMeOrMyGroup((Creature*)this);
/* If the creature has tapped flag but is tapped by us, remove the flag */
if (send_value & UNIT_DYNFLAG_TAPPED && is_tapped)
{ send_value = send_value & ~UNIT_DYNFLAG_TAPPED; }
{
send_value = send_value & ~UNIT_DYNFLAG_TAPPED;
}
*data << send_value;
}
@ -753,7 +773,9 @@ void Object::ClearUpdateMask(bool remove)
if (m_objectUpdated)
{
if (remove)
{ RemoveFromClientUpdateList(); }
{
RemoveFromClientUpdateList();
}
m_objectUpdated = false;
}
}
@ -765,7 +787,9 @@ bool Object::LoadValues(const char* data)
Tokens tokens = StrSplit(data, " ");
if (tokens.size() != m_valuesCount)
{ return false; }
{
return false;
}
Tokens::iterator iter;
int index;
@ -785,7 +809,9 @@ void Object::_SetUpdateBits(UpdateMask* updateMask, Player* target) const
for (uint16 index = 0; index < valuesCount; ++index )
if (m_changedValues[index])
{ updateMask->SetBit(index); }
{
updateMask->SetBit(index);
}
}
void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const
@ -796,7 +822,9 @@ void Object::_SetCreateBits(UpdateMask* updateMask, Player* target) const
for (uint16 index = 0; index < valuesCount; ++index)
if (GetUInt32Value(index) != 0)
{ updateMask->SetBit(index); }
{
updateMask->SetBit(index);
}
}
void Object::SetInt32Value(uint16 index, int32 value)
@ -897,7 +925,9 @@ void Object::SetUInt16Value(uint16 index, uint8 offset, uint16 value)
void Object::SetStatFloatValue(uint16 index, float value)
{
if (value < 0)
{ value = 0.0f; }
{
value = 0.0f;
}
SetFloatValue(index, value);
}
@ -905,7 +935,9 @@ void Object::SetStatFloatValue(uint16 index, float value)
void Object::SetStatInt32Value(uint16 index, int32 value)
{
if (value < 0)
{ value = 0; }
{
value = 0;
}
SetUInt32Value(index, uint32(value));
}
@ -915,7 +947,9 @@ void Object::ApplyModUInt32Value(uint16 index, int32 val, bool apply)
int32 cur = GetUInt32Value(index);
cur += (apply ? val : -val);
if (cur < 0)
{ cur = 0; }
{
cur = 0;
}
SetUInt32Value(index, cur);
}
@ -938,7 +972,9 @@ void Object::ApplyModPositiveFloatValue(uint16 index, float val, bool apply)
float cur = GetFloatValue(index);
cur += (apply ? val : -val);
if (cur < 0)
{ cur = 0; }
{
cur = 0;
}
SetFloatValue(index, cur);
}
@ -1145,7 +1181,9 @@ void WorldObject::Relocate(float x, float y, float z, float orientation)
m_position.o = NormalizeOrientation(orientation);
if (isType(TYPEMASK_UNIT))
{ ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation); }
{
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, orientation);
}
}
void WorldObject::Relocate(float x, float y, float z)
@ -1155,7 +1193,9 @@ void WorldObject::Relocate(float x, float y, float z)
m_position.z = z;
if (isType(TYPEMASK_UNIT))
{ ((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation()); }
{
((Unit*)this)->m_movementInfo.ChangePosition(x, y, z, GetOrientation());
}
}
void WorldObject::SetOrientation(float orientation)
@ -1163,7 +1203,9 @@ void WorldObject::SetOrientation(float orientation)
m_position.o = NormalizeOrientation(orientation);
if (isType(TYPEMASK_UNIT))
{ ((Unit*)this)->m_movementInfo.ChangeOrientation(orientation); }
{
((Unit*)this)->m_movementInfo.ChangeOrientation(orientation);
}
}
uint32 WorldObject::GetZoneId() const
@ -1330,7 +1372,9 @@ bool WorldObject::IsInRange(WorldObject const* obj, float minRange, float maxRan
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
{ return false; }
{
return false;
}
}
float maxdist = maxRange + sizefactor;
@ -1350,7 +1394,9 @@ bool WorldObject::IsInRange2d(float x, float y, float minRange, float maxRange)
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
{ return false; }
{
return false;
}
}
float maxdist = maxRange + sizefactor;
@ -1371,7 +1417,9 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
{
float mindist = minRange + sizefactor;
if (distsq < mindist * mindist)
{ return false; }
{
return false;
}
}
float maxdist = maxRange + sizefactor;
@ -1381,7 +1429,9 @@ bool WorldObject::IsInRange3d(float x, float y, float z, float minRange, float m
float WorldObject::GetAngle(const WorldObject* obj) const
{
if (!obj)
{ return 0.0f; }
{
return 0.0f;
}
// Rework the assert, when more cases where such a call can happen have been fixed
// MANGOS_ASSERT(obj != this || PrintEntryError("GetAngle (for self)"));
@ -1408,7 +1458,9 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
{
// always have self in arc
if (obj == this)
{ return true; }
{
return true;
}
float arc = arcangle;
@ -1421,7 +1473,9 @@ bool WorldObject::HasInArc(const float arcangle, const WorldObject* obj) const
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
if (angle > M_PI_F)
{ angle -= 2.0f * M_PI_F; }
{
angle -= 2.0f * M_PI_F;
}
float lborder = -1 * (arc / 2.0f); // in range -pi..0
float rborder = (arc / 2.0f); // in range 0..pi
@ -1490,7 +1544,9 @@ void WorldObject::UpdateGroundPositionZ(float x, float y, float& z) const
void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap /*=NULL*/) const
{
if (!atMap)
{ atMap = GetMap(); }
{
atMap = GetMap();
}
switch (GetTypeId())
{
@ -1508,7 +1564,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
{ z = max_z; }
{
z = max_z;
}
else if (z < ground_z)
{ z = ground_z; }
}
@ -1517,7 +1575,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
{
float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z);
if (z < ground_z)
{ z = ground_z; }
{
z = ground_z;
}
}
break;
}
@ -1531,7 +1591,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
if (max_z > INVALID_HEIGHT)
{
if (z > max_z)
{ z = max_z; }
{
z = max_z;
}
else if (z < ground_z)
{ z = ground_z; }
}
@ -1548,7 +1610,9 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float& z, Map* atMap
{
float ground_z = atMap->GetHeight(GetPhaseMask(), x, y, z);
if (ground_z > INVALID_HEIGHT)
{ z = ground_z; }
{
z = ground_z;
}
break;
}
}
@ -1586,7 +1650,9 @@ void WorldObject::MonsterTextEmote(const char* text, Unit const* target, bool Is
void WorldObject::MonsterWhisper(const char* text, Unit const* target, bool IsBossWhisper) const
{
if (!target || target->GetTypeId() != TYPEID_PLAYER)
{ return; }
{
return;
}
WorldPacket data(SMSG_MESSAGECHAT, 200);
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, text, LANG_UNIVERSAL, CHAT_TAG_NONE, GetObjectGuid(), GetName(),
@ -1605,7 +1671,9 @@ namespace MaNGOS
{
char const* text = NULL;
if ((int32)i_textData->Content.size() > loc_idx + 1 && !i_textData->Content[loc_idx + 1].empty())
{ text = i_textData->Content[loc_idx + 1].c_str(); }
{
text = i_textData->Content[loc_idx + 1].c_str();
}
else
{ text = i_textData->Content[0].c_str(); }
@ -1653,7 +1721,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
case CHAT_TYPE_WHISPER:
{
if (!target || target->GetTypeId() != TYPEID_PLAYER)
{ return; }
{
return;
}
MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_MONSTER_WHISPER, textData, LANG_UNIVERSAL, target);
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
say_do((Player*)target);
@ -1662,7 +1732,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
case CHAT_TYPE_BOSS_WHISPER:
{
if (!target || target->GetTypeId() != TYPEID_PLAYER)
{ return; }
{
return;
}
MaNGOS::MonsterChatBuilder say_build(*this, CHAT_MSG_RAID_BOSS_WHISPER, textData, LANG_UNIVERSAL, target);
MaNGOS::LocalizedPacketDo<MaNGOS::MonsterChatBuilder> say_do(say_build);
say_do((Player*)target);
@ -1676,7 +1748,9 @@ void WorldObject::MonsterText(MangosStringLocale const* textData, Unit const* ta
Map::PlayerList const& pList = GetMap()->GetPlayers();
for (Map::PlayerList::const_iterator itr = pList.begin(); itr != pList.end(); ++itr)
if (itr->getSource()->GetZoneId() == zoneid)
{ say_do(itr->getSource()); }
{
say_do(itr->getSource());
}
break;
}
}
@ -1686,14 +1760,18 @@ void WorldObject::SendMessageToSet(WorldPacket* data, bool /*bToSelf*/) const
{
// if object is in world, map for it already created!
if (IsInWorld())
{ GetMap()->MessageBroadcast(this, data); }
{
GetMap()->MessageBroadcast(this, data);
}
}
void WorldObject::SendMessageToSetInRange(WorldPacket* data, float dist, bool /*bToSelf*/) const
{
// if object is in world, map for it already created!
if (IsInWorld())
{ GetMap()->MessageDistBroadcast(this, data, dist); }
{
GetMap()->MessageDistBroadcast(this, data, dist);
}
}
void WorldObject::SendMessageToSetExcept(WorldPacket* data, Player const* skipped_receiver) const
@ -1768,12 +1846,16 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
Team team = TEAM_NONE;
if (GetTypeId() == TYPEID_PLAYER)
{ team = ((Player*)this)->GetTeam(); }
{
team = ((Player*)this)->GetTeam();
}
CreatureCreatePos pos(GetMap(), x, y, z, ang, GetPhaseMask());
if (x == 0.0f && y == 0.0f && z == 0.0f)
{ pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang); }
{
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang);
}
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(cinfo->GetHighGuid()), pos, cinfo, team))
{
@ -1792,7 +1874,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
pCreature->Summon(spwtype, despwtime); // Also initializes the AI and MMGen
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
{ ((Creature*)this)->AI()->JustSummoned(pCreature); }
{
((Creature*)this)->AI()->JustSummoned(pCreature);
}
#ifdef ENABLE_ELUNA
if (Unit* summoner = ToUnit())
@ -1801,7 +1885,9 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
// Creature Linking, Initial load is handled like respawn
if (pCreature->IsLinkingEventTrigger())
{ GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature); }
{
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_RESPAWN, pCreature);
}
// return the creature therewith the summoner has access to it
return pCreature;
@ -1847,7 +1933,9 @@ namespace MaNGOS
{
// skip self or target
if (c == i_searcher || c == &i_object)
{ return; }
{
return;
}
float x, y, z;
@ -1865,7 +1953,9 @@ namespace MaNGOS
{
// skip self or target
if (u == i_searcher || u == &i_object)
{ return; }
{
return;
}
float x, y;
@ -1885,19 +1975,25 @@ namespace MaNGOS
// It is ok for the objects to require a bit more space
float delta = u->GetObjectBoundingRadius();
if (i_selector.m_searchPosFor && i_selector.m_searchPosFor != u)
{ delta += i_selector.m_searchPosFor->GetObjectBoundingRadius(); }
{
delta += i_selector.m_searchPosFor->GetObjectBoundingRadius();
}
delta *= OCCUPY_POS_DEPTH_FACTOR; // Increase by factor
// u is too near/far away from i_object. Do not consider it to occupy space
if (fabs(i_selector.m_searcherDist - dist2d) > delta)
{ return; }
{
return;
}
float angle = i_object.GetAngle(u) - i_absAngle;
// move angle to range -pi ... +pi, range before is -2Pi..2Pi
if (angle > M_PI_F)
{ angle -= 2.0f * M_PI_F; }
{
angle -= 2.0f * M_PI_F;
}
else if (angle < -M_PI_F)
{ angle += 2.0f * M_PI_F; }
@ -1964,7 +2060,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
{ return; }
{
return;
}
first_los_conflict = true; // first point have LOS problems
}
@ -1986,7 +2084,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
{ return; }
{
return;
}
}
// BAD NEWS: not free pos (or used or have LOS problems)
@ -2018,7 +2118,9 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float& x, float& y,
{ UpdateGroundPositionZ(x, y, z); }
if (fabs(init_z - z) < dist && IsWithinLOS(x, y, z))
{ return; }
{
return;
}
}
// BAD BAD NEWS: all found pos (free and used) have LOS problem :(
@ -2046,7 +2148,9 @@ void WorldObject::PlayDistanceSound(uint32 sound_id, Player const* target /*= NU
data << GetObjectGuid();
data << GetObjectGuid();
if (target)
{ target->SendDirectMessage(&data); }
{
target->SendDirectMessage(&data);
}
else
{ SendMessageToSet(&data, true); }
}
@ -2057,7 +2161,9 @@ void WorldObject::PlayDirectSound(uint32 sound_id, Player const* target /*= NULL
data << uint32(sound_id);
data << ObjectGuid();
if (target)
{ target->SendDirectMessage(&data); }
{
target->SendDirectMessage(&data);
}
else
{ SendMessageToSet(&data, true); }
}
@ -2067,7 +2173,9 @@ void WorldObject::PlayMusic(uint32 sound_id, Player const* target /*= NULL*/) co
WorldPacket data(SMSG_PLAY_MUSIC, 4);
data << uint32(sound_id);
if (target)
{ target->SendDirectMessage(&data); }
{
target->SendDirectMessage(&data);
}
else
{ SendMessageToSet(&data, true); }
}
@ -2106,7 +2214,9 @@ struct WorldObjectChangeAccumulator
// send self fields changes in another way, otherwise
// with new camera system when player's camera too far from player, camera wouldn't receive packets and changes from player
if (i_object.isType(TYPEMASK_PLAYER))
{ i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas); }
{
i_object.BuildUpdateDataForPlayer((Player*)&i_object, i_updateDatas);
}
}
void Visit(CameraMapType& m)
@ -2115,7 +2225,9 @@ struct WorldObjectChangeAccumulator
{
Player* owner = iter->getSource()->GetOwner();
if (owner != &i_object && owner->HaveAtClient(&i_object))
{ i_object.BuildUpdateDataForPlayer(owner, i_updateDatas); }
{
i_object.BuildUpdateDataForPlayer(owner, i_updateDatas);
}
}
}
@ -2157,14 +2269,18 @@ bool WorldObject::PrintCoordinatesError(float x, float y, float z, char const* d
void WorldObject::SetActiveObjectState(bool active)
{
if (m_isActiveObject == active || (isType(TYPEMASK_PLAYER) && !active)) // player shouldn't became inactive, never
{ return; }
{
return;
}
if (IsInWorld() && !isType(TYPEMASK_PLAYER))
// player's update implemented in a different from other active worldobject's way
// it's considired to use generic way in future
{
if (IsActiveObject() && !active)
{ GetMap()->RemoveFromActive(this); }
{
GetMap()->RemoveFromActive(this);
}
else if (!IsActiveObject() && active)
{ GetMap()->AddToActive(this); }
}

View file

@ -128,7 +128,9 @@ class WorldUpdateCounter
time_t timeElapsed()
{
if (!m_tmStart)
{ m_tmStart = WorldTimer::tickPrevTime(); }
{
m_tmStart = WorldTimer::tickPrevTime();
}
return WorldTimer::getMSTimeDiff(m_tmStart, WorldTimer::tickTime());
}
@ -148,7 +150,9 @@ class Object
virtual void AddToWorld()
{
if (m_inWorld)
{ return; }
{
return;
}
m_inWorld = true;
@ -284,7 +288,9 @@ class Object
void ToggleFlag(uint16 index, uint32 flag)
{
if (HasFlag(index, flag))
{ RemoveFlag(index, flag); }
{
RemoveFlag(index, flag);
}
else
{ SetFlag(index, flag); }
}
@ -306,7 +312,9 @@ class Object
void ApplyModFlag(uint16 index, uint32 flag, bool apply)
{
if (apply)
{ SetFlag(index, flag); }
{
SetFlag(index, flag);
}
else
{ RemoveFlag(index, flag); }
}
@ -317,7 +325,9 @@ class Object
void ToggleByteFlag(uint16 index, uint8 offset, uint8 flag)
{
if (HasByteFlag(index, offset, flag))
{ RemoveByteFlag(index, offset, flag); }
{
RemoveByteFlag(index, offset, flag);
}
else
{ SetByteFlag(index, offset, flag); }
}
@ -332,7 +342,9 @@ class Object
void ApplyModByteFlag(uint16 index, uint8 offset, uint32 flag, bool apply)
{
if (apply)
{ SetByteFlag(index, offset, flag); }
{
SetByteFlag(index, offset, flag);
}
else
{ RemoveByteFlag(index, offset, flag); }
}
@ -343,7 +355,9 @@ class Object
void ToggleShortFlag(uint16 index, bool highpart, uint8 flag)
{
if (HasShortFlag(index, highpart, flag))
{ RemoveShortFlag(index, highpart, flag); }
{
RemoveShortFlag(index, highpart, flag);
}
else
{ SetShortFlag(index, highpart, flag); }
}
@ -357,7 +371,9 @@ class Object
void ApplyModShortFlag(uint16 index, bool highpart, uint32 flag, bool apply)
{
if (apply)
{ SetShortFlag(index, highpart, flag); }
{
SetShortFlag(index, highpart, flag);
}
else
{ RemoveShortFlag(index, highpart, flag); }
}
@ -379,7 +395,9 @@ class Object
void ToggleFlag64(uint16 index, uint64 flag)
{
if (HasFlag64(index, flag))
{ RemoveFlag64(index, flag); }
{
RemoveFlag64(index, flag);
}
else
{ SetFlag64(index, flag); }
}
@ -393,7 +411,9 @@ class Object
void ApplyModFlag64(uint16 index, uint64 flag, bool apply)
{
if (apply)
{ SetFlag64(index, flag); }
{
SetFlag64(index, flag);
}
else
{ RemoveFlag64(index, flag); }
}

View file

@ -59,13 +59,19 @@ Unit*
ObjectAccessor::GetUnit(WorldObject const& u, ObjectGuid guid)
{
if (!guid)
{ return NULL; }
{
return NULL;
}
if (guid.IsPlayer())
{ return FindPlayer(guid); }
{
return FindPlayer(guid);
}
if (!u.IsInWorld())
{ return NULL; }
{
return NULL;
}
return u.GetMap()->GetAnyTypeCreature(guid);
}
@ -74,9 +80,13 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
{
Corpse* ret = HashMapHolder<Corpse>::Find(guid);
if (!ret)
{ return NULL; }
{
return NULL;
}
if (ret->GetMapId() != mapid)
{ return NULL; }
{
return NULL;
}
return ret;
}
@ -84,11 +94,15 @@ Corpse* ObjectAccessor::GetCorpseInMap(ObjectGuid guid, uint32 mapid)
Player* ObjectAccessor::FindPlayer(ObjectGuid guid, bool inWorld /*= true*/)
{
if (!guid)
{ return NULL; }
{
return NULL;
}
Player* plr = HashMapHolder<Player>::Find(guid);
if (!plr || (!plr->IsInWorld() && inWorld))
{ return NULL; }
{
return NULL;
}
return plr;
}
@ -99,7 +113,9 @@ Player* ObjectAccessor::FindPlayerByName(const char* name)
HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter)
if (iter->second->IsInWorld() && (::strcmp(name, iter->second->GetName()) == 0))
{ return iter->second; }
{
return iter->second;
}
return NULL;
}
@ -130,7 +146,9 @@ ObjectAccessor::GetCorpseForPlayerGUID(ObjectGuid guid)
Player2CorpsesMapType::iterator iter = i_player2corpse.find(guid);
if (iter == i_player2corpse.end())
{ return NULL; }
{
return NULL;
}
MANGOS_ASSERT(iter->second->GetType() != CORPSE_BONES);
return iter->second;
@ -145,7 +163,9 @@ ObjectAccessor::RemoveCorpse(Corpse* corpse)
Player2CorpsesMapType::iterator iter = i_player2corpse.find(corpse->GetOwnerGuid());
if (iter == i_player2corpse.end())
{ return; }
{
return;
}
// build mapid*cellid -> guid_set map
CellPair cell_pair = MaNGOS::ComputeCellPair(corpse->GetPositionX(), corpse->GetPositionY());
@ -218,7 +238,9 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
// do not load the map if it's not loaded
Map* map = sMapMgr.FindMap(corpse->GetMapId(), corpse->GetInstanceId());
if (map)
{ map->Remove(corpse, false); }
{
map->Remove(corpse, false);
}
// remove corpse from DB
corpse->DeleteFromDB();
@ -250,7 +272,9 @@ ObjectAccessor::ConvertCorpseForPlayer(ObjectGuid player_guid, bool insignia)
for (int i = 0; i < EQUIPMENT_SLOT_END; ++i)
{
if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
{ bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0); }
{
bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
}
}
// add bones in grid store if grid loaded where corpse placed
@ -273,7 +297,9 @@ void ObjectAccessor::RemoveOldCorpses()
++next;
if (!itr->second->IsExpired(now))
{ continue; }
{
continue;
}
ConvertCorpseForPlayer(itr->first);
}

View file

@ -60,12 +60,16 @@ std::string ObjectGuid::GetString() const
{
std::string name;
if (sObjectMgr.GetPlayerNameByGUID(*this, name))
{ str << " " << name; }
{
str << " " << name;
}
}
str << " (";
if (HasEntry())
{ str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " "; }
{
str << (IsPet() ? "Petnumber: " : "Entry: ") << GetEntry() << " ";
}
str << "Guid: " << GetCounter() << ")";
return str.str();
}

File diff suppressed because it is too large Load diff

View file

@ -649,7 +649,9 @@ class ObjectMgr
{
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
if (itr != mQuestAreaTriggerMap.end())
{ return itr->second; }
{
return itr->second;
}
return 0;
}
bool IsTavernAreaTrigger(uint32 Trigger_ID) const
@ -674,7 +676,9 @@ class ObjectMgr
{
AreaTriggerMap::const_iterator itr = mAreaTriggers.find(trigger);
if (itr != mAreaTriggers.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -685,7 +689,9 @@ class ObjectMgr
{
RepRewardRateMap::const_iterator itr = m_RepRewardRateMap.find(factionId);
if (itr != m_RepRewardRateMap.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -694,7 +700,9 @@ class ObjectMgr
{
RepOnKillMap::const_iterator itr = mRepOnKill.find(id);
if (itr != mRepOnKill.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -702,7 +710,9 @@ class ObjectMgr
{
RepSpilloverTemplateMap::const_iterator itr = m_RepSpilloverTemplateMap.find(factionId);
if (itr != m_RepSpilloverTemplateMap.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -711,7 +721,9 @@ class ObjectMgr
{
PointOfInterestMap::const_iterator itr = mPointsOfInterest.find(id);
if (itr != mPointsOfInterest.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -735,7 +747,9 @@ class ObjectMgr
{
DungeonFinderRewardsMap::const_iterator itr = mDungeonFinderRewardsMap.find(level);
if (itr != mDungeonFinderRewardsMap.end())
{ return &itr->second; }
{
return &itr->second;
}
return NULL;
}
@ -884,13 +898,17 @@ class ObjectMgr
uint32 GenerateStaticCreatureLowGuid()
{
if (m_StaticCreatureGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryCreatureGuid)
{ return 0; }
{
return 0;
}
return m_StaticCreatureGuids.Generate();
}
uint32 GenerateStaticGameObjectLowGuid()
{
if (m_StaticGameObjectGuids.GetNextAfterMaxUsed() >= m_FirstTemporaryGameObjectGuid)
{ return 0; }
{
return 0;
}
return m_StaticGameObjectGuids.Generate();
}
@ -966,7 +984,9 @@ class ObjectMgr
{
for (CreatureDataMap::const_iterator itr = mCreatureDataMap.begin(); itr != mCreatureDataMap.end(); ++itr)
if (worker(*itr))
{ break; }
{
break;
}
}
CreatureLocale const* GetCreatureLocale(uint32 entry) const
@ -1059,7 +1079,9 @@ class ObjectMgr
{
for (GameObjectDataMap::const_iterator itr = mGameObjectDataMap.begin(); itr != mGameObjectDataMap.end(); ++itr)
if (worker(*itr)) // arg = GameObjectDataPair
{ break; }
{
break;
}
}
MangosStringLocale const* GetMangosStringLocale(int32 entry) const
@ -1072,7 +1094,9 @@ class ObjectMgr
{
std::map<int32, uint32>::const_iterator itr = m_loadedStringCount.find(minEntry);
if (itr != m_loadedStringCount.end())
{ return itr->second; }
{
return itr->second;
}
return 0;
}
@ -1134,7 +1158,9 @@ class ObjectMgr
{
CacheNpcTextIdMap::const_iterator iter = m_mCacheNpcTextIdMap.find(entry);
if (iter == m_mCacheNpcTextIdMap.end())
{ return 0; }
{
return 0;
}
return iter->second;
}
@ -1143,7 +1169,9 @@ class ObjectMgr
{
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerSpellMap.find(entry);
if (iter == m_mCacheTrainerSpellMap.end())
{ return NULL; }
{
return NULL;
}
return &iter->second;
}
@ -1152,7 +1180,9 @@ class ObjectMgr
{
CacheTrainerSpellMap::const_iterator iter = m_mCacheTrainerTemplateSpellMap.find(entry);
if (iter == m_mCacheTrainerTemplateSpellMap.end())
{ return NULL; }
{
return NULL;
}
return &iter->second;
}
@ -1161,7 +1191,9 @@ class ObjectMgr
{
CacheVendorItemMap::const_iterator iter = m_mCacheVendorItemMap.find(entry);
if (iter == m_mCacheVendorItemMap.end())
{ return NULL; }
{
return NULL;
}
return &iter->second;
}
@ -1170,7 +1202,9 @@ class ObjectMgr
{
CacheVendorItemMap::const_iterator iter = m_mCacheVendorTemplateItemMap.find(entry);
if (iter == m_mCacheVendorTemplateItemMap.end())
{ return NULL; }
{
return NULL;
}
return &iter->second;
}

View file

@ -33,11 +33,15 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float dist, float searche
{
// if size == 0, m_anglestep will become 0 -> freeze
if (searchedForSize == 0.0f)
{ searchedForSize = DEFAULT_WORLD_OBJECT_SIZE; }
{
searchedForSize = DEFAULT_WORLD_OBJECT_SIZE;
}
// undefined behaviour
if (m_searcherDist == 0.0f)
{ m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE; }
{
m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE;
}
m_searchedForReqHAngle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * searchedForSize / m_searcherDist);
@ -64,13 +68,17 @@ void ObjectPosSelector::AddUsedArea(WorldObject const* obj, float angle, float d
// skip some unexpected results.
if (dist == 0.0f)
{ return; }
{
return;
}
// (half) angle that obj occupies
float sr_angle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * obj->GetObjectBoundingRadius() / dist);
if (angle >= 0)
{ m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj))); }
{
m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj)));
}
else
{ m_UsedAreaLists[USED_POS_MINUS].insert(UsedArea(-angle, OccupiedArea(sr_angle, obj))); }
}
@ -149,13 +157,17 @@ bool ObjectPosSelector::NextAngle(float& angle)
if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS])
{
if (NextSideAngle(USED_POS_PLUS, angle))
{ return true; }
{
return true;
}
}
// -- direction less updated
else if (m_stepAngle[USED_POS_MINUS] < M_PI_F)
{
if (NextSideAngle(USED_POS_MINUS, angle))
{ return true; }
{
return true;
}
}
// both sides finishes
else
@ -182,7 +194,9 @@ bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float& angle)
// prevent jump to another side
if (m_stepAngle[side] > M_PI_F)
{ return false; }
{
return false;
}
// no used area anymore on this side
if (m_nextUsedAreaItr[side] == m_UsedAreaLists[side].end())

View file

@ -51,7 +51,9 @@ Pet::Pet(PetType type) :
CharmInfo* charmInfo = InitCharmInfo(this);
if (type == MINI_PET) // always passive
{ charmInfo->SetReactState(REACT_PASSIVE); }
{
charmInfo->SetReactState(REACT_PASSIVE);
}
}
Pet::~Pet()
@ -63,7 +65,9 @@ void Pet::AddToWorld()
{
///- Register the pet for guid lookup
if (!IsInWorld())
{ GetMap()->GetObjectsStore().insert<Pet>(GetObjectGuid(), (Pet*)this); }
{
GetMap()->GetObjectsStore().insert<Pet>(GetObjectGuid(), (Pet*)this);
}
Unit::AddToWorld();
}
@ -72,7 +76,9 @@ void Pet::RemoveFromWorld()
{
///- Remove the pet from the accessor
if (IsInWorld())
{ GetMap()->GetObjectsStore().erase<Pet>(GetObjectGuid(), (Pet*)NULL); }
{
GetMap()->GetObjectsStore().erase<Pet>(GetObjectGuid(), (Pet*)NULL);
}
///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld();
@ -200,7 +206,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType());
if (owner->IsPvP())
{ SetPvP(true); }
{
SetPvP(true);
}
if (owner->IsFFAPvP())
SetFFAPvP(true);
@ -292,7 +300,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
{
((Player*)owner)->PetSpellInitialize();
if (((Player*)owner)->GetGroup())
{ ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); }
{
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET);
}
((Player*)owner)->SendTalentsInfoData(true);
}
@ -323,19 +333,27 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
void Pet::SavePetToDB(PetSaveMode mode)
{
if (!GetEntry())
{ return; }
{
return;
}
// save only fully controlled creature
if (!isControlled())
{ return; }
{
return;
}
// not save not player pets
if (!GetOwnerGuid().IsPlayer())
{ return; }
{
return;
}
Player* pOwner = (Player*)GetOwner();
if (!pOwner)
{ return; }
{
return;
}
// current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT)
@ -355,7 +373,9 @@ void Pet::SavePetToDB(PetSaveMode mode)
{
// pet will lost anyway at restore temporary unsummoned
if (getPetType() == HUNTER_PET)
{ return; }
{
return;
}
// for warlock case
mode = PET_SAVE_NOT_IN_SLOT;
@ -366,7 +386,9 @@ void Pet::SavePetToDB(PetSaveMode mode)
// stable and not in slot saves
if (mode != PET_SAVE_AS_CURRENT)
{ RemoveAllAuras(); }
{
RemoveAllAuras();
}
// save pet's data as one single transaction
CharacterDatabase.BeginTransaction();
@ -445,7 +467,9 @@ void Pet::SavePetToDB(PetSaveMode mode)
void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction)
{
if (separate_transaction)
{ CharacterDatabase.BeginTransaction(); }
{
CharacterDatabase.BeginTransaction();
}
static SqlStatementID delPet ;
static SqlStatementID delDeclName ;
@ -469,7 +493,9 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction)
stmt.PExecute(guidlow);
if (separate_transaction)
{ CharacterDatabase.CommitTransaction(); }
{
CharacterDatabase.CommitTransaction();
}
}
void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
@ -479,7 +505,9 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual
{
// remove summoned pet (no corpse)
if (getPetType() == SUMMON_PET)
{ Unsummon(PET_SAVE_NOT_IN_SLOT); }
{
Unsummon(PET_SAVE_NOT_IN_SLOT);
}
// other will despawn at corpse desppawning (Pet::Update code)
else
{
@ -500,7 +528,9 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual
void Pet::Update(uint32 update_diff, uint32 diff)
{
if (m_removed) // pet already removed, just wait in remove queue, no updates
{ return; }
{
return;
}
switch (m_deathState)
{
@ -538,7 +568,9 @@ void Pet::Update(uint32 update_diff, uint32 diff)
if (m_duration > 0)
{
if (m_duration > (int32)update_diff)
{ m_duration -= (int32)update_diff; }
{
m_duration -= (int32)update_diff;
}
else
{
Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner);
@ -560,7 +592,9 @@ void Pet::RegenerateAll(uint32 update_diff)
if (m_regenTimer <= update_diff)
{
if (!IsInCombat() || IsPolymorphed())
{ RegenerateHealth(); }
{
RegenerateHealth();
}
RegeneratePower();
@ -576,17 +610,23 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
uint32 chainstartstore[ACTIVE_SPELLS_MAX];
if (IsPassiveSpell(spellid))
{ return true; }
{
return true;
}
chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid);
for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
{
if (itr->second.state == PETSPELL_REMOVED)
{ continue; }
{
continue;
}
if (IsPassiveSpell(itr->first))
{ continue; }
{
continue;
}
uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first);
@ -595,14 +635,18 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
for (x = 0; x < activecount; ++x)
{
if (chainstart == chainstartstore[x])
{ break; }
{
break;
}
}
if (x == activecount) // spellchain not yet saved -> add active count
{
++activecount;
if (activecount > ACTIVE_SPELLS_MAX)
{ return false; }
{
return false;
}
chainstartstore[x] = chainstart;
}
}
@ -612,14 +656,18 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
{
if (!owner)
{ owner = GetOwner(); }
{
owner = GetOwner();
}
CombatStop();
if (owner)
{
if (GetOwnerGuid() != owner->GetObjectGuid())
{ return; }
{
return;
}
Player* p_owner = owner->GetTypeId() == TYPEID_PLAYER ? (Player*)owner : NULL;
@ -661,7 +709,9 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
p_owner->RemovePetActionBar();
if (p_owner->GetGroup())
{ p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); }
{
p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET);
}
}
}
@ -678,7 +728,9 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
break;
default:
if (owner->GetPetGuid() == GetObjectGuid())
{ owner->SetPet(NULL); }
{
owner->SetPet(NULL);
}
break;
}
}
@ -691,20 +743,28 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
void Pet::GivePetXP(uint32 xp)
{
if (getPetType() != HUNTER_PET)
{ return; }
{
return;
}
if (xp < 1)
{ return; }
{
return;
}
if (!IsAlive())
{ return; }
{
return;
}
uint32 level = getLevel();
uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel());
// pet not receive xp for level equal to owner level
if (level >= maxlevel)
{ return; }
{
return;
}
xp *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL);
@ -728,7 +788,9 @@ void Pet::GivePetXP(uint32 xp)
void Pet::GivePetLevel(uint32 level)
{
if (!level || level == getLevel())
{ return; }
{
return;
}
if (getPetType() == HUNTER_PET)
{
@ -756,7 +818,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
BASIC_LOG("Create pet");
uint32 pet_number = sObjectMgr.GeneratePetNumber();
if (!Create(guid, pos, creature->GetCreatureInfo(), pet_number))
{ return false; }
{
return false;
}
CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo)
@ -774,7 +838,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family))
{ SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); }
{
SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]);
}
else
{ SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); }
@ -918,7 +984,9 @@ void Pet::InitStatsForLevel(uint32 petlevel)
// 40% damage bonus of mage's frost damage
float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4f;
if (val < 0)
{ val = 0; }
{
val = 0;
}
SetBonusDamage(int32(val));
break;
}
@ -1097,15 +1165,21 @@ void Pet::InitStatsForLevel(uint32 petlevel)
bool Pet::HaveInDiet(ItemPrototype const* item) const
{
if (!item->FoodType)
{ return false; }
{
return false;
}
CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo)
{ return false; }
{
return false;
}
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family);
if (!cFamily)
{ return false; }
{
return false;
}
uint32 diet = cFamily->petFoodMask;
uint32 FoodMask = 1 << (item->FoodType - 1);
@ -1116,7 +1190,9 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel)
{
// -5 or greater food level
if (getLevel() <= itemlevel + 5) // possible to feed level 60 pet with level 55 level food for full effect
{ return 35000; }
{
return 35000;
}
// -10..-6
else if (getLevel() <= itemlevel + 10) // pure guess, but sounds good
{ return 17000; }
@ -1158,7 +1234,9 @@ void Pet::_LoadSpellCooldowns()
// skip outdated cooldown
if (db_time <= curTime)
{ continue; }
{
continue;
}
data << uint32(spell_id);
data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS);
@ -1192,7 +1270,9 @@ void Pet::_SaveSpellCooldowns()
for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
{
if (itr->second <= curTime)
{ m_CreatureSpellCooldowns.erase(itr++); }
{
m_CreatureSpellCooldowns.erase(itr++);
}
else
{
stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES (?, ?, ?)");
@ -1231,7 +1311,9 @@ void Pet::_SaveSpells()
// prevent saving family passives to DB
if (itr->second.type == PETSPELL_FAMILY)
{ continue; }
{
continue;
}
switch (itr->second.state)
{
@ -1303,12 +1385,16 @@ void Pet::_LoadAuras(uint32 timediff)
// do not load single target auras (unless they were cast by the player)
if (casterGuid != GetObjectGuid() && IsSingleTargetSpell(spellproto))
{ continue; }
{
continue;
}
if (remaintime != -1 && !IsPositiveSpell(spellproto))
{
if (remaintime / IN_MILLISECONDS <= int32(timediff))
{ continue; }
{
continue;
}
remaintime -= timediff * IN_MILLISECONDS;
}
@ -1325,7 +1411,9 @@ void Pet::_LoadAuras(uint32 timediff)
uint32 defstackamount = spellproto->GetStackAmount();
if (!defstackamount)
{ stackcount = 1; }
{
stackcount = 1;
}
else if (defstackamount < stackcount)
stackcount = defstackamount;
else if (!stackcount)
@ -1337,18 +1425,24 @@ void Pet::_LoadAuras(uint32 timediff)
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{
if ((effIndexMask & (1 << i)) == 0)
{ continue; }
{
continue;
}
Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this);
if (!damage[i])
{ damage[i] = aura->GetModifier()->m_amount; }
{
damage[i] = aura->GetModifier()->m_amount;
}
aura->SetLoadedState(damage[i], periodicTime[i]);
holder->AddAura(aura, SpellEffectIndex(i));
}
if (!holder->IsEmptyHolder())
{ AddSpellAuraHolder(holder); }
{
AddSpellAuraHolder(holder);
}
else
{ delete holder; }
}
@ -1369,7 +1463,9 @@ void Pet::_SaveAuras()
SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap();
if (auraHolders.empty())
{ return; }
{
return;
}
stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, "
"basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) "
@ -1413,7 +1509,9 @@ void Pet::_SaveAuras()
{
// don't save not own area auras
if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid())
{ continue; }
{
continue;
}
damage[i] = aur->GetModifier()->m_amount;
periodicTime[i] = aur->GetModifier()->periodictime;
@ -1422,7 +1520,9 @@ void Pet::_SaveAuras()
}
if (!effIndexMask)
{ continue; }
{
continue;
}
stmt.addUInt32(m_charmInfo->GetPetNumber());
stmt.addUInt64(holder->GetCasterGuid().GetRawValue());
@ -1476,7 +1576,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
itr->second.state = PETSPELL_UNCHANGED;
if (active == ACT_ENABLED)
{ ToggleAutocast(spell_id, true); }
{
ToggleAutocast(spell_id, true);
}
else if (active == ACT_DISABLED)
{ ToggleAutocast(spell_id, false); }
@ -1495,7 +1597,9 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
{
if (IsPassiveSpell(spellInfo))
{ newspell.active = ACT_PASSIVE; }
{
newspell.active = ACT_PASSIVE;
}
else
{ newspell.active = ACT_DISABLED; }
}
@ -1551,12 +1655,16 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
m_spells[spell_id] = newspell;
if (IsPassiveSpell(spellInfo))
{ CastSpell(this, spell_id, true); }
{
CastSpell(this, spell_id, true);
}
else
{ m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); }
if (newspell.active == ACT_ENABLED)
{ ToggleAutocast(spell_id, true); }
{
ToggleAutocast(spell_id, true);
}
uint32 talentCost = GetTalentSpellCost(spell_id);
if (talentCost)
@ -1571,7 +1679,9 @@ bool Pet::learnSpell(uint32 spell_id)
{
// prevent duplicated entires in spell book
if (!addSpell(spell_id))
{ return false; }
{
return false;
}
if (!m_loading)
{
@ -1652,13 +1762,19 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
{
PetSpellMap::iterator itr = m_spells.find(spell_id);
if (itr == m_spells.end())
{ return false; }
{
return false;
}
if (itr->second.state == PETSPELL_REMOVED)
{ return false; }
{
return false;
}
if (itr->second.state == PETSPELL_NEW)
{ m_spells.erase(itr); }
{
m_spells.erase(itr);
}
else
{ itr->second.state = PETSPELL_REMOVED; }
@ -1678,7 +1794,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
if (learn_prev)
{
if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id))
{ learnSpell(prev_id); }
{
learnSpell(prev_id);
}
else
{ learn_prev = false; }
}
@ -1691,7 +1809,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
// need update action bar for last removed rank
if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER)
{ ((Player*)owner)->PetSpellInitialize(); }
{
((Player*)owner)->PetSpellInitialize();
}
}
}
@ -1704,7 +1824,9 @@ void Pet::CleanupActionBar()
if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i))
if (uint32 action = ab->GetAction())
if (ab->IsActionBarForSpell() && !HasSpell(action))
{ m_charmInfo->SetActionBar(i, 0, ACT_DISABLED); }
{
m_charmInfo->SetActionBar(i, 0, ACT_DISABLED);
}
}
void Pet::InitPetCreateSpells()
@ -1914,7 +2036,9 @@ uint32 Pet::resetTalentsCost() const
// The first time reset costs 10 silver; after 1 day cost is reset to 10 silver
if (m_resetTalentsCost < 10 * SILVER || days > 0)
{ return 10 * SILVER; }
{
return 10 * SILVER;
}
// then 50 silver
else if (m_resetTalentsCost < 50 * SILVER)
{ return 50 * SILVER; }
@ -1938,7 +2062,9 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level)
void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
if (IsPassiveSpell(spellid))
{ return; }
{
return;
}
PetSpellMap::iterator itr = m_spells.find(spellid);
PetSpell &petSpell = itr->second;
@ -1958,7 +2084,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
petSpell.active = ACT_ENABLED;
if (petSpell.state != PETSPELL_NEW)
{ petSpell.state = PETSPELL_CHANGED; }
{
petSpell.state = PETSPELL_CHANGED;
}
}
}
}
@ -1975,7 +2103,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{
petSpell.active = ACT_DISABLED;
if (petSpell.state != PETSPELL_NEW)
{ petSpell.state = PETSPELL_CHANGED; }
{
petSpell.state = PETSPELL_CHANGED;
}
}
}
}
@ -1991,17 +2121,23 @@ bool Pet::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* ci
m_originalEntry = cinfo->Entry;
if (!InitEntry(cinfo->Entry))
{ return false; }
{
return false;
}
cPos.SelectFinalPoint(this);
if (!cPos.Relocate(this))
{ return false; }
{
return false;
}
SetSheath(SHEATH_STATE_MELEE);
if (getPetType() == MINI_PET) // always non-attackable
{ SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); }
{
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
return true;
}
@ -2017,11 +2153,15 @@ void Pet::LearnPetPassives()
{
CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo)
{ return; }
{
return;
}
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family);
if (!cFamily)
{ return; }
{
return;
}
PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID);
if (petStore != sPetFamilySpellsStore.end())
@ -2044,7 +2184,9 @@ void Pet::CastPetAuras(bool current)
++itr;
if (!current && pa->IsRemovedOnChangePet())
{ owner->RemovePetAura(pa); }
{
owner->RemovePetAura(pa);
}
else
{ CastPetAura(pa); }
}
@ -2092,7 +2234,9 @@ void Pet::CastPetAura(PetAura const* aura)
{
uint32 auraId = aura->GetAura(GetEntry());
if (!auraId)
{ return; }
{
return;
}
if (auraId == 35696) // Demonic Knowledge
{
@ -2122,7 +2266,9 @@ void Pet::SynchronizeLevelWithOwner()
{
Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
{ return; }
{
return;
}
switch (getPetType())
{
@ -2133,7 +2279,9 @@ void Pet::SynchronizeLevelWithOwner()
// can't be greater owner level
case HUNTER_PET:
if (getLevel() > owner->getLevel())
{ GivePetLevel(owner->getLevel()); }
{
GivePetLevel(owner->getLevel());
}
else if (getLevel() + 5 < owner->getLevel())
GivePetLevel(owner->getLevel() - 5);
break;
@ -2148,7 +2296,9 @@ void Pet::SetModeFlags(PetModeFlags mode)
Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
{ return; }
{
return;
}
WorldPacket data(SMSG_PET_MODE, 12);
data << GetObjectGuid();

View file

@ -37,7 +37,9 @@
int PetAI::Permissible(const Creature* creature)
{
if (creature->IsPet())
{ return PERMIT_BASE_SPECIAL; }
{
return PERMIT_BASE_SPECIAL;
}
return PERMIT_BASE_NO;
}
@ -75,7 +77,9 @@ void PetAI::MoveInLineOfSight(Unit* pWho)
void PetAI::AttackStart(Unit* u)
{
if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET))
{ return; }
{
return;
}
if (m_creature->Attack(u, true))
{
@ -103,7 +107,9 @@ bool PetAI::_needToStop() const
{
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat
if (m_creature->IsCharmed() && m_creature->getVictim() == m_creature->GetCharmer())
{ return true; }
{
return true;
}
return !m_creature->getVictim()->IsTargetableForAttack();
}
@ -129,7 +135,9 @@ void PetAI::_stopAttack()
void PetAI::UpdateAI(const uint32 diff)
{
if (!m_creature->IsAlive())
{ return; }
{
return;
}
Unit* owner = m_creature->GetCharmerOrOwner();
Unit* victim = NULL;
@ -218,21 +226,29 @@ void PetAI::UpdateAI(const uint32 diff)
{
uint32 spellID = m_creature->GetPetAutoSpellOnPos(i);
if (!spellID)
{ continue; }
{
continue;
}
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
if (!spellInfo)
{ continue; }
{
continue;
}
if (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
{ continue; }
{
continue;
}
// ignore some combinations of combat state and combat/noncombat spells
if (!inCombat)
{
// ignore attacking spells, and allow only self/around spells
if (!IsPositiveSpell(spellInfo->Id))
{ continue; }
{
continue;
}
// non combat spells allowed
// only pet spells have IsNonCombatSpell and not fit this reqs:
@ -242,14 +258,18 @@ void PetAI::UpdateAI(const uint32 diff)
int32 duration = GetSpellDuration(spellInfo);
SpellPowerEntry const* spellPower = spellInfo->GetSpellPower();
if (spellPower && (spellPower->manaCost || spellPower->ManaCostPercentage || spellPower->manaPerSecond) && duration > 0)
{ continue; }
{
continue;
}
// allow only spell without cooldown > duration
int32 cooldown = GetSpellRecoveryTime(spellInfo);
// allow only spell not on cooldown
if (cooldown != 0 && duration < cooldown)
{ continue; }
{
continue;
}
}
}
// just ignore non-combat spells
@ -272,7 +292,9 @@ void PetAI::UpdateAI(const uint32 diff)
// only buff targets that are in combat, unless the spell can only be cast while out of combat
if (!Target)
{ continue; }
{
continue;
}
if (spell->CanAutoCast(Target))
{
@ -282,7 +304,9 @@ void PetAI::UpdateAI(const uint32 diff)
}
}
if (!spellUsed)
{ delete spell; }
{
delete spell;
}
}
}
@ -303,10 +327,14 @@ void PetAI::UpdateAI(const uint32 diff)
{
m_creature->SetInFront(target);
if (target->GetTypeId() == TYPEID_PLAYER)
{ m_creature->SendCreateUpdateToPlayer((Player*)target); }
{
m_creature->SendCreateUpdateToPlayer((Player*)target);
}
if (owner && owner->GetTypeId() == TYPEID_PLAYER)
{ m_creature->SendCreateUpdateToPlayer((Player*)owner); }
{
m_creature->SendCreateUpdateToPlayer((Player*)owner);
}
}
m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id);
@ -433,16 +461,22 @@ void PetAI::UpdateAllies()
m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance
if (!owner)
{ return; }
{
return;
}
else if (owner->GetTypeId() == TYPEID_PLAYER)
{ pGroup = ((Player*)owner)->GetGroup(); }
// only pet and owner/not in group->ok
if (m_AllySet.size() == 2 && !pGroup)
{ return; }
{
return;
}
// owner is in group; group members filled in already (no raid -> subgroupcount = whole count)
if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2))
{ return; }
{
return;
}
m_AllySet.clear();
m_AllySet.insert(m_creature->GetObjectGuid());
@ -452,10 +486,14 @@ void PetAI::UpdateAllies()
{
Player* target = itr->getSource();
if (!target || !pGroup->SameSubGroup((Player*)owner, target))
{ continue; }
{
continue;
}
if (target->GetObjectGuid() == owner->GetObjectGuid())
{ continue; }
{
continue;
}
m_AllySet.insert(target->GetObjectGuid());
}

View file

@ -224,11 +224,15 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
}
if (m_TaxiDestinations.empty())
{ return true; }
{
return true;
}
// Check integrity
if (m_TaxiDestinations.size() < 2)
{ return false; }
{
return false;
}
for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
{
@ -236,12 +240,16 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
uint32 path;
sObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
if (!path)
{ return false; }
{
return false;
}
}
// can't load taxi path without mount set (quest taxi path?)
if (!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(), team, true))
{ return false; }
{
return false;
}
return true;
}
@ -249,7 +257,9 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
std::string PlayerTaxi::SaveTaxiDestinationsToString()
{
if (m_TaxiDestinations.empty())
{ return ""; }
{
return "";
}
std::ostringstream ss;
@ -262,7 +272,9 @@ std::string PlayerTaxi::SaveTaxiDestinationsToString()
uint32 PlayerTaxi::GetCurrentTaxiPath() const
{
if (m_TaxiDestinations.size() < 2)
{ return 0; }
{
return 0;
}
uint32 path;
uint32 cost;
@ -294,7 +306,9 @@ bool TradeData::HasItem(ObjectGuid item_guid) const
{
for (int i = 0; i < TRADE_SLOT_COUNT; ++i)
if (m_items[i] == item_guid)
{ return true; }
{
return true;
}
return false;
}
@ -309,7 +323,9 @@ void TradeData::SetItem(TradeSlots slot, Item* item)
ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid();
if (m_items[slot] == itemGuid)
{ return; }
{
return;
}
m_items[slot] = itemGuid;
@ -320,7 +336,9 @@ void TradeData::SetItem(TradeSlots slot, Item* item)
// need remove possible trader spell applied to changed item
if (slot == TRADE_SLOT_NONTRADED)
{ GetTraderData()->SetSpell(0); }
{
GetTraderData()->SetSpell(0);
}
// need remove possible player spell applied (possible move reagent)
SetSpell(0);
@ -331,7 +349,9 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/)
ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid();
if (m_spell == spell_id && m_spellCastItem == itemGuid)
{ return; }
{
return;
}
m_spell = spell_id;
m_spellCastItem = itemGuid;
@ -346,7 +366,9 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/)
void TradeData::SetMoney(uint64 money)
{
if (m_money == money)
{ return; }
{
return;
}
if (money > m_player->GetMoney())
{
@ -377,7 +399,9 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
if (!state)
{
if (crosssend)
{ m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); }
{
m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE);
}
else
{ m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); }
}
@ -405,11 +429,15 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_ExtraFlags = 0;
if (GetSession()->GetSecurity() >= SEC_GAMEMASTER)
{ SetAcceptTicket(true); }
{
SetAcceptTicket(true);
}
// players always accept
if (GetSession()->GetSecurity() == SEC_PLAYER)
{ SetAcceptWhispers(true); }
{
SetAcceptWhispers(true);
}
m_comboPoints = 0;
@ -786,14 +814,18 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
{
if (oEntry->ItemId[j] <= 0)
{ continue; }
{
continue;
}
uint32 item_id = oEntry->ItemId[j];
// just skip, reported in ObjectMgr::LoadItemPrototypes
ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id);
if (!iProto)
{ continue; }
{
continue;
}
// BuyCount by default
int32 count = iProto->BuyCount;
@ -850,7 +882,9 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
// if this is ammo then use it
msg = CanUseAmmo(pItem->GetEntry());
if (msg == EQUIP_ERR_OK)
{ SetAmmo(pItem->GetEntry()); }
{
SetAmmo(pItem->GetEntry());
}
}
}
}
@ -872,7 +906,9 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount)
uint16 eDest;
uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false);
if (msg != EQUIP_ERR_OK)
{ break; }
{
break;
}
EquipNewItem(eDest, titem_id, true);
AutoUnequipOffhandIfNeed();
@ -907,7 +943,9 @@ Item* Player::StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount)
if (msg == EQUIP_ERR_OK)
{
if (Item* pItem = StoreNewItem(vDest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry)))
{ return pItem; }
{
return pItem;
}
}
return NULL;
@ -918,7 +956,9 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre
if (int(MaxValue) == DISABLED_MIRROR_TIMER)
{
if (int(CurrentValue) != DISABLED_MIRROR_TIMER)
{ StopMirrorTimer(Type); }
{
StopMirrorTimer(Type);
}
return;
}
WorldPacket data(SMSG_START_MIRROR_TIMER, (21));
@ -942,13 +982,17 @@ void Player::StopMirrorTimer(MirrorTimerType Type)
uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
{
if (!IsAlive() || isGameMaster())
{ return 0; }
{
return 0;
}
// Absorb, resist some environmental damage type
uint32 absorb = 0;
uint32 resist = 0;
if (type == DAMAGE_LAVA)
{ CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist); }
{
CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist);
}
else if (type == DAMAGE_SLIME)
{ CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); }
@ -993,7 +1037,9 @@ int32 Player::getMaxTimer(MirrorTimerType timer)
{
case FATIGUE_TIMER:
if (GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL))
{ return DISABLED_MIRROR_TIMER; }
{
return DISABLED_MIRROR_TIMER;
}
return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX) * IN_MILLISECONDS;
case BREATH_TIMER:
{
@ -1009,7 +1055,9 @@ int32 Player::getMaxTimer(MirrorTimerType timer)
case FIRE_TIMER:
{
if (!IsAlive() || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL))
{ return DISABLED_MIRROR_TIMER; }
{
return DISABLED_MIRROR_TIMER;
}
return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX) * IN_MILLISECONDS;
}
default:
@ -1022,13 +1070,17 @@ void Player::UpdateMirrorTimers()
{
// Desync flags for update on next HandleDrowning
if (m_MirrorTimerFlags)
{ m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; }
{
m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags;
}
}
void Player::HandleDrowning(uint32 time_diff)
{
if (!m_MirrorTimerFlags)
{ return; }
{
return;
}
// In water
if (m_MirrorTimerFlags & UNDERWATER_INWATER)
@ -1061,7 +1113,9 @@ void Player::HandleDrowning(uint32 time_diff)
// Need breath regen
m_MirrorTimer[BREATH_TIMER] += 10 * time_diff;
if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive())
{ StopMirrorTimer(BREATH_TIMER); }
{
StopMirrorTimer(BREATH_TIMER);
}
else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER)
{ SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); }
}
@ -1099,7 +1153,9 @@ void Player::HandleDrowning(uint32 time_diff)
int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER);
m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff;
if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive())
{ StopMirrorTimer(FATIGUE_TIMER); }
{
StopMirrorTimer(FATIGUE_TIMER);
}
else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER)
{ SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); }
}
@ -1108,7 +1164,9 @@ void Player::HandleDrowning(uint32 time_diff)
{
// Breath timer not activated - activate it
if (m_MirrorTimer[FIRE_TIMER] == DISABLED_MIRROR_TIMER)
{ m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); }
{
m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER);
}
else
{
m_MirrorTimer[FIRE_TIMER] -= time_diff;
@ -1119,7 +1177,9 @@ void Player::HandleDrowning(uint32 time_diff)
// TODO: Check this formula
uint32 damage = urand(600, 700);
if (m_MirrorTimerFlags & UNDERWATER_INLAVA)
{ EnvironmentalDamage(DAMAGE_LAVA, damage); }
{
EnvironmentalDamage(DAMAGE_LAVA, damage);
}
// need to skip Slime damage in Undercity,
// maybe someone can find better way to handle environmental damage
//else if (m_zoneUpdateId != 1497)
@ -13117,7 +13177,9 @@ void Player::OnGossipSelect(WorldObject* pSource, uint32 gossipListId, uint32 me
if (pMenuData.m_gAction_script)
{
if (pSource->GetTypeId() == TYPEID_UNIT)
{ GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, pSource, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); }
{
GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, pSource, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE);
}
else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT)
{ GetMap()->ScriptsStart(DBS_ON_GOSSIP, pMenuData.m_gAction_script, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); }
}
@ -13160,7 +13222,9 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* pSource)
// Start related script
if (scriptId)
{ GetMap()->ScriptsStart(DBS_ON_GOSSIP, scriptId, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET); }
{
GetMap()->ScriptsStart(DBS_ON_GOSSIP, scriptId, this, pSource, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_TARGET);
}
return textId;
}
@ -13705,7 +13769,9 @@ void Player::AddQuest(Quest const* pQuest, Object* questGiver)
// starting initial DB quest script
if (pQuest->GetQuestStartScript() != 0)
{ GetMap()->ScriptsStart(DBS_ON_QUEST_START, pQuest->GetQuestStartScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); }
{
GetMap()->ScriptsStart(DBS_ON_QUEST_START, pQuest->GetQuestStartScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE);
}
}
// remove start item if not need
@ -13928,7 +13994,9 @@ void Player::RewardQuest(Quest const* pQuest, uint32 reward, Object* questGiver,
}
if (!handled && pQuest->GetQuestCompleteScript() != 0)
{ GetMap()->ScriptsStart(DBS_ON_QUEST_END, pQuest->GetQuestCompleteScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE); }
{
GetMap()->ScriptsStart(DBS_ON_QUEST_END, pQuest->GetQuestCompleteScript(), questGiver, this, Map::SCRIPT_EXEC_PARAM_UNIQUE_BY_SOURCE);
}
// cast spells after mark quest complete (some spells have quest completed state reqyurements in spell_area data)
if (pQuest->GetRewSpellCast() > 0)
@ -16022,7 +16090,9 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder* holder)
case 1: SetGameMaster(true); break; // enable
case 2: // save state
if (extraflags & PLAYER_EXTRA_GM_ON)
{ SetGameMaster(true); }
{
SetGameMaster(true);
}
break;
}
@ -16084,7 +16154,9 @@ bool Player::IsTappedByMeOrMyGroup(Creature* creature)
{
/* Nobody tapped the monster (solo kill by another NPC) */
if (!creature->HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_TAPPED))
{ return false; }
{
return false;
}
/* If there is a loot recipient, assign it to recipient */
if (Player* recipient = creature->GetLootRecipient())
@ -18183,7 +18255,9 @@ void Player::outDebugStatsValues() const
{
// optimize disabled debug output
if (!sLog.HasLogLevelOrHigher(LOG_LVL_DEBUG) || sLog.HasLogFilter(LOG_FILTER_PLAYER_STATS))
{ return; }
{
return;
}
sLog.outDebug("HP is: \t\t\t%u\t\tMP is: \t\t\t%u", GetMaxHealth(), GetMaxPower(POWER_MANA));
sLog.outDebug("AGILITY is: \t\t%f\t\tSTRENGTH is: \t\t%f", GetStat(STAT_AGILITY), GetStat(STAT_STRENGTH));

View file

@ -209,7 +209,9 @@ struct ActionButton
{
packedData = newData;
if (uState != ACTIONBUTTON_NEW)
{ uState = ACTIONBUTTON_CHANGED; }
{
uState = ACTIONBUTTON_CHANGED;
}
}
}
};
@ -1185,7 +1187,9 @@ class Player : public Unit
m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL);
if (state < 0)
{ m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY; }
{
m_ExtraFlags |= PLAYER_EXTRA_AUCTION_ENEMY;
}
else if (state > 0)
{ m_ExtraFlags |= PLAYER_EXTRA_AUCTION_NEUTRAL; }
}
@ -1308,7 +1312,9 @@ class Player : public Unit
InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const
{
if (!pItem)
{ return EQUIP_ERR_ITEM_NOT_FOUND; }
{
return EQUIP_ERR_ITEM_NOT_FOUND;
}
uint32 count = pItem->GetCount();
return _CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL);
}
@ -2284,7 +2290,9 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE)
{ return true; }
{
return true;
}
return false;
}
@ -2300,14 +2308,18 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
{ return i; }
{
return i;
}
return PLAYER_MAX_BATTLEGROUND_QUEUES;
}
bool IsInvitedForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
{ return m_bgBattleGroundQueueID[i].invitedToInstance != 0; }
{
return m_bgBattleGroundQueueID[i].invitedToInstance != 0;
}
return false;
}
bool InBattleGroundQueueForBattleGroundQueueType(BattleGroundQueueTypeId bgQueueTypeId) const
@ -2338,7 +2350,9 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
{ return true; }
{
return true;
}
return false;
}
void RemoveBattleGroundQueueId(BattleGroundQueueTypeId val)
@ -2357,13 +2371,17 @@ class Player : public Unit
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].bgQueueTypeId == bgQueueTypeId)
{ m_bgBattleGroundQueueID[i].invitedToInstance = instanceId; }
{
m_bgBattleGroundQueueID[i].invitedToInstance = instanceId;
}
}
bool IsInvitedForBattleGroundInstance(uint32 instanceId) const
{
for (int i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
if (m_bgBattleGroundQueueID[i].invitedToInstance == instanceId)
{ return true; }
{
return true;
}
return false;
}
WorldLocation const& GetBattleGroundEntryPoint() const { return m_bgData.joinPos; }
@ -2876,7 +2894,9 @@ class Player : public Unit
void ScheduleDelayedOperation(uint32 operation)
{
if (operation < DELAYED_END)
{ m_DelayedOperations |= operation; }
{
m_DelayedOperations |= operation;
}
}
void _fillGearScoreData(Item* item, GearScoreVec* gearScore, uint32& twoHandScore);

View file

@ -40,7 +40,9 @@
bool Player::UpdateStats(Stats stat)
{
if (stat > STAT_SPIRIT)
{ return false; }
{
return false;
}
// value = ((base_value * base_pct) + total_value) * total_pct
float value = GetTotalStatValue(stat);
@ -346,7 +348,9 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
{
UpdateDamagePhysical(BASE_ATTACK);
if (CanDualWield() && haveOffhandWeapon()) // allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
{ UpdateDamagePhysical(OFF_ATTACK); }
{
UpdateDamagePhysical(OFF_ATTACK);
}
}
}
@ -711,7 +715,9 @@ void Player::UpdateManaRegen()
// Set regen rate in cast state apply only on spirit based regen
int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT);
if (modManaRegenInterrupt > 100)
{ modManaRegenInterrupt = 100; }
{
modManaRegenInterrupt = 100;
}
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen + power_regen_mp5 + spirit_regen * modManaRegenInterrupt / 100.0f);
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, base_regen + 0.001f + power_regen_mp5 + spirit_regen);
@ -868,7 +874,9 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
SetFloatValue(index_mult, attPowerMultiplier); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
if (ranged)
{ return; }
{
return;
}
// automatically update weapon damage after attack power modification
UpdateDamagePhysical(BASE_ATTACK);
@ -878,7 +886,9 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
void Creature::UpdateDamagePhysical(WeaponAttackType attType)
{
if (attType > OFF_ATTACK)
{ return; }
{
return;
}
UnitMods unitMod = (attType == BASE_ATTACK ? UNIT_MOD_DAMAGE_MAINHAND : UNIT_MOD_DAMAGE_OFFHAND);
@ -909,7 +919,9 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType)
bool Pet::UpdateStats(Stats stat)
{
if (stat > STAT_SPIRIT)
{ return false; }
{
return false;
}
// value = ((base_value * base_pct) + total_value) * total_pct
float value = GetTotalStatValue(stat);
@ -1026,14 +1038,18 @@ void Pet::UpdateMaxPower(Powers power)
void Pet::UpdateAttackPowerAndDamage(bool ranged)
{
if (ranged)
{ return; }
{
return;
}
float val = 0.0f;
float bonusAP = 0.0f;
UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
if (GetEntry() == 416) // imp's attack power
{ val = GetStat(STAT_STRENGTH) - 10.0f; }
{
val = GetStat(STAT_STRENGTH) - 10.0f;
}
else
{ val = 2 * GetStat(STAT_STRENGTH) - 20.0f; }
@ -1087,7 +1103,9 @@ void Pet::UpdateAttackPowerAndDamage(bool ranged)
void Pet::UpdateDamagePhysical(WeaponAttackType attType)
{
if (attType > BASE_ATTACK)
{ return; }
{
return;
}
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;

View file

@ -604,7 +604,9 @@ Unit::~Unit()
void Unit::Update(uint32 update_diff, uint32 p_time)
{
if (!IsInWorld())
{ return; }
{
return;
}
/*if(p_time > m_AurasCheck)
{
@ -639,7 +641,9 @@ void Unit::Update(uint32 update_diff, uint32 p_time)
{
// m_CombatTimer set at aura start and it will be freeze until aura removing
if (m_CombatTimer <= update_diff)
{ CombatStop(); }
{
CombatStop();
}
else
{ m_CombatTimer -= update_diff; }
}
@ -684,10 +688,14 @@ bool Unit::UpdateMeleeAttackingState()
{
Unit* victim = getVictim();
if (!victim || IsNonMeleeSpellCasted(false))
{ return false; }
{
return false;
}
if (!isAttackReady(BASE_ATTACK) && !(isAttackReady(OFF_ATTACK) && haveOffhandWeapon()))
{ return false; }
{
return false;
}
uint8 swingError = 0;
if (!CanReachWithMeleeAttack(victim))
@ -711,7 +719,9 @@ bool Unit::UpdateMeleeAttackingState()
if (haveOffhandWeapon())
{
if (getAttackTimer(OFF_ATTACK) < ATTACK_DISPLAY_DELAY)
{ setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY); }
{
setAttackTimer(OFF_ATTACK, ATTACK_DISPLAY_DELAY);
}
}
AttackerStateUpdate(victim, BASE_ATTACK);
resetAttackTimer(BASE_ATTACK);
@ -721,7 +731,9 @@ bool Unit::UpdateMeleeAttackingState()
// prevent base and off attack in same time, delay attack at 0.2 sec
uint32 base_att = getAttackTimer(BASE_ATTACK);
if (base_att < ATTACK_DISPLAY_DELAY)
{ setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY); }
{
setAttackTimer(BASE_ATTACK, ATTACK_DISPLAY_DELAY);
}
// do attack
AttackerStateUpdate(victim, OFF_ATTACK);
resetAttackTimer(OFF_ATTACK);
@ -732,7 +744,9 @@ bool Unit::UpdateMeleeAttackingState()
if (player && swingError != player->LastSwingErrorMsg())
{
if (swingError == 1)
{ player->SendAttackSwingNotInRange(); }
{
player->SendAttackSwingNotInRange();
}
else if (swingError == 2)
{ player->SendAttackSwingBadFacingAttack(); }
player->SwingErrorMsg(swingError);
@ -744,10 +758,14 @@ bool Unit::UpdateMeleeAttackingState()
bool Unit::haveOffhandWeapon() const
{
if (!CanUseEquippedWeapon(OFF_ATTACK))
{ return false; }
{
return false;
}
if (GetTypeId() == TYPEID_PLAYER)
{ return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK, true, true); }
{
return ((Player*)this)->GetWeaponForAttack(OFF_ATTACK, true, true);
}
else
{
uint32 ItemId = GetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1);
@ -781,7 +799,9 @@ float Unit::GetCombatReach(Unit const* pVictim, bool forMeleeRange /*=true*/, fl
BASE_MELEERANGE_OFFSET + flat_mod;
if (forMeleeRange && reach < ATTACK_DISTANCE)
{ reach = ATTACK_DISTANCE; }
{
reach = ATTACK_DISTANCE;
}
return reach;
}
@ -856,7 +876,9 @@ void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb)
if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()))
{
if (absorb)
{ *absorb += damage; }
{
*absorb += damage;
}
damage = 0;
return;
}
@ -874,13 +896,19 @@ void Unit::DealDamageMods(Unit* pVictim, uint32& damage, uint32* absorb)
// Script Event damage Deal
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
{ ((Creature*)this)->AI()->DamageDeal(pVictim, damage); }
{
((Creature*)this)->AI()->DamageDeal(pVictim, damage);
}
// Script Event damage taken
if (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->AI())
{ ((Creature*)pVictim)->AI()->DamageTaken(this, damage); }
{
((Creature*)pVictim)->AI()->DamageTaken(this, damage);
}
if (absorb && originalDamage > damage)
{ *absorb += (originalDamage - damage); }
{
*absorb += (originalDamage - damage);
}
}
uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool durabilityLoss)
@ -1030,7 +1058,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
((Player*)pVictim)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_HIT_RECEIVED, damage);
if (pVictim->GetTypeId() == TYPEID_UNIT && !((Creature*)pVictim)->IsPet() && !((Creature*)pVictim)->HasLootRecipient())
{ ((Creature*)pVictim)->SetLootRecipient(this); }
{
((Creature*)pVictim)->SetLootRecipient(this);
}
if (health <= damage)
{
@ -1049,13 +1079,17 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
group_tap = ((Creature*)pVictim)->GetGroupLootRecipient();
if (Player* recipient = ((Creature*)pVictim)->GetOriginalLootRecipient())
{ player_tap = recipient; }
{
player_tap = recipient;
}
}
// in player kill case group tap selected by player_tap (killer-player itself, or charmer, or owner, etc)
else
{
if (player_tap)
{ group_tap = player_tap->GetGroup(); }
{
group_tap = player_tap->GetGroup();
}
}
// Spirit of Redemtion Talent
@ -1089,7 +1123,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
data << pVictim->GetObjectGuid(); // victim
if (group_tap)
{ group_tap->BroadcastPacket(&data, false, group_tap->GetMemberGroup(player_tap->GetObjectGuid()), player_tap->GetObjectGuid()); }
{
group_tap->BroadcastPacket(&data, false, group_tap->GetMemberGroup(player_tap->GetObjectGuid()), player_tap->GetObjectGuid());
}
player_tap->SendDirectMessage(&data);
}
@ -1100,7 +1136,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
if (player_tap != pVictim)
{
if (group_tap)
{ group_tap->RewardGroupAtKill(pVictim, player_tap); }
{
group_tap->RewardGroupAtKill(pVictim, player_tap);
}
else if (player_tap)
{ player_tap->RewardSinglePlayerAtKill(pVictim); }
}
@ -1120,7 +1158,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
// save value before aura remove
uint32 ressSpellId = pVictim->GetUInt32Value(PLAYER_SELF_RES_SPELL);
if (!ressSpellId)
{ ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId(); }
{
ressSpellId = ((Player*)pVictim)->GetResurrectionSpellId();
}
// Remove all expected to remove at death auras (most important negative case like DoT or periodic triggers)
pVictim->RemoveAllAurasOnDeath();
@ -1136,7 +1176,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
// Call KilledUnit for creatures
if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())
{ ((Creature*)this)->AI()->KilledUnit(pVictim); }
{
((Creature*)this)->AI()->KilledUnit(pVictim);
}
if (Creature* killer = ToCreature())
{
@ -1160,7 +1202,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
// remember victim PvP death for corpse type and corpse reclaim delay
// at original death (not at SpiritOfRedemtionTalent timeout)
if (!damageFromSpiritOfRedemtionTalent)
{ playerVictim->SetPvPDeath(player_tap != NULL); }
{
playerVictim->SetPvPDeath(player_tap != NULL);
}
// achievement stuff
playerVictim->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_TOTAL_DAMAGE_RECEIVED, health);
@ -1208,7 +1252,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
{
// selfkills are not handled in outdoor pvp scripts
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(playerVictim->GetCachedZoneId()))
{ outdoorPvP->HandlePlayerKill(player_tap, playerVictim); }
{
outdoorPvP->HandlePlayerKill(player_tap, playerVictim);
}
}
// Used by Eluna
@ -1282,14 +1328,18 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
{
// skip channeled spell (processed differently below)
if (i == CURRENT_CHANNELED_SPELL)
{ continue; }
{
continue;
}
if (Spell* spell = pVictim->GetCurrentSpell(CurrentSpellTypes(i)))
{
if (spell->getState() == SPELL_STATE_PREPARING)
{
if(spell->m_spellInfo->GetInterruptFlags() & SPELL_INTERRUPT_FLAG_ABORT_ON_DMG)
{ pVictim->InterruptSpell(CurrentSpellTypes(i)); }
{
pVictim->InterruptSpell(CurrentSpellTypes(i));
}
else
{ spell->Delayed(); }
}
@ -1305,7 +1355,9 @@ uint32 Unit::DealDamage(Unit* pVictim, uint32 damage, CleanDamage const* cleanDa
if (channelInterruptFlags & CHANNEL_FLAG_DELAY)
{
if (pVictim != this) // don't shorten the duration of channeling if you damage yourself
{ spell->DelayedChannel(); }
{
spell->DelayedChannel();
}
}
else if ((channelInterruptFlags & (CHANNEL_FLAG_DAMAGE | CHANNEL_FLAG_DAMAGE2)))
{
@ -1353,7 +1405,9 @@ struct PetOwnerKilledUnitHelper
if (pTarget->GetTypeId() == TYPEID_UNIT)
{
if (((Creature*)pTarget)->AI())
{ ((Creature*)pTarget)->AI()->OwnerKilledUnit(m_victim); }
{
((Creature*)pTarget)->AI()->OwnerKilledUnit(m_victim);
}
}
}
@ -1369,7 +1423,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
if (victim->GetCreatureType() == CREATURE_TYPE_CRITTER && GetTypeId() == TYPEID_PLAYER)
{
if (CreatureInfo const* normalInfo = ObjectMgr::GetCreatureTemplate(victim->GetEntry()))
{ ((Player*)this)->KilledMonster(normalInfo, victim->GetObjectGuid()); }
{
((Player*)this)->KilledMonster(normalInfo, victim->GetObjectGuid());
}
}
// Interrupt channeling spell when a Possessed Summoned is killed
@ -1381,14 +1437,18 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
{
Spell* channeledSpell = creator->GetCurrentSpell(CURRENT_CHANNELED_SPELL);
if (channeledSpell && channeledSpell->m_spellInfo->Id == spellInfo->Id)
{ creator->InterruptNonMeleeSpells(false); }
{
creator->InterruptNonMeleeSpells(false);
}
}
}
/* ******************************* Inform various hooks ************************************ */
// Inform victim's AI
if (victim->AI())
{ victim->AI()->JustDied(this); }
{
victim->AI()->JustDied(this);
}
// Inform Owner
Unit* pOwner = victim->GetCharmerOrOwner();
@ -1398,17 +1458,23 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
if (pSummon->GetSummonerGuid().IsCreatureOrVehicle())
if (Creature* pSummoner = victim->GetMap()->GetCreature(pSummon->GetSummonerGuid()))
if (pSummoner->AI())
{ pSummoner->AI()->SummonedCreatureJustDied(victim); }
{
pSummoner->AI()->SummonedCreatureJustDied(victim);
}
}
else if (pOwner && pOwner->GetTypeId() == TYPEID_UNIT)
{
if (((Creature*)pOwner)->AI())
{ ((Creature*)pOwner)->AI()->SummonedCreatureJustDied(victim); }
{
((Creature*)pOwner)->AI()->SummonedCreatureJustDied(victim);
}
}
// Inform Instance Data and Linking
if (InstanceData* mapInstance = victim->GetInstanceData())
{ mapInstance->OnCreatureDeath(victim); }
{
mapInstance->OnCreatureDeath(victim);
}
if (responsiblePlayer) // killedby Player, inform BG
if (BattleGround* bg = responsiblePlayer->GetBattleGround())
@ -1421,13 +1487,17 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
// Notify the outdoor pvp script
if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(responsiblePlayer ? responsiblePlayer->GetCachedZoneId() : GetZoneId()))
{ outdoorPvP->HandleCreatureDeath(victim); }
{
outdoorPvP->HandleCreatureDeath(victim);
}
// Start creature death script
GetMap()->ScriptsStart(DBS_ON_CREATURE_DEATH, victim->GetEntry(), victim, responsiblePlayer ? responsiblePlayer : this);
if (victim->IsLinkingEventTrigger())
{ victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim); }
{
victim->GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_DIE, victim);
}
// Dungeon specific stuff
if (victim->GetInstanceId())
@ -1441,7 +1511,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
if (m->IsRaidOrHeroicDungeon())
{
if (victim->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_INSTANCE_BIND)
{ ((DungeonMap*)m)->PermBindAllPlayers(creditedPlayer); }
{
((DungeonMap*)m)->PermBindAllPlayers(creditedPlayer);
}
}
else
{
@ -1450,7 +1522,9 @@ void Unit::JustKilledCreature(Creature* victim, Player* responsiblePlayer)
// until the players leave the instance
time_t resettime = victim->GetRespawnTimeEx() + 2 * HOUR;
if (save->GetResetTime() < resettime)
{ save->SetResetTime(resettime); }
{
save->SetResetTime(resettime);
}
}
// update encounter state if needed
((DungeonMap*)m)->GetPersistanceState()->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, victim->GetEntry());
@ -1484,7 +1558,9 @@ void Unit::CastStop(uint32 except_spellid)
{
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id != except_spellid)
{ InterruptSpell(CurrentSpellTypes(i), false); }
{
InterruptSpell(CurrentSpellTypes(i), false);
}
}
void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castItem, Aura* triggeredByAura, ObjectGuid originalCaster, SpellEntry const* triggeredBy)
@ -1494,7 +1570,9 @@ void Unit::CastSpell(Unit* Victim, uint32 spellId, bool triggered, Item* castIte
if (!spellInfo)
{
if (triggeredByAura)
{ sLog.outError("CastSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); }
{
sLog.outError("CastSpell: unknown spell id %i by caster: %s triggered by aura %u (eff %u)", spellId, GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex());
}
else
{ sLog.outError("CastSpell: unknown spell id %i by caster: %s", spellId, GetGuidStr().c_str()); }
return;
@ -1508,19 +1586,25 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered,
if (!spellInfo)
{
if (triggeredByAura)
{ sLog.outError("CastSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex()); }
{
sLog.outError("CastSpell: unknown spell by caster: %s triggered by aura %u (eff %u)", GetGuidStr().c_str(), triggeredByAura->GetId(), triggeredByAura->GetEffIndex());
}
else
{ sLog.outError("CastSpell: unknown spell by caster: %s", GetGuidStr().c_str()); }
return;
}
if (castItem)
{ DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); }
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id);
}
if (triggeredByAura)
{
if (!originalCaster)
{ originalCaster = triggeredByAura->GetCasterGuid(); }
{
originalCaster = triggeredByAura->GetCasterGuid();
}
triggeredBy = triggeredByAura->GetSpellProto();
}
@ -1540,7 +1624,9 @@ void Unit::CastSpell(Unit* Victim, SpellEntry const* spellInfo, bool triggered,
targets.setUnitTarget(Victim);
if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION)
{ targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); }
{
targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ());
}
if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION)
if (WorldObject* caster = spell->GetCastingObject())
targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
@ -1577,12 +1663,16 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 cons
}
if (castItem)
{ DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); }
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id);
}
if (triggeredByAura)
{
if (!originalCaster)
{ originalCaster = triggeredByAura->GetCasterGuid(); }
{
originalCaster = triggeredByAura->GetCasterGuid();
}
triggeredBy = triggeredByAura->GetSpellProto();
}
@ -1590,23 +1680,33 @@ void Unit::CastCustomSpell(Unit* Victim, SpellEntry const* spellInfo, int32 cons
Spell* spell = new Spell(this, spellInfo, triggered, originalCaster, triggeredBy);
if (bp0)
{ spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0; }
{
spell->m_currentBasePoints[EFFECT_INDEX_0] = *bp0;
}
if (bp1)
{ spell->m_currentBasePoints[EFFECT_INDEX_1] = *bp1; }
{
spell->m_currentBasePoints[EFFECT_INDEX_1] = *bp1;
}
if (bp2)
{ spell->m_currentBasePoints[EFFECT_INDEX_2] = *bp2; }
{
spell->m_currentBasePoints[EFFECT_INDEX_2] = *bp2;
}
SpellCastTargets targets;
targets.setUnitTarget(Victim);
spell->m_CastItem = castItem;
if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION)
{ targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ()); }
{
targets.setDestination(Victim->GetPositionX(), Victim->GetPositionY(), Victim->GetPositionZ());
}
if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION)
if (WorldObject* caster = spell->GetCastingObject())
{ targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ()); }
{
targets.setSource(caster->GetPositionX(), caster->GetPositionY(), caster->GetPositionZ());
}
spell->SpellStart(&targets, triggeredByAura);
}
@ -1641,12 +1741,16 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, boo
}
if (castItem)
{ DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id); }
{
DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: cast Item spellId - %i", spellInfo->Id);
}
if (triggeredByAura)
{
if (!originalCaster)
{ originalCaster = triggeredByAura->GetCasterGuid(); }
{
originalCaster = triggeredByAura->GetCasterGuid();
}
triggeredBy = triggeredByAura->GetSpellProto();
}
@ -1656,13 +1760,19 @@ void Unit::CastSpell(float x, float y, float z, SpellEntry const* spellInfo, boo
SpellCastTargets targets;
if (spellInfo->GetTargets() & TARGET_FLAG_DEST_LOCATION)
{ targets.setDestination(x, y, z); }
{
targets.setDestination(x, y, z);
}
if (spellInfo->GetTargets() & TARGET_FLAG_SOURCE_LOCATION)
{ targets.setSource(x, y, z); }
{
targets.setSource(x, y, z);
}
// Spell cast with x,y,z but without dbc target-mask, set destination
if (!(targets.m_targetMask & (TARGET_FLAG_DEST_LOCATION | TARGET_FLAG_SOURCE_LOCATION)))
{ targets.setDestination(x, y, z); }
{
targets.setDestination(x, y, z);
}
spell->m_CastItem = castItem;
spell->SpellStart(&targets, triggeredByAura);
@ -1687,7 +1797,9 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S
Unit* pVictim = damageInfo->target;
if (damage < 0)
{ return; }
{
return;
}
if (!this || !pVictim)
return;
@ -1767,15 +1879,21 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* damageInfo, int32 damage, S
void Unit::DealSpellDamage(SpellNonMeleeDamage* damageInfo, bool durabilityLoss)
{
if (!damageInfo)
{ return; }
{
return;
}
Unit* pVictim = damageInfo->target;
if (!this || !pVictim)
{ return; }
{
return;
}
if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()))
{ return; }
{
return;
}
SpellEntry const* spellProto = sSpellStore.LookupEntry(damageInfo->SpellID);
if (spellProto == NULL)
@ -1815,9 +1933,13 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
damageInfo->hitOutCome = MELEE_HIT_EVADE;
if (!this || !pVictim)
{ return; }
{
return;
}
if (!this->IsAlive() || !pVictim->IsAlive())
{ return; }
{
return;
}
// Select HitInfo/procAttacker/procVictim flag based on attack type
switch (attackType)
@ -2001,17 +2123,25 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
// apply max/min bounds
if (lowEnd < 0.01f) // the low end must not go bellow 0.01f
{ lowEnd = 0.01f; }
{
lowEnd = 0.01f;
}
else if (lowEnd > maxLowEnd) // the smaller value of this and 0.6 is kept as the low end
{ lowEnd = maxLowEnd; }
if (highEnd < 0.2f) // high end limits
{ highEnd = 0.2f; }
{
highEnd = 0.2f;
}
if (highEnd > 0.99f)
{ highEnd = 0.99f; }
{
highEnd = 0.99f;
}
if (lowEnd > highEnd) // prevent negative range size
{ lowEnd = highEnd; }
{
lowEnd = highEnd;
}
reducePercent = lowEnd + rand_norm_f() * (highEnd - lowEnd);
@ -2057,7 +2187,9 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* damageInfo, Weapo
damageInfo->procEx |= PROC_EX_ABSORB;
}
if (damageInfo->resist)
{ damageInfo->HitInfo |= HITINFO_RESIST; }
{
damageInfo->HitInfo |= HITINFO_RESIST;
}
}
else // Umpossible get negative result but....
{ damageInfo->damage = 0; }
@ -2069,10 +2201,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
Unit* pVictim = damageInfo->target;
if (!this || !pVictim)
{ return; }
{
return;
}
if (!pVictim->IsAlive() || pVictim->IsTaxiFlying() || (pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode()))
{ return; }
{
return;
}
// You don't lose health from damage taken from another player while in a sanctuary
// You still see it in the combat log though
@ -2081,9 +2217,13 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// Hmmmm dont like this emotes client must by self do all animations
if (damageInfo->HitInfo & HITINFO_CRITICALHIT)
{ pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL); }
{
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_WOUNDCRITICAL);
}
if (damageInfo->blocked_amount && damageInfo->TargetState != VICTIMSTATE_BLOCKS)
{ pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD); }
{
pVictim->HandleEmoteCommand(EMOTE_ONESHOT_PARRYSHIELD);
}
// This seems to reduce the victims time until next attack if your attack was parried
if (damageInfo->TargetState == VICTIMSTATE_PARRY)
@ -2140,7 +2280,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
// there is a newbie protection, at level 10 just 7% base chance; assuming linear function
if (pVictim->getLevel() < 30)
{ Probability = 0.65f * pVictim->getLevel() + 0.5f; }
{
Probability = 0.65f * pVictim->getLevel() + 0.5f;
}
uint32 VictimDefense = pVictim->GetMaxSkillValueForLevel(this);
uint32 AttackerMeleeSkill = GetMaxSkillValueForLevel();
@ -2148,10 +2290,14 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
Probability *= AttackerMeleeSkill / (float)VictimDefense;
if (Probability > 40.0f)
{ Probability = 40.0f; }
{
Probability = 40.0f;
}
if (roll_chance_f(Probability))
{ CastSpell(pVictim, 1604, true); }
{
CastSpell(pVictim, 1604, true);
}
}
// If not miss
@ -2159,7 +2305,9 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
{
// on weapon hit casts
if (GetTypeId() == TYPEID_PLAYER && pVictim->IsAlive())
{ ((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType); }
{
((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType);
}
// victim's damage shield
std::set<Aura*> alreadyDone;
@ -2219,11 +2367,15 @@ void Unit::HandleEmoteState(uint32 emote_id)
void Unit::HandleEmote(uint32 emote_id)
{
if (!emote_id)
{ HandleEmoteState(0); }
{
HandleEmoteState(0);
}
else if (EmotesEntry const* emoteEntry = sEmotesStore.LookupEntry(emote_id))
{
if (emoteEntry->EmoteType) // 1,2 states, 0 command
{ HandleEmoteState(emote_id); }
{
HandleEmoteState(emote_id);
}
else
{ HandleEmoteCommand(emote_id); }
}
@ -2282,7 +2434,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
}
if (armor < 0.0f)
{ armor = 0.0f; }
{
armor = 0.0f;
}
float levelModifier = (float)getLevel();
if (levelModifier > 59)
@ -2292,9 +2446,13 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
tmpvalue = tmpvalue / (1.0f + tmpvalue);
if (tmpvalue < 0.0f)
{ tmpvalue = 0.0f; }
{
tmpvalue = 0.0f;
}
if (tmpvalue > 0.75f)
{ tmpvalue = 0.75f; }
{
tmpvalue = 0.75f;
}
newdamage = uint32(damage - (damage * tmpvalue));
@ -2304,7 +2462,9 @@ uint32 Unit::CalcArmorReducedDamage(Unit* pVictim, const uint32 damage)
void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolMask, DamageEffectType damagetype, const uint32 damage, uint32* absorb, uint32* resist, bool canReflect)
{
if (!pCaster || !IsAlive() || !damage)
{ return; }
{
return;
}
// Magic damage, check for resists
if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0)
@ -2319,9 +2479,13 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
tmpvalue2 *= (float)(0.15f / getLevel());
if (tmpvalue2 < 0.0f)
{ tmpvalue2 = 0.0f; }
{
tmpvalue2 = 0.0f;
}
if (tmpvalue2 > 0.75f)
{ tmpvalue2 = 0.75f; }
{
tmpvalue2 = 0.75f;
}
uint32 ran = urand(0, 100);
float faq[4] = {24.0f, 6.0f, 4.0f, 6.0f};
uint8 m = 0;
@ -2330,16 +2494,22 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
{
Binom += 2400 * (powf(tmpvalue2, float(i)) * powf((1 - tmpvalue2), float(4 - i))) / faq[i];
if (ran > Binom)
{ ++m; }
{
++m;
}
else
{ break; }
}
if (damagetype == DOT && m == 4)
{ *resist += uint32(damage - 1); }
{
*resist += uint32(damage - 1);
}
else
{ *resist += uint32(damage * m / 4); }
if (*resist > damage)
{ *resist = damage; }
{
*resist = damage;
}
}
else
{ *resist = 0; }
@ -2620,7 +2790,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
// currentAbsorb - damage can be absorbed by shield
// If need absorb less damage
if (RemainingDamage < currentAbsorb)
{ currentAbsorb = RemainingDamage; }
{
currentAbsorb = RemainingDamage;
}
RemainingDamage -= currentAbsorb;
@ -2632,10 +2804,14 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
// Reduce shield amount
mod->m_amount -= currentAbsorb;
if ((*i)->GetHolder()->DropAuraCharge())
{ mod->m_amount = 0; }
{
mod->m_amount = 0;
}
// Need remove it later
if (mod->m_amount <= 0)
{ existExpired = true; }
{
existExpired = true;
}
}
// Remove all expired absorb auras
@ -2668,11 +2844,15 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
// check damage school mask
if (((*i)->GetModifier()->m_miscvalue & schoolMask) == 0)
{ continue; }
{
continue;
}
int32 currentAbsorb;
if (RemainingDamage >= (*i)->GetModifier()->m_amount)
{ currentAbsorb = (*i)->GetModifier()->m_amount; }
{
currentAbsorb = (*i)->GetModifier()->m_amount;
}
else
{ currentAbsorb = RemainingDamage; }
@ -2681,11 +2861,15 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* pCaster, SpellSchoolMask schoolM
if (float manaMultiplier = (spellEffect ? spellEffect->EffectMultipleValue : 0))
{
if (Player* modOwner = GetSpellModOwner())
{ modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier); }
{
modOwner->ApplySpellMod((*i)->GetId(), SPELLMOD_MULTIPLE_VALUE, manaMultiplier);
}
int32 maxAbsorb = int32(GetPower(POWER_MANA) / manaMultiplier);
if (currentAbsorb > maxAbsorb)
{ currentAbsorb = maxAbsorb; }
{
currentAbsorb = maxAbsorb;
}
int32 manaReduction = int32(currentAbsorb * manaMultiplier);
ApplyPowerMod(POWER_MANA, manaReduction, false);
@ -3941,7 +4125,7 @@ void Unit::SetCurrentCastedSpell(Spell* pSpell)
m_currentSpells[CSpellType] = pSpell;
pSpell->SetReferencedFromCurrent(true);
pSpell->SetSelfContainer(&(m_currentSpells[pSpell->GetCurrentContainer()])); // this works, but is not safe - <looks at Cédric>
pSpell->SetSelfContainer(&(m_currentSpells[pSpell->GetCurrentContainer()])); // this works, but is not safe - <looks at C<EFBFBD>dric>
// original and faulty code - delete once the above has been proven to work
// pSpell->m_selfContainer = &(m_currentSpells[pSpell->GetCurrentContainer()]); // m_selfContainer is not accessible, due to being a protected member
@ -8529,23 +8713,31 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
{
// only alive units can be in combat
if (!IsAlive())
{ return; }
{
return;
}
if (PvP)
{ m_CombatTimer = 5000; }
{
m_CombatTimer = 5000;
}
bool creatureNotInCombat = GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
if (IsCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet()))
{ SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); }
{
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
}
// interrupt all delayed non-combat casts
for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i)))
if (IsNonCombatSpell(spell->m_spellInfo))
{ InterruptSpell(CurrentSpellTypes(i), false); }
{
InterruptSpell(CurrentSpellTypes(i), false);
}
if (getRace() == RACE_WORGEN && !IsInWorgenForm(true) && HasWorgenForm())
CastSpell(this, 97709, true); // cast Altered Form
@ -8562,17 +8754,25 @@ void Unit::SetInCombatState(bool PvP, Unit* enemy)
Creature* pCreature = (Creature*)this;
if (pCreature->AI())
{ pCreature->AI()->EnterCombat(enemy); }
{
pCreature->AI()->EnterCombat(enemy);
}
// Some bosses are set into combat with zone
if (GetMap()->IsDungeon() && (pCreature->GetCreatureInfo()->ExtraFlags & CREATURE_EXTRA_FLAG_AGGRO_ZONE) && enemy && enemy->IsControlledByPlayer())
{ pCreature->SetInCombatWithZone(); }
{
pCreature->SetInCombatWithZone();
}
if (InstanceData* mapInstance = GetInstanceData())
{ mapInstance->OnCreatureEnterCombat(pCreature); }
{
mapInstance->OnCreatureEnterCombat(pCreature);
}
if (m_isCreatureLinkingTrigger)
{ GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_AGGRO, pCreature, enemy); }
{
GetMap()->GetCreatureLinkingHolder()->DoCreatureLinkingEvent(LINKING_EVENT_AGGRO, pCreature, enemy);
}
}
// Used by Eluna
@ -8588,7 +8788,9 @@ void Unit::ClearInCombat()
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
if (IsCharmed() || (GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->IsPet()))
{ RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT); }
{
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PET_IN_COMBAT);
}
// Used by Eluna
#ifdef ENABLE_ELUNA

View file

@ -2779,7 +2779,9 @@ class Unit : public WorldObject
ObjectGuid const& GetCharmerOrOwnerOrOwnGuid() const
{
if (ObjectGuid const& guid = GetCharmerOrOwnerGuid())
{ return guid; }
{
return guid;
}
return GetObjectGuid();
}
/**
@ -2839,7 +2841,9 @@ class Unit : public WorldObject
Unit* GetCharmerOrOwnerOrSelf()
{
if (Unit* u = GetCharmerOrOwner())
{ return u; }
{
return u;
}
return this;
}
@ -3658,29 +3662,39 @@ void Unit::CallForAllControlledUnits(Func const& func, uint32 controlledMask)
{
if (controlledMask & CONTROLLED_PET)
if (Pet* pet = GetPet())
{ func(pet); }
{
func(pet);
}
if (controlledMask & CONTROLLED_MINIPET)
if (Pet* mini = GetMiniPet())
{ func(mini); }
{
func(mini);
}
if (controlledMask & CONTROLLED_GUARDIANS)
{
for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();)
if (Pet* guardian = _GetPet(*(itr++)))
{ func(guardian); }
{
func(guardian);
}
}
if (controlledMask & CONTROLLED_TOTEMS)
{
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (Unit* totem = _GetTotem(TotemSlot(i)))
{ func(totem); }
{
func(totem);
}
}
if (controlledMask & CONTROLLED_CHARM)
if (Unit* charm = GetCharm())
{ func(charm); }
{
func(charm);
}
}
@ -3690,19 +3704,25 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons
if (controlledMask & CONTROLLED_PET)
if (Pet const* pet = GetPet())
if (func(pet))
{ return true; }
{
return true;
}
if (controlledMask & CONTROLLED_MINIPET)
if (Pet const* mini = GetMiniPet())
if (func(mini))
{ return true; }
{
return true;
}
if (controlledMask & CONTROLLED_GUARDIANS)
{
for (GuidSet::const_iterator itr = m_guardianPets.begin(); itr != m_guardianPets.end();)
if (Pet const* guardian = _GetPet(*(itr++)))
if (func(guardian))
{ return true; }
{
return true;
}
}
if (controlledMask & CONTROLLED_TOTEMS)
@ -3710,13 +3730,17 @@ bool Unit::CheckAllControlledUnits(Func const& func, uint32 controlledMask) cons
for (int i = 0; i < MAX_TOTEM_SLOT; ++i)
if (Unit const* totem = _GetTotem(TotemSlot(i)))
if (func(totem))
{ return true; }
{
return true;
}
}
if (controlledMask & CONTROLLED_CHARM)
if (Unit const* charm = GetCharm())
if (func(charm))
{ return true; }
{
return true;
}
return false;
}