diff options
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 422 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 395 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 6 |
5 files changed, 497 insertions, 337 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 35d8cebb952..d8209ff9de9 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1827,6 +1827,13 @@ void WorldObject::GetRandomPoint(const Position &pos, float distance, float &ran UpdateGroundPositionZ(rand_x, rand_y, rand_z); // update to LOS height if available } +void WorldObject::GetRandomPoint(const Position &srcPos, float distance, Position &pos) const +{ + float x, y, z; + GetRandomPoint(srcPos, distance, x, y, z); + pos.Relocate(x, y, z, GetOrientation()); +} + void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const { float new_z = GetBaseMap()->GetHeight(GetPhaseMask(), x, y, z, true); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cae664ffa1a..a405dc8ce02 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1342,6 +1342,18 @@ void Player::UpdateMirrorTimers() m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; } +void Player::StopMirrorTimers() +{ + StopMirrorTimer(FATIGUE_TIMER); + StopMirrorTimer(BREATH_TIMER); + StopMirrorTimer(FIRE_TIMER); +} + +bool Player::IsMirrorTimerActive(MirrorTimerType type) +{ + return m_MirrorTimer[type] == getMaxTimer(type); +} + void Player::HandleDrowning(uint32 time_diff) { if (!m_MirrorTimerFlags) @@ -1873,6 +1885,15 @@ void Player::setDeathState(DeathState s) SetUInt32Value(PLAYER_SELF_RES_SPELL, 0); } +void Player::InnEnter(time_t time, uint32 mapid, float x, float y, float z) +{ + inn_pos_mapid = mapid; + inn_pos_x = x; + inn_pos_y = y; + inn_pos_z = z; + time_inn_enter = time; +} + bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) { // 0 1 2 3 4 5 6 7 @@ -2312,6 +2333,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return true; } +bool Player::TeleportTo(WorldLocation const &loc, uint32 options /*= 0*/) +{ + return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options); +} + bool Player::TeleportToBGEntryPoint() { if (m_bgData.joinPos.m_mapId == MAPID_INVALID) @@ -2882,6 +2908,11 @@ bool Player::IsInSameGroupWith(Player const* p) const GetGroup()->SameSubGroup(this, p)); } +bool Player::IsInSameRaidWith(Player const* p) const +{ + return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); +} + ///- If the player is invited, remove him. If the group if then only 1 person, disband the group. /// \todo Shouldn't we also check if there is no other invitees before disbanding the group? void Player::UninviteFromGroup() @@ -7335,6 +7366,16 @@ uint8 Player::GetRankFromDB(uint64 guid) return 0; } +void Player::SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type) +{ + SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId); + SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type); +} +void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value) +{ + SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value); +} + uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID); @@ -10132,6 +10173,14 @@ Item* Player::GetItemByPos(uint8 bag, uint8 slot) const return NULL; } +//Does additional check for disarmed weapons +Item* Player::GetUseableItemByPos(uint8 bag, uint8 slot) const +{ + if (!CanUseAttackType(GetAttackBySlot(slot))) + return NULL; + return GetItemByPos(bag, slot); +} + Bag* Player::GetBagByPos(uint8 bag) const { if ((bag >= INVENTORY_SLOT_BAG_START && bag < INVENTORY_SLOT_BAG_END) @@ -10496,6 +10545,19 @@ InventoryResult Player::CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item return EQUIP_ERR_OK; } +InventoryResult Player::CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count /*= NULL*/) const +{ + return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count); +} + +InventoryResult Player::CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap /*= false*/) const +{ + if (!pItem) + return EQUIP_ERR_ITEM_NOT_FOUND; + uint32 count = pItem->GetCount(); + return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); +} + bool Player::HasItemTotemCategory(uint32 TotemCategory) const { Item* pItem; @@ -12415,6 +12477,11 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) pItem->SetState(ITEM_CHANGED, this); } +Item* Player::BankItem(ItemPosCountVec const& dest, Item* pItem, bool update) +{ + return StoreItem(dest, pItem, update); +} + void Player::RemoveItem(uint8 bag, uint8 slot, bool update) { // note: removeitem does not actually change the item @@ -13565,6 +13632,18 @@ void Player::SendSellError(SellResult msg, Creature* creature, uint64 guid, uint GetSession()->SendPacket(&data); } +bool Player::IsUseEquipedWeapon(bool mainhand) const +{ + // disarm applied only to mainhand weapon + return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)); +} + +bool Player::IsTwoHandUsed() const +{ + Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); + return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); +} + void Player::TradeCancel(bool sendback) { if (m_trade) @@ -15897,6 +15976,70 @@ uint16 Player::FindQuestSlot(uint32 quest_id) const return MAX_QUEST_LOG_SIZE; } +uint32 Player::GetQuestSlotQuestId(uint16 slot) const +{ + return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); +} + +uint32 Player::GetQuestSlotState(uint16 slot) const +{ + return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); +} + +uint16 Player::GetQuestSlotCounter(uint16 slot, uint8 counter) const +{ + return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16)); +} + +uint32 Player::GetQuestSlotTime(uint16 slot) const +{ + return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); +} + +void Player::SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer /*= 0*/) +{ + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, 0); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, 0); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET + 1, 0); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); +} + +void Player::SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count) +{ + uint64 val = GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); + val &= ~((uint64)0xFFFF << (counter * 16)); + val |= ((uint64)count << (counter * 16)); + SetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, val); +} + +void Player::SetQuestSlotState(uint16 slot, uint32 state) +{ + SetFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); +} + +void Player::RemoveQuestSlotState(uint16 slot, uint32 state) +{ + RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); +} + +void Player::SetQuestSlotTimer(uint16 slot, uint32 timer) +{ + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); +} + +void Player::SwapQuestSlot(uint16 slot1, uint16 slot2) +{ + for (int i = 0; i < MAX_QUEST_OFFSET; ++i) + { + uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i); + uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i); + + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i, temp2); + SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i, temp1); + } +} + void Player::AreaExploredOrEventHappens(uint32 questId) { if (questId) @@ -18462,6 +18605,12 @@ void Player::BindToInstance() GetSession()->SendCalendarRaidLockout(mapSave, true); } +void Player::SetPendingBind(uint32 instanceId, uint32 bindTimer) +{ + _pendingBindId = instanceId; + _pendingBindTimer = bindTimer; +} + void Player::SendRaidInfo() { uint32 counter = 0; @@ -18663,6 +18812,11 @@ bool Player::CheckInstanceCount(uint32 instanceId) const return _instanceResetTimes.find(instanceId) != _instanceResetTimes.end(); } +void Player::AddInstanceEnterTime(uint32 instanceId, time_t enterTime) +{ + if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end()) + _instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR)); +} bool Player::_LoadHomeBind(PreparedQueryResult result) { @@ -19917,6 +20071,13 @@ void Player::UpdateContestedPvP(uint32 diff) m_contestedPvPTimer -= diff; } +void Player::ResetContestedPvP() +{ + ClearUnitState(UNIT_STATE_ATTACK_PLAYER); + RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); + m_contestedPvPTimer = 0; +} + void Player::UpdatePvPFlag(time_t currTime) { if (!IsPvP()) @@ -20152,6 +20313,30 @@ void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, rPlayer->GetName().c_str(), rPlayer->autoReplyMsg.c_str()); } +Item* Player::GetMItem(uint32 id) +{ + ItemMap::const_iterator itr = mMitems.find(id); + return itr != mMitems.end() ? itr->second : NULL; +} + +void Player::AddMItem(Item* it) +{ + ASSERT(it); + //ASSERT deleted, because items can be added before loading + mMitems[it->GetGUIDLow()] = it; +} + +bool Player::RemoveMItem(uint32 id) +{ + return mMitems.erase(id) ? true : false; +} + +void Player::SendOnCancelExpectedVehicleRideAura() +{ + WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); + GetSession()->SendPacket(&data); +} + void Player::PetSpellInitialize() { Pet* pet = GetPet(); @@ -21400,6 +21585,13 @@ void Player::UpdatePvPState(bool onlyFFA) } } +void Player::SetPvP(bool state) +{ + Unit::SetPvP(state); + for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) + (*itr)->SetPvP(state); +} + void Player::UpdatePvP(bool state, bool override) { if (!state || override) @@ -21414,6 +21606,19 @@ void Player::UpdatePvP(bool state, bool override) } } +bool Player::HasSpellCooldown(uint32 spell_id) const +{ + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + return itr != m_spellCooldowns.end() && itr->second.end > time(NULL); +} + +uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const +{ + SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); + time_t t = time(NULL); + return uint32(itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0); +} + void Player::AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell, bool infinityCooldown) { // init cooldown values @@ -21554,6 +21759,16 @@ void Player::UpdatePotionCooldown(Spell* spell) m_lastPotionId = 0; } +void Player::setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) +{ + m_resurrectGUID = guid; + m_resurrectMap = mapId; + m_resurrectX = X; + m_resurrectY = Y; + m_resurrectZ = Z; + m_resurrectHealth = health; + m_resurrectMana = mana; +} //slot to be excluded while counting bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) { @@ -21757,6 +21972,17 @@ void Player::SetBattlegroundEntryPoint() m_bgData.joinPos = WorldLocation(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, 0.0f); } +void Player::SetBGTeam(uint32 team) +{ + m_bgData.bgTeam = team; + SetByteValue(PLAYER_BYTES_3, 3, uint8(team == ALLIANCE ? 1 : 0)); +} + +uint32 Player::GetBGTeam() const +{ + return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); +} + void Player::LeaveBattleground(bool teleportToEntryPoint) { if (Battleground* bg = GetBattleground()) @@ -21839,6 +22065,11 @@ WorldLocation Player::GetStartPosition() const return WorldLocation(mapId, info->positionX, info->positionY, info->positionZ, 0); } +bool Player::HaveAtClient(WorldObject const* u) const +{ + return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); +} + bool Player::IsNeverVisible() const { if (Unit::IsNeverVisible()) @@ -22103,6 +22334,25 @@ bool Player::ModifyMoney(int32 amount, bool sendError /*= true*/) return true; } +bool Player::HasEnoughMoney(int32 amount) const +{ + if (amount > 0) + return (GetMoney() >= (uint32) amount); + return true; +} + +void Player::SetMoney(uint32 value) +{ + SetUInt32Value(PLAYER_FIELD_COINAGE, value); + MoneyChanged(value); + UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED); +} + +bool Player::IsQuestRewarded(uint32 quest_id) const +{ + return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); +} + Unit* Player::GetSelectedUnit() const { if (m_curSelection) @@ -22737,6 +22987,96 @@ Battleground* Player::GetBattleground() const return sBattlegroundMgr->GetBattleground(GetBattlegroundId(), m_bgData.bgTypeID); } +bool Player::InBattlegroundQueue() const +{ + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE) + return true; + return false; +} + +BattlegroundQueueTypeId Player::GetBattlegroundQueueTypeId(uint32 index) const +{ + return m_bgBattlegroundQueueID[index].bgQueueTypeId; +} + +uint32 Player::GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const +{ + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) + return i; + return PLAYER_MAX_BATTLEGROUND_QUEUES; +} + +bool Player::IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const +{ + for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) + return m_bgBattlegroundQueueID[i].invitedToInstance != 0; + return false; +} + +bool Player::InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const +{ + return GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES; +} + +void Player::SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId) +{ + m_bgData.bgInstanceID = val; + m_bgData.bgTypeID = bgTypeId; +} + +uint32 Player::AddBattlegroundQueueId(BattlegroundQueueTypeId val) +{ + for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + { + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val) + { + m_bgBattlegroundQueueID[i].bgQueueTypeId = val; + m_bgBattlegroundQueueID[i].invitedToInstance = 0; + return i; + } + } + return PLAYER_MAX_BATTLEGROUND_QUEUES; +} + +bool Player::HasFreeBattlegroundQueueId() +{ + for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE) + return true; + return false; +} + +void Player::RemoveBattlegroundQueueId(BattlegroundQueueTypeId val) +{ + for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + { + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == val) + { + m_bgBattlegroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE; + m_bgBattlegroundQueueID[i].invitedToInstance = 0; + return; + } + } +} + +void Player::SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId) +{ + for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) + m_bgBattlegroundQueueID[i].invitedToInstance = instanceId; +} + +bool Player::IsInvitedForBattlegroundInstance(uint32 instanceId) const +{ + for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) + if (m_bgBattlegroundQueueID[i].invitedToInstance == instanceId) + return true; + return false; +} + bool Player::InArena() const { Battleground* bg = GetBattleground(); @@ -22885,6 +23225,15 @@ void Player::UpdateForQuestWorldObjects() GetSession()->SendPacket(&packet); } +void Player::SetSummonPoint(uint32 mapid, float x, float y, float z) +{ + m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY; + m_summon_mapid = mapid; + m_summon_x = x; + m_summon_y = y; + m_summon_z = z; +} + void Player::SummonIfPossible(bool agree) { if (!agree) @@ -23288,6 +23637,13 @@ void Player::SetClientControl(Unit* target, uint8 allowMove) SetMover(this); } +void Player::SetMover(Unit* target) +{ + m_mover->m_movedPlayer = NULL; + m_mover = target; + m_mover->m_movedPlayer = this; +} + void Player::UpdateZoneDependentAuras(uint32 newZone) { // Some spells applied at enter into zone (with subzones), aura removed in UpdateAreaDependentAuras that called always at zone->area update @@ -23788,6 +24144,12 @@ void Player::InitGlyphsForLevel() SetUInt32Value(PLAYER_GLYPHS_ENABLED, value); } +void Player::SetGlyph(uint8 slot, uint32 glyph) +{ + m_Glyphs[m_activeSpec][slot] = glyph; + SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); +} + bool Player::isTotalImmune() { AuraEffectList const& immune = GetAuraEffectsByType(SPELL_AURA_SCHOOL_IMMUNITY); @@ -23909,6 +24271,22 @@ uint32 Player::GetRuneBaseCooldown(uint8 index) return cooldown; } +void Player::SetRuneCooldown(uint8 index, uint32 cooldown) +{ + m_runes->runes[index].Cooldown = cooldown; + m_runes->SetRuneState(index, (cooldown == 0) ? true : false); +} + +void Player::SetRuneConvertAura(uint8 index, AuraEffect const* aura) +{ + m_runes->runes[index].ConvertAura = aura; +} + +void Player::AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura) +{ + SetRuneConvertAura(index, aura); ConvertRune(index, newType); +} + void Player::RemoveRunesByAuraEffect(AuraEffect const* aura) { for (uint8 i = 0; i < MAX_RUNES; ++i) @@ -24333,6 +24711,12 @@ InventoryResult Player::CanEquipUniqueItem(ItemTemplate const* itemProto, uint8 return EQUIP_ERR_OK; } +void Player::SetFallInformation(uint32 time, float z) +{ + m_lastFallTime = time; + m_lastFallZ = z; +} + void Player::HandleFall(MovementInfo const& movementInfo) { // calculate total z distance of the fall @@ -24719,6 +25103,11 @@ void Player::ResummonPetTemporaryUnSummonedIfAny() m_temporaryUnsummonedPetNumber = 0; } +bool Player::IsPetNeedBeTemporaryUnsummoned() const +{ + return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; +} + bool Player::canSeeSpellClickOn(Creature const* c) const { if (!c->HasFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK)) @@ -25776,6 +26165,39 @@ void Player::SendMovementSetFeatherFall(bool apply) SendDirectMessage(&data); } +float Player::GetCollisionHeight(bool mounted) const +{ + if (mounted) + { + CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID)); + if (!mountDisplayInfo) + return GetCollisionHeight(false); + + CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId); + if (!mountModelData) + return GetCollisionHeight(false); + + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); + ASSERT(displayInfo); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); + ASSERT(modelData); + + float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this + + return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f; + } + else + { + //! Dismounting case - use basic default model data + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); + ASSERT(displayInfo); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); + ASSERT(modelData); + + return modelData->CollisionHeight; + } +} + Guild* Player::GetGuild() { uint32 guildId = GetGuildId(); diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index a7c0cb2e736..a95c81fb6bc 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -28,7 +28,6 @@ #include "QuestDef.h" #include "SpellMgr.h" #include "Unit.h" -#include "Opcodes.h" #include <string> #include <vector> @@ -1073,20 +1072,10 @@ class Player : public Unit, public GridObject<Player> void RemoveFromWorld(); bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0); - bool TeleportTo(WorldLocation const &loc, uint32 options = 0) - { - return TeleportTo(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation(), options); - } + bool TeleportTo(WorldLocation const &loc, uint32 options = 0); bool TeleportToBGEntryPoint(); - void SetSummonPoint(uint32 mapid, float x, float y, float z) - { - m_summon_expire = time(NULL) + MAX_PLAYER_SUMMON_DELAY; - m_summon_mapid = mapid; - m_summon_x = x; - m_summon_y = y; - m_summon_z = z; - } + void SetSummonPoint(uint32 mapid, float x, float y, float z); void SummonIfPossible(bool agree); bool Create(uint32 guidlow, CharacterCreateInfo* createInfo); @@ -1161,14 +1150,7 @@ class Player : public Unit, public GridObject<Player> void setDeathState(DeathState s); // overwrite Unit::setDeathState - void InnEnter (time_t time, uint32 mapid, float x, float y, float z) - { - inn_pos_mapid = mapid; - inn_pos_x = x; - inn_pos_y = y; - inn_pos_z = z; - time_inn_enter = time; - } + void InnEnter(time_t time, uint32 mapid, float x, float y, float z); float GetRestBonus() const { return m_rest_bonus; } void SetRestBonus(float rest_bonus_new); @@ -1213,13 +1195,8 @@ class Player : public Unit, public GridObject<Player> Item* GetItemByEntry(uint32 entry) const; Item* GetItemByPos(uint16 pos) const; Item* GetItemByPos(uint8 bag, uint8 slot) const; + Item* GetUseableItemByPos(uint8 bag, uint8 slot) const; Bag* GetBagByPos(uint8 slot) const; - inline Item* GetUseableItemByPos(uint8 bag, uint8 slot) const //Does additional check for disarmed weapons - { - if (!CanUseAttackType(GetAttackBySlot(slot))) - return NULL; - return GetItemByPos(bag, slot); - } Item* GetWeaponForAttack(WeaponAttackType attackType, bool useable = false) const; Item* GetShield(bool useable = false) const; static uint8 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot @@ -1242,17 +1219,8 @@ class Player : public Unit, public GridObject<Player> bool HasItemOrGemWithLimitCategoryEquipped(uint32 limitCategory, uint32 count, uint8 except_slot = NULL_SLOT) const; InventoryResult CanTakeMoreSimilarItems(Item* pItem) const { return CanTakeMoreSimilarItems(pItem->GetEntry(), pItem->GetCount(), pItem); } InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count) const { return CanTakeMoreSimilarItems(entry, count, NULL); } - InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const - { - return CanStoreItem(bag, slot, dest, item, count, NULL, false, no_space_count); - } - InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const - { - if (!pItem) - return EQUIP_ERR_ITEM_NOT_FOUND; - uint32 count = pItem->GetCount(); - return CanStoreItem(bag, slot, dest, pItem->GetEntry(), count, pItem, swap, NULL); - } + InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = NULL) const; + InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, Item* pItem, bool swap = false) const; InventoryResult CanStoreItems(Item** pItem, int count) const; InventoryResult CanEquipNewItem(uint8 slot, uint16& dest, uint32 item, bool swap) const; InventoryResult CanEquipItem(uint8 slot, uint16& dest, Item* pItem, bool swap, bool not_loading = true) const; @@ -1292,11 +1260,7 @@ class Player : public Unit, public GridObject<Player> void QuickEquipItem(uint16 pos, Item* pItem); void VisualizeItem(uint8 slot, Item* pItem); void SetVisibleItemSlot(uint8 slot, Item* pItem); - Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update) - { - return StoreItem(dest, pItem, update); - } - Item* BankItem(uint16 pos, Item* pItem, bool update); + Item* BankItem(ItemPosCountVec const& dest, Item* pItem, bool update); void RemoveItem(uint8 bag, uint8 slot, bool update); void MoveItemFromInventory(uint8 bag, uint8 slot, bool update); // in trade, auction, guild bank, mail.... @@ -1321,16 +1285,8 @@ class Player : public Unit, public GridObject<Player> void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } uint32 GetArmorProficiency() const { return m_ArmorProficiency; } - bool IsUseEquipedWeapon(bool mainhand) const - { - // disarm applied only to mainhand weapon - return !IsInFeralForm() && (!mainhand || !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISARMED)); - } - bool IsTwoHandUsed() const - { - Item* mainItem = GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND); - return mainItem && mainItem->GetTemplate()->InventoryType == INVTYPE_2HWEAPON && !CanTitanGrip(); - } + bool IsUseEquipedWeapon(bool mainhand) const; + bool IsTwoHandUsed() const; void SendNewItem(Item* item, uint32 count, bool received, bool created, bool broadcast = false); bool BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot); bool _StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot, int32 price, ItemTemplate const* pProto, Creature* pVendor, VendorItem const* crItem, bool bStore); @@ -1434,39 +1390,17 @@ class Player : public Unit, public GridObject<Player> void ResetSeasonalQuestStatus(uint16 event_id); uint16 FindQuestSlot(uint32 quest_id) const; - uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); } - uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); } - uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const { return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16)); } - uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); } - void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0) - { - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, 0); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, 0); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET + 1, 0); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); - } - void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count) - { - uint64 val = GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET); - val &= ~((uint64)0xFFFF << (counter * 16)); - val |= ((uint64)count << (counter * 16)); - SetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET, val); - } - void SetQuestSlotState(uint16 slot, uint32 state) { SetFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); } - void RemoveQuestSlotState(uint16 slot, uint32 state) { RemoveFlag(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET, state); } - void SetQuestSlotTimer(uint16 slot, uint32 timer) { SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET, timer); } - void SwapQuestSlot(uint16 slot1, uint16 slot2) - { - for (int i = 0; i < MAX_QUEST_OFFSET; ++i) - { - uint32 temp1 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i); - uint32 temp2 = GetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i); + uint32 GetQuestSlotQuestId(uint16 slot) const; + uint32 GetQuestSlotState(uint16 slot) const; + uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const; + uint32 GetQuestSlotTime(uint16 slot) const; + void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0); + void SetQuestSlotCounter(uint16 slot, uint8 counter, uint16 count); + void SetQuestSlotState(uint16 slot, uint32 state); + void RemoveQuestSlotState(uint16 slot, uint32 state); + void SetQuestSlotTimer(uint16 slot, uint32 timer); + void SwapQuestSlot(uint16 slot1, uint16 slot2); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot1 + i, temp2); - SetUInt32Value(PLAYER_QUEST_LOG_1_1 + MAX_QUEST_OFFSET * slot2 + i, temp1); - } - } uint16 GetReqKillOrCastCurrentCount(uint32 quest_id, int32 entry); void AreaExploredOrEventHappens(uint32 questId); void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); @@ -1557,28 +1491,14 @@ class Player : public Unit, public GridObject<Player> uint32 GetMoney() const { return GetUInt32Value(PLAYER_FIELD_COINAGE); } bool ModifyMoney(int32 amount, bool sendError = true); bool HasEnoughMoney(uint32 amount) const { return (GetMoney() >= amount); } - bool HasEnoughMoney(int32 amount) const - { - if (amount > 0) - return (GetMoney() >= (uint32) amount); - return true; - } - - void SetMoney(uint32 value) - { - SetUInt32Value(PLAYER_FIELD_COINAGE, value); - MoneyChanged(value); - UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_GOLD_VALUE_OWNED); - } + bool HasEnoughMoney(int32 amount) const; + void SetMoney(uint32 value); RewardedQuestSet const& getRewardedQuests() const { return m_RewardedQuests; } QuestStatusMap& getQuestStatusMap() { return m_QuestStatus; } size_t GetRewardedQuestCount() const { return m_RewardedQuests.size(); } - bool IsQuestRewarded(uint32 quest_id) const - { - return m_RewardedQuests.find(quest_id) != m_RewardedQuests.end(); - } + bool IsQuestRewarded(uint32 quest_id) const; uint64 GetSelection() const { return m_curSelection; } Unit* GetSelectedUnit() const; @@ -1619,29 +1539,11 @@ class Player : public Unit, public GridObject<Player> ItemMap mMitems; //template defined in objectmgr.cpp - Item* GetMItem(uint32 id) - { - ItemMap::const_iterator itr = mMitems.find(id); - return itr != mMitems.end() ? itr->second : NULL; - } - - void AddMItem(Item* it) - { - ASSERT(it); - //ASSERT deleted, because items can be added before loading - mMitems[it->GetGUIDLow()] = it; - } + Item* GetMItem(uint32 id); + void AddMItem(Item* it); + bool RemoveMItem(uint32 id); - bool RemoveMItem(uint32 id) - { - return mMitems.erase(id) ? true : false; - } - - void SendOnCancelExpectedVehicleRideAura() - { - WorldPacket data(SMSG_ON_CANCEL_EXPECTED_RIDE_VEHICLE_AURA, 0); - GetSession()->SendPacket(&data); - } + void SendOnCancelExpectedVehicleRideAura(); void PetSpellInitialize(); void CharmSpellInitialize(); void PossessSpellInitialize(); @@ -1695,11 +1597,7 @@ class Player : public Unit, public GridObject<Player> void InitGlyphsForLevel(); void SetGlyphSlot(uint8 slot, uint32 slottype) { SetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot, slottype); } uint32 GetGlyphSlot(uint8 slot) { return GetUInt32Value(PLAYER_FIELD_GLYPH_SLOTS_1 + slot); } - void SetGlyph(uint8 slot, uint32 glyph) - { - m_Glyphs[m_activeSpec][slot] = glyph; - SetUInt32Value(PLAYER_FIELD_GLYPHS_1 + slot, glyph); - } + void SetGlyph(uint8 slot, uint32 glyph); uint32 GetGlyph(uint8 slot) { return m_Glyphs[m_activeSpec][slot]; } uint32 GetFreePrimaryProfessionPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS2); } @@ -1722,17 +1620,8 @@ class Player : public Unit, public GridObject<Player> static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check static uint32 const infinityCooldownDelayCheck = MONTH/2; - bool HasSpellCooldown(uint32 spell_id) const - { - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - return itr != m_spellCooldowns.end() && itr->second.end > time(NULL); - } - uint32 GetSpellCooldownDelay(uint32 spell_id) const - { - SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id); - time_t t = time(NULL); - return uint32(itr != m_spellCooldowns.end() && itr->second.end > t ? itr->second.end - t : 0); - } + bool HasSpellCooldown(uint32 spell_id) const; + uint32 GetSpellCooldownDelay(uint32 spell_id) const; void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false); void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time); void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true); @@ -1751,29 +1640,14 @@ class Player : public Unit, public GridObject<Player> void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } void UpdatePotionCooldown(Spell* spell = NULL); - void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) - { - m_resurrectGUID = guid; - m_resurrectMap = mapId; - m_resurrectX = X; - m_resurrectY = Y; - m_resurrectZ = Z; - m_resurrectHealth = health; - m_resurrectMana = mana; - } + void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana); void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); } bool isRessurectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } bool isRessurectRequested() const { return m_resurrectGUID != 0; } void ResurectUsingRequestData(); - uint8 getCinematic() - { - return m_cinematic; - } - void setCinematic(uint8 cine) - { - m_cinematic = cine; - } + uint8 getCinematic() { return m_cinematic; } + void setCinematic(uint8 cine) { m_cinematic = cine; } ActionButton* addActionButton(uint8 button, uint32 action, uint8 type); void removeActionButton(uint8 button); @@ -1784,12 +1658,7 @@ class Player : public Unit, public GridObject<Player> PvPInfo pvpInfo; void UpdatePvPState(bool onlyFFA = false); - void SetPvP(bool state) - { - Unit::SetPvP(state); - for (ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr) - (*itr)->SetPvP(state); - } + void SetPvP(bool state); void UpdatePvP(bool state, bool override=false); void UpdateZone(uint32 newZone, uint32 newArea); void UpdateArea(uint32 newArea); @@ -1801,12 +1670,7 @@ class Player : public Unit, public GridObject<Player> void UpdatePvPFlag(time_t currTime); void UpdateContestedPvP(uint32 currTime); void SetContestedPvPTimer(uint32 newTime) {m_contestedPvPTimer = newTime;} - void ResetContestedPvP() - { - ClearUnitState(UNIT_STATE_ATTACK_PLAYER); - RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP); - m_contestedPvPTimer = 0; - } + void ResetContestedPvP(); /** todo: -maybe move UpdateDuelFlag+DuelComplete to independent DuelHandler.. **/ DuelInfo* duel; @@ -1817,7 +1681,7 @@ class Player : public Unit, public GridObject<Player> bool IsGroupVisibleFor(Player const* p) const; bool IsInSameGroupWith(Player const* p) const; - bool IsInSameRaidWith(Player const* p) const { return p == this || (GetGroup() != NULL && GetGroup() == p->GetGroup()); } + bool IsInSameRaidWith(Player const* p) const; void UninviteFromGroup(); static void RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, uint64 kicker = 0, const char* reason = NULL); void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } @@ -1835,15 +1699,8 @@ class Player : public Unit, public GridObject<Player> static void RemovePetitionsAndSigns(uint64 guid, uint32 type); // Arena Team - void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type) - { - SetArenaTeamInfoField(slot, ARENA_TEAM_ID, ArenaTeamId); - SetArenaTeamInfoField(slot, ARENA_TEAM_TYPE, type); - } - void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value) - { - SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value); - } + void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type); + void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value); static uint32 GetArenaTeamIdFromDB(uint64 guid, uint8 slot); static void LeaveAllArenaTeams(uint64 guid); uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); } @@ -1980,13 +1837,8 @@ class Player : public Unit, public GridObject<Player> uint32 DurabilityRepair(uint16 pos, bool cost, float discountMod, bool guildBank); void UpdateMirrorTimers(); - void StopMirrorTimers() - { - StopMirrorTimer(FATIGUE_TIMER); - StopMirrorTimer(BREATH_TIMER); - StopMirrorTimer(FIRE_TIMER); - } - bool IsMirrorTimerActive(MirrorTimerType type) { return m_MirrorTimer[type] == getMaxTimer(type); } + void StopMirrorTimers(); + bool IsMirrorTimerActive(MirrorTimerType type); void SetMovement(PlayerMovementType pType); @@ -2152,93 +2004,24 @@ class Player : public Unit, public GridObject<Player> BattlegroundTypeId GetBattlegroundTypeId() const { return m_bgData.bgTypeID; } Battleground* GetBattleground() const; - bool InBattlegroundQueue() const - { - for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].bgQueueTypeId != BATTLEGROUND_QUEUE_NONE) - return true; - return false; - } + bool InBattlegroundQueue() const; - BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const { return m_bgBattlegroundQueueID[index].bgQueueTypeId; } - uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const - { - for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - return i; - return PLAYER_MAX_BATTLEGROUND_QUEUES; - } - bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const - { - for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - return m_bgBattlegroundQueueID[i].invitedToInstance != 0; - return false; - } - bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const - { - return GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES; - } + BattlegroundQueueTypeId GetBattlegroundQueueTypeId(uint32 index) const; + uint32 GetBattlegroundQueueIndex(BattlegroundQueueTypeId bgQueueTypeId) const; + bool IsInvitedForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; + bool InBattlegroundQueueForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId) const; - void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId) - { - m_bgData.bgInstanceID = val; - m_bgData.bgTypeID = bgTypeId; - } - uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val) - { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - { - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE || m_bgBattlegroundQueueID[i].bgQueueTypeId == val) - { - m_bgBattlegroundQueueID[i].bgQueueTypeId = val; - m_bgBattlegroundQueueID[i].invitedToInstance = 0; - return i; - } - } - return PLAYER_MAX_BATTLEGROUND_QUEUES; - } - bool HasFreeBattlegroundQueueId() - { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == BATTLEGROUND_QUEUE_NONE) - return true; - return false; - } - void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val) - { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - { - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == val) - { - m_bgBattlegroundQueueID[i].bgQueueTypeId = BATTLEGROUND_QUEUE_NONE; - m_bgBattlegroundQueueID[i].invitedToInstance = 0; - return; - } - } - } - void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId) - { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].bgQueueTypeId == bgQueueTypeId) - m_bgBattlegroundQueueID[i].invitedToInstance = instanceId; - } - bool IsInvitedForBattlegroundInstance(uint32 instanceId) const - { - for (uint8 i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i) - if (m_bgBattlegroundQueueID[i].invitedToInstance == instanceId) - return true; - return false; - } + void SetBattlegroundId(uint32 val, BattlegroundTypeId bgTypeId); + uint32 AddBattlegroundQueueId(BattlegroundQueueTypeId val); + bool HasFreeBattlegroundQueueId(); + void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val); + void SetInviteForBattlegroundQueueType(BattlegroundQueueTypeId bgQueueTypeId, uint32 instanceId); + bool IsInvitedForBattlegroundInstance(uint32 instanceId) const; WorldLocation const& GetBattlegroundEntryPoint() const { return m_bgData.joinPos; } void SetBattlegroundEntryPoint(); - void SetBGTeam(uint32 team) - { - m_bgData.bgTeam = team; - SetByteValue(PLAYER_BYTES_3, 3, uint8(team == ALLIANCE ? 1 : 0)); - } - uint32 GetBGTeam() const { return m_bgData.bgTeam ? m_bgData.bgTeam : GetTeam(); } + void SetBGTeam(uint32 team); + uint32 GetBGTeam() const; void LeaveBattleground(bool teleportToEntryPoint = true); bool CanJoinToBattleground(Battleground const* bg) const; @@ -2293,23 +2076,14 @@ class Player : public Unit, public GridObject<Player> void UpdateFallInformationIfNeed(MovementInfo const& minfo, uint16 opcode); Unit* m_mover; WorldObject* m_seer; - void SetFallInformation(uint32 time, float z) - { - m_lastFallTime = time; - m_lastFallZ = z; - } + void SetFallInformation(uint32 time, float z); void HandleFall(MovementInfo const& movementInfo); bool IsKnowHowFlyIn(uint32 mapid, uint32 zone) const; void SetClientControl(Unit* target, uint8 allowMove); - void SetMover(Unit* target) - { - m_mover->m_movedPlayer = NULL; - m_mover = target; - m_mover->m_movedPlayer = this; - } + void SetMover(Unit* target); void SetSeer(WorldObject* target) { m_seer = target; } void SetViewpoint(WorldObject* target, bool apply); @@ -2343,7 +2117,7 @@ class Player : public Unit, public GridObject<Player> typedef std::set<uint64> ClientGUIDs; ClientGUIDs m_clientGUIDs; - bool HaveAtClient(WorldObject const* u) const { return u == this || m_clientGUIDs.find(u->GetGUID()) != m_clientGUIDs.end(); } + bool HaveAtClient(WorldObject const* u) const; bool IsNeverVisible() const; @@ -2375,7 +2149,7 @@ class Player : public Unit, public GridObject<Player> void SetTemporaryUnsummonedPetNumber(uint32 petnumber) { m_temporaryUnsummonedPetNumber = petnumber; } void UnsummonPetTemporaryIfAny(); void ResummonPetTemporaryUnSummonedIfAny(); - bool IsPetNeedBeTemporaryUnsummoned() const { return !IsInWorld() || !isAlive() || IsMounted() /*+in flight*/; } + bool IsPetNeedBeTemporaryUnsummoned() const; void SendCinematicStart(uint32 CinematicSequenceId); void SendMovieStart(uint32 MovieId); @@ -2399,7 +2173,7 @@ class Player : public Unit, public GridObject<Player> void UnbindInstance(BoundInstancesMap::iterator &itr, Difficulty difficulty, bool unload = false); InstancePlayerBind* BindToInstance(InstanceSave* save, bool permanent, bool load = false); void BindToInstance(); - void SetPendingBind(uint32 instanceId, uint32 bindTimer) { _pendingBindId = instanceId; _pendingBindTimer = bindTimer; } + void SetPendingBind(uint32 instanceId, uint32 bindTimer); bool HasPendingBind() const { return _pendingBindId > 0; } void SendRaidInfo(); void SendSavedInstances(); @@ -2407,12 +2181,7 @@ class Player : public Unit, public GridObject<Player> bool Satisfy(AccessRequirement const* ar, uint32 target_map, bool report = false); bool CheckInstanceLoginValid(); bool CheckInstanceCount(uint32 instanceId) const; - - void AddInstanceEnterTime(uint32 instanceId, time_t enterTime) - { - if (_instanceResetTimes.find(instanceId) == _instanceResetTimes.end()) - _instanceResetTimes.insert(InstanceTimeMap::value_type(instanceId, enterTime + HOUR)); - } + void AddInstanceEnterTime(uint32 instanceId, time_t enterTime); // last used pet number (for BG's) uint32 GetLastPetNumber() const { return m_lastpetnumber; } @@ -2466,9 +2235,9 @@ class Player : public Unit, public GridObject<Player> void SetLastUsedRune(RuneType type) { m_runes->lastUsedRune = type; } void SetBaseRune(uint8 index, RuneType baseRune) { m_runes->runes[index].BaseRune = baseRune; } void SetCurrentRune(uint8 index, RuneType currentRune) { m_runes->runes[index].CurrentRune = currentRune; } - void SetRuneCooldown(uint8 index, uint32 cooldown) { m_runes->runes[index].Cooldown = cooldown; m_runes->SetRuneState(index, (cooldown == 0) ? true : false); } - void SetRuneConvertAura(uint8 index, AuraEffect const* aura) { m_runes->runes[index].ConvertAura = aura; } - void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura) { SetRuneConvertAura(index, aura); ConvertRune(index, newType); } + void SetRuneCooldown(uint8 index, uint32 cooldown); + void SetRuneConvertAura(uint8 index, AuraEffect const* aura); + void AddRuneByAuraEffect(uint8 index, RuneType newType, AuraEffect const* aura); void RemoveRunesByAuraEffect(AuraEffect const* aura); void RestoreBaseRune(uint8 index); void ConvertRune(uint8 index, RuneType newType); @@ -2516,38 +2285,7 @@ class Player : public Unit, public GridObject<Player> bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } //! Return collision height sent to client - float GetCollisionHeight(bool mounted) - { - if (mounted) - { - CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID)); - if (!mountDisplayInfo) - return GetCollisionHeight(false); - - CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelId); - if (!mountModelData) - return GetCollisionHeight(false); - - CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); - ASSERT(displayInfo); - CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); - ASSERT(modelData); - - float scaleMod = GetFloatValue(OBJECT_FIELD_SCALE_X); // 99% sure about this - - return scaleMod * mountModelData->MountHeight + modelData->CollisionHeight * 0.5f; - } - else - { - //! Dismounting case - use basic default model data - CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.LookupEntry(GetNativeDisplayId()); - ASSERT(displayInfo); - CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(displayInfo->ModelId); - ASSERT(modelData); - - return modelData->CollisionHeight; - } - } + float GetCollisionHeight(bool mounted) const; protected: // Gamemaster whisper whitelist @@ -2717,8 +2455,6 @@ class Player : public Unit, public GridObject<Player> int32 m_spellPenetrationItemMod; SpellModList m_spellMods[MAX_SPELLMOD]; - //uint32 m_pad; -// Spell* m_spellModTakingSpell; // Spell for which charges are dropped in spell::finish EnchantDurationList m_enchantDuration; ItemDurationList m_itemDuration; @@ -2833,12 +2569,7 @@ class Player : public Unit, public GridObject<Player> void SetCanDelayTeleport(bool setting) { m_bCanDelayTeleport = setting; } bool IsHasDelayedTeleport() const { return m_bHasDelayedTeleport; } void SetDelayedTeleportFlag(bool setting) { m_bHasDelayedTeleport = setting; } - - void ScheduleDelayedOperation(uint32 operation) - { - if (operation < DELAYED_END) - m_DelayedOperations |= operation; - } + void ScheduleDelayedOperation(uint32 operation) { if (operation < DELAYED_END) m_DelayedOperations |= operation; } MapReference m_mapRef; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 857ceba8e0c..edf32d3d48d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -493,9 +493,9 @@ void Unit::GetRandomContactPoint(const Unit* obj, float &x, float &y, float &z, , GetAngle(obj) + (attacker_number ? (static_cast<float>(M_PI/2) - static_cast<float>(M_PI) * (float)rand_norm()) * float(attacker_number) / combat_reach * 0.3f : 0)); } -AuraApplication * Unit::GetVisibleAura(uint8 slot) +AuraApplication * Unit::GetVisibleAura(uint8 slot) const { - VisibleAuraMap::iterator itr = m_visibleAuras.find(slot); + VisibleAuraMap::const_iterator itr = m_visibleAuras.find(slot); if (itr != m_visibleAuras.end()) return itr->second; return 0; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 227b40bfd2e..5684a7bfa37 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1893,7 +1893,7 @@ class Unit : public WorldObject HostileRefManager& getHostileRefManager() { return m_HostileRefManager; } VisibleAuraMap const* GetVisibleAuras() { return &m_visibleAuras; } - AuraApplication * GetVisibleAura(uint8 slot); + AuraApplication * GetVisibleAura(uint8 slot) const; void SetVisibleAura(uint8 slot, AuraApplication * aur); void RemoveVisibleAura(uint8 slot); @@ -1901,9 +1901,9 @@ class Unit : public WorldObject void AddInterruptMask(uint32 mask) { m_interruptMask |= mask; } void UpdateInterruptMask(); - uint32 GetDisplayId() { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } + uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); } void SetDisplayId(uint32 modelId); - uint32 GetNativeDisplayId() { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } + uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); } void RestoreDisplayId(); void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); } void setTransForm(uint32 spellid) { m_transform = spellid;} |