Minor cleanups here and there

This commit is contained in:
Spp
2011-10-18 11:13:56 +02:00
parent ee69fc940e
commit e5fb7f093f
3 changed files with 34 additions and 40 deletions
@@ -729,7 +729,6 @@ struct ItemTemplate
bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; } bool IsWeaponVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_WEAPON_ENCHANTMENT; }
bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; } bool IsArmorVellum() const { return Class == ITEM_CLASS_TRADE_GOODS && SubClass == ITEM_SUBCLASS_ARMOR_ENCHANTMENT; }
bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); } bool IsConjuredConsumable() const { return Class == ITEM_CLASS_CONSUMABLE && (Flags & ITEM_PROTO_FLAG_CONJURED); }
}; };
// Benchmarked: Faster than std::map (insert/find) // Benchmarked: Faster than std::map (insert/find)
@@ -72,6 +72,9 @@ class UpdateMask
UpdateMask& operator = (const UpdateMask& mask) UpdateMask& operator = (const UpdateMask& mask)
{ {
if (this == &mask)
return *this;
SetCount(mask.mCount); SetCount(mask.mCount);
memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2); memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2);
+30 -38
View File
@@ -1148,7 +1148,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
} }
} }
for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr++) for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr)
StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount); StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount);
// bags and main-hand weapon must equipped at this moment // bags and main-hand weapon must equipped at this moment
@@ -2456,7 +2456,7 @@ void Player::RegenerateAll()
// Runes act as cooldowns, and they don't need to send any data // Runes act as cooldowns, and they don't need to send any data
if (getClass() == CLASS_DEATH_KNIGHT) if (getClass() == CLASS_DEATH_KNIGHT)
for (uint32 i = 0; i < MAX_RUNES; ++i) for (uint8 i = 0; i < MAX_RUNES; ++i)
if (uint32 cd = GetRuneCooldown(i)) if (uint32 cd = GetRuneCooldown(i))
SetRuneCooldown(i, (cd > m_regenTimer) ? cd - m_regenTimer : 0); SetRuneCooldown(i, (cd > m_regenTimer) ? cd - m_regenTimer : 0);
@@ -2860,7 +2860,6 @@ void Player::SetGMVisible(bool on)
if (on) if (on)
{ {
m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag m_ExtraFlags &= ~PLAYER_EXTRA_GM_INVISIBLE; //remove flag
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER); m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
} }
else else
@@ -5063,7 +5062,7 @@ void Player::BuildPlayerRepop()
StopMirrorTimers(); //disable timers(bars) StopMirrorTimers(); //disable timers(bars)
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0f); //see radius of death player? SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, float(1.0f)); //see radius of death player?
// set and clear other // set and clear other
SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND); SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND);
@@ -13343,17 +13342,17 @@ void Player::UpdateSoulboundTradeItems()
{ {
if (!*itr) if (!*itr)
{ {
itr = m_itemSoulboundTradeable.erase(itr++); m_itemSoulboundTradeable.erase(itr++);
continue; continue;
} }
if ((*itr)->GetOwnerGUID() != GetGUID()) if ((*itr)->GetOwnerGUID() != GetGUID())
{ {
itr = m_itemSoulboundTradeable.erase(itr++); m_itemSoulboundTradeable.erase(itr++);
continue; continue;
} }
if ((*itr)->CheckSoulboundTradeExpire()) if ((*itr)->CheckSoulboundTradeExpire())
{ {
itr = m_itemSoulboundTradeable.erase(itr++); m_itemSoulboundTradeable.erase(itr++);
continue; continue;
} }
++itr; ++itr;
@@ -13599,7 +13598,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
} }
} }
} }
// Cast custom spell vs all equal basepoints getted from enchant_amount // Cast custom spell vs all equal basepoints got from enchant_amount
if (basepoints) if (basepoints)
CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item); CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item);
else else
@@ -14589,8 +14588,7 @@ bool Player::CanCompleteQuest(uint32 quest_id)
if (!qInfo) if (!qInfo)
return false; return false;
RewardedQuestSet::iterator rewItr = m_RewardedQuests.find(quest_id); if (!qInfo->IsRepeatable() && m_RewardedQuests.find(quest_id) != m_RewardedQuests.end())
if (!qInfo->IsRepeatable() && rewItr != m_RewardedQuests.end())
return false; // not allow re-complete quest return false; // not allow re-complete quest
// auto complete quest // auto complete quest
@@ -14919,8 +14917,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
if (log_slot < MAX_QUEST_LOG_SIZE) if (log_slot < MAX_QUEST_LOG_SIZE)
SetQuestSlot(log_slot, 0); SetQuestSlot(log_slot, 0);
RewardedQuestSet::const_iterator rewItr = m_RewardedQuests.find(quest_id); bool rewarded = (m_RewardedQuests.find(quest_id) != m_RewardedQuests.end());
bool rewarded = (rewItr != m_RewardedQuests.end());
// Not give XP in case already completed once repeatable quest // Not give XP in case already completed once repeatable quest
uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST)); uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST));
@@ -15669,11 +15666,11 @@ void Player::GroupEventHappens(uint32 questId, WorldObject const* pEventObject)
{ {
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* pGroupGuy = itr->getSource(); Player* player = itr->getSource();
// for any leave or dead (with not released body) group member at appropriate distance // for any leave or dead (with not released body) group member at appropriate distance
if (pGroupGuy && pGroupGuy->IsAtGroupRewardDistance(pEventObject) && !pGroupGuy->GetCorpse()) if (player && player->IsAtGroupRewardDistance(pEventObject) && !player->GetCorpse())
pGroupGuy->AreaExploredOrEventHappens(questId); player->AreaExploredOrEventHappens(questId);
} }
} }
else else
@@ -19803,7 +19800,7 @@ void Player::RemoveSpellMods(Spell* spell)
for (uint8 i=0; i<MAX_SPELLMOD; ++i) for (uint8 i=0; i<MAX_SPELLMOD; ++i)
{ {
for (SpellModList::iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();) for (SpellModList::const_iterator itr = m_spellMods[i].begin(); itr != m_spellMods[i].end();)
{ {
SpellModifier* mod = *itr; SpellModifier* mod = *itr;
++itr; ++itr;
@@ -19835,8 +19832,7 @@ void Player::DropModCharge(SpellModifier* mod, Spell* spell)
if (spell && mod->ownerAura && mod->charges > 0) if (spell && mod->ownerAura && mod->charges > 0)
{ {
--mod->charges; if (--mod->charges == 0)
if (mod->charges == 0)
mod->charges = -1; mod->charges = -1;
spell->m_appliedMods.insert(mod->ownerAura); spell->m_appliedMods.insert(mod->ownerAura);
@@ -21504,7 +21500,7 @@ void Player::SendInitialPacketsBeforeAddToMap()
data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4); data.Initialize(SMSG_LOGIN_SETTIMESPEED, 4 + 4 + 4);
data << uint32(secsToTimeBitFields(sWorld->GetGameTime())); data << uint32(secsToTimeBitFields(sWorld->GetGameTime()));
data << (float)0.01666667f; // game speed data << float(0.01666667f); // game speed
data << uint32(0); // added in 3.1.2 data << uint32(0); // added in 3.1.2
GetSession()->SendPacket(&data); GetSession()->SendPacket(&data);
@@ -21549,7 +21545,7 @@ void Player::SendInitialPacketsAfterAddToMap()
if (HasAuraType(SPELL_AURA_MOD_STUN)) if (HasAuraType(SPELL_AURA_MOD_STUN))
SetMovement(MOVE_ROOT); SetMovement(MOVE_ROOT);
// manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that don't must be re-applied. // manual send package (have code in HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true); that must not be re-applied.
if (HasAuraType(SPELL_AURA_MOD_ROOT)) if (HasAuraType(SPELL_AURA_MOD_ROOT))
{ {
WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10); WorldPacket data2(SMSG_FORCE_MOVE_ROOT, 10);
@@ -22328,27 +22324,27 @@ bool Player::GetsRecruitAFriendBonus(bool forXP)
{ {
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* pGroupGuy = itr->getSource(); Player* player = itr->getSource();
if (!pGroupGuy) if (!player)
continue; continue;
if (!pGroupGuy->IsAtRecruitAFriendDistance(this)) if (!player->IsAtRecruitAFriendDistance(this))
continue; // member (alive or dead) or his corpse at req. distance continue; // member (alive or dead) or his corpse at req. distance
if (forXP) if (forXP)
{ {
// level must be allowed to get RaF bonus // level must be allowed to get RaF bonus
if (pGroupGuy->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL)) if (player->getLevel() > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
continue; continue;
// level difference must be small enough to get RaF bonus, UNLESS we are lower level // level difference must be small enough to get RaF bonus, UNLESS we are lower level
if (pGroupGuy->getLevel() < getLevel()) if (player->getLevel() < getLevel())
if (uint8(getLevel() - pGroupGuy->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE)) if (uint8(getLevel() - player->getLevel()) > sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL_DIFFERENCE))
continue; continue;
} }
bool ARecruitedB = (pGroupGuy->GetSession()->GetRecruiterId() == GetSession()->GetAccountId()); bool ARecruitedB = (player->GetSession()->GetRecruiterId() == GetSession()->GetAccountId());
bool BRecruitedA = (GetSession()->GetRecruiterId() == pGroupGuy->GetSession()->GetAccountId()); bool BRecruitedA = (GetSession()->GetRecruiterId() == player->GetSession()->GetAccountId());
if (ARecruitedB || BRecruitedA) if (ARecruitedB || BRecruitedA)
{ {
recruitAFriend = true; recruitAFriend = true;
@@ -22376,16 +22372,16 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar
{ {
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{ {
Player* pGroupGuy = itr->getSource(); Player* player = itr->getSource();
if (!pGroupGuy) if (!player)
continue; continue;
if (!pGroupGuy->IsAtGroupRewardDistance(pRewardSource)) if (!player->IsAtGroupRewardDistance(pRewardSource))
continue; // member (alive or dead) or his corpse at req. distance continue; // member (alive or dead) or his corpse at req. distance
// quest objectives updated only for alive group member or dead but with not released body // quest objectives updated only for alive group member or dead but with not released body
if (pGroupGuy->isAlive()|| !pGroupGuy->GetCorpse()) if (player->isAlive()|| !player->GetCorpse())
pGroupGuy->KilledMonsterCredit(creature_id, creature_guid); player->KilledMonsterCredit(creature_id, creature_guid);
} }
} }
else // if (!group) else // if (!group)
@@ -22787,10 +22783,6 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
return false; return false;
} }
// ***********************************
// -------------TRINITY---------------
// ***********************************
void Player::StopCastingBindSight() void Player::StopCastingBindSight()
{ {
if (WorldObject* target = GetViewpoint()) if (WorldObject* target = GetViewpoint())
@@ -24724,7 +24716,7 @@ float Player::GetAverageItemLevel()
if (m_items[i] && m_items[i]->GetTemplate()) if (m_items[i] && m_items[i]->GetTemplate())
sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality(); sum += m_items[i]->GetTemplate()->GetItemLevelIncludingQuality();
count++; ++count;
} }
return ((float)sum) / count; return ((float)sum) / count;