diff options
| author | Shauren <shauren.trinity@gmail.com> | 2014-09-14 16:14:12 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2014-09-14 16:14:12 +0200 |
| commit | a0e50ea35fca61447bf07fc45d93c98234ba59f7 (patch) | |
| tree | b4ee69a63866f42e466a3c03fc031ce0710ac762 /src/server/game/Entities/Player | |
| parent | ce67a097bf3c0c3241f4441a808e32639ddbaafb (diff) | |
Core/Entities: Use ObjectGuid class in game project
Diffstat (limited to 'src/server/game/Entities/Player')
| -rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 387 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/Player.h | 131 | ||||
| -rw-r--r-- | src/server/game/Entities/Player/SocialMgr.cpp | 6 |
3 files changed, 261 insertions, 263 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index df306120a37..018282cb6bc 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -300,7 +300,7 @@ Item* TradeData::GetItem(TradeSlots slot) const return m_items[slot] ? m_player->GetItemByGuid(m_items[slot]) : NULL; } -bool TradeData::HasItem(uint64 itemGuid) const +bool TradeData::HasItem(ObjectGuid itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == itemGuid) @@ -309,7 +309,7 @@ bool TradeData::HasItem(uint64 itemGuid) const return false; } -TradeSlots TradeData::GetTradeSlotForItem(uint64 itemGuid) const +TradeSlots TradeData::GetTradeSlotForItem(ObjectGuid itemGuid) const { for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i) if (m_items[i] == itemGuid) @@ -325,7 +325,9 @@ Item* TradeData::GetSpellCastItem() const void TradeData::SetItem(TradeSlots slot, Item* item) { - uint64 itemGuid = item ? item->GetGUID() : 0; + ObjectGuid itemGuid; + if (item) + itemGuid = item->GetGUID(); if (m_items[slot] == itemGuid) return; @@ -347,7 +349,7 @@ void TradeData::SetItem(TradeSlots slot, Item* item) void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/) { - uint64 itemGuid = castItem ? castItem->GetGUID() : 0; + ObjectGuid itemGuid = castItem ? castItem->GetGUID() : ObjectGuid::Empty; if (m_spell == spell_id && m_spellCastItem == itemGuid) return; @@ -457,7 +459,7 @@ KillRewarder::KillRewarder(Player* killer, Unit* victim, bool isBattleGround) : if (victim->GetTypeId() == TYPEID_PLAYER) _isPvP = true; // or if its owned by player and its not a vehicle - else if (IS_PLAYER_GUID(victim->GetCharmerOrOwnerGUID())) + else if (victim->GetCharmerOrOwnerGUID().IsPlayer()) _isPvP = !victim->IsVehicle(); _InitGroupData(); @@ -666,7 +668,6 @@ Player::Player(WorldSession* session): Unit(true) m_session = session; - m_divider = 0; m_ingametime = 0; m_ExtraFlags = 0; @@ -678,9 +679,6 @@ Player::Player(WorldSession* session): Unit(true) if (!GetSession()->HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS)) SetAcceptWhispers(true); - m_lootGuid = 0; - - m_comboTarget = 0; m_comboPoints = 0; m_usedTalentCount = 0; @@ -775,13 +773,13 @@ Player::Player(WorldSession* session): Unit(true) m_lastpetnumber = 0; ////////////////////Rest System///////////////////// - time_inn_enter=0; - inn_pos_mapid=0; - inn_pos_x=0; - inn_pos_y=0; - inn_pos_z=0; - m_rest_bonus=0; - rest_type=REST_TYPE_NO; + time_inn_enter = 0; + inn_pos_mapid = 0; + inn_pos_x = 0.0f; + inn_pos_y = 0.0f; + inn_pos_z = 0.0f; + m_rest_bonus = 0; + rest_type = REST_TYPE_NO; ////////////////////Rest System///////////////////// m_mailsLoaded = false; @@ -1948,7 +1946,7 @@ bool Player::BuildEnumData(PreparedQueryResult result, WorldPacket* data) return false; } - *data << uint64(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + *data << ObjectGuid(HIGHGUID_PLAYER, guid); *data << fields[1].GetString(); // name *data << uint8(plrRace); // race *data << uint8(plrClass); // class @@ -2169,7 +2167,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati // The player was ported to another map and loses the duel immediately. // We have to perform this check before the teleport, otherwise the // ObjectAccessor won't find the flag. - if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER))) + if (duel && GetMapId() != mapid && GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER))) DuelComplete(DUEL_FLED); if (GetMapId() == mapid) @@ -2252,7 +2250,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati return true; } - SetSelection(0); + SetSelection(ObjectGuid::Empty); CombatStop(); @@ -2706,7 +2704,7 @@ bool Player::CanInteractWithQuestGiver(Object* questGiver) return false; } -Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask) +Creature* Player::GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask) { // unit checks if (!guid) @@ -2757,7 +2755,7 @@ Creature* Player::GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask) return creature; } -GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const +GameObject* Player::GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const { if (GameObject* go = GetMap()->GetGameObject(guid)) { @@ -2925,7 +2923,7 @@ void Player::UninviteFromGroup() } } -void Player::RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, uint64 kicker /* = 0 */, const char* reason /* = NULL */) +void Player::RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method /* = GROUP_REMOVEMETHOD_DEFAULT*/, ObjectGuid kicker /* = ObjectGuid::Empty */, const char* reason /* = NULL */) { if (!group) return; @@ -2936,7 +2934,7 @@ void Player::RemoveFromGroup(Group* group, uint64 guid, RemoveMethod method /* = void Player::SendLogXPGain(uint32 GivenXP, Unit* victim, uint32 BonusXP, bool recruitAFriend, float /*group_rate*/) { WorldPacket data(SMSG_LOG_XPGAIN, 21); // guess size? - data << uint64(victim ? victim->GetGUID() : 0); // guid + data << uint64(victim ? victim->GetGUID() : ObjectGuid::Empty); data << uint32(GivenXP + BonusXP); // given experience data << uint8(victim ? 0 : 1); // 00-kill_xp type, 01-non_kill_xp type @@ -4621,19 +4619,19 @@ TrainerSpellState Player::GetTrainerSpellState(TrainerSpell const* trainer_spell * @param updateRealmChars when this flag is set, the amount of characters on that realm will be updated in the realmlist * @param deleteFinally if this flag is set, the config option will be ignored and the character will be permanently removed from the database */ -void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally) +void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars, bool deleteFinally) { // Avoid realm-update for non-existing account if (accountId == 0) updateRealmChars = false; // Convert guid to low GUID for CharacterNameData, but also other methods on success - uint32 guid = GUID_LOPART(playerguid); + uint32 guid = playerguid.GetCounter(); uint32 charDelete_method = sWorld->getIntConfig(CONFIG_CHARDELETE_METHOD); if (deleteFinally) charDelete_method = CHAR_DELETE_REMOVE; - else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(guid)) // To avoid a query, we select loaded data. If it doesn't exist, return. + else if (CharacterNameData const* nameData = sWorld->GetCharacterNameData(playerguid)) // To avoid a query, we select loaded data. If it doesn't exist, return. { // Define the required variables uint32 charDelete_minLvl = sWorld->getIntConfig(nameData->m_class != CLASS_DEATH_KNIGHT ? CONFIG_CHARDELETE_MIN_LEVEL : CONFIG_CHARDELETE_HEROIC_MIN_LEVEL); @@ -4650,7 +4648,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC if (uint32 guildId = GetGuildIdFromDB(playerguid)) if (Guild* guild = sGuildMgr->GetGuildById(guildId)) - guild->DeleteMember(guid, false, false, true); + guild->DeleteMember(playerguid, false, false, true); // remove from arena teams LeaveAllArenaTeams(playerguid); @@ -4739,7 +4737,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC } Item* pItem = NewItemOrBag(itemProto); - if (!pItem->LoadFromDB(item_guidlow, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER), itemFields, item_template)) + if (!pItem->LoadFromDB(item_guidlow, playerguid, itemFields, item_template)) { pItem->FSetState(ITEM_REMOVED); pItem->SaveToDB(trans); // it also deletes item object! @@ -4756,7 +4754,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC stmt->setUInt32(0, mail_id); trans->Append(stmt); - uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + uint32 pl_account = sObjectMgr->GetPlayerAccountIdByGUID(playerguid); draft.AddMoney(money).SendReturnToSender(pl_account, guid, sender, trans); } @@ -4787,7 +4785,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC { do { - if (Player* pFriend = ObjectAccessor::FindPlayer(MAKE_NEW_GUID((*resultFriends)[0].GetUInt32(), 0, HIGHGUID_PLAYER))) + if (Player* pFriend = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, 0, (*resultFriends)[0].GetUInt32()))) { if (pFriend->IsInWorld()) { @@ -4960,7 +4958,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC if (updateRealmChars) sWorld->UpdateRealmCharCount(accountId); - sWorld->DeleteCharacterNameData(guid); + sWorld->DeleteCharacterNameData(playerguid); } /** @@ -4998,7 +4996,7 @@ void Player::DeleteOldCharacters(uint32 keepDays) do { Field* fields = result->Fetch(); - Player::DeleteFromDB(fields[0].GetUInt32(), fields[1].GetUInt32(), true, true); + Player::DeleteFromDB(ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()), fields[1].GetUInt32(), true, true); } while (result->NextRow()); } @@ -6627,13 +6625,13 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) { if (button >= MAX_ACTION_BUTTONS) { - TC_LOG_ERROR("entities.player", "Action %u not added into button %u for player %s (GUID: %u): button must be < %u", action, button, GetName().c_str(), GUID_LOPART(GetGUID()), MAX_ACTION_BUTTONS ); + TC_LOG_ERROR("entities.player", "Action %u not added into button %u for player %s (GUID: %u): button must be < %u", action, button, GetName().c_str(), GetGUIDLow(), MAX_ACTION_BUTTONS ); return false; } if (action >= MAX_ACTION_BUTTON_ACTION_VALUE) { - TC_LOG_ERROR("entities.player", "Action %u not added into button %u for player %s (GUID: %u): action must be < %u", action, button, GetName().c_str(), GUID_LOPART(GetGUID()), MAX_ACTION_BUTTON_ACTION_VALUE); + TC_LOG_ERROR("entities.player", "Action %u not added into button %u for player %s (GUID: %u): action must be < %u", action, button, GetName().c_str(), GetGUIDLow(), MAX_ACTION_BUTTON_ACTION_VALUE); return false; } @@ -6642,20 +6640,20 @@ bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) case ACTION_BUTTON_SPELL: if (!sSpellMgr->GetSpellInfo(action)) { - TC_LOG_ERROR("entities.player", "Spell action %u not added into button %u for player %s (GUID: %u): spell not exist", action, button, GetName().c_str(), GUID_LOPART(GetGUID())); + TC_LOG_ERROR("entities.player", "Spell action %u not added into button %u for player %s (GUID: %u): spell not exist", action, button, GetName().c_str(), GetGUIDLow()); return false; } if (!HasSpell(action)) { - TC_LOG_ERROR("entities.player", "Spell action %u not added into button %u for player %s (GUID: %u): player don't known this spell", action, button, GetName().c_str(), GUID_LOPART(GetGUID())); + TC_LOG_ERROR("entities.player", "Spell action %u not added into button %u for player %s (GUID: %u): player don't known this spell", action, button, GetName().c_str(), GetGUIDLow()); return false; } break; case ACTION_BUTTON_ITEM: if (!sObjectMgr->GetItemTemplate(action)) { - TC_LOG_ERROR("entities.player", "Item action %u not added into button %u for player %s (GUID: %u): item not exist", action, button, GetName().c_str(), GUID_LOPART(GetGUID())); + TC_LOG_ERROR("entities.player", "Item action %u not added into button %u for player %s (GUID: %u): item not exist", action, button, GetName().c_str(), GetGUIDLow()); return false; } break; @@ -7131,7 +7129,7 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto if (HasAura(SPELL_AURA_PLAYER_INACTIVE)) return false; - uint64 victim_guid = 0; + ObjectGuid victim_guid; uint32 victim_rank = 0; // need call before fields update to have chance move yesterday data to appropriate fields before today data change. @@ -7176,13 +7174,13 @@ bool Player::RewardHonor(Unit* victim, uint32 groupsize, int32 honor, bool pvpto // title[15..28] -> rank[5..18] // title[other] -> 0 if (victim_title == 0) - victim_guid = 0; // Don't show HK: <rank> message, only log. + victim_guid.Clear(); // Don't show HK: <rank> message, only log. else if (victim_title < 15) victim_rank = victim_title + 4; else if (victim_title < 29) victim_rank = victim_title - 14 + 4; else - victim_guid = 0; // Don't show HK: <rank> message, only log. + victim_guid.Clear(); // Don't show HK: <rank> message, only log. honor_f = std::ceil(Trinity::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey)); @@ -7318,10 +7316,10 @@ void Player::ModifyArenaPoints(int32 value, SQLTransaction trans) } } -uint32 Player::GetGuildIdFromDB(uint64 guid) +uint32 Player::GetGuildIdFromDB(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -7331,10 +7329,10 @@ uint32 Player::GetGuildIdFromDB(uint64 guid) return id; } -uint8 Player::GetRankFromDB(uint64 guid) +uint8 Player::GetRankFromDB(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) @@ -7356,10 +7354,10 @@ void Player::SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 va SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + type, value); } -uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) +uint32 Player::GetArenaTeamIdFromDB(ObjectGuid guid, uint8 type) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENA_TEAM_ID_BY_PLAYER_GUID); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, type); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -7370,9 +7368,9 @@ uint32 Player::GetArenaTeamIdFromDB(uint64 guid, uint8 type) return id; } -uint32 Player::GetZoneIdFromDB(uint64 guid) +uint32 Player::GetZoneIdFromDB(ObjectGuid guid) { - uint32 guidLow = GUID_LOPART(guid); + uint32 guidLow = guid.GetCounter(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_ZONE); stmt->setUInt32(0, guidLow); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -7416,10 +7414,10 @@ uint32 Player::GetZoneIdFromDB(uint64 guid) return zone; } -uint32 Player::GetLevelFromDB(uint64 guid) +uint32 Player::GetLevelFromDB(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_LEVEL); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -7583,7 +7581,7 @@ void Player::CheckDuelDistance(time_t currTime) if (!duel) return; - uint64 duelFlagGUID = GetUInt64Value(PLAYER_DUEL_ARBITER); + ObjectGuid duelFlagGUID = GetGuidValue(PLAYER_DUEL_ARBITER); GameObject* obj = GetMap()->GetGameObject(duelFlagGUID); if (!obj) return; @@ -7683,7 +7681,7 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->CastSpell(duel->opponent, 52852, true); //Remove Duel Flag object - GameObject* obj = GetMap()->GetGameObject(GetUInt64Value(PLAYER_DUEL_ARBITER)); + GameObject* obj = GetMap()->GetGameObject(GetGuidValue(PLAYER_DUEL_ARBITER)); if (obj) duel->initiator->RemoveGameObject(obj, true); @@ -7720,9 +7718,9 @@ void Player::DuelComplete(DuelCompleteType type) duel->opponent->ClearComboPoints(); //cleanups - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); SetUInt32Value(PLAYER_DUEL_TEAM, 0); - duel->opponent->SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + duel->opponent->SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); duel->opponent->SetUInt32Value(PLAYER_DUEL_TEAM, 0); delete duel->opponent->duel; @@ -8728,23 +8726,23 @@ void Player::RemovedInsignia(Player* looterPlr) looterPlr->SendLoot(bones->GetGUID(), LOOT_INSIGNIA); } -void Player::SendLootRelease(uint64 guid) +void Player::SendLootRelease(ObjectGuid guid) { WorldPacket data(SMSG_LOOT_RELEASE_RESPONSE, (8+1)); data << uint64(guid) << uint8(1); SendDirectMessage(&data); } -void Player::SendLoot(uint64 guid, LootType loot_type) +void Player::SendLoot(ObjectGuid guid, LootType loot_type) { - if (uint64 lguid = GetLootGUID()) + if (ObjectGuid lguid = GetLootGUID()) m_session->DoLootRelease(lguid); Loot* loot = 0; PermissionTypes permission = ALL_PERMISSION; TC_LOG_DEBUG("loot", "Player::SendLoot"); - if (IS_GAMEOBJECT_GUID(guid)) + if (guid.IsGameObject()) { TC_LOG_DEBUG("loot", "IS_GAMEOBJECT_GUID(guid)"); GameObject* go = GetMap()->GetGameObject(guid); @@ -8841,7 +8839,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) permission = ALL_PERMISSION; } } - else if (IS_ITEM_GUID(guid)) + else if (guid.IsItem()) { Item* item = GetItemByGuid(guid); @@ -8886,7 +8884,7 @@ void Player::SendLoot(uint64 guid, LootType loot_type) } } } - else if (IS_CORPSE_GUID(guid)) // remove insignia + else if (guid.IsCorpse()) // remove insignia { Corpse* bones = ObjectAccessor::GetCorpse(*this, guid); @@ -9066,11 +9064,11 @@ void Player::SendLoot(uint64 guid, LootType loot_type) else SendLootError(GetLootGUID(), LOOT_ERROR_DIDNT_KILL); - if (loot_type == LOOT_CORPSE && !IS_ITEM_GUID(guid)) + if (loot_type == LOOT_CORPSE && !guid.IsItem()) SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING); } -void Player::SendLootError(uint64 guid, LootError error) +void Player::SendLootError(ObjectGuid guid, LootError error) { WorldPacket data(SMSG_LOOT_RESPONSE, 10); data << uint64(guid); @@ -9762,14 +9760,14 @@ uint32 Player::GetXPRestBonus(uint32 xp) return rested_bonus; } -void Player::SetBindPoint(uint64 guid) +void Player::SetBindPoint(ObjectGuid guid) { WorldPacket data(SMSG_BINDER_CONFIRM, 8); data << uint64(guid); GetSession()->SendPacket(&data); } -void Player::SendTalentWipeConfirm(uint64 guid) +void Player::SendTalentWipeConfirm(ObjectGuid guid) { WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4)); data << uint64(guid); @@ -10160,7 +10158,7 @@ uint32 Player::GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipIte return count; } -Item* Player::GetItemByGuid(uint64 guid) const +Item* Player::GetItemByGuid(ObjectGuid guid) const { for (uint8 i = EQUIPMENT_SLOT_START; i < INVENTORY_SLOT_ITEM_END; ++i) if (Item* pItem = GetItemByPos(INVENTORY_SLOT_BAG_0, i)) @@ -12250,9 +12248,9 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool if (!pBag) { m_items[slot] = pItem; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetGUID()); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID()); pItem->SetSlot(slot); pItem->SetContainer(NULL); @@ -12497,9 +12495,9 @@ void Player::VisualizeItem(uint8 slot, Item* pItem) TC_LOG_DEBUG("entities.player.items", "STORAGE: EquipItem slot = %u, item = %u", slot, pItem->GetEntry()); m_items[slot] = pItem; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, GetGUID()); - pItem->SetUInt64Value(ITEM_FIELD_OWNER, GetGUID()); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), pItem->GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, GetGUID()); + pItem->SetGuidValue(ITEM_FIELD_OWNER, GetGUID()); pItem->SetSlot(slot); pItem->SetContainer(NULL); @@ -12579,7 +12577,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) } m_items[slot] = NULL; - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); if (slot < EQUIPMENT_SLOT_END) SetVisibleItemSlot(slot, NULL); @@ -12587,7 +12585,7 @@ void Player::RemoveItem(uint8 bag, uint8 slot, bool update) else if (Bag* pBag = GetBagByPos(bag)) pBag->RemoveItem(slot, update); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty); // pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0); not clear owner at remove (it will be set at store). This used in mail and auction code pItem->SetSlot(NULL_SLOT); if (IsInWorld() && update) @@ -12676,7 +12674,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) if (bag == INVENTORY_SLOT_BAG_0) { - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); // equipment and equipped bags can have applied bonuses if (slot < INVENTORY_SLOT_BAG_END) @@ -12733,7 +12731,7 @@ void Player::DestroyItem(uint8 bag, uint8 slot, bool update) } //pItem->SetOwnerGUID(0); - pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0); + pItem->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty); pItem->SetSlot(NULL_SLOT); pItem->SetState(ITEM_REMOVED, this); } @@ -13537,7 +13535,7 @@ void Player::AddItemToBuyBackSlot(Item* pItem) uint32 etime = uint32(base - m_logintime + (30 * 3600)); uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID()); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), pItem->GetGUID()); if (ItemTemplate const* proto = pItem->GetTemplate()) SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, proto->SellPrice * pItem->GetCount()); else @@ -13574,7 +13572,7 @@ void Player::RemoveItemFromBuyBackSlot(uint32 slot, bool del) m_items[slot] = NULL; uint32 eslot = slot - BUYBACK_SLOT_START; - SetUInt64Value(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), 0); + SetGuidValue(PLAYER_FIELD_VENDORBUYBACK_SLOT_1 + (eslot * 2), ObjectGuid::Empty); SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0); SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0); @@ -13592,8 +13590,8 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2, uint if (msg != EQUIP_ERR_OK) { - data << uint64(pItem ? pItem->GetGUID() : 0); - data << uint64(pItem2 ? pItem2->GetGUID() : 0); + data << uint64(pItem ? pItem->GetGUID() : ObjectGuid::Empty); + data << uint64(pItem2 ? pItem2->GetGUID() : ObjectGuid::Empty); data << uint8(0); // bag type subclass, used with EQUIP_ERR_EVENT_AUTOEQUIP_BIND_CONFIRM and EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 switch (msg) @@ -13631,7 +13629,7 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 { TC_LOG_DEBUG("network", "WORLD: Sent SMSG_BUY_FAILED"); WorldPacket data(SMSG_BUY_FAILED, (8+4+4+1)); - data << uint64(creature ? creature->GetGUID() : 0); + data << uint64(creature ? creature->GetGUID() : ObjectGuid::Empty); data << uint32(item); if (param > 0) data << uint32(param); @@ -13639,11 +13637,11 @@ void Player::SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 GetSession()->SendPacket(&data); } -void Player::SendSellError(SellResult msg, Creature* creature, uint64 guid, uint32 param) +void Player::SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param) { TC_LOG_DEBUG("network", "WORLD: Sent SMSG_SELL_ITEM"); WorldPacket data(SMSG_SELL_ITEM, (8+8+(param?4:0)+1)); // last check 2.0.10 - data << uint64(creature ? creature->GetGUID() : 0); + data << uint64(creature ? creature->GetGUID() : ObjectGuid::Empty); data << uint64(guid); if (param > 0) data << uint32(param); @@ -14532,7 +14530,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men return; uint32 gossipOptionId = item->OptionType; - uint64 guid = source->GetGUID(); + ObjectGuid guid = source->GetGUID(); if (source->GetTypeId() == TYPEID_GAMEOBJECT) { @@ -14699,7 +14697,7 @@ uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source) /*** QUEST SYSTEM ***/ /*********************************************************/ -void Player::PrepareQuestMenu(uint64 guid) +void Player::PrepareQuestMenu(ObjectGuid guid) { QuestRelationBounds objectQR; QuestRelationBounds objectQIR; @@ -14759,7 +14757,7 @@ void Player::PrepareQuestMenu(uint64 guid) } } -void Player::SendPreparedQuest(uint64 guid) +void Player::SendPreparedQuest(ObjectGuid guid) { QuestMenu& questMenu = PlayerTalkClass->GetQuestMenu(); if (questMenu.Empty()) @@ -14850,7 +14848,7 @@ bool Player::IsActiveQuest(uint32 quest_id) const return m_QuestStatus.find(quest_id) != m_QuestStatus.end(); } -Quest const* Player::GetNextQuest(uint64 guid, Quest const* quest) +Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest) { QuestRelationBounds objectQR; @@ -16426,7 +16424,7 @@ void Player::ItemRemovedQuestCheck(uint32 entry, uint32 count) UpdateForQuestWorldObjects(); } -void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid) +void Player::KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid) { ASSERT(cInfo); @@ -16435,10 +16433,10 @@ void Player::KilledMonster(CreatureTemplate const* cInfo, uint64 guid) for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i) if (cInfo->KillCredit[i]) - KilledMonsterCredit(cInfo->KillCredit[i], 0); + KilledMonsterCredit(cInfo->KillCredit[i], ObjectGuid::Empty); } -void Player::KilledMonsterCredit(uint32 entry, uint64 guid /*= 0*/) +void Player::KilledMonsterCredit(uint32 entry, ObjectGuid guid /*= ObjectGuid::Empty*/) { uint16 addkillcount = 1; uint32 real_entry = entry; @@ -16540,7 +16538,7 @@ void Player::KilledPlayerCredit() } } -void Player::KillCreditGO(uint32 entry, uint64 guid) +void Player::KillCreditGO(uint32 entry, ObjectGuid guid) { uint16 addCastCount = 1; for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -16594,7 +16592,7 @@ void Player::KillCreditGO(uint32 entry, uint64 guid) } } -void Player::TalkedToCreature(uint32 entry, uint64 guid) +void Player::TalkedToCreature(uint32 entry, ObjectGuid guid) { uint16 addTalkCount = 1; for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i) @@ -16904,11 +16902,11 @@ void Player::SendQuestUpdateAddItem(Quest const* /*quest*/, uint32 /*item_idx*/, GetSession()->SendPacket(&data); } -void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count) +void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGO_idx, uint16 old_count, uint16 add_count) { ASSERT(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)"); - int32 entry = quest->RequiredNpcOrGo[ creatureOrGO_idx ]; + int32 entry = quest->RequiredNpcOrGo[creatureOrGO_idx]; if (entry < 0) // client expected gameobject template id in form (id|0x80000000) entry = (-entry) | 0x80000000; @@ -16924,7 +16922,7 @@ void Player::SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uin uint16 log_slot = FindQuestSlot(quest->GetQuestId()); if (log_slot < MAX_QUEST_LOG_SIZE) - SetQuestSlotCounter(log_slot, creatureOrGO_idx, GetQuestSlotCounter(log_slot, creatureOrGO_idx)+add_count); + SetQuestSlotCounter(log_slot, creatureOrGO_idx, GetQuestSlotCounter(log_slot, creatureOrGO_idx) + add_count); } void Player::SendQuestUpdateAddPlayer(Quest const* quest, uint16 old_count, uint16 add_count) @@ -17078,10 +17076,10 @@ void Player::_LoadBGData(PreparedQueryResult result) m_bgData.mountSpell = fields[9].GetUInt32(); } -bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid) +bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_POSITION); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -17138,7 +17136,7 @@ bool Player::isBeingLoaded() const return GetSession()->PlayerLoading(); } -bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) +bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder) { //// 0 1 2 3 4 5 6 7 8 9 10 11 //QueryResult* result = CharacterDatabase.PQuery("SELECT guid, account, name, race, class, gender, level, xp, money, playerBytes, playerBytes2, playerFlags, " @@ -17155,7 +17153,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) { std::string name = "<unknown>"; sObjectMgr->GetPlayerNameByGUID(guid, name); - TC_LOG_ERROR("entities.player", "Player %s (GUID: %u) not found in table `characters`, can't load. ", name.c_str(), guid); + TC_LOG_ERROR("entities.player", "Player %s %s not found in table `characters`, can't load. ", name.c_str(), guid.ToString().c_str()); return false; } @@ -17167,17 +17165,17 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // player should be able to load/delete character only with correct account! if (dbAccountId != GetSession()->GetAccountId()) { - TC_LOG_ERROR("entities.player", "Player (GUID: %u) loading from wrong account (is: %u, should be: %u)", guid, GetSession()->GetAccountId(), dbAccountId); + TC_LOG_ERROR("entities.player", "Player %s loading from wrong account (is: %u, should be: %u)", guid.ToString().c_str(), GetSession()->GetAccountId(), dbAccountId); return false; } if (holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_BANNED)) { - TC_LOG_ERROR("entities.player", "Player (GUID: %u) is banned, can't load.", guid); + TC_LOG_ERROR("entities.player", "%s is banned, can't load.", guid.ToString().c_str()); return false; } - Object::_Create(guid, 0, HIGHGUID_PLAYER); + Object::_Create(guid.GetCounter(), 0, HIGHGUID_PLAYER); m_name = fields[2].GetString(); @@ -17188,18 +17186,18 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); - stmt->setUInt32(1, guid); + stmt->setUInt32(1, guid.GetCounter()); CharacterDatabase.Execute(stmt); return false; } // overwrite possible wrong/corrupted guid - SetUInt64Value(OBJECT_FIELD_GUID, MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); + SetGuidValue(OBJECT_FIELD_GUID, guid); uint8 gender = fields[5].GetUInt8(); if (!IsValidGender(gender)) { - TC_LOG_ERROR("entities.player", "Player (GUID: %u) has wrong gender (%u), can't be loaded.", guid, gender); + TC_LOG_ERROR("entities.player", "Player %s has wrong gender (%u), can't be loaded.", guid.ToString().c_str(), gender); return false; } @@ -17214,7 +17212,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) PlayerInfo const* info = sObjectMgr->GetPlayerInfo(getRace(), getClass()); if (!info) { - TC_LOG_ERROR("entities.player", "Player (GUID: %u) has wrong race/class (%u/%u), can't be loaded.", guid, getRace(), getClass()); + TC_LOG_ERROR("entities.player", "Player %s has wrong race/class (%u/%u), can't be loaded.", guid.ToString().c_str(), getRace(), getClass()); return false; } @@ -17254,7 +17252,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // cleanup inventory related item value fields (its will be filled correctly in _LoadInventory) for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot) { - SetUInt64Value(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), 0); + SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (slot * 2), ObjectGuid::Empty); SetVisibleItemSlot(slot, NULL); delete m_items[slot]; @@ -17330,7 +17328,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); if (!mapEntry || !IsPositionValid()) { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) have invalid coordinates (MapId: %u X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + TC_LOG_ERROR("entities.player", "Player %s have invalid coordinates (MapId: %u X: %f Y: %f Z: %f O: %f). Teleport to default race/class locations.", + guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); RelocateToHomebind(); } // Player was saved in Arena or Bg @@ -17370,7 +17369,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) //if (mapId == MAPID_INVALID) -- code kept for reference if (int16(mapId) == int16(-1)) // Battleground Entry Point not found (???) { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) was in BG in database, but BG was not found, and entry point was invalid! Teleport to default race/class locations.", guid); + TC_LOG_ERROR("entities.player", "Player %s was in BG in database, but BG was not found, and entry point was invalid! Teleport to default race/class locations.", + guid.ToString().c_str()); RelocateToHomebind(); } else @@ -17383,7 +17383,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) // currently we do not support transport in bg else if (transLowGUID) { - uint64 transGUID = MAKE_NEW_GUID(transLowGUID, 0, HIGHGUID_MO_TRANSPORT); + ObjectGuid transGUID(HIGHGUID_MO_TRANSPORT, transLowGUID); Transport* transport = NULL; if (GameObject* go = HashMapHolder<GameObject>::Find(transGUID)) @@ -17401,8 +17401,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) std::fabs(m_movementInfo.transport.pos.GetPositionY()) > 250.0f || std::fabs(m_movementInfo.transport.pos.GetPositionZ()) > 250.0f) { - TC_LOG_ERROR("entities.player", "Player (guidlow %d) have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.", - guid, x, y, z, o); + TC_LOG_ERROR("entities.player", "Player %s have invalid transport coordinates (X: %f Y: %f Z: %f O: %f). Teleport to bind location.", + guid.ToString().c_str(), x, y, z, o); m_movementInfo.transport.Reset(); @@ -17418,8 +17418,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) } else { - TC_LOG_ERROR("entities.player", "Player (guidlow %u) have problems with transport guid (%u). Teleport to bind location.", - guid, transLowGUID); + TC_LOG_ERROR("entities.player", "Player %s have problems with transport guid (%u). Teleport to bind location.", + guid.ToString().c_str(), transLowGUID); RelocateToHomebind(); } @@ -17527,7 +17527,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) } else { - TC_LOG_ERROR("entities.player", "Player %s (guid: %d) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", m_name.c_str(), guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Areatrigger not found.", + m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); map = NULL; } } @@ -17539,7 +17540,8 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) map = sMapMgr->CreateMap(mapId, this); if (!map) { - TC_LOG_ERROR("entities.player", "Player %s (guid: %d) Map: %u, X: %f, Y: %f, Z: %f, O: %f. Invalid default map coordinates or instance couldn't be created.", m_name.c_str(), guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); + TC_LOG_ERROR("entities.player", "Player %s %s Map: %u, X: %f, Y: %f, Z: %f, O: %f. Invalid default map coordinates or instance couldn't be created.", + m_name.c_str(), guid.ToString().c_str(), mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); return false; } } @@ -17604,16 +17606,16 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) m_deathExpireTime = now + MAX_DEATH_COUNT * DEATH_EXPIRE_STEP - 1; // clear channel spell data (if saved at channel spell casting) - SetUInt64Value(UNIT_FIELD_CHANNEL_OBJECT, 0); + SetChannelObjectGuid(ObjectGuid::Empty); SetUInt32Value(UNIT_CHANNEL_SPELL, 0); // clear charm/summon related fields - SetOwnerGUID(0); - SetUInt64Value(UNIT_FIELD_CHARMEDBY, 0); - SetUInt64Value(UNIT_FIELD_CHARM, 0); - SetUInt64Value(UNIT_FIELD_SUMMON, 0); - SetUInt64Value(PLAYER_FARSIGHT, 0); - SetCreatorGUID(0); + SetOwnerGUID(ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_CHARMEDBY, ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_CHARM, ObjectGuid::Empty); + SetGuidValue(UNIT_FIELD_SUMMON, ObjectGuid::Empty); + SetGuidValue(PLAYER_FARSIGHT, ObjectGuid::Empty); + SetCreatorGUID(ObjectGuid::Empty); RemoveFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FORCE_MOVEMENT); @@ -17625,7 +17627,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder) ClearInCombat(); // make sure the unit is considered not in duel for proper loading - SetUInt64Value(PLAYER_DUEL_ARBITER, 0); + SetGuidValue(PLAYER_DUEL_ARBITER, ObjectGuid::Empty); SetUInt32Value(PLAYER_DUEL_TEAM, 0); // reset stats before loading any modifiers @@ -17838,7 +17840,7 @@ bool Player::isAllowedToLoot(const Creature* creature) case ROUND_ROBIN: // may only loot if the player is the loot roundrobin player // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer == 0 || loot->roundRobinPlayer == GetGUID()) + if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) return true; return loot->hasItemFor(this); @@ -17847,7 +17849,7 @@ bool Player::isAllowedToLoot(const Creature* creature) // may only loot if the player is the loot roundrobin player // or item over threshold (so roll(s) can be launched) // or if there are free/quest/conditional item for the player - if (loot->roundRobinPlayer == 0 || loot->roundRobinPlayer == GetGUID()) + if (loot->roundRobinPlayer.IsEmpty() || loot->roundRobinPlayer == GetGUID()) return true; if (loot->hasOverThresholdItem()) @@ -17902,7 +17904,7 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) Field* fields = result->Fetch(); int32 damage[3]; int32 baseDamage[3]; - uint64 caster_guid = fields[0].GetUInt64(); + ObjectGuid caster_guid(fields[0].GetUInt64()); uint32 spellid = fields[1].GetUInt32(); uint8 effmask = fields[2].GetUInt8(); uint8 recalculatemask = fields[3].GetUInt8(); @@ -18186,7 +18188,7 @@ Item* Player::_LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, F item->SetRefundRecipient((*result)[0].GetUInt32()); item->SetPaidMoney((*result)[1].GetUInt32()); item->SetPaidExtendedCost((*result)[2].GetUInt16()); - AddRefundReference(item->GetGUIDLow()); + AddRefundReference(item->GetGUID()); } else { @@ -18300,7 +18302,7 @@ void Player::_LoadMailedItems(Mail* mail) Item* item = NewItemOrBag(proto); - if (!item->LoadFromDB(itemGuid, MAKE_NEW_GUID(fields[13].GetUInt32(), 0, HIGHGUID_PLAYER), fields, itemTemplate)) + if (!item->LoadFromDB(itemGuid, ObjectGuid(HIGHGUID_PLAYER, fields[13].GetUInt32()), fields, itemTemplate)) { TC_LOG_ERROR("entities.player", "Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, itemGuid); @@ -18726,7 +18728,7 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) } else if (!perm && group) { - TC_LOG_ERROR("entities.player", "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d (%s), %d, %d", GetName().c_str(), GetGUIDLow(), GUID_LOPART(group->GetGUID()), mapId, mapname.c_str(), instanceId, difficulty); + TC_LOG_ERROR("entities.player", "_LoadBoundInstances: player %s(%d) is in group %d but has a non-permanent character bind to map %d (%s), %d, %d", GetName().c_str(), GetGUIDLow(), group->GetLowGUID(), mapId, mapname.c_str(), instanceId, difficulty); deleteInstance = true; } } @@ -19022,7 +19024,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report uint32 missingAchievement = 0; Player* leader = this; - uint64 leaderGuid = GetGroup() ? GetGroup()->GetLeaderGUID() : GetGUID(); + ObjectGuid leaderGuid = GetGroup() ? GetGroup()->GetLeaderGUID() : GetGUID(); if (leaderGuid != GetGUID()) leader = ObjectAccessor::FindPlayer(leaderGuid); @@ -19548,8 +19550,8 @@ void Player::_SaveAuras(SQLTransaction& trans) uint8 index = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA); stmt->setUInt32(index++, GetGUIDLow()); - stmt->setUInt64(index++, itr->second->GetCasterGUID()); - stmt->setUInt64(index++, itr->second->GetCastItemGUID()); + stmt->setUInt64(index++, itr->second->GetCasterGUID().GetRawValue()); + stmt->setUInt64(index++, itr->second->GetCastItemGUID().GetRawValue()); stmt->setUInt32(index++, itr->second->GetId()); stmt->setUInt8(index++, effMask); stmt->setUInt8(index++, recalculateMask); @@ -19592,14 +19594,14 @@ void Player::_SaveInventory(SQLTransaction& trans) // the client auto counts down in real time after having received the initial played time on the first // SMSG_ITEM_REFUND_INFO_RESPONSE packet. // Item::UpdatePlayedTime is only called when needed, which is in DB saves, and item refund info requests. - std::set<uint32>::iterator i_next; - for (std::set<uint32>::iterator itr = m_refundableItems.begin(); itr!= m_refundableItems.end(); itr = i_next) + GuidSet::iterator i_next; + for (GuidSet::iterator itr = m_refundableItems.begin(); itr!= m_refundableItems.end(); itr = i_next) { // use copy iterator because itr may be invalid after operations in this loop i_next = itr; ++i_next; - Item* iPtr = GetItemByGuid(MAKE_NEW_GUID(*itr, 0, HIGHGUID_ITEM)); + Item* iPtr = GetItemByGuid(*itr); if (iPtr) { iPtr->UpdatePlayedTime(this); @@ -19607,7 +19609,7 @@ void Player::_SaveInventory(SQLTransaction& trans) } else { - TC_LOG_ERROR("entities.player", "Can't find item guid %u but is in refundable storage for player %u ! Removing.", *itr, GetGUIDLow()); + TC_LOG_ERROR("entities.player", "Can't find %s but is in refundable storage for player %u ! Removing.", itr->ToString().c_str(), GetGUIDLow()); m_refundableItems.erase(itr); } } @@ -19648,7 +19650,7 @@ void Player::_SaveInventory(SQLTransaction& trans) // also THIS item should be somewhere else, cheat attempt item->FSetState(ITEM_REMOVED); // we are IN updateQueue right now, can't use SetState which modifies the queue - DeleteRefundReference(item->GetGUIDLow()); + DeleteRefundReference(item->GetGUID()); // don't skip, let the switch delete it //continue; } @@ -20153,7 +20155,7 @@ void Player::SendAttackSwingNotInRange() GetSession()->SendPacket(&data); } -void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid) +void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION); @@ -20163,7 +20165,7 @@ void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o, stmt->setFloat(3, o); stmt->setUInt16(4, uint16(mapid)); stmt->setUInt16(5, uint16(zone)); - stmt->setUInt32(6, GUID_LOPART(guid)); + stmt->setUInt32(6, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -20179,10 +20181,10 @@ void Player::SetUInt32ValueInArray(Tokenizer& tokens, uint16 index, uint32 value tokens[index] = buf; } -void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) +void Player::Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PLAYERBYTES2); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -20199,7 +20201,7 @@ void Player::Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 stmt->setUInt8(0, gender); stmt->setUInt32(1, skin | (face << 8) | (hairStyle << 16) | (hairColor << 24)); stmt->setUInt32(2, playerBytes2); - stmt->setUInt32(3, GUID_LOPART(guid)); + stmt->setUInt32(3, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -20401,9 +20403,9 @@ void Player::UpdateDuelFlag(time_t currTime) Pet* Player::GetPet() const { - if (uint64 pet_guid = GetPetGUID()) + if (ObjectGuid pet_guid = GetPetGUID()) { - if (!IS_PET_GUID(pet_guid)) + if (!pet_guid.IsPet()) return NULL; Pet* pet = ObjectAccessor::GetPet(*this, pet_guid); @@ -20558,7 +20560,7 @@ void Player::TextEmote(const std::string& text) SendMessageToSetInRange(&data, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true, !GetSession()->HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT)); } -void Player::Whisper(const std::string& text, uint32 language, uint64 receiver) +void Player::Whisper(const std::string& text, uint32 language, ObjectGuid receiver) { bool isAddonMessage = language == LANG_ADDON; @@ -21070,7 +21072,7 @@ void Player::SendProficiency(ItemClass itemClass, uint32 itemSubclassMask) GetSession()->SendPacket(&data); } -void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) +void Player::RemovePetitionsAndSigns(ObjectGuid guid, uint32 type) { PreparedStatement* stmt; @@ -21082,7 +21084,7 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) stmt->setUInt8(1, uint8(type)); } - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) @@ -21090,8 +21092,8 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) do // this part effectively does nothing, since the deletion / modification only takes place _after_ the PetitionQuery. Though I don't know if the result remains intact if I execute the delete query beforehand. { // and SendPetitionQueryOpcode reads data from the DB Field* fields = result->Fetch(); - uint64 ownerguid = MAKE_NEW_GUID(fields[0].GetUInt32(), 0, HIGHGUID_PLAYER); - uint64 petitionguid = MAKE_NEW_GUID(fields[1].GetUInt32(), 0, HIGHGUID_ITEM); + ObjectGuid ownerguid = ObjectGuid(HIGHGUID_PLAYER, fields[0].GetUInt32()); + ObjectGuid petitionguid = ObjectGuid(HIGHGUID_ITEM, fields[1].GetUInt32()); // send update if charter owner in game Player* owner = ObjectAccessor::FindPlayer(ownerguid); @@ -21103,7 +21105,7 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_PETITION_SIGNATURES); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); CharacterDatabase.Execute(stmt); } @@ -21111,7 +21113,7 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); CharacterDatabase.Execute(stmt); @@ -21122,32 +21124,32 @@ void Player::RemovePetitionsAndSigns(uint64 guid, uint32 type) if (type == 10) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_OWNER); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); trans->Append(stmt); } else { stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_OWNER_AND_TYPE); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_OWNER_AND_TYPE); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); stmt->setUInt8(1, uint8(type)); trans->Append(stmt); } CharacterDatabase.CommitTransaction(trans); } -void Player::LeaveAllArenaTeams(uint64 guid) +void Player::LeaveAllArenaTeams(ObjectGuid guid) { PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PLAYER_ARENA_TEAMS); - stmt->setUInt32(0, GUID_LOPART(guid)); + stmt->setUInt32(0, guid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -21629,14 +21631,14 @@ inline bool Player::_StoreOrEquipNewItem(uint32 vendorslot, uint32 item, uint8 c it->SetPaidMoney(price); it->SetPaidExtendedCost(crItem->ExtendedCost); it->SaveRefundDataToDB(); - AddRefundReference(it->GetGUIDLow()); + AddRefundReference(it->GetGUID()); } } return true; } // Return true is the bought item has a max count to force refresh of window by caller -bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) +bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uint32 item, uint8 count, uint8 bag, uint8 slot) { // cheating attempt if (count < 1) count = 1; @@ -21667,7 +21669,7 @@ bool Player::BuyItemFromVendorSlot(uint64 vendorguid, uint32 vendorslot, uint32 Creature* creature = GetNPCIfCanInteractWith(vendorguid, UNIT_NPC_FLAG_VENDOR); if (!creature) { - TC_LOG_DEBUG("network", "WORLD: BuyItemFromVendor - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(vendorguid))); + TC_LOG_DEBUG("network", "WORLD: BuyItemFromVendor - %s not found or you can't interact with him.", vendorguid.ToString().c_str()); SendBuyError(BUY_ERR_DISTANCE_TOO_FAR, NULL, item, 0); return false; } @@ -22115,7 +22117,7 @@ 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) +void Player::setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) { m_resurrectGUID = guid; m_resurrectMap = mapId; @@ -22443,7 +22445,7 @@ bool Player::CanAlwaysSee(WorldObject const* obj) const if (m_mover == obj) return true; - if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) + if (ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT)) if (obj->GetGUID() == guid) return true; @@ -22488,13 +22490,13 @@ bool Player::IsVisibleGloballyFor(Player const* u) const } template<class T> -inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, T* target, std::set<Unit*>& /*v*/) +inline void UpdateVisibilityOf_helper(GuidSet& s64, T* target, std::set<Unit*>& /*v*/) { s64.insert(target->GetGUID()); } template<> -inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, GameObject* target, std::set<Unit*>& /*v*/) +inline void UpdateVisibilityOf_helper(GuidSet& s64, GameObject* target, std::set<Unit*>& /*v*/) { // @HACK: This is to prevent objects like deeprun tram from disappearing when player moves far from its spawn point while riding it if ((target->GetGOInfo()->type != GAMEOBJECT_TYPE_TRANSPORT)) @@ -22502,14 +22504,14 @@ inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, GameObject* target, } template<> -inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, Creature* target, std::set<Unit*>& v) +inline void UpdateVisibilityOf_helper(GuidSet& s64, Creature* target, std::set<Unit*>& v) { s64.insert(target->GetGUID()); v.insert(target); } template<> -inline void UpdateVisibilityOf_helper(std::set<uint64>& s64, Player* target, std::set<Unit*>& v) +inline void UpdateVisibilityOf_helper(GuidSet& s64, Player* target, std::set<Unit*>& v) { s64.insert(target->GetGUID()); v.insert(target); @@ -22571,9 +22573,9 @@ void Player::UpdateTriggerVisibility() UpdateData udata; WorldPacket packet; - for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) + for (GuidSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { - if (IS_CREATURE_GUID(*itr)) + if (itr->IsCreature()) { Creature* creature = GetMap()->GetCreature(*itr); // Update fields of triggers, transformed units or unselectable units (values dependent on GM state) @@ -22584,7 +22586,7 @@ void Player::UpdateTriggerVisibility() creature->BuildValuesUpdateBlockForPlayer(&udata, this); creature->RemoveFieldNotifyFlag(UF_FLAG_PUBLIC); } - else if (IS_GAMEOBJECT_GUID((*itr))) + else if (itr->IsGameObject()) { GameObject* go = GetMap()->GetGameObject(*itr); if (!go) @@ -22721,14 +22723,14 @@ bool Player::IsQuestRewarded(uint32 quest_id) const Unit* Player::GetSelectedUnit() const { - if (uint64 selectionGUID = GetUInt64Value(UNIT_FIELD_TARGET)) + if (ObjectGuid selectionGUID = GetTarget()) return ObjectAccessor::GetUnit(*this, selectionGUID); return NULL; } Player* Player::GetSelectedPlayer() const { - if (uint64 selectionGUID = GetUInt64Value(UNIT_FIELD_TARGET)) + if (ObjectGuid selectionGUID = GetTarget()) return ObjectAccessor::GetPlayer(*this, selectionGUID); return NULL; } @@ -22768,7 +22770,7 @@ void Player::AddComboPoints(Unit* target, int8 count, Spell* spell) { if (m_comboTarget) if (Unit* target2 = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target2->RemoveComboPointHolder(GetGUIDLow()); + target2->RemoveComboPointHolder(GetGUID()); // Spells will always add value to m_comboPoints eventualy, so it must be cleared first if (spell) @@ -22777,7 +22779,7 @@ void Player::AddComboPoints(Unit* target, int8 count, Spell* spell) m_comboTarget = target->GetGUID(); *comboPoints = count; - target->AddComboPointHolder(GetGUIDLow()); + target->AddComboPointHolder(GetGUID()); } if (*comboPoints > 5) @@ -22814,9 +22816,9 @@ void Player::ClearComboPoints() SendComboPoints(); if (Unit* target = ObjectAccessor::GetUnit(*this, m_comboTarget)) - target->RemoveComboPointHolder(GetGUIDLow()); + target->RemoveComboPointHolder(GetGUID()); - m_comboTarget = 0; + m_comboTarget.Clear(); } void Player::SetGroup(Group* group, int8 subgroup) @@ -23630,14 +23632,14 @@ void Player::UpdateForQuestWorldObjects() UpdateData udata; WorldPacket packet; - for (ClientGUIDs::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) + for (GuidSet::iterator itr = m_clientGUIDs.begin(); itr != m_clientGUIDs.end(); ++itr) { - if (IS_GAMEOBJECT_GUID(*itr)) + if (itr->IsGameObject()) { if (GameObject* obj = HashMapHolder<GameObject>::Find(*itr)) obj->BuildValuesUpdateBlockForPlayer(&udata, this); } - else if (IS_CRE_OR_VEH_GUID(*itr)) + else if (itr->IsCreatureOrVehicle()) { Creature* obj = ObjectAccessor::GetCreatureOrPetOrVehicle(*this, *itr); if (!obj) @@ -23978,7 +23980,8 @@ void Player::RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject* pRewar { if (!pRewardSource) return; - uint64 creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : uint64(0); + + ObjectGuid creature_guid = (pRewardSource->GetTypeId() == TYPEID_UNIT) ? pRewardSource->GetGUID() : ObjectGuid::Empty; // prepare data for near group iteration if (Group* group = GetGroup()) @@ -24258,7 +24261,7 @@ PartyResult Player::CanUninviteFromGroup() const if (grp->isLFGGroup()) { - uint64 gguid = grp->GetGUID(); + ObjectGuid gguid = grp->GetGUID(); if (!sLFGMgr->GetKicksLeft(gguid)) return ERR_PARTY_LFG_BOOT_LIMIT; @@ -24466,7 +24469,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) { TC_LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s create seer %u (TypeId: %u).", GetName().c_str(), target->GetEntry(), target->GetTypeId()); - if (!AddUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) + if (!AddGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { TC_LOG_FATAL("entities.player", "Player::CreateViewpoint: Player %s cannot add new viewpoint!", GetName().c_str()); return; @@ -24482,7 +24485,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) { TC_LOG_DEBUG("maps", "Player::CreateViewpoint: Player %s remove seer", GetName().c_str()); - if (!RemoveUInt64Value(PLAYER_FARSIGHT, target->GetGUID())) + if (!RemoveGuidValue(PLAYER_FARSIGHT, target->GetGUID())) { TC_LOG_FATAL("entities.player", "Player::CreateViewpoint: Player %s cannot remove current viewpoint!", GetName().c_str()); return; @@ -24501,7 +24504,7 @@ void Player::SetViewpoint(WorldObject* target, bool apply) WorldObject* Player::GetViewpoint() const { - if (uint64 guid = GetUInt64Value(PLAYER_FARSIGHT)) + if (ObjectGuid guid = GetGuidValue(PLAYER_FARSIGHT)) return (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*this, guid, TYPEMASK_SEER); return NULL; } @@ -25371,7 +25374,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank) SetFreeTalentPoints(CurTalentPoints - (talentRank - curtalent_maxrank + 1)); } -void Player::LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank) +void Player::LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank) { Pet* pet = GetPet(); @@ -25766,7 +25769,7 @@ void Player::BuildEnchantmentsInfoData(WorldPacket* data) data->put<uint16>(enchantmentMaskPos, enchantmentMask); *data << uint16(0); // unknown - data->appendPackGUID(item->GetUInt64Value(ITEM_FIELD_CREATOR)); // item creator + *data << item->GetGuidValue(ITEM_FIELD_CREATOR).WriteAsPacked(); // item creator *data << uint32(0); // seed? } @@ -25793,7 +25796,7 @@ void Player::SendEquipmentSetList() if (itr->second.IgnoreMask & (1 << i)) data.appendPackGUID(uint64(1)); else - data.appendPackGUID(MAKE_NEW_GUID(itr->second.Items[i], 0, HIGHGUID_ITEM)); + data << ObjectGuid(HIGHGUID_ITEM, 0, itr->second.Items[i]).WriteAsPacked(); } ++count; // client have limit but it checked at loading and set @@ -26299,18 +26302,16 @@ void Player::SendDuelCountdown(uint32 counter) GetSession()->SendPacket(&data); } -void Player::AddRefundReference(uint32 it) +void Player::AddRefundReference(ObjectGuid it) { m_refundableItems.insert(it); } -void Player::DeleteRefundReference(uint32 it) +void Player::DeleteRefundReference(ObjectGuid it) { - std::set<uint32>::iterator itr = m_refundableItems.find(it); + GuidSet::iterator itr = m_refundableItems.find(it); if (itr != m_refundableItems.end()) - { m_refundableItems.erase(itr); - } } void Player::SendRefundInfo(Item* item) @@ -26579,9 +26580,9 @@ void Player::_SaveInstanceTimeRestrictions(SQLTransaction& trans) } } -bool Player::IsInWhisperWhiteList(uint64 guid) +bool Player::IsInWhisperWhiteList(ObjectGuid guid) { - for (WhisperListContainer::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr) + for (GuidList::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr) if (*itr == guid) return true; diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 27ea8355345..92639c0589d 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -126,8 +126,6 @@ typedef std::unordered_map<uint32, PlayerTalent*> PlayerTalentMap; typedef std::unordered_map<uint32, PlayerSpell*> PlayerSpellMap; typedef std::list<SpellModifier*> SpellModList; -typedef std::list<uint64> WhisperListContainer; - struct SpellCooldown { time_t end; @@ -999,11 +997,11 @@ struct BGData struct TradeStatusInfo { - TradeStatusInfo() : Status(TRADE_STATUS_BUSY), TraderGuid(0), Result(EQUIP_ERR_OK), + TradeStatusInfo() : Status(TRADE_STATUS_BUSY), TraderGuid(), Result(EQUIP_ERR_OK), IsTargetResult(false), ItemLimitCategoryId(0), Slot(0) { } TradeStatus Status; - uint64 TraderGuid; + ObjectGuid TraderGuid; InventoryResult Result; bool IsTargetResult; uint32 ItemLimitCategoryId; @@ -1015,21 +1013,21 @@ class TradeData public: // constructors TradeData(Player* player, Player* trader) : m_player(player), m_trader(trader), m_accepted(false), m_acceptProccess(false), - m_money(0), m_spell(0), m_spellCastItem(0) { memset(m_items, 0, TRADE_SLOT_COUNT * sizeof(uint64)); } + m_money(0), m_spell(0), m_spellCastItem() { } Player* GetTrader() const { return m_trader; } TradeData* GetTraderData() const; Item* GetItem(TradeSlots slot) const; - bool HasItem(uint64 itemGuid) const; - TradeSlots GetTradeSlotForItem(uint64 itemGuid) const; + bool HasItem(ObjectGuid itemGuid) const; + TradeSlots GetTradeSlotForItem(ObjectGuid itemGuid) const; void SetItem(TradeSlots slot, Item* item); uint32 GetSpell() const { return m_spell; } void SetSpell(uint32 spell_id, Item* castItem = NULL); Item* GetSpellCastItem() const; - bool HasSpellCastItem() const { return m_spellCastItem != 0; } + bool HasSpellCastItem() const { return !m_spellCastItem.IsEmpty(); } uint32 GetMoney() const { return m_money; } void SetMoney(uint32 money); @@ -1055,9 +1053,9 @@ class TradeData uint32 m_money; // m_player place money to trade uint32 m_spell; // m_player apply spell to non-traded slot item - uint64 m_spellCastItem; // applied spell cast by item use + ObjectGuid m_spellCastItem; // applied spell cast by item use - uint64 m_items[TRADE_SLOT_COUNT]; // traded items from m_player side including non-traded slot + ObjectGuid m_items[TRADE_SLOT_COUNT]; // traded items from m_player side including non-traded slot }; class KillRewarder @@ -1139,8 +1137,8 @@ class Player : public Unit, public GridObject<Player> void SendInstanceResetWarning(uint32 mapid, Difficulty difficulty, uint32 time); bool CanInteractWithQuestGiver(Object* questGiver); - Creature* GetNPCIfCanInteractWith(uint64 guid, uint32 npcflagmask); - GameObject* GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes type) const; + Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask); + GameObject* GetGameObjectIfCanInteractWith(ObjectGuid guid, GameobjectTypes type) const; void ToggleAFK(); void ToggleDND(); @@ -1221,7 +1219,7 @@ class Player : public Unit, public GridObject<Player> /// Outputs an universal text which is supposed to be an action. void TextEmote(std::string const& text); /// Handles whispers from Addons and players based on sender, receiver's guid and language. - void Whisper(std::string const& text, const uint32 language, uint64 receiver); + void Whisper(std::string const& text, const uint32 language, ObjectGuid receiver); /*********************************************************/ /*** STORAGE SYSTEM ***/ @@ -1232,7 +1230,7 @@ class Player : public Unit, public GridObject<Player> uint8 FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool swap) const; uint32 GetItemCount(uint32 item, bool inBankAlso = false, Item* skipItem = NULL) const; uint32 GetItemCountWithLimitCategory(uint32 limitCategory, Item* skipItem = NULL) const; - Item* GetItemByGuid(uint64 guid) const; + Item* GetItemByGuid(ObjectGuid guid) const; Item* GetItemByEntry(uint32 entry) const; Item* GetItemByPos(uint16 pos) const; Item* GetItemByPos(uint8 bag, uint8 slot) const; @@ -1289,8 +1287,8 @@ class Player : public Unit, public GridObject<Player> InventoryResult CanTakeMoreSimilarItems(uint32 entry, uint32 count, Item* pItem, uint32* no_space_count = NULL, uint32* itemLimitCategory = NULL) const; InventoryResult CanStoreItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 entry, uint32 count, Item* pItem = NULL, bool swap = false, uint32* no_space_count = NULL) const; - void AddRefundReference(uint32 it); - void DeleteRefundReference(uint32 it); + void AddRefundReference(ObjectGuid it); + void DeleteRefundReference(ObjectGuid it); void ApplyEquipCooldown(Item* pItem); void SetAmmo(uint32 item); @@ -1320,7 +1318,7 @@ class Player : public Unit, public GridObject<Player> uint32 GetMaxKeyringSize() const { return KEYRING_SLOT_END-KEYRING_SLOT_START; } void SendEquipError(InventoryResult msg, Item* pItem, Item* pItem2 = NULL, uint32 itemid = 0); void SendBuyError(BuyResult msg, Creature* creature, uint32 item, uint32 param); - void SendSellError(SellResult msg, Creature* creature, uint64 guid, uint32 param); + void SendSellError(SellResult msg, Creature* creature, ObjectGuid guid, uint32 param); void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } @@ -1328,7 +1326,7 @@ class Player : public Unit, public GridObject<Player> 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 BuyItemFromVendorSlot(ObjectGuid 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); float GetReputationPriceDiscount(Creature const* creature) const; @@ -1379,10 +1377,10 @@ class Player : public Unit, public GridObject<Player> int32 GetQuestLevel(Quest const* quest) const { return quest && (quest->GetQuestLevel() > 0) ? quest->GetQuestLevel() : getLevel(); } - void PrepareQuestMenu(uint64 guid); - void SendPreparedQuest(uint64 guid); + void PrepareQuestMenu(ObjectGuid guid); + void SendPreparedQuest(ObjectGuid guid); bool IsActiveQuest(uint32 quest_id) const; - Quest const* GetNextQuest(uint64 guid, Quest const* quest); + Quest const* GetNextQuest(ObjectGuid guid, Quest const* quest); bool CanSeeStartQuest(Quest const* quest); bool CanTakeQuest(Quest const* quest, bool msg); bool CanAddQuest(Quest const* quest, bool msg); @@ -1449,11 +1447,11 @@ class Player : public Unit, public GridObject<Player> void GroupEventHappens(uint32 questId, WorldObject const* pEventObject); void ItemAddedQuestCheck(uint32 entry, uint32 count); void ItemRemovedQuestCheck(uint32 entry, uint32 count); - void KilledMonster(CreatureTemplate const* cInfo, uint64 guid); - void KilledMonsterCredit(uint32 entry, uint64 guid = 0); + void KilledMonster(CreatureTemplate const* cInfo, ObjectGuid guid); + void KilledMonsterCredit(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); void KilledPlayerCredit(); - void KillCreditGO(uint32 entry, uint64 guid = 0); - void TalkedToCreature(uint32 entry, uint64 guid); + void KillCreditGO(uint32 entry, ObjectGuid guid = ObjectGuid::Empty); + void TalkedToCreature(uint32 entry, ObjectGuid guid); void MoneyChanged(uint32 value); void ReputationChanged(FactionEntry const* factionEntry); void ReputationChanged2(FactionEntry const* factionEntry); @@ -1470,11 +1468,11 @@ class Player : public Unit, public GridObject<Player> void SendQuestConfirmAccept(Quest const* quest, Player* pReceiver); void SendPushToPartyResponse(Player* player, uint8 msg); void SendQuestUpdateAddItem(Quest const* quest, uint32 itemIdx, uint16 count); - void SendQuestUpdateAddCreatureOrGo(Quest const* quest, uint64 guid, uint32 creatureOrGOIdx, uint16 oldCount, uint16 addCount); + void SendQuestUpdateAddCreatureOrGo(Quest const* quest, ObjectGuid guid, uint32 creatureOrGOIdx, uint16 oldCount, uint16 addCount); void SendQuestUpdateAddPlayer(Quest const* quest, uint16 oldCount, uint16 addCount); - uint64 GetDivider() const { return m_divider; } - void SetDivider(uint64 guid) { m_divider = guid; } + ObjectGuid GetDivider() const { return m_divider; } + void SetDivider(ObjectGuid guid) { m_divider = guid; } uint32 GetInGameTime() const { return m_ingametime; } void SetInGameTime(uint32 time) { m_ingametime = time; } @@ -1488,15 +1486,15 @@ class Player : public Unit, public GridObject<Player> /*** LOAD SYSTEM ***/ /*********************************************************/ - bool LoadFromDB(uint32 guid, SQLQueryHolder *holder); + bool LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder); bool isBeingLoaded() const override; void Initialize(uint32 guid); static uint32 GetUInt32ValueFromArray(Tokenizer const& data, uint16 index); static float GetFloatValueFromArray(Tokenizer const& data, uint16 index); - static uint32 GetZoneIdFromDB(uint64 guid); - static uint32 GetLevelFromDB(uint64 guid); - static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, uint64 guid); + static uint32 GetZoneIdFromDB(ObjectGuid guid); + static uint32 GetLevelFromDB(ObjectGuid guid); + static bool LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, float& o, bool& in_flight, ObjectGuid guid); static bool IsValidGender(uint8 Gender) { return Gender <= GENDER_FEMALE; } @@ -1510,18 +1508,18 @@ class Player : public Unit, public GridObject<Player> static void SetUInt32ValueInArray(Tokenizer& data, uint16 index, uint32 value); static void SetFloatValueInArray(Tokenizer& data, uint16 index, float value); - static void Customize(uint64 guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); - static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, uint64 guid); + static void Customize(ObjectGuid guid, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair); + static void SavePositionInDB(uint32 mapid, float x, float y, float z, float o, uint32 zone, ObjectGuid guid); - static void DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); + static void DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRealmChars = true, bool deleteFinally = false); static void DeleteOldCharacters(); static void DeleteOldCharacters(uint32 keepDays); bool m_mailsLoaded; bool m_mailsUpdated; - void SetBindPoint(uint64 guid); - void SendTalentWipeConfirm(uint64 guid); + void SetBindPoint(ObjectGuid guid); + void SendTalentWipeConfirm(ObjectGuid guid); void ResetPetTalents(); void CalcRage(uint32 damage, bool attacker); void RegenerateAll(); @@ -1545,11 +1543,11 @@ class Player : public Unit, public GridObject<Player> Unit* GetSelectedUnit() const; Player* GetSelectedPlayer() const; - void SetTarget(uint64 /*guid*/) override { } /// Used for serverside target changes, does not apply to players - void SetSelection(uint64 guid) { SetUInt64Value(UNIT_FIELD_TARGET, guid); } + void SetTarget(ObjectGuid /*guid*/) override { } /// Used for serverside target changes, does not apply to players + void SetSelection(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_TARGET, guid); } uint8 GetComboPoints() const { return m_comboPoints; } - uint64 GetComboTarget() const { return m_comboTarget; } + ObjectGuid GetComboTarget() const { return m_comboTarget; } void AddComboPoints(Unit* target, int8 count, Spell* spell = NULL); void GainSpellComboPoints(int8 count); @@ -1626,7 +1624,7 @@ class Player : public Unit, public GridObject<Player> void BuildPetTalentsInfoData(WorldPacket* data); void SendTalentsInfoData(bool pet); void LearnTalent(uint32 talentId, uint32 talentRank); - void LearnPetTalent(uint64 petGuid, uint32 talentId, uint32 talentRank); + void LearnPetTalent(ObjectGuid petGuid, uint32 talentId, uint32 talentRank); bool AddTalent(uint32 spellId, uint8 spec, bool learning); bool HasTalent(uint32 spell_id, uint8 spec) const; @@ -1689,10 +1687,10 @@ 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); - void clearResurrectRequestData() { setResurrectRequestData(0, 0, 0.0f, 0.0f, 0.0f, 0, 0); } - bool isResurrectRequestedBy(uint64 guid) const { return m_resurrectGUID == guid; } - bool isResurrectRequested() const { return m_resurrectGUID != 0; } + void setResurrectRequestData(ObjectGuid guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana); + void clearResurrectRequestData() { setResurrectRequestData(ObjectGuid::Empty, 0, 0.0f, 0.0f, 0.0f, 0, 0); } + bool isResurrectRequestedBy(ObjectGuid guid) const { return m_resurrectGUID == guid; } + bool isResurrectRequested() const { return !m_resurrectGUID.IsEmpty(); } void ResurrectUsingRequestData(); uint8 getCinematic() { return m_cinematic; } @@ -1733,7 +1731,7 @@ class Player : public Unit, public GridObject<Player> bool IsInSameGroupWith(Player const* p) const; 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); + static void RemoveFromGroup(Group* group, ObjectGuid guid, RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker = ObjectGuid::Empty, const char* reason = NULL); void RemoveFromGroup(RemoveMethod method = GROUP_REMOVEMETHOD_DEFAULT) { RemoveFromGroup(GetGroup(), GetGUID(), method); } void SendUpdateToOutOfRangeGroupMembers(); @@ -1743,16 +1741,16 @@ class Player : public Unit, public GridObject<Player> void SetGuildIdInvited(uint32 GuildId) { m_GuildIdInvited = GuildId; } uint32 GetGuildId() const { return GetUInt32Value(PLAYER_GUILDID); } Guild* GetGuild(); - static uint32 GetGuildIdFromDB(uint64 guid); - static uint8 GetRankFromDB(uint64 guid); + static uint32 GetGuildIdFromDB(ObjectGuid guid); + static uint8 GetRankFromDB(ObjectGuid guid); int GetGuildIdInvited() { return m_GuildIdInvited; } - static void RemovePetitionsAndSigns(uint64 guid, uint32 type); + static void RemovePetitionsAndSigns(ObjectGuid guid, uint32 type); // Arena Team 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); + static uint32 GetArenaTeamIdFromDB(ObjectGuid guid, uint8 slot); + static void LeaveAllArenaTeams(ObjectGuid guid); uint32 GetArenaTeamId(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_ID); } uint32 GetArenaPersonalRating(uint8 slot) const { return GetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (slot * ARENA_TEAM_END) + ARENA_TEAM_PERSONAL_RATING); } void SetArenaTeamIdInvited(uint32 ArenaTeamId) { m_ArenaTeamIdInvited = ArenaTeamId; } @@ -1831,8 +1829,8 @@ class Player : public Unit, public GridObject<Player> void UpdateManaRegen(); void UpdateRuneRegen(RuneType rune); - uint64 GetLootGUID() const { return m_lootGuid; } - void SetLootGUID(uint64 guid) { m_lootGuid = guid; } + ObjectGuid GetLootGUID() const { return m_lootGuid; } + void SetLootGUID(ObjectGuid guid) { m_lootGuid = guid; } void RemovedInsignia(Player* looterPlr); @@ -2040,9 +2038,9 @@ class Player : public Unit, public GridObject<Player> PlayerMenu* PlayerTalkClass; std::vector<ItemSetEffect*> ItemSetEff; - void SendLoot(uint64 guid, LootType loot_type); - void SendLootError(uint64 guid, LootError error); - void SendLootRelease(uint64 guid); + void SendLoot(ObjectGuid guid, LootType loot_type); + void SendLootError(ObjectGuid guid, LootError error); + void SendLootRelease(ObjectGuid guid); void SendNotifyLootItemRemoved(uint8 lootSlot); void SendNotifyLootMoneyRemoved(); @@ -2166,8 +2164,7 @@ class Player : public Unit, public GridObject<Player> WorldLocation GetStartPosition() const; // currently visible objects at player client - typedef std::set<uint64> ClientGUIDs; - ClientGUIDs m_clientGUIDs; + GuidSet m_clientGUIDs; bool HaveAtClient(WorldObject const* u) const; @@ -2322,9 +2319,9 @@ class Player : public Unit, public GridObject<Player> bool isDebugAreaTriggers; void ClearWhisperWhiteList() { WhisperList.clear(); } - void AddWhisperWhiteList(uint64 guid) { WhisperList.push_back(guid); } - bool IsInWhisperWhiteList(uint64 guid); - void RemoveFromWhisperWhiteList(uint64 guid) { WhisperList.remove(guid); } + void AddWhisperWhiteList(ObjectGuid guid) { WhisperList.push_back(guid); } + bool IsInWhisperWhiteList(ObjectGuid guid); + void RemoveFromWhisperWhiteList(ObjectGuid guid) { WhisperList.remove(guid); } bool SetDisableGravity(bool disable, bool packetOnly /* = false */) override; bool SetCanFly(bool apply) override; @@ -2344,7 +2341,7 @@ class Player : public Unit, public GridObject<Player> protected: // Gamemaster whisper whitelist - WhisperListContainer WhisperList; + GuidList WhisperList; uint32 m_regenTimerCount; float m_powerFraction[MAX_POWERS]; uint32 m_contestedPvPTimer; @@ -2380,7 +2377,7 @@ class Player : public Unit, public GridObject<Player> QuestSet m_monthlyquests; SeasonalEventQuestMap m_seasonalquests; - uint64 m_divider; + ObjectGuid m_divider; uint32 m_ingametime; /*********************************************************/ @@ -2452,7 +2449,7 @@ class Player : public Unit, public GridObject<Player> time_t m_lastHonorUpdateTime; void outDebugValues() const; - uint64 m_lootGuid; + ObjectGuid m_lootGuid; uint32 m_team; uint32 m_nextSave; @@ -2472,7 +2469,7 @@ class Player : public Unit, public GridObject<Player> uint32 m_ExtraFlags; - uint64 m_comboTarget; + ObjectGuid m_comboTarget; int8 m_comboPoints; QuestStatusMap m_QuestStatus; @@ -2517,7 +2514,7 @@ class Player : public Unit, public GridObject<Player> void ResetTimeSync(); void SendTimeSync(); - uint64 m_resurrectGUID; + ObjectGuid m_resurrectGUID; uint32 m_resurrectMap; float m_resurrectX, m_resurrectY, m_resurrectZ; uint32 m_resurrectHealth, m_resurrectMana; @@ -2612,7 +2609,7 @@ class Player : public Unit, public GridObject<Player> Item* _StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool update); Item* _LoadItem(SQLTransaction& trans, uint32 zoneId, uint32 timeDiff, Field* fields); - std::set<uint32> m_refundableItems; + GuidSet m_refundableItems; void SendRefundInfo(Item* item); void RefundItem(Item* item); diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp index f2c2ada5666..498cdfecf6e 100644 --- a/src/server/game/Entities/Player/SocialMgr.cpp +++ b/src/server/game/Entities/Player/SocialMgr.cpp @@ -205,7 +205,7 @@ void SocialMgr::GetFriendInfo(Player* player, uint32 friendGUID, FriendInfo &fri friendInfo.Level = 0; friendInfo.Class = 0; - Player* target = ObjectAccessor::FindPlayer(friendGUID); + Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, friendGUID)); if (!target) return; @@ -290,10 +290,10 @@ void SocialMgr::BroadcastToFriendListers(Player* player, WorldPacket* packet) AccountTypes gmSecLevel = AccountTypes(sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST)); for (SocialMap::const_iterator itr = m_socialMap.begin(); itr != m_socialMap.end(); ++itr) { - PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUID()); + PlayerSocialMap::const_iterator itr2 = itr->second.m_playerSocialMap.find(player->GetGUIDLow()); if (itr2 != itr->second.m_playerSocialMap.end() && (itr2->second.Flags & SOCIAL_FLAG_FRIEND)) { - Player* target = ObjectAccessor::FindPlayer(MAKE_NEW_GUID(itr->first, 0, HIGHGUID_PLAYER)); + Player* target = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, 0, itr->first)); if (!target || !target->IsInWorld()) continue; |
