TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WorldSession Class Reference

Player session in the World. More...

#include <WorldSession.h>

Classes

union  ConnectToKey
 
class  DosProtection
 

Public Member Functions

 WorldSession (uint32 id, std::string &&name, uint32 battlenetAccountId, std::shared_ptr< WorldSocket > sock, AccountTypes sec, uint8 expansion, time_t mute_time, std::string os, LocaleConstant locale, uint32 recruiter, bool isARecruiter)
 WorldSession constructor. More...
 
 ~WorldSession ()
 WorldSession destructor. More...
 
bool PlayerLoading () const
 
bool PlayerLogout () const
 
bool PlayerLogoutWithSave () const
 
bool PlayerRecentlyLoggedOut () const
 
bool PlayerDisconnected () const
 
void ReadAddonsInfo (ByteBuffer &data)
 
void SendAddonsInfo ()
 
bool IsAddonRegistered (const std::string &prefix) const
 
void SendPacket (WorldPacket const *packet, bool forced=false)
 Send a packet to the client. More...
 
void AddInstanceConnection (std::shared_ptr< WorldSocket > sock)
 
void SendNotification (char const *format,...) ATTR_PRINTF(2
 
void void SendNotification (uint32 stringId,...)
 
void SendPetNameInvalid (uint32 error, std::string const &name, DeclinedName *declinedName)
 
void SendPartyResult (PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
 
void SendSetPhaseShift (std::set< uint32 > const &phaseIds, std::set< uint32 > const &terrainswaps, std::set< uint32 > const &worldMapAreaSwaps)
 
void SendQueryTimeResponse ()
 
void SendAuthResponse (uint32 code, bool queued, uint32 queuePos=0)
 
void SendClientCacheVersion (uint32 version)
 
void InitializeSession ()
 
void InitializeSessionCallback (SQLQueryHolder *realmHolder, SQLQueryHolder *holder)
 
rbac::RBACDataGetRBACData ()
 
bool HasPermission (uint32 permissionId)
 
void LoadPermissions ()
 
PreparedQueryResultFuture LoadPermissionsAsync ()
 
void InvalidateRBACData ()
 
AccountTypes GetSecurity () const
 
uint32 GetAccountId () const
 
ObjectGuid GetAccountGUID () const
 
std::string constGetAccountName () const
 
uint32 GetBattlenetAccountId () const
 
ObjectGuid GetBattlenetAccountGUID () const
 
PlayerGetPlayer () const
 
std::string constGetPlayerName () const
 
std::string GetPlayerInfo () const
 
void SetSecurity (AccountTypes security)
 
std::string constGetRemoteAddress () const
 
void SetPlayer (Player *player)
 
uint8 GetExpansion () const
 
std::string constGetOS () const
 
void InitWarden (BigNumber *k)
 
void SetInQueue (bool state)
 Session in auth.queue currently. More...
 
bool isLogingOut () const
 Is the user engaged in a log out process? More...
 
void SetLogoutStartTime (time_t requestTime)
 Engage the logout process for the user. More...
 
bool ShouldLogOut (time_t currTime) const
 Is logout cooldown expired? More...
 
void LogoutPlayer (bool save)
 Log the player out More...
 
void KickPlayer ()
 Kick a player out of the World. More...
 
void QueuePacket (WorldPacket *new_packet)
 Add an incoming packet to the queue. More...
 
bool Update (uint32 diff, PacketFilter &updater)
 Update the WorldSession (triggered by World update) More...
 
void SendAuthWaitQue (uint32 position)
 Handle the authentication waiting queue (to be completed) More...
 
void SendSetTimeZoneInformation ()
 
void SendFeatureSystemStatus ()
 
void SendFeatureSystemStatusGlueScreen ()
 
void SendNameQueryOpcode (ObjectGuid guid)
 
void SendTrainerList (ObjectGuid guid)
 
void SendTrainerList (ObjectGuid guid, std::string const &strTitle)
 
void SendListInventory (ObjectGuid guid)
 
void SendShowBank (ObjectGuid guid)
 
bool CanOpenMailBox (ObjectGuid guid)
 
void SendShowMailBox (ObjectGuid guid)
 
void SendTabardVendorActivate (ObjectGuid guid)
 
void SendSpiritResurrect ()
 
void SendBindPoint (Creature *npc)
 
void SendAttackStop (Unit const *enemy)
 
void SendTradeStatus (WorldPackets::Trade::TradeStatus &status)
 
void SendUpdateTrade (bool trader_data=true)
 
void SendCancelTrade ()
 
void SendPetitionQueryOpcode (ObjectGuid petitionguid)
 
void SendQueryPetNameResponse (ObjectGuid guid)
 
void SendStablePet (ObjectGuid guid)
 
void SendStablePetCallback (PreparedQueryResult result, ObjectGuid guid)
 
void SendPetStableResult (uint8 guid)
 
bool CheckStableMaster (ObjectGuid guid)
 
AccountData constGetAccountData (AccountDataType type) const
 
void SetAccountData (AccountDataType type, uint32 time, std::string const &data)
 
void LoadAccountData (PreparedQueryResult result, uint32 mask)
 
void LoadTutorialsData (PreparedQueryResult result)
 
void SendTutorialsData ()
 
void SaveTutorialsData (SQLTransaction &trans)
 
uint32 GetTutorialInt (uint8 index) const
 
void SetTutorialInt (uint8 index, uint32 value)
 
bool SendItemInfo (uint32 itemid, WorldPacket data)
 
void SendAuctionHello (ObjectGuid guid, Creature *unit)
 
void SendAuctionCommandResult (AuctionEntry *auction, uint32 Action, uint32 ErrorCode, uint32 bidError=0)
 Notifies the client of the result of his last auction operation. It is called when the player bids, creates, or deletes an auction. More...
 
void SendAuctionOutBidNotification (AuctionEntry const *auction, Item const *item)
 
void SendAuctionClosedNotification (AuctionEntry const *auction, float mailDelay, bool sold, Item const *item)
 
void SendAuctionWonNotification (AuctionEntry const *auction, Item const *item)
 
void SendAuctionOwnerBidNotification (AuctionEntry const *auction, Item const *item)
 
void SendBlackMarketOpenResult (ObjectGuid guid, Creature *auctioneer)
 
void SendEnchantmentLog (ObjectGuid target, ObjectGuid caster, uint32 itemId, uint32 enchantId)
 
void SendItemEnchantTimeUpdate (ObjectGuid Playerguid, ObjectGuid Itemguid, uint32 slot, uint32 Duration)
 
void SendTaxiStatus (ObjectGuid guid)
 
void SendTaxiMenu (Creature *unit)
 
void SendDoFlight (uint32 mountDisplayId, uint32 path, uint32 pathNode=0)
 
bool SendLearnNewTaxiNode (Creature *unit)
 
void SendDiscoverNewTaxiNode (uint32 nodeid)
 
void SendNotInArenaTeamPacket (uint8 type)
 
void SendPetitionShowList (ObjectGuid guid)
 
void DoLootRelease (ObjectGuid lguid)
 
LocaleConstant GetSessionDbcLocale () const
 
LocaleConstant GetSessionDbLocaleIndex () const
 
char constGetTrinityString (uint32 entry) const
 
uint32 GetLatency () const
 
void SetLatency (uint32 latency)
 
void ResetClientTimeDelay ()
 
void UpdateTimeOutTime (uint32 diff)
 
void ResetTimeOutTime ()
 
bool IsConnectionIdle () const
 
uint32 GetRecruiterId () const
 
bool IsARecruiter () const
 
BattlePetMgrGetBattlePetMgr () const
 
CollectionMgrGetCollectionMgr () const
 
void Handle_NULL (WorldPackets::Null &null)
 
void Handle_EarlyProccess (WorldPacket &recvPacket)
 
void HandleCharEnum (PreparedQueryResult result)
 
void HandleCharEnumOpcode (WorldPackets::Character::EnumCharacters &)
 
void HandleCharUndeleteEnum (PreparedQueryResult result)
 
void HandleCharUndeleteEnumOpcode (WorldPackets::Character::EnumCharacters &)
 
void HandleCharDeleteOpcode (WorldPackets::Character::CharDelete &charDelete)
 
void HandleCharCreateOpcode (WorldPackets::Character::CreateCharacter &charCreate)
 
void HandleCharCreateCallback (PreparedQueryResult result, WorldPackets::Character::CharacterCreateInfo *createInfo)
 
void HandlePlayerLoginOpcode (WorldPackets::Character::PlayerLogin &playerLogin)
 
void SendConnectToInstance (WorldPackets::Auth::ConnectToSerial serial)
 
void HandleContinuePlayerLogin ()
 
void AbortLogin (WorldPackets::Character::LoginFailureReason reason)
 
void HandleLoadScreenOpcode (WorldPackets::Character::LoadingScreenNotify &loadingScreenNotify)
 
void HandlePlayerLogin (LoginQueryHolder *holder)
 
void HandleCharRenameOpcode (WorldPackets::Character::CharacterRenameRequest &request)
 
void HandleCharRenameCallBack (PreparedQueryResult result, WorldPackets::Character::CharacterRenameInfo *renameInfo)
 
void HandleSetPlayerDeclinedNames (WorldPackets::Character::SetPlayerDeclinedNames &packet)
 
void HandleAlterAppearance (WorldPackets::Character::AlterApperance &packet)
 
void HandleCharCustomizeOpcode (WorldPackets::Character::CharCustomize &packet)
 
void HandleCharCustomizeCallback (PreparedQueryResult result, WorldPackets::Character::CharCustomizeInfo *customizeInfo)
 
void HandleCharRaceOrFactionChangeOpcode (WorldPackets::Character::CharRaceOrFactionChange &packet)
 
void HandleCharRaceOrFactionChangeCallback (PreparedQueryResult result, WorldPackets::Character::CharRaceOrFactionChangeInfo *factionChangeInfo)
 
void HandleRandomizeCharNameOpcode (WorldPackets::Character::GenerateRandomCharacterName &packet)
 
void HandleReorderCharacters (WorldPackets::Character::ReorderCharacters &reorderChars)
 
void HandleOpeningCinematic (WorldPackets::Misc::OpeningCinematic &packet)
 
void HandleGetUndeleteCooldownStatus (WorldPackets::Character::GetUndeleteCharacterCooldownStatus &)
 
void HandleUndeleteCooldownStatusCallback (PreparedQueryResult result)
 
void HandleCharUndeleteOpcode (WorldPackets::Character::UndeleteCharacter &undeleteInfo)
 
void HandleCharUndeleteCallback (PreparedQueryResult result, WorldPackets::Character::CharacterUndeleteInfo *undeleteInfo)
 
void SendCharCreate (ResponseCodes result)
 
void SendCharDelete (ResponseCodes result)
 
void SendCharRename (ResponseCodes result, WorldPackets::Character::CharacterRenameInfo const *renameInfo)
 
void SendCharCustomize (ResponseCodes result, WorldPackets::Character::CharCustomizeInfo const *customizeInfo)
 
void SendCharFactionChange (ResponseCodes result, WorldPackets::Character::CharRaceOrFactionChangeInfo const *factionChangeInfo)
 
void SendSetPlayerDeclinedNamesResult (DeclinedNameResult result, ObjectGuid guid)
 
void SendBarberShopResult (BarberShopResult result)
 
void SendUndeleteCooldownStatusResponse (uint32 currentCooldown, uint32 maxCooldown)
 
void SendUndeleteCharacterResponse (CharacterUndeleteResult result, WorldPackets::Character::CharacterUndeleteInfo const *undeleteInfo)
 
void HandlePlayedTime (WorldPackets::Character::RequestPlayedTime &packet)
 
void HandleLookingForGroup (WorldPacket &recvPacket)
 
void HandlePortGraveyard (WorldPackets::Misc::PortGraveyard &packet)
 
void HandleRequestCemeteryList (WorldPackets::Misc::RequestCemeteryList &packet)
 
void HandleInspectOpcode (WorldPackets::Inspect::Inspect &inspect)
 
void HandleRequestHonorStatsOpcode (WorldPackets::Inspect::RequestHonorStats &request)
 
void HandleInspectPVP (WorldPackets::Inspect::InspectPVPRequest &request)
 
void HandleQueryInspectAchievements (WorldPackets::Inspect::QueryInspectAchievements &inspect)
 
void HandleMountSpecialAnimOpcode (WorldPackets::Misc::MountSpecial &mountSpecial)
 
void HandleShowingHelmOpcode (WorldPackets::Character::ShowingHelm &packet)
 
void HandleShowingCloakOpcode (WorldPackets::Character::ShowingCloak &packet)
 
void HandleRepairItemOpcode (WorldPackets::Item::RepairItem &packet)
 
void HandleMoveKnockBackAck (WorldPackets::Movement::MovementAckMessage &movementAck)
 
void HandleMoveTeleportAck (WorldPackets::Movement::MoveTeleportAck &packet)
 
void HandleForceSpeedChangeAck (WorldPackets::Movement::MovementSpeedAck &packet)
 
void HandleSetCollisionHeightAck (WorldPackets::Movement::MoveSetCollisionHeightAck &setCollisionHeightAck)
 
void HandlePingOpcode (WorldPacket &recvPacket)
 
void HandleRepopRequest (WorldPackets::Misc::RepopRequest &packet)
 
void HandleAutostoreLootItemOpcode (WorldPackets::Loot::LootItem &packet)
 
void HandleLootMoneyOpcode (WorldPackets::Loot::LootMoney &packet)
 
void HandleLootOpcode (WorldPackets::Loot::LootUnit &packet)
 
void HandleLootReleaseOpcode (WorldPackets::Loot::LootRelease &packet)
 
void HandleLootMasterGiveOpcode (WorldPacket &recvPacket)
 
void HandleSetLootSpecialization (WorldPackets::Loot::SetLootSpecialization &packet)
 
void HandleWhoOpcode (WorldPackets::Who::WhoRequestPkt &whoRequest)
 
void HandleLogoutRequestOpcode (WorldPackets::Character::LogoutRequest &logoutRequest)
 
void HandleLogoutCancelOpcode (WorldPackets::Character::LogoutCancel &logoutCancel)
 
void HandleGMTicketGetCaseStatusOpcode (WorldPackets::Ticket::GMTicketGetCaseStatus &packet)
 
void HandleGMTicketSystemStatusOpcode (WorldPackets::Ticket::GMTicketGetSystemStatus &packet)
 
void HandleSupportTicketSubmitBug (WorldPackets::Ticket::SupportTicketSubmitBug &packet)
 
void HandleSupportTicketSubmitSuggestion (WorldPackets::Ticket::SupportTicketSubmitSuggestion &packet)
 
void HandleSupportTicketSubmitComplaint (WorldPackets::Ticket::SupportTicketSubmitComplaint &packet)
 
void HandleBugReportOpcode (WorldPackets::Ticket::BugReport &bugReport)
 
void HandleComplaint (WorldPackets::Ticket::Complaint &packet)
 
void HandleTogglePvP (WorldPackets::Misc::TogglePvP &packet)
 
void HandleSetPvP (WorldPackets::Misc::SetPvP &packet)
 
void HandleSetSelectionOpcode (WorldPackets::Misc::SetSelection &packet)
 
void HandleStandStateChangeOpcode (WorldPackets::Misc::StandStateChange &packet)
 
void HandleEmoteOpcode (WorldPackets::Chat::EmoteClient &packet)
 
void HandleContactListOpcode (WorldPackets::Social::SendContactList &packet)
 
void HandleAddFriendOpcode (WorldPackets::Social::AddFriend &packet)
 
void HandleAddFriendOpcodeCallBack (PreparedQueryResult result, std::string const &friendNote)
 
void HandleDelFriendOpcode (WorldPackets::Social::DelFriend &packet)
 
void HandleAddIgnoreOpcode (WorldPackets::Social::AddIgnore &packet)
 
void HandleAddIgnoreOpcodeCallBack (PreparedQueryResult result)
 
void HandleDelIgnoreOpcode (WorldPackets::Social::DelIgnore &packet)
 
void HandleSetContactNotesOpcode (WorldPackets::Social::SetContactNotes &packet)
 
void HandleAreaTriggerOpcode (WorldPackets::Misc::AreaTrigger &packet)
 
void HandleSetFactionAtWar (WorldPackets::Character::SetFactionAtWar &packet)
 
void HandleSetFactionNotAtWar (WorldPackets::Character::SetFactionNotAtWar &packet)
 
void HandleSetFactionCheat (WorldPacket &recvData)
 
void HandleSetWatchedFactionOpcode (WorldPackets::Character::SetWatchedFaction &packet)
 
void HandleSetFactionInactiveOpcode (WorldPackets::Character::SetFactionInactive &packet)
 
void HandleRequestForcedReactionsOpcode (WorldPackets::Reputation::RequestForcedReactions &requestForcedReactions)
 
void HandleUpdateAccountData (WorldPackets::ClientConfig::UserClientUpdateAccountData &packet)
 
void HandleRequestAccountData (WorldPackets::ClientConfig::RequestAccountData &request)
 
void HandleSetAdvancedCombatLogging (WorldPackets::ClientConfig::SetAdvancedCombatLogging &setAdvancedCombatLogging)
 
void HandleSetActionButtonOpcode (WorldPackets::Spells::SetActionButton &packet)
 
void HandleGameObjectUseOpcode (WorldPackets::GameObject::GameObjUse &packet)
 
void HandleMeetingStoneInfo (WorldPacket &recPacket)
 
void HandleGameobjectReportUse (WorldPackets::GameObject::GameObjReportUse &packet)
 
void HandleNameQueryOpcode (WorldPackets::Query::QueryPlayerName &packet)
 
void HandleQueryTimeOpcode (WorldPackets::Query::QueryTime &queryTime)
 
void HandleCreatureQuery (WorldPackets::Query::QueryCreature &packet)
 Only static data is sent in this packet !!! More...
 
void HandleDBQueryBulk (WorldPackets::Query::DBQueryBulk &packet)
 
void HandleGameObjectQueryOpcode (WorldPackets::Query::QueryGameObject &packet)
 Only static data is sent in this packet !!! More...
 
void HandleMoveWorldportAckOpcode (WorldPackets::Movement::WorldPortResponse &packet)
 
void HandleMoveWorldportAckOpcode ()
 
void HandleMovementOpcodes (WorldPackets::Movement::ClientPlayerMovement &packet)
 
void HandleSetActiveMoverOpcode (WorldPackets::Movement::SetActiveMover &packet)
 
void HandleMoveDismissVehicle (WorldPackets::Vehicle::MoveDismissVehicle &moveDismissVehicle)
 
void HandleRequestVehiclePrevSeat (WorldPackets::Vehicle::RequestVehiclePrevSeat &requestVehiclePrevSeat)
 
void HandleRequestVehicleNextSeat (WorldPackets::Vehicle::RequestVehicleNextSeat &requestVehicleNextSeat)
 
void HandleMoveChangeVehicleSeats (WorldPackets::Vehicle::MoveChangeVehicleSeats &moveChangeVehicleSeats)
 
void HandleRequestVehicleSwitchSeat (WorldPackets::Vehicle::RequestVehicleSwitchSeat &requestVehicleSwitchSeat)
 
void HandleRideVehicleInteract (WorldPackets::Vehicle::RideVehicleInteract &rideVehicleInteract)
 
void HandleEjectPassenger (WorldPackets::Vehicle::EjectPassenger &ejectPassenger)
 
void HandleRequestVehicleExit (WorldPackets::Vehicle::RequestVehicleExit &requestVehicleExit)
 
void HandleMoveSetVehicleRecAck (WorldPackets::Vehicle::MoveSetVehicleRecIdAck &setVehicleRecIdAck)
 
void HandleMoveTimeSkippedOpcode (WorldPackets::Movement::MoveTimeSkipped &moveTimeSkipped)
 
void HandleMovementAckMessage (WorldPackets::Movement::MovementAckMessage &movementAck)
 
void HandleRequestRaidInfoOpcode (WorldPackets::Party::RequestRaidInfo &packet)
 
void HandlePartyInviteOpcode (WorldPackets::Party::PartyInviteClient &packet)
 
void HandlePartyInviteResponseOpcode (WorldPackets::Party::PartyInviteResponse &packet)
 
void HandlePartyUninviteOpcode (WorldPackets::Party::PartyUninvite &packet)
 
void HandleSetPartyLeaderOpcode (WorldPackets::Party::SetPartyLeader &packet)
 
void HandleSetRoleOpcode (WorldPackets::Party::SetRole &packet)
 
void HandleLeaveGroupOpcode (WorldPackets::Party::LeaveGroup &packet)
 
void HandleOptOutOfLootOpcode (WorldPackets::Party::OptOutOfLoot &packet)
 
void HandleSetLootMethodOpcode (WorldPackets::Party::SetLootMethod &packet)
 
void HandleLootRoll (WorldPackets::Loot::LootRoll &packet)
 
void HandleRequestPartyMemberStatsOpcode (WorldPackets::Party::RequestPartyMemberStats &packet)
 
void HandleUpdateRaidTargetOpcode (WorldPackets::Party::UpdateRaidTarget &packet)
 
void HandleDoReadyCheckOpcode (WorldPackets::Party::DoReadyCheck &packet)
 
void HandleReadyCheckResponseOpcode (WorldPackets::Party::ReadyCheckResponseClient &packet)
 
void HandleConvertRaidOpcode (WorldPackets::Party::ConvertRaid &packet)
 
void HandleRequestPartyJoinUpdates (WorldPackets::Party::RequestPartyJoinUpdates &packet)
 
void HandleChangeSubGroupOpcode (WorldPackets::Party::ChangeSubGroup &packet)
 
void HandleSwapSubGroupsOpcode (WorldPackets::Party::SwapSubGroups &packet)
 
void HandleSetAssistantLeaderOpcode (WorldPackets::Party::SetAssistantLeader &packet)
 
void HandleSetPartyAssignment (WorldPackets::Party::SetPartyAssignment &packet)
 
void HandleInitiateRolePoll (WorldPackets::Party::InitiateRolePoll &packet)
 
void HandleSetEveryoneIsAssistant (WorldPackets::Party::SetEveryoneIsAssistant &packet)
 
void HandleClearRaidMarker (WorldPackets::Party::ClearRaidMarker &packet)
 
void HandleDeclinePetition (WorldPackets::Petition::DeclinePetition &packet)
 
void HandleOfferPetition (WorldPackets::Petition::OfferPetition &packet)
 
void HandlePetitionBuy (WorldPackets::Petition::PetitionBuy &packet)
 
void HandlePetitionShowSignatures (WorldPackets::Petition::PetitionShowSignatures &packet)
 
void HandleQueryPetition (WorldPackets::Petition::QueryPetition &packet)
 
void HandlePetitionRenameGuild (WorldPackets::Petition::PetitionRenameGuild &packet)
 
void HandleSignPetition (WorldPackets::Petition::SignPetition &packet)
 
void HandleTurnInPetition (WorldPackets::Petition::TurnInPetition &packet)
 
void HandleGuildQueryOpcode (WorldPackets::Guild::QueryGuildInfo &query)
 
void HandleGuildInviteByName (WorldPackets::Guild::GuildInviteByName &packet)
 
void HandleGuildOfficerRemoveMember (WorldPackets::Guild::GuildOfficerRemoveMember &packet)
 
void HandleGuildAcceptInvite (WorldPackets::Guild::AcceptGuildInvite &invite)
 
void HandleGuildDeclineInvitation (WorldPackets::Guild::GuildDeclineInvitation &decline)
 
void HandleGuildEventLogQuery (WorldPackets::Guild::GuildEventLogQuery &packet)
 
void HandleGuildGetRoster (WorldPackets::Guild::GuildGetRoster &packet)
 
void HandleRequestGuildRewardsList (WorldPackets::Guild::RequestGuildRewardsList &packet)
 
void HandleGuildPromoteMember (WorldPackets::Guild::GuildPromoteMember &promote)
 
void HandleGuildDemoteMember (WorldPackets::Guild::GuildDemoteMember &demote)
 
void HandleGuildAssignRank (WorldPackets::Guild::GuildAssignMemberRank &packet)
 
void HandleGuildLeave (WorldPackets::Guild::GuildLeave &leave)
 
void HandleGuildDelete (WorldPackets::Guild::GuildDelete &packet)
 
void HandleGuildSetAchievementTracking (WorldPackets::Guild::GuildSetAchievementTracking &packet)
 
void HandleGuildSetGuildMaster (WorldPackets::Guild::GuildSetGuildMaster &packet)
 
void HandleGuildUpdateMotdText (WorldPackets::Guild::GuildUpdateMotdText &packet)
 
void HandleGuildNewsUpdateSticky (WorldPackets::Guild::GuildNewsUpdateSticky &packet)
 
void HandleGuildSetMemberNote (WorldPackets::Guild::GuildSetMemberNote &packet)
 
void HandleGuildGetRanks (WorldPackets::Guild::GuildGetRanks &packet)
 
void HandleGuildQueryNews (WorldPackets::Guild::GuildQueryNews &newsQuery)
 
void HandleGuildSetRankPermissions (WorldPackets::Guild::GuildSetRankPermissions &packet)
 
void HandleGuildAddRank (WorldPackets::Guild::GuildAddRank &packet)
 
void HandleGuildDeleteRank (WorldPackets::Guild::GuildDeleteRank &packet)
 
void HandleGuildUpdateInfoText (WorldPackets::Guild::GuildUpdateInfoText &packet)
 
void HandleSaveGuildEmblem (WorldPackets::Guild::SaveGuildEmblem &packet)
 
void HandleGuildRequestPartyState (WorldPackets::Guild::RequestGuildPartyState &packet)
 
void HandleGuildChallengeUpdateRequest (WorldPackets::Guild::GuildChallengeUpdateRequest &packet)
 
void HandleDeclineGuildInvites (WorldPackets::Guild::DeclineGuildInvites &packet)
 
void HandleGuildFinderAddRecruit (WorldPackets::GuildFinder::LFGuildAddRecruit &lfGuildAddRecruit)
 
void HandleGuildFinderBrowse (WorldPackets::GuildFinder::LFGuildBrowse &lfGuildBrowse)
 
void HandleGuildFinderDeclineRecruit (WorldPackets::GuildFinder::LFGuildDeclineRecruit &lfGuildDeclineRecruit)
 
void HandleGuildFinderGetApplications (WorldPackets::GuildFinder::LFGuildGetApplications &lfGuildGetApplications)
 
void HandleGuildFinderGetGuildPost (WorldPackets::GuildFinder::LFGuildGetGuildPost &lfGuildGetGuildPost)
 
void HandleGuildFinderGetRecruits (WorldPackets::GuildFinder::LFGuildGetRecruits &lfGuildGetRecruits)
 
void HandleGuildFinderRemoveRecruit (WorldPackets::GuildFinder::LFGuildRemoveRecruit &lfGuildRemoveRecruit)
 
void HandleGuildFinderSetGuildPost (WorldPackets::GuildFinder::LFGuildSetGuildPost &lfGuildSetGuildPost)
 
void HandleEnableTaxiNodeOpcode (WorldPackets::Taxi::EnableTaxiNode &enableTaxiNode)
 
void HandleTaxiNodeStatusQueryOpcode (WorldPackets::Taxi::TaxiNodeStatusQuery &taxiNodeStatusQuery)
 
void HandleTaxiQueryAvailableNodesOpcode (WorldPackets::Taxi::TaxiQueryAvailableNodes &taxiQueryAvailableNodes)
 
void HandleActivateTaxiOpcode (WorldPackets::Taxi::ActivateTaxi &activateTaxi)
 
void HandleMoveSplineDoneOpcode (WorldPackets::Movement::MoveSplineDone &moveSplineDone)
 
void SendActivateTaxiReply (ActivateTaxiReply reply)
 
void HandleTaxiRequestEarlyLanding (WorldPackets::Taxi::TaxiRequestEarlyLanding &taxiRequestEarlyLanding)
 
void HandleTabardVendorActivateOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleBankerActivateOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleTrainerListOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleTrainerBuySpellOpcode (WorldPackets::NPC::TrainerBuySpell &packet)
 
void HandlePetitionShowList (WorldPackets::Petition::PetitionShowList &packet)
 
void HandleGossipHelloOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleGossipSelectOptionOpcode (WorldPackets::NPC::GossipSelectOption &packet)
 
void HandleSpiritHealerActivate (WorldPackets::NPC::SpiritHealerActivate &packet)
 
void HandleNpcTextQueryOpcode (WorldPackets::Query::QueryNPCText &packet)
 
void HandleBinderActivateOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleRequestStabledPets (WorldPackets::NPC::RequestStabledPets &packet)
 
void HandleStablePet (WorldPacket &recvPacket)
 
void HandleStablePetCallback (PreparedQueryResult result)
 
void HandleUnstablePet (WorldPacket &recvPacket)
 
void HandleUnstablePetCallback (PreparedQueryResult result, uint32 petId)
 
void HandleBuyStableSlot (WorldPacket &recvPacket)
 
void HandleStableRevivePet (WorldPacket &recvPacket)
 
void HandleStableSwapPet (WorldPacket &recvPacket)
 
void HandleStableSwapPetCallback (PreparedQueryResult result, uint32 petId)
 
void SendTrainerBuyFailed (ObjectGuid trainerGUID, uint32 spellID, int32 trainerFailedReason)
 
void HandleCanDuel (WorldPackets::Duel::CanDuel &packet)
 
void HandleDuelResponseOpcode (WorldPackets::Duel::DuelResponse &duelResponse)
 
void HandleDuelAccepted ()
 
void HandleDuelCancelled ()
 
void HandleAcceptTradeOpcode (WorldPackets::Trade::AcceptTrade &acceptTrade)
 
void HandleBeginTradeOpcode (WorldPackets::Trade::BeginTrade &beginTrade)
 
void HandleBusyTradeOpcode (WorldPackets::Trade::BusyTrade &busyTrade)
 
void HandleCancelTradeOpcode (WorldPackets::Trade::CancelTrade &cancelTrade)
 
void HandleClearTradeItemOpcode (WorldPackets::Trade::ClearTradeItem &clearTradeItem)
 
void HandleIgnoreTradeOpcode (WorldPackets::Trade::IgnoreTrade &ignoreTrade)
 
void HandleInitiateTradeOpcode (WorldPackets::Trade::InitiateTrade &initiateTrade)
 
void HandleSetTradeCurrencyOpcode (WorldPackets::Trade::SetTradeCurrency &setTradeCurrency)
 
void HandleSetTradeGoldOpcode (WorldPackets::Trade::SetTradeGold &setTradeGold)
 
void HandleSetTradeItemOpcode (WorldPackets::Trade::SetTradeItem &setTradeItem)
 
void HandleUnacceptTradeOpcode (WorldPackets::Trade::UnacceptTrade &unacceptTrade)
 
void HandleAuctionHelloOpcode (WorldPackets::AuctionHouse::AuctionHelloRequest &packet)
 
void HandleAuctionListItems (WorldPackets::AuctionHouse::AuctionListItems &packet)
 
void HandleAuctionListBidderItems (WorldPackets::AuctionHouse::AuctionListBidderItems &packet)
 
void HandleAuctionSellItem (WorldPackets::AuctionHouse::AuctionSellItem &packet)
 
void HandleAuctionRemoveItem (WorldPackets::AuctionHouse::AuctionRemoveItem &packet)
 
void HandleAuctionListOwnerItems (WorldPackets::AuctionHouse::AuctionListOwnerItems &packet)
 
void HandleAuctionPlaceBid (WorldPackets::AuctionHouse::AuctionPlaceBid &packet)
 
void HandleAuctionListPendingSales (WorldPackets::AuctionHouse::AuctionListPendingSales &packet)
 
void HandleReplicateItems (WorldPackets::AuctionHouse::AuctionReplicateItems &packet)
 
void HandleAutoBankItemOpcode (WorldPackets::Bank::AutoBankItem &packet)
 
void HandleAutoStoreBankItemOpcode (WorldPackets::Bank::AutoStoreBankItem &packet)
 
void HandleBuyBankSlotOpcode (WorldPackets::Bank::BuyBankSlot &packet)
 
void HandleBlackMarketOpen (WorldPackets::BlackMarket::BlackMarketOpen &packet)
 
void HandleGetMailList (WorldPackets::Mail::MailGetList &packet)
 
void HandleSendMail (WorldPackets::Mail::SendMail &packet)
 
void HandleMailTakeMoney (WorldPackets::Mail::MailTakeMoney &packet)
 
void HandleMailTakeItem (WorldPackets::Mail::MailTakeItem &packet)
 
void HandleMailMarkAsRead (WorldPackets::Mail::MailMarkAsRead &packet)
 
void HandleMailReturnToSender (WorldPackets::Mail::MailReturnToSender &packet)
 
void HandleMailDelete (WorldPackets::Mail::MailDelete &packet)
 
void HandleItemTextQuery (WorldPackets::Query::ItemTextQuery &itemTextQuery)
 
void HandleMailCreateTextItem (WorldPackets::Mail::MailCreateTextItem &packet)
 
void HandleQueryNextMailTime (WorldPackets::Mail::MailQueryNextMailTime &packet)
 
void HandleCancelChanneling (WorldPackets::Spells::CancelChannelling &cancelChanneling)
 
void SendItemPageInfo (ItemTemplate *itemProto)
 
void HandleSplitItemOpcode (WorldPackets::Item::SplitItem &splitItem)
 
void HandleSwapInvItemOpcode (WorldPackets::Item::SwapInvItem &swapInvItem)
 
void HandleDestroyItemOpcode (WorldPackets::Item::DestroyItem &destroyItem)
 
void HandleAutoEquipItemOpcode (WorldPackets::Item::AutoEquipItem &autoEquipItem)
 
void HandleSellItemOpcode (WorldPackets::Item::SellItem &packet)
 
void HandleBuyItemOpcode (WorldPackets::Item::BuyItem &packet)
 
void HandleListInventoryOpcode (WorldPackets::NPC::Hello &packet)
 
void HandleAutoStoreBagItemOpcode (WorldPackets::Item::AutoStoreBagItem &packet)
 
void HandleReadItem (WorldPackets::Item::ReadItem &readItem)
 
void HandleAutoEquipItemSlotOpcode (WorldPackets::Item::AutoEquipItemSlot &autoEquipItemSlot)
 
void HandleSwapItem (WorldPackets::Item::SwapItem &swapItem)
 
void HandleBuybackItem (WorldPackets::Item::BuyBackItem &packet)
 
void HandleWrapItem (WorldPackets::Item::WrapItem &packet)
 
void HandleUseCritterItem (WorldPackets::Item::UseCritterItem &packet)
 
void HandleAttackSwingOpcode (WorldPackets::Combat::AttackSwing &packet)
 
void HandleAttackStopOpcode (WorldPackets::Combat::AttackStop &packet)
 
void HandleSetSheathedOpcode (WorldPackets::Combat::SetSheathed &packet)
 
void HandleUseItemOpcode (WorldPackets::Spells::UseItem &packet)
 
void HandleOpenItemOpcode (WorldPackets::Spells::OpenItem &packet)
 
void HandleCastSpellOpcode (WorldPackets::Spells::CastSpell &castRequest)
 
void HandleCancelCastOpcode (WorldPackets::Spells::CancelCast &packet)
 
void HandleCancelAuraOpcode (WorldPackets::Spells::CancelAura &cancelAura)
 
void HandleCancelGrowthAuraOpcode (WorldPackets::Spells::CancelGrowthAura &cancelGrowthAura)
 
void HandleCancelMountAuraOpcode (WorldPackets::Spells::CancelMountAura &cancelMountAura)
 
void HandleCancelAutoRepeatSpellOpcode (WorldPackets::Spells::CancelAutoRepeatSpell &cancelAutoRepeatSpell)
 
void HandleMissileTrajectoryCollision (WorldPackets::Spells::MissileTrajectoryCollision &packet)
 
void HandleUpdateMissileTrajectory (WorldPackets::Spells::UpdateMissileTrajectory &packet)
 
void HandleLearnTalentsOpcode (WorldPackets::Talent::LearnTalents &packet)
 
void HandleConfirmRespecWipeOpcode (WorldPackets::Talent::ConfirmRespecWipe &confirmRespecWipe)
 
void HandleUnlearnSkillOpcode (WorldPackets::Spells::UnlearnSkill &packet)
 
void HandleSetSpecializationOpcode (WorldPackets::Talent::SetSpecialization &packet)
 
void HandleQuestgiverStatusQueryOpcode (WorldPackets::Quest::QuestGiverStatusQuery &packet)
 
void HandleQuestgiverStatusMultipleQuery (WorldPackets::Quest::QuestGiverStatusMultipleQuery &packet)
 
void HandleQuestgiverHelloOpcode (WorldPackets::Quest::QuestGiverHello &packet)
 
void HandleQuestgiverAcceptQuestOpcode (WorldPackets::Quest::QuestGiverAcceptQuest &packet)
 
void HandleQuestgiverQueryQuestOpcode (WorldPackets::Quest::QuestGiverQueryQuest &packet)
 
void HandleQuestgiverChooseRewardOpcode (WorldPackets::Quest::QuestGiverChooseReward &packet)
 
void HandleQuestgiverRequestRewardOpcode (WorldPackets::Quest::QuestGiverRequestReward &packet)
 
void HandleQuestQueryOpcode (WorldPackets::Quest::QueryQuestInfo &packet)
 
void HandleQuestgiverCancel (WorldPacket &recvData)
 
void HandleQuestLogRemoveQuest (WorldPackets::Quest::QuestLogRemoveQuest &packet)
 
void HandleQuestConfirmAccept (WorldPackets::Quest::QuestConfirmAccept &packet)
 
void HandleQuestgiverCompleteQuest (WorldPackets::Quest::QuestGiverCompleteQuest &packet)
 
void HandleQuestgiverQuestAutoLaunch (WorldPacket &recvPacket)
 
void HandlePushQuestToParty (WorldPackets::Quest::PushQuestToParty &packet)
 
void HandleQuestPushResult (WorldPackets::Quest::QuestPushResult &packet)
 
void HandleChatMessageOpcode (WorldPackets::Chat::ChatMessage &chatMessage)
 
void HandleChatMessageWhisperOpcode (WorldPackets::Chat::ChatMessageWhisper &chatMessageWhisper)
 
void HandleChatMessageChannelOpcode (WorldPackets::Chat::ChatMessageChannel &chatMessageChannel)
 
void HandleChatMessage (ChatMsg type, uint32 lang, std::string msg, std::string target="")
 
void HandleChatAddonMessageOpcode (WorldPackets::Chat::ChatAddonMessage &chatAddonMessage)
 
void HandleChatAddonMessageWhisperOpcode (WorldPackets::Chat::ChatAddonMessageWhisper &chatAddonMessageWhisper)
 
void HandleChatAddonMessageChannelOpcode (WorldPackets::Chat::ChatAddonMessageChannel &chatAddonMessageChannel)
 
void HandleChatAddonMessage (ChatMsg type, std::string prefix, std::string text, std::string target="")
 
void HandleChatMessageAFKOpcode (WorldPackets::Chat::ChatMessageAFK &chatMessageAFK)
 
void HandleChatMessageDNDOpcode (WorldPackets::Chat::ChatMessageDND &chatMessageDND)
 
void HandleChatMessageEmoteOpcode (WorldPackets::Chat::ChatMessageEmote &chatMessageEmote)
 
void SendChatPlayerNotfoundNotice (std::string const &name)
 
void SendPlayerAmbiguousNotice (std::string const &name)
 
void SendChatRestricted (ChatRestrictionType restriction)
 
void HandleTextEmoteOpcode (WorldPackets::Chat::CTextEmote &packet)
 
void HandleChatIgnoredOpcode (WorldPackets::Chat::ChatReportIgnored &chatReportIgnored)
 
void HandleUnregisterAllAddonPrefixesOpcode (WorldPackets::Chat::ChatUnregisterAllAddonPrefixes &packet)
 
void HandleAddonRegisteredPrefixesOpcode (WorldPackets::Chat::ChatRegisterAddonPrefixes &packet)
 
void HandleReclaimCorpse (WorldPackets::Misc::ReclaimCorpse &packet)
 
void HandleQueryCorpseLocation (WorldPackets::Query::QueryCorpseLocationFromClient &packet)
 
void HandleQueryCorpseTransport (WorldPackets::Query::QueryCorpseTransport &packet)
 
void HandleResurrectResponse (WorldPackets::Misc::ResurrectResponse &packet)
 
void HandleSummonResponseOpcode (WorldPackets::Movement::SummonResponse &packet)
 
void HandleJoinChannel (WorldPackets::Channel::JoinChannel &packet)
 
void HandleLeaveChannel (WorldPackets::Channel::LeaveChannel &packet)
 
template<void(Channel::*)(Player const *) CommandFunction>
void HandleChannelCommand (WorldPackets::Channel::ChannelPlayerCommand &packet)
 
template<void(Channel::*)(Player const *, std::string const &) CommandFunction>
void HandleChannelPlayerCommand (WorldPackets::Channel::ChannelPlayerCommand &packet)
 
void HandleVoiceSessionEnable (WorldPackets::Voice::VoiceSessionEnable &packet)
 
void HandleSetActiveVoiceChannel (WorldPackets::Voice::SetActiveVoiceChannel &packet)
 
void HandleCompleteCinematic (WorldPackets::Misc::CompleteCinematic &packet)
 
void HandleNextCinematicCamera (WorldPackets::Misc::NextCinematicCamera &packet)
 
void HandleQueryPageText (WorldPackets::Query::QueryPageText &packet)
 Only static data is sent in this packet !!! More...
 
void HandleTutorialFlag (WorldPackets::Misc::TutorialSetFlag &packet)
 
void HandlePetAction (WorldPackets::Pet::PetAction &packet)
 
void HandlePetStopAttack (WorldPackets::Pet::PetStopAttack &packet)
 
void HandlePetActionHelper (Unit *pet, ObjectGuid guid1, uint32 spellid, uint16 flag, ObjectGuid guid2, float x, float y, float z)
 
void HandleQueryPetName (WorldPackets::Query::QueryPetName &packet)
 
void HandlePetSetAction (WorldPackets::Pet::PetSetAction &packet)
 
void HandlePetAbandon (WorldPackets::Pet::PetAbandon &packet)
 
void HandlePetRename (WorldPackets::Pet::PetRename &packet)
 
void HandlePetCancelAuraOpcode (WorldPackets::Spells::PetCancelAura &packet)
 
void HandlePetSpellAutocastOpcode (WorldPackets::Pet::PetSpellAutocast &packet)
 
void HandlePetCastSpellOpcode (WorldPackets::Spells::PetCastSpell &petCastSpell)
 
void HandleSetActionBarToggles (WorldPackets::Character::SetActionBarToggles &packet)
 
void HandleTotemDestroyed (WorldPackets::Totem::TotemDestroyed &totemDestroyed)
 
void HandleDismissCritter (WorldPackets::Pet::DismissCritter &dismissCritter)
 
void HandleBattlemasterHelloOpcode (WorldPackets::NPC::Hello &hello)
 
void HandleBattlemasterJoinOpcode (WorldPackets::Battleground::BattlemasterJoin &battlemasterJoin)
 
void HandlePVPLogDataOpcode (WorldPackets::Battleground::PVPLogDataRequest &pvpLogDataRequest)
 
void HandleBattleFieldPortOpcode (WorldPackets::Battleground::BattlefieldPort &battlefieldPort)
 
void HandleBattlefieldListOpcode (WorldPackets::Battleground::BattlefieldListRequest &battlefieldList)
 
void HandleBattlefieldLeaveOpcode (WorldPackets::Battleground::BattlefieldLeave &battlefieldLeave)
 
void HandleBattlemasterJoinArena (WorldPackets::Battleground::BattlemasterJoinArena &packet)
 
void HandleReportPvPAFK (WorldPackets::Battleground::ReportPvPPlayerAFK &reportPvPPlayerAFK)
 
void HandleRequestRatedBattlefieldInfo (WorldPackets::Battleground::RequestRatedBattlefieldInfo &packet)
 
void HandleGetPVPOptionsEnabled (WorldPackets::Battleground::GetPVPOptionsEnabled &getPvPOptionsEnabled)
 
void HandleRequestPvpReward (WorldPackets::Battleground::RequestPVPRewards &packet)
 
void HandleAreaSpiritHealerQueryOpcode (WorldPackets::Battleground::AreaSpiritHealerQuery &areaSpiritHealerQuery)
 
void HandleAreaSpiritHealerQueueOpcode (WorldPackets::Battleground::AreaSpiritHealerQueue &areaSpiritHealerQueue)
 
void HandleHearthAndResurrect (WorldPackets::Battleground::HearthAndResurrect &hearthAndResurrect)
 
void HandleRequestBattlefieldStatusOpcode (WorldPackets::Battleground::RequestBattlefieldStatus &requestBattlefieldStatus)
 
void SendBfInvitePlayerToWar (uint64 queueId, uint32 zoneId, uint32 acceptTime)
 This send to player windows for invite player to join the war. More...
 
void SendBfInvitePlayerToQueue (uint64 queueId, int8 battleState)
 This send invitation to player to join the queue. More...
 
void SendBfQueueInviteResponse (uint64 queueId, uint32 zoneId, int8 battleStatus, bool canQueue=true, bool loggingIn=false)
 This send packet for inform player that he join queue. More...
 
void SendBfEntered (uint64 queueId, bool relocated, bool onOffense)
 This is call when player accept to join war. More...
 
void SendBfLeaveMessage (uint64 queueId, int8 battleState, bool relocated, BFLeaveReason reason=BF_LEAVE_REASON_EXITED)
 This is call when player leave battlefield zone. More...
 
void HandleBfEntryInviteResponse (WorldPackets::Battlefield::BFMgrEntryInviteResponse &bfMgrEntryInviteResponse)
 Send by client on clicking in accept or refuse of invitation windows for join game. More...
 
void HandleBfQueueInviteResponse (WorldPackets::Battlefield::BFMgrQueueInviteResponse &bfMgrQueueInviteResponse)
 Send by client when he click on accept for queue. More...
 
void HandleBfQueueExitRequest (WorldPackets::Battlefield::BFMgrQueueExitRequest &bfMgrQueueExitRequest)
 
void HandleWorldTeleportOpcode (WorldPackets::Misc::WorldTeleport &worldTeleport)
 
void HandleMinimapPingOpcode (WorldPackets::Party::MinimapPingClient &packet)
 
void HandleRandomRollOpcode (WorldPackets::Misc::RandomRollClient &packet)
 
void HandleFarSightOpcode (WorldPackets::Misc::FarSight &packet)
 
void HandleSetDungeonDifficultyOpcode (WorldPackets::Misc::SetDungeonDifficulty &setDungeonDifficulty)
 
void HandleSetRaidDifficultyOpcode (WorldPackets::Misc::SetRaidDifficulty &setRaidDifficulty)
 
void HandleSetTitleOpcode (WorldPackets::Character::SetTitle &packet)
 
void HandleTimeSyncResponse (WorldPackets::Misc::TimeSyncResponse &packet)
 
void HandleWhoIsOpcode (WorldPackets::Who::WhoIsRequest &packet)
 
void HandleResetInstancesOpcode (WorldPackets::Instance::ResetInstances &packet)
 
void HandleInstanceLockResponse (WorldPackets::Instance::InstanceLockResponse &packet)
 
void HandleLfgSetCommentOpcode (WorldPacket &recvData)
 
void HandleDFGetSystemInfo (WorldPacket &recvData)
 
void SendLfgPlayerLockInfo ()
 
void SendLfgPartyLockInfo ()
 
void HandleLfgJoinOpcode (WorldPacket &recvData)
 
void HandleLfgLeaveOpcode (WorldPacket &recvData)
 
void HandleLfgSetRolesOpcode (WorldPacket &recvData)
 
void HandleLfgProposalResultOpcode (WorldPacket &recvData)
 
void HandleLfgSetBootVoteOpcode (WorldPacket &recvData)
 
void HandleLfgTeleportOpcode (WorldPacket &recvData)
 
void HandleLfrJoinOpcode (WorldPacket &recvData)
 
void HandleLfrLeaveOpcode (WorldPacket &recvData)
 
void HandleDFGetJoinStatus (WorldPacket &recvData)
 
void SendLfgUpdateStatus (lfg::LfgUpdateData const &updateData, bool party)
 
void SendLfgRoleChosen (ObjectGuid guid, uint8 roles)
 
void SendLfgRoleCheckUpdate (lfg::LfgRoleCheck const &pRoleCheck)
 
void SendLfgLfrList (bool update)
 
void SendLfgJoinResult (lfg::LfgJoinResultData const &joinData)
 
void SendLfgQueueStatus (lfg::LfgQueueStatusData const &queueData)
 
void SendLfgPlayerReward (lfg::LfgPlayerRewardData const &lfgPlayerRewardData)
 
void SendLfgBootProposalUpdate (lfg::LfgPlayerBoot const &boot)
 
void SendLfgUpdateProposal (lfg::LfgProposal const &proposal)
 
void SendLfgDisabled ()
 
void SendLfgOfferContinue (uint32 dungeonEntry)
 
void SendLfgTeleportError (uint8 err)
 
void HandleSelfResOpcode (WorldPackets::Spells::SelfRes &packet)
 
void HandleRequestPetInfo (WorldPackets::Pet::RequestPetInfo &packet)
 
void HandleSocketGems (WorldPackets::Item::SocketGems &socketGems)
 
void HandleCancelTempEnchantmentOpcode (WorldPackets::Item::CancelTempEnchantment &cancelTempEnchantment)
 
void HandleGetItemPurchaseData (WorldPackets::Item::GetItemPurchaseData &packet)
 
void HandleItemRefund (WorldPackets::Item::ItemPurchaseRefund &packet)
 
void HandleSetTaxiBenchmark (WorldPackets::Misc::SetTaxiBenchmarkMode &packet)
 
void HandleGuildPermissionsQuery (WorldPackets::Guild::GuildPermissionsQuery &packet)
 
void HandleGuildBankMoneyWithdrawn (WorldPackets::Guild::GuildBankRemainingWithdrawMoneyQuery &packet)
 
void HandleGuildBankActivate (WorldPackets::Guild::GuildBankActivate &packet)
 
void HandleGuildBankQueryTab (WorldPackets::Guild::GuildBankQueryTab &packet)
 
void HandleGuildBankLogQuery (WorldPackets::Guild::GuildBankLogQuery &packet)
 
void HandleGuildBankDepositMoney (WorldPackets::Guild::GuildBankDepositMoney &packet)
 
void HandleGuildBankWithdrawMoney (WorldPackets::Guild::GuildBankWithdrawMoney &packet)
 
void HandleGuildBankSwapItems (WorldPackets::Guild::GuildBankSwapItems &packet)
 
void HandleGuildBankUpdateTab (WorldPackets::Guild::GuildBankUpdateTab &packet)
 
void HandleGuildBankBuyTab (WorldPackets::Guild::GuildBankBuyTab &packet)
 
void HandleGuildBankTextQuery (WorldPackets::Guild::GuildBankTextQuery &packet)
 
void HandleGuildBankSetTabText (WorldPackets::Guild::GuildBankSetTabText &packet)
 
void HandleGrantLevel (WorldPackets::RaF::GrantLevel &grantLevel)
 
void HandleAcceptGrantLevel (WorldPackets::RaF::AcceptLevelGrant &acceptLevelGrant)
 
void HandleCalendarGetCalendar (WorldPackets::Calendar::CalendarGetCalendar &calendarGetCalendar)
 
void HandleCalendarGetEvent (WorldPackets::Calendar::CalendarGetEvent &calendarGetEvent)
 
void HandleCalendarGuildFilter (WorldPackets::Calendar::CalendarGuildFilter &calendarGuildFilter)
 
void HandleCalendarAddEvent (WorldPackets::Calendar::CalendarAddEvent &calendarAddEvent)
 
void HandleCalendarUpdateEvent (WorldPackets::Calendar::CalendarUpdateEvent &calendarUpdateEvent)
 
void HandleCalendarRemoveEvent (WorldPackets::Calendar::CalendarRemoveEvent &calendarRemoveEvent)
 
void HandleCalendarCopyEvent (WorldPackets::Calendar::CalendarCopyEvent &calendarCopyEvent)
 
void HandleCalendarEventInvite (WorldPackets::Calendar::CalendarEventInvite &calendarEventInvite)
 
void HandleCalendarEventRsvp (WorldPackets::Calendar::CalendarEventRSVP &calendarEventRSVP)
 
void HandleCalendarEventRemoveInvite (WorldPackets::Calendar::CalendarRemoveInvite &calendarRemoveInvite)
 
void HandleCalendarEventStatus (WorldPackets::Calendar::CalendarEventStatus &calendarEventStatus)
 
void HandleCalendarEventModeratorStatus (WorldPackets::Calendar::CalendarEventModeratorStatus &calendarEventModeratorStatus)
 
void HandleCalendarComplain (WorldPackets::Calendar::CalendarComplain &calendarComplain)
 
void HandleCalendarGetNumPending (WorldPackets::Calendar::CalendarGetNumPending &calendarGetNumPending)
 
void HandleCalendarEventSignup (WorldPackets::Calendar::CalendarEventSignUp &calendarEventSignUp)
 
void SendCalendarRaidLockout (InstanceSave const *save, bool add)
 
void SendCalendarRaidLockoutUpdated (InstanceSave const *save)
 
void HandleSetSavedInstanceExtend (WorldPackets::Calendar::SetSavedInstanceExtend &setSavedInstanceExtend)
 
void HandleVoidStorageUnlock (WorldPackets::VoidStorage::UnlockVoidStorage &unlockVoidStorage)
 
void HandleVoidStorageQuery (WorldPackets::VoidStorage::QueryVoidStorage &queryVoidStorage)
 
void HandleVoidStorageTransfer (WorldPackets::VoidStorage::VoidStorageTransfer &voidStorageTransfer)
 
void HandleVoidSwapItem (WorldPackets::VoidStorage::SwapVoidItem &swapVoidItem)
 
void SendVoidStorageTransferResult (VoidTransferError result)
 
void HandleTransmogrifyItems (WorldPackets::Item::TransmogrifyItems &transmogrifyItems)
 
void HandleSpellClick (WorldPackets::Spells::SpellClick &spellClick)
 
void HandleMirrorImageDataRequest (WorldPackets::Spells::GetMirrorImageData &getMirrorImageData)
 
void HandleRemoveGlyph (WorldPacket &recvData)
 
void HandleGuildSetFocusedAchievement (WorldPackets::Achievement::GuildSetFocusedAchievement &setFocusedAchievement)
 
void HandleEquipmentSetSave (WorldPackets::EquipmentSet::SaveEquipmentSet &saveEquipmentSet)
 
void HandleDeleteEquipmentSet (WorldPackets::EquipmentSet::DeleteEquipmentSet &deleteEquipmentSet)
 
void HandleUseEquipmentSet (WorldPackets::EquipmentSet::UseEquipmentSet &useEquipmentSet)
 
void HandleUITimeRequest (WorldPackets::Misc::UITimeRequest &)
 
void HandleQueryQuestCompletionNPCs (WorldPackets::Query::QueryQuestCompletionNPCs &queryQuestCompletionNPCs)
 
void HandleQuestPOIQuery (WorldPackets::Query::QuestPOIQuery &questPoiQuery)
 
void HandleViolenceLevel (WorldPackets::Misc::ViolenceLevel &violenceLevel)
 
void HandleObjectUpdateFailedOpcode (WorldPackets::Misc::ObjectUpdateFailed &objectUpdateFailed)
 
void HandleObjectUpdateRescuedOpcode (WorldPackets::Misc::ObjectUpdateRescued &objectUpdateRescued)
 
void HandleRequestCategoryCooldowns (WorldPackets::Spells::RequestCategoryCooldowns &requestCategoryCooldowns)
 
void HandleAddToy (WorldPackets::Toy::AddToy &packet)
 
void HandleToySetFavorite (WorldPackets::Toy::ToySetFavorite &packet)
 
void HandleUseToy (WorldPackets::Toy::UseToy &packet)
 
void HandleSceneTriggerEvent (WorldPackets::Scenes::SceneTriggerEvent &sceneTriggerEvent)
 
void HandleScenePlaybackComplete (WorldPackets::Scenes::ScenePlaybackComplete &scenePlaybackComplete)
 
void HandleScenePlaybackCanceled (WorldPackets::Scenes::ScenePlaybackCanceled &scenePlaybackCanceled)
 
void HandleUpdateListedAuctionableTokens (WorldPackets::Token::UpdateListedAuctionableTokens &updateListedAuctionableTokens)
 
void HandleRequestWowTokenMarketPrice (WorldPackets::Token::RequestWowTokenMarketPrice &requestWowTokenMarketPrice)
 
void HandleSaveCUFProfiles (WorldPackets::Misc::SaveCUFProfiles &packet)
 
void SendLoadCUFProfiles ()
 
void HandleGetGarrisonInfo (WorldPackets::Garrison::GetGarrisonInfo &getGarrisonInfo)
 
void HandleGarrisonPurchaseBuilding (WorldPackets::Garrison::GarrisonPurchaseBuilding &garrisonPurchaseBuilding)
 
void HandleGarrisonCancelConstruction (WorldPackets::Garrison::GarrisonCancelConstruction &garrisonCancelConstruction)
 
void HandleGarrisonRequestBlueprintAndSpecializationData (WorldPackets::Garrison::GarrisonRequestBlueprintAndSpecializationData &garrisonRequestBlueprintAndSpecializationData)
 
void HandleGarrisonGetBuildingLandmarks (WorldPackets::Garrison::GarrisonGetBuildingLandmarks &garrisonGetBuildingLandmarks)
 
void HandleBattlePetRequestJournal (WorldPackets::BattlePet::BattlePetRequestJournal &battlePetRequestJournal)
 
void HandleBattlePetSetBattleSlot (WorldPackets::BattlePet::BattlePetSetBattleSlot &battlePetSetBattleSlot)
 
void HandleBattlePetModifyName (WorldPackets::BattlePet::BattlePetModifyName &battlePetModifyName)
 
void HandleBattlePetDeletePet (WorldPackets::BattlePet::BattlePetDeletePet &battlePetDeletePet)
 
void HandleBattlePetSetFlags (WorldPackets::BattlePet::BattlePetSetFlags &battlePetSetFlags)
 
void HandleBattlePetSummon (WorldPackets::BattlePet::BattlePetSummon &battlePetSummon)
 
void HandleCageBattlePet (WorldPackets::BattlePet::CageBattlePet &cageBattlePet)
 
void HandleWardenData (WorldPackets::Warden::WardenData &packet)
 
void HandleBattlenetRequest (WorldPackets::Battlenet::Request &request)
 
void HandleBattlenetRequestRealmListTicket (WorldPackets::Battlenet::RequestRealmListTicket &requestRealmListTicket)
 
void SendBattlenetResponse (uint32 serviceHash, uint32 methodId, uint32 token, pb::Message const *response)
 
void SendBattlenetResponse (uint32 serviceHash, uint32 methodId, uint32 token, uint32 status)
 
void SendBattlenetRequest (uint32 serviceHash, uint32 methodId, pb::Message const *request, std::function< void(MessageBuffer)> callback)
 
void SendBattlenetRequest (uint32 serviceHash, uint32 methodId, pb::Message const *request)
 
std::array< uint8, 32 > constGetRealmListSecret () const
 
void SetRealmListSecret (std::array< uint8, 32 > const &secret)
 
std::unordered_map< uint32,
uint8 > const
GetRealmCharacterCounts () const
 
uint64 GetConnectToInstanceKey () const
 

Public Attributes

time_t m_muteTime
 
std::atomic< int32m_timeOutTime
 

Protected Attributes

class WorldSession::DosProtection AntiDOS
 

Private Types

typedef std::list< AddonInfoAddonsList
 

Private Member Functions

void InitializeQueryCallbackParameters ()
 
void ProcessQueryCallbacks ()
 
void moveItems (Item *myItems[], Item *hisItems[])
 
bool CanUseBank (ObjectGuid bankerGUID=ObjectGuid::Empty) const
 
void LogUnexpectedOpcode (WorldPacket *packet, const char *status, const char *reason)
 Logging helper for unexpected opcodes. More...
 
void LogUnprocessedTail (WorldPacket *packet)
 Logging helper for unexpected opcodes. More...
 
bool IsLegitCharacterForAccount (ObjectGuid lowGUID)
 
 WorldSession (WorldSession const &right)=delete
 
WorldSessionoperator= (WorldSession const &right)=delete
 

Private Attributes

QueryResultHolderFuture _realmAccountLoginCallback
 
QueryResultHolderFuture _accountLoginCallback
 
PreparedQueryResultFuture _addIgnoreCallback
 
PreparedQueryResultFuture _stablePetCallback
 
QueryCallback
< PreparedQueryResult, bool
_charEnumCallback
 
QueryCallback
< PreparedQueryResult,
std::string > 
_addFriendCallback
 
QueryCallback
< PreparedQueryResult, uint32
_unstablePetCallback
 
QueryCallback
< PreparedQueryResult, uint32
_stableSwapCallback
 
QueryCallback
< PreparedQueryResult,
ObjectGuid
_sendStabledPetCallback
 
QueryCallback
< PreparedQueryResult,
std::shared_ptr
< WorldPackets::Character::CharacterCreateInfo >
, true
_charCreateCallback
 
QueryCallback
< PreparedQueryResult,
std::shared_ptr
< WorldPackets::Character::CharacterRenameInfo > > 
_charRenameCallback
 
QueryCallback
< PreparedQueryResult,
std::shared_ptr
< WorldPackets::Character::CharCustomizeInfo > > 
_charCustomizeCallback
 
QueryCallback
< PreparedQueryResult,
std::shared_ptr
< WorldPackets::Character::CharRaceOrFactionChangeInfo > > 
_charFactionChangeCallback
 
QueryCallback
< PreparedQueryResult, bool,
true
_undeleteCooldownStatusCallback
 
QueryCallback
< PreparedQueryResult,
std::shared_ptr
< WorldPackets::Character::CharacterUndeleteInfo >
, true
_charUndeleteCallback
 
QueryResultHolderFuture _charLoginCallback
 
GuidSet _legitCharacters
 
ObjectGuid::LowType m_GUIDLow
 
Player_player
 
std::shared_ptr< WorldSocketm_Socket [MAX_CONNECTION_TYPES]
 
std::string m_Address
 
AccountTypes _security
 
uint32 _accountId
 
std::string _accountName
 
uint32 _battlenetAccountId
 
uint8 m_expansion
 
std::string _os
 
std::array< uint8, 32 > _realmListSecret
 
std::unordered_map< uint32, uint8_realmCharacterCounts
 
std::unordered_map< uint32,
std::function< void(MessageBuffer)> > 
_battlenetResponseCallbacks
 
uint32 _battlenetRequestToken
 
Warden_warden
 
time_t _logoutTime
 
bool m_inQueue
 
ObjectGuid m_playerLoading
 
bool m_playerLogout
 
bool m_playerRecentlyLogout
 
bool m_playerSave
 
LocaleConstant m_sessionDbcLocale
 
LocaleConstant m_sessionDbLocaleIndex
 
std::atomic< uint32m_latency
 
std::atomic< uint32m_clientTimeDelay
 
AccountData _accountData [NUM_ACCOUNT_DATA_TYPES]
 
uint32 _tutorials [MAX_ACCOUNT_TUTORIAL_VALUES]
 
bool _tutorialsChanged
 
AddonsList m_addonsList
 
std::vector< std::string > _registeredAddonPrefixes
 
bool _filterAddonMessages
 
uint32 recruiterId
 
bool isRecruiter
 
LockedQueue< WorldPacket * > _recvQueue
 
rbac::RBACData_RBACData
 
uint32 expireTime
 
bool forceExit
 
ObjectGuid m_currentBankerGUID
 
std::unique_ptr< BattlePetMgr_battlePetMgr
 
std::unique_ptr< CollectionMgr_collectionMgr
 
ConnectToKey _instanceConnectKey
 

Friends

class World
 

Detailed Description

Player session in the World.

Member Typedef Documentation

typedef std::list<AddonInfo> WorldSession::AddonsList
private

Constructor & Destructor Documentation

WorldSession::WorldSession ( uint32  id,
std::string &&  name,
uint32  battlenetAccountId,
std::shared_ptr< WorldSocket sock,
AccountTypes  sec,
uint8  expansion,
time_t  mute_time,
std::string  os,
LocaleConstant  locale,
uint32  recruiter,
bool  isARecruiter 
)

WorldSession constructor.

108  :
109  m_muteTime(mute_time),
110  m_timeOutTime(0),
111  AntiDOS(this),
112  m_GUIDLow(UI64LIT(0)),
113  _player(NULL),
114  _security(sec),
115  _accountId(id),
116  _accountName(std::move(name)),
117  _battlenetAccountId(battlenetAccountId),
118  m_expansion(expansion),
119  _os(os),
120  _warden(NULL),
121  _logoutTime(0),
122  m_inQueue(false),
123  m_playerLogout(false),
124  m_playerRecentlyLogout(false),
125  m_playerSave(false),
126  m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
127  m_sessionDbLocaleIndex(locale),
128  m_latency(0),
130  _tutorialsChanged(false),
131  _filterAddonMessages(false),
132  recruiterId(recruiter),
133  isRecruiter(isARecruiter),
134  _RBACData(NULL),
135  expireTime(60000), // 1 min after socket loss, session is deleted
136  forceExit(false),
138  _battlePetMgr(Trinity::make_unique<BattlePetMgr>(this)),
139  _collectionMgr(Trinity::make_unique<CollectionMgr>(this))
140 {
141  memset(_tutorials, 0, sizeof(_tutorials));
142 
143  if (sock)
144  {
145  m_Address = sock->GetRemoteIpAddress().to_string();
147  LoginDatabase.PExecute("UPDATE account SET online = 1 WHERE id = %u;", GetAccountId()); // One-time query
148  }
149 
152 
154 }
std::atomic< uint32 > m_latency
Definition: WorldSession.h:1827
Warden * _warden
Definition: WorldSession.h:1817
LocaleConstant m_sessionDbcLocale
Definition: WorldSession.h:1825
bool isRecruiter
Definition: WorldSession.h:1836
time_t _logoutTime
Definition: WorldSession.h:1819
bool _filterAddonMessages
Definition: WorldSession.h:1834
bool m_playerLogout
Definition: WorldSession.h:1822
LocaleConstant m_sessionDbLocaleIndex
Definition: WorldSession.h:1826
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
void ResetTimeOutTime()
Definition: WorldSession.h:1074
uint32 GetAccountId() const
Definition: WorldSession.h:922
uint8 m_expansion
Definition: WorldSession.h:1806
#define sWorld
Definition: World.h:887
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
uint32 expireTime
Definition: WorldSession.h:1839
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void PExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:99
uint32 recruiterId
Definition: WorldSession.h:1835
ObjectGuid::LowType m_GUIDLow
Definition: WorldSession.h:1796
time_t m_muteTime
Definition: WorldSession.h:1056
std::string _os
Definition: WorldSession.h:1807
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
uint64 Raw
Definition: WorldSession.h:1721
std::atomic< int32 > m_timeOutTime
Definition: WorldSession.h:1067
AccountTypes _security
Definition: WorldSession.h:1802
bool m_playerRecentlyLogout
Definition: WorldSession.h:1823
std::unique_ptr< CollectionMgr > _collectionMgr
Definition: WorldSession.h:1845
std::unique_ptr< BattlePetMgr > _battlePetMgr
Definition: WorldSession.h:1843
uint32 _accountId
Definition: WorldSession.h:1803
class WorldSession::DosProtection AntiDOS
std::string m_Address
Definition: WorldSession.h:1799
void InitializeQueryCallbackParameters()
Definition: WorldSession.cpp:944
uint32 _battlenetAccountId
Definition: WorldSession.h:1805
ConnectToKey _instanceConnectKey
Definition: WorldSession.h:1847
Player * _player
Definition: WorldSession.h:1797
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830
bool m_inQueue
Definition: WorldSession.h:1820
bool forceExit
Definition: WorldSession.h:1840
std::atomic< uint32 > m_clientTimeDelay
Definition: WorldSession.h:1828
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838
Definition: Opcodes.h:31
bool _tutorialsChanged
Definition: WorldSession.h:1831
std::string _accountName
Definition: WorldSession.h:1804
bool m_playerSave
Definition: WorldSession.h:1824

+ Here is the call graph for this function:

WorldSession::~WorldSession ( )

WorldSession destructor.

  • unload player if not unloaded
  • If have unclosed socket, close it
  • empty incoming packet queue
158 {
160  if (_player)
161  LogoutPlayer (true);
162 
164  for (uint8 i = 0; i < 2; ++i)
165  {
166  if (m_Socket[i])
167  {
168  m_Socket[i]->CloseSocket();
169  m_Socket[i].reset();
170  }
171  }
172 
173  delete _warden;
174  delete _RBACData;
175 
177  WorldPacket* packet = NULL;
178  while (_recvQueue.next(packet))
179  delete packet;
180 
181  LoginDatabase.PExecute("UPDATE account SET online = 0 WHERE id = %u;", GetAccountId()); // One-time query
182 }
Warden * _warden
Definition: WorldSession.h:1817
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 GetAccountId() const
Definition: WorldSession.h:922
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void PExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:99
void LogoutPlayer(bool save)
Log the player out
Definition: WorldSession.cpp:498
bool next(T &result)
Gets the next result in the queue, if any.
Definition: LockedQueue.h:69
Player * _player
Definition: WorldSession.h:1797
LockedQueue< WorldPacket * > _recvQueue
Definition: WorldSession.h:1837
uint8_t uint8
Definition: Define.h:152
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

WorldSession::WorldSession ( WorldSession const right)
privatedelete

Member Function Documentation

void WorldSession::AbortLogin ( WorldPackets::Character::LoginFailureReason  reason)
877 {
878  if (!PlayerLoading() || GetPlayer())
879  {
880  KickPlayer();
881  return;
882  }
883 
886 }
Player * GetPlayer() const
Definition: WorldSession.h:927
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
Definition: CharacterPackets.h:451
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
void Clear()
Definition: ObjectGuid.h:215
bool PlayerLoading() const
Definition: WorldSession.h:889

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::AddInstanceConnection ( std::shared_ptr< WorldSocket sock)
inline
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
Definition: Opcodes.h:32

+ Here is the caller graph for this function:

bool WorldSession::CanOpenMailBox ( ObjectGuid  guid)
36 {
37  if (guid == _player->GetGUID())
38  {
40  {
41  TC_LOG_WARN("cheat", "%s attempt open mailbox in cheating way.", _player->GetName().c_str());
42  return false;
43  }
44  }
45  else if (guid.IsGameObject())
46  {
47  if (!_player->GetGameObjectIfCanInteractWith(guid, GAMEOBJECT_TYPE_MAILBOX))
48  return false;
49  }
50  else if (guid.IsAnyTypeCreature())
51  {
52  if (!_player->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_MAILBOX))
53  return false;
54  }
55  else
56  return false;
57 
58  return true;
59 }
bool IsGameObject() const
Definition: ObjectGuid.h:252
Definition: SharedDefines.h:2084
Definition: Unit.h:761
Player * _player
Definition: WorldSession.h:1797
bool IsAnyTypeCreature() const
Definition: ObjectGuid.h:248
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
Definition: RBAC.h:671
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WorldSession::CanUseBank ( ObjectGuid  bankerGUID = ObjectGuid::Empty) const
private
1257 {
1258  // bankerGUID parameter is optional, set to 0 by default.
1259  if (!bankerGUID)
1260  bankerGUID = m_currentBankerGUID;
1261 
1262  bool isUsingBankCommand = (bankerGUID == GetPlayer()->GetGUID() && bankerGUID == m_currentBankerGUID);
1263 
1264  if (!isUsingBankCommand)
1265  {
1266  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(bankerGUID, UNIT_NPC_FLAG_BANKER);
1267  if (!creature)
1268  return false;
1269  }
1270 
1271  return true;
1272 }
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
Definition: Unit.h:752

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WorldSession::CheckStableMaster ( ObjectGuid  guid)
435 {
436  // spell case or GM
437  if (guid == GetPlayer()->GetGUID())
438  {
439  if (!GetPlayer()->IsGameMaster() && !GetPlayer()->HasAuraType(SPELL_AURA_OPEN_STABLE))
440  {
441  TC_LOG_DEBUG("network", "%s attempt open stable in cheating way.", guid.ToString().c_str());
442  return false;
443  }
444  }
445  // stable master case
446  else
447  {
448  if (!GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_STABLEMASTER))
449  {
450  TC_LOG_DEBUG("network", "Stablemaster %s not found or you can't interact with him.", guid.ToString().c_str());
451  return false;
452  }
453  }
454  return true;
455 }
Definition: Unit.h:757
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:352
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::DoLootRelease ( ObjectGuid  lguid)
251 {
252  Player *player = GetPlayer();
253  Loot *loot;
254 
255  player->SetLootGUID(ObjectGuid::Empty);
256  player->SendLootRelease(lguid);
257 
258  player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_LOOTING);
259 
260  if (!player->IsInWorld())
261  return;
262 
263  if (lguid.IsGameObject())
264  {
265  GameObject* go = GetPlayer()->GetMap()->GetGameObject(lguid);
266 
267  // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
268  if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
269  return;
270 
271  loot = &go->loot;
272 
273  if (go->GetGoType() == GAMEOBJECT_TYPE_DOOR)
274  {
275  // locked doors are opened with spelleffect openlock, prevent remove its as looted
276  go->UseDoorOrButton();
277  }
278  else if (loot->isLooted() || go->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
279  {
281  { // The fishing hole used once more
282  go->AddUse(); // if the max usage is reached, will be despawned in next tick
283  if (go->GetUseCount() >= go->GetGOValue()->FishingHole.MaxOpens)
285  else
286  go->SetLootState(GO_READY);
287  }
288  else
290 
291  loot->clear();
292  }
293  else
294  {
295  // not fully looted object
296  go->SetLootState(GO_ACTIVATED, player);
297 
298  // if the round robin player release, reset it.
299  if (player->GetGUID() == loot->roundRobinPlayer)
300  loot->roundRobinPlayer.Clear();
301  }
302  }
303  else if (lguid.IsCorpse()) // ONLY remove insignia at BG
304  {
305  Corpse* corpse = ObjectAccessor::GetCorpse(*player, lguid);
306  if (!corpse || !corpse->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
307  return;
308 
309  loot = &corpse->loot;
310 
311  if (loot->isLooted())
312  {
313  loot->clear();
315  }
316  }
317  else if (lguid.IsItem())
318  {
319  Item* pItem = player->GetItemByGuid(lguid);
320  if (!pItem)
321  return;
322 
323  ItemTemplate const* proto = pItem->GetTemplate();
324 
325  // destroy only 5 items from stack in case prospecting and milling
327  {
328  pItem->m_lootGenerated = false;
329  pItem->loot.clear();
330 
331  uint32 count = pItem->GetCount();
332 
333  // >=5 checked in spell code, but will work for cheating cases also with removing from another stacks.
334  if (count > 5)
335  count = 5;
336 
337  player->DestroyItemCount(pItem, count, true);
338  }
339  else
340  {
341  // Only delete item if no loot or money (unlooted loot is saved to db) or if it isn't an openable item
342  if (pItem->loot.isLooted() || !(proto->GetFlags() & ITEM_FLAG_OPENABLE))
343  player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
344  }
345  return; // item can be looted only single player
346  }
347  else
348  {
349  Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
350 
351  bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
352  if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
353  return;
354 
355  loot = &creature->loot;
356  if (loot->isLooted())
357  {
359 
360  // skip pickpocketing loot for speed, skinning timer reduction is no-op in fact
361  if (!creature->IsAlive())
362  creature->AllLootRemovedFromCorpse();
363 
364  loot->clear();
365  }
366  else
367  {
368  // if the round robin player release, reset it.
369  if (player->GetGUID() == loot->roundRobinPlayer)
370  {
371  loot->roundRobinPlayer.Clear();
372 
373  if (Group* group = player->GetGroup())
374  {
375  group->SendLooter(creature, NULL);
376 
377  // force update of dynamic flags, otherwise other group's players still not able to loot.
379  }
380  }
381  }
382  }
383 
384  //Player is not looking at loot list, he doesn't need to see updates on the loot list
385  loot->RemoveLooter(player->GetGUID());
386 }
#define INTERACTION_DISTANCE
Definition: Object.h:34
Definition: SharedDefines.h:170
uint32 GetCount() const
Definition: Item.h:322
bool IsGameObject() const
Definition: ObjectGuid.h:252
Definition: Corpse.h:49
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: GameObject.h:871
Definition: GameObject.h:870
Loot loot
Definition: Creature.h:578
bool m_lootGenerated
Definition: Item.h:368
Definition: SharedDefines.h:4213
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Definition: UpdateFields.h:362
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2082
void AllLootRemovedFromCorpse()
Definition: Creature.cpp:2382
void clear()
Definition: LootMgr.h:349
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
void RemoveLooter(ObjectGuid GUID)
Definition: LootMgr.h:381
bool IsItem() const
Definition: ObjectGuid.h:251
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
Definition: ItemTemplate.h:202
uint32 MaxOpens
Definition: GameObject.h:788
Definition: LootMgr.h:314
bool IsAlive() const
Definition: Unit.h:1692
Definition: Item.h:259
Definition: Unit.h:683
uint32_t uint32
Definition: Define.h:150
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
Loot loot
Definition: GameObject.h:1007
struct GameObjectValue::@274 FishingHole
Definition: GameObject.h:880
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
ObjectGuid roundRobinPlayer
Definition: LootMgr.h:324
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:1182
uint8 GetSlot() const
Definition: Item.h:329
Definition: SharedDefines.h:2090
Definition: SharedDefines.h:4201
void Clear()
Definition: ObjectGuid.h:215
void ForceValuesUpdateAtIndex(uint32)
Definition: Object.cpp:2138
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: ItemTemplate.h:647
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
bool isLooted() const
Definition: LootMgr.h:375
Player * _player
Definition: WorldSession.h:1797
Definition: UpdateFields.h:109
void AddUse()
Definition: GameObject.h:1000
LootType loot_type
Definition: LootMgr.h:325
Definition: LootMgr.h:91
Loot loot
Definition: Corpse.h:76
uint32 GetFlags() const
Definition: ItemTemplate.h:656
Definition: UpdateFields.h:30
GameObjectValue const * GetGOValue() const
Definition: GameObject.h:896
Definition: ItemTemplate.h:191
uint8 GetBagSlot() const
Definition: Item.cpp:759
Definition: GameObject.h:869
Loot loot
Definition: Item.h:367
Definition: Group.h:191
Definition: ItemTemplate.h:175
Definition: SharedDefines.h:2065
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
bool IsCorpse() const
Definition: ObjectGuid.h:254
uint32 GetUseCount() const
Definition: GameObject.h:1002

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AccountData const* WorldSession::GetAccountData ( AccountDataType  type) const
inline
998 { return &_accountData[type]; }
AccountData _accountData[NUM_ACCOUNT_DATA_TYPES]
Definition: WorldSession.h:1829

+ Here is the caller graph for this function:

ObjectGuid WorldSession::GetAccountGUID ( ) const
inline
923 { return ObjectGuid::Create<HighGuid::WowAccount>(GetAccountId()); }
uint32 GetAccountId() const
Definition: WorldSession.h:922

+ Here is the caller graph for this function:

uint32 WorldSession::GetAccountId ( ) const
inline
922 { return _accountId; }
uint32 _accountId
Definition: WorldSession.h:1803
std::string const& WorldSession::GetAccountName ( ) const
inline
924 { return _accountName; }
std::string _accountName
Definition: WorldSession.h:1804
ObjectGuid WorldSession::GetBattlenetAccountGUID ( ) const
inline
926 { return ObjectGuid::Create<HighGuid::BNetAccount>(GetBattlenetAccountId()); }
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
uint32 WorldSession::GetBattlenetAccountId ( ) const
inline
925 { return _battlenetAccountId; }
uint32 _battlenetAccountId
Definition: WorldSession.h:1805

+ Here is the caller graph for this function:

BattlePetMgr* WorldSession::GetBattlePetMgr ( ) const
inline
1089 { return _battlePetMgr.get(); }
std::unique_ptr< BattlePetMgr > _battlePetMgr
Definition: WorldSession.h:1843

+ Here is the caller graph for this function:

CollectionMgr* WorldSession::GetCollectionMgr ( ) const
inline
1091 { return _collectionMgr.get(); }
std::unique_ptr< CollectionMgr > _collectionMgr
Definition: WorldSession.h:1845
uint64 WorldSession::GetConnectToInstanceKey ( ) const
inline
1724 { return _instanceConnectKey.Raw; }
uint64 Raw
Definition: WorldSession.h:1721
ConnectToKey _instanceConnectKey
Definition: WorldSession.h:1847

+ Here is the caller graph for this function:

uint8 WorldSession::GetExpansion ( ) const
inline
934 { return m_expansion; }
uint8 m_expansion
Definition: WorldSession.h:1806

+ Here is the caller graph for this function:

uint32 WorldSession::GetLatency ( ) const
inline
1063 { return m_latency; }
std::atomic< uint32 > m_latency
Definition: WorldSession.h:1827

+ Here is the caller graph for this function:

std::string const& WorldSession::GetOS ( ) const
inline
935 { return _os; }
std::string _os
Definition: WorldSession.h:1807
Player* WorldSession::GetPlayer ( ) const
inline
927 { return _player; }
Player * _player
Definition: WorldSession.h:1797
std::string WorldSession::GetPlayerInfo ( ) const
196 {
197  std::ostringstream ss;
198 
199  ss << "[Player: ";
200  if (!m_playerLoading.IsEmpty())
201  ss << "Logging in: " << m_playerLoading.ToString() << ", ";
202  else if (_player)
203  ss << _player->GetName() << ' ' << _player->GetGUID().ToString() << ", ";
204 
205  ss << "Account: " << GetAccountId() << "]";
206 
207  return ss.str();
208 }
uint32 GetAccountId() const
Definition: WorldSession.h:922
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
Player * _player
Definition: WorldSession.h:1797
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

std::string const & WorldSession::GetPlayerName ( ) const
191 {
192  return _player != NULL ? _player->GetName() : DefaultPlayerName;
193 }
arena_t NULL
Definition: jemalloc_internal.h:624
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

rbac::RBACData * WorldSession::GetRBACData ( )
1255 {
1256  return _RBACData;
1257 }
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838

+ Here is the caller graph for this function:

std::unordered_map<uint32, uint8> const& WorldSession::GetRealmCharacterCounts ( ) const
inline
1710 { return _realmCharacterCounts; }
std::unordered_map< uint32, uint8 > _realmCharacterCounts
Definition: WorldSession.h:1810
std::array<uint8, 32> const& WorldSession::GetRealmListSecret ( ) const
inline
1707 { return _realmListSecret; }
std::array< uint8, 32 > _realmListSecret
Definition: WorldSession.h:1809
uint32 WorldSession::GetRecruiterId ( ) const
inline
1085 { return recruiterId; }
uint32 recruiterId
Definition: WorldSession.h:1835

+ Here is the caller graph for this function:

std::string const& WorldSession::GetRemoteAddress ( ) const
inline
932 { return m_Address; }
std::string m_Address
Definition: WorldSession.h:1799

+ Here is the caller graph for this function:

AccountTypes WorldSession::GetSecurity ( ) const
inline
921 { return _security; }
AccountTypes _security
Definition: WorldSession.h:1802

+ Here is the caller graph for this function:

LocaleConstant WorldSession::GetSessionDbcLocale ( ) const
inline
1059 { return m_sessionDbcLocale; }
LocaleConstant m_sessionDbcLocale
Definition: WorldSession.h:1825

+ Here is the caller graph for this function:

LocaleConstant WorldSession::GetSessionDbLocaleIndex ( ) const
inline
1060 { return m_sessionDbLocaleIndex; }
LocaleConstant m_sessionDbLocaleIndex
Definition: WorldSession.h:1826

+ Here is the caller graph for this function:

char const * WorldSession::GetTrinityString ( uint32  entry) const
690 {
691  return sObjectMgr->GetTrinityString(entry, GetSessionDbLocaleIndex());
692 }
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1060
#define sObjectMgr
Definition: ObjectMgr.h:1567

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 WorldSession::GetTutorialInt ( uint8  index) const
inline
1005 { return _tutorials[index]; }
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830

+ Here is the caller graph for this function:

void WorldSession::Handle_EarlyProccess ( WorldPacket recvPacket)
700 {
701  TC_LOG_ERROR("network.opcode", "Received opcode %s that must be processed in WorldSocket::OnRead from %s"
702  , GetOpcodeNameForLogging(static_cast<OpcodeClient>(recvPacket.GetOpcode())).c_str(), GetPlayerInfo().c_str());
703 }
uint32 GetOpcode() const
Definition: WorldPacket.h:79
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::Handle_NULL ( WorldPackets::Null null)
695 {
696  TC_LOG_ERROR("network.opcode", "Received unhandled opcode %s from %s", GetOpcodeNameForLogging(null.GetOpcode()).c_str(), GetPlayerInfo().c_str());
697 }
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
OpcodeClient GetOpcode() const
Definition: Packet.h:72
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAcceptGrantLevel ( WorldPackets::RaF::AcceptLevelGrant acceptLevelGrant)
65 {
66  Player* other = ObjectAccessor::GetPlayer(*_player, acceptLevelGrant.Granter);
67  if (!(other && other->GetSession()))
68  return;
69 
70  if (GetAccountId() != other->GetSession()->GetRecruiterId())
71  return;
72 
73  if (other->GetGrantableLevels())
74  other->SetGrantableLevels(other->GetGrantableLevels() - 1);
75  else
76  return;
77 
78  _player->GiveLevel(_player->getLevel() + 1);
79 }
ObjectGuid Granter
Definition: ReferAFriendPackets.h:35
uint32 GetAccountId() const
Definition: WorldSession.h:922
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAcceptTradeOpcode ( WorldPackets::Trade::AcceptTrade acceptTrade)
224 {
225  TradeData* my_trade = _player->m_trade;
226  if (!my_trade)
227  return;
228 
229  Player* trader = my_trade->GetTrader();
230 
231  TradeData* his_trade = trader->m_trade;
232  if (!his_trade)
233  return;
234 
235  Item* myItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
236  Item* hisItems[TRADE_SLOT_TRADED_COUNT] = { NULL, NULL, NULL, NULL, NULL, NULL };
237 
238  // set before checks for propertly undo at problems (it already set in to client)
239  my_trade->SetAccepted(true);
240 
242  if (his_trade->GetServerStateIndex() != acceptTrade.StateIndex)
243  {
245  SendTradeStatus(info);
246  my_trade->SetAccepted(false);
247  return;
248  }
249 
250  if (!_player->IsWithinDistInMap(trader, TRADE_DISTANCE, false))
251  {
253  SendTradeStatus(info);
254  my_trade->SetAccepted(false);
255  return;
256  }
257 
258  // not accept case incorrect money amount
259  if (!_player->HasEnoughMoney(my_trade->GetMoney()))
260  {
263  SendTradeStatus(info);
264  my_trade->SetAccepted(false, true);
265  return;
266  }
267 
268  // not accept case incorrect money amount
269  if (!trader->HasEnoughMoney(his_trade->GetMoney()))
270  {
273  trader->GetSession()->SendTradeStatus(info);
274  his_trade->SetAccepted(false, true);
275  return;
276  }
277 
278  if (_player->GetMoney() >= uint64(MAX_MONEY_AMOUNT) - his_trade->GetMoney())
279  {
282  SendTradeStatus(info);
283  my_trade->SetAccepted(false, true);
284  return;
285  }
286 
287  if (trader->GetMoney() >= uint64(MAX_MONEY_AMOUNT) - my_trade->GetMoney())
288  {
291  trader->GetSession()->SendTradeStatus(info);
292  his_trade->SetAccepted(false, true);
293  return;
294  }
295 
296  // not accept if some items now can't be trade (cheating)
297  for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i)
298  {
299  if (Item* item = my_trade->GetItem(TradeSlots(i)))
300  {
301  if (!item->CanBeTraded(false, true))
302  {
304  SendTradeStatus(info);
305  return;
306  }
307 
308  if (item->IsBindedNotWith(trader))
309  {
312  SendTradeStatus(info);
313  return;
314  }
315  }
316 
317  if (Item* item = his_trade->GetItem(TradeSlots(i)))
318  {
319  if (!item->CanBeTraded(false, true))
320  {
322  SendTradeStatus(info);
323  return;
324  }
325  //if (item->IsBindedNotWith(_player)) // dont mark as invalid when his item isnt good (not exploitable because if item is invalid trade will fail anyway later on the same check)
326  //{
327  // SendTradeStatus(TRADE_STATUS_NOT_ELIGIBLE);
328  // his_trade->SetAccepted(false, true);
329  // return;
330  //}
331  }
332  }
333 
334  if (his_trade->IsAccepted())
335  {
336  setAcceptTradeMode(my_trade, his_trade, myItems, hisItems);
337 
338  Spell* my_spell = NULL;
339  SpellCastTargets my_targets;
340 
341  Spell* his_spell = NULL;
342  SpellCastTargets his_targets;
343 
344  // not accept if spell can't be cast now (cheating)
345  if (uint32 my_spell_id = my_trade->GetSpell())
346  {
347  SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(my_spell_id);
348  Item* castItem = my_trade->GetSpellCastItem();
349 
350  if (!spellEntry || !his_trade->GetItem(TRADE_SLOT_NONTRADED) ||
351  (my_trade->HasSpellCastItem() && !castItem))
352  {
353  clearAcceptTradeMode(my_trade, his_trade);
354  clearAcceptTradeMode(myItems, hisItems);
355 
356  my_trade->SetSpell(0);
357  return;
358  }
359 
360  my_spell = new Spell(_player, spellEntry, TRIGGERED_FULL_MASK);
361  my_spell->m_CastItem = castItem;
362  my_targets.SetTradeItemTarget(_player);
363  my_spell->m_targets = my_targets;
364 
365  SpellCastResult res = my_spell->CheckCast(true);
366  if (res != SPELL_CAST_OK)
367  {
368  my_spell->SendCastResult(res);
369 
370  clearAcceptTradeMode(my_trade, his_trade);
371  clearAcceptTradeMode(myItems, hisItems);
372 
373  delete my_spell;
374  my_trade->SetSpell(0);
375  return;
376  }
377  }
378 
379  // not accept if spell can't be cast now (cheating)
380  if (uint32 his_spell_id = his_trade->GetSpell())
381  {
382  SpellInfo const* spellEntry = sSpellMgr->GetSpellInfo(his_spell_id);
383  Item* castItem = his_trade->GetSpellCastItem();
384 
385  if (!spellEntry || !my_trade->GetItem(TRADE_SLOT_NONTRADED) || (his_trade->HasSpellCastItem() && !castItem))
386  {
387  delete my_spell;
388  his_trade->SetSpell(0);
389 
390  clearAcceptTradeMode(my_trade, his_trade);
391  clearAcceptTradeMode(myItems, hisItems);
392  return;
393  }
394 
395  his_spell = new Spell(trader, spellEntry, TRIGGERED_FULL_MASK);
396  his_spell->m_CastItem = castItem;
397  his_targets.SetTradeItemTarget(trader);
398  his_spell->m_targets = his_targets;
399 
400  SpellCastResult res = his_spell->CheckCast(true);
401  if (res != SPELL_CAST_OK)
402  {
403  his_spell->SendCastResult(res);
404 
405  clearAcceptTradeMode(my_trade, his_trade);
406  clearAcceptTradeMode(myItems, hisItems);
407 
408  delete my_spell;
409  delete his_spell;
410 
411  his_trade->SetSpell(0);
412  return;
413  }
414  }
415 
416  // inform partner client
418  trader->GetSession()->SendTradeStatus(info);
419 
420  // test if item will fit in each inventory
421  WorldPackets::Trade::TradeStatus myCanCompleteInfo, hisCanCompleteInfo;
422  hisCanCompleteInfo.BagResult = trader->CanStoreItems(myItems, TRADE_SLOT_TRADED_COUNT, &hisCanCompleteInfo.ItemID);
423  myCanCompleteInfo.BagResult = _player->CanStoreItems(hisItems, TRADE_SLOT_TRADED_COUNT, &myCanCompleteInfo.ItemID);
424 
425  clearAcceptTradeMode(myItems, hisItems);
426 
427  // in case of missing space report error
428  if (myCanCompleteInfo.BagResult != EQUIP_ERR_OK)
429  {
430  clearAcceptTradeMode(my_trade, his_trade);
431 
432  myCanCompleteInfo.Status = TRADE_STATUS_FAILED;
433  trader->GetSession()->SendTradeStatus(myCanCompleteInfo);
434  myCanCompleteInfo.FailureForYou = true;
435  SendTradeStatus(myCanCompleteInfo);
436  my_trade->SetAccepted(false);
437  his_trade->SetAccepted(false);
438  delete my_spell;
439  delete his_spell;
440  return;
441  }
442  else if (hisCanCompleteInfo.BagResult != EQUIP_ERR_OK)
443  {
444  clearAcceptTradeMode(my_trade, his_trade);
445 
446  hisCanCompleteInfo.Status = TRADE_STATUS_FAILED;
447  SendTradeStatus(hisCanCompleteInfo);
448  hisCanCompleteInfo.FailureForYou = true;
449  trader->GetSession()->SendTradeStatus(hisCanCompleteInfo);
450  my_trade->SetAccepted(false);
451  his_trade->SetAccepted(false);
452  delete my_spell;
453  delete his_spell;
454  return;
455  }
456 
457  // execute trade: 1. remove
458  for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i)
459  {
460  if (myItems[i])
461  {
462  myItems[i]->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
463  _player->MoveItemFromInventory(myItems[i]->GetBagSlot(), myItems[i]->GetSlot(), true);
464  }
465  if (hisItems[i])
466  {
467  hisItems[i]->SetGuidValue(ITEM_FIELD_GIFTCREATOR, trader->GetGUID());
468  trader->MoveItemFromInventory(hisItems[i]->GetBagSlot(), hisItems[i]->GetSlot(), true);
469  }
470  }
471 
472  // execute trade: 2. store
473  moveItems(myItems, hisItems);
474 
475  // logging money
477  {
478  if (my_trade->GetMoney() > 0)
479  {
480  sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: " UI64FMTD ") to player: %s (Account: %u)",
481  _player->GetName().c_str(), _player->GetSession()->GetAccountId(),
482  my_trade->GetMoney(),
483  trader->GetName().c_str(), trader->GetSession()->GetAccountId());
484  }
485 
486  if (his_trade->GetMoney() > 0)
487  {
488  sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) give money (Amount: " UI64FMTD ") to player: %s (Account: %u)",
489  trader->GetName().c_str(), trader->GetSession()->GetAccountId(),
490  his_trade->GetMoney(),
491  _player->GetName().c_str(), _player->GetSession()->GetAccountId());
492  }
493  }
494 
495  // update money
496  _player->ModifyMoney(-int64(my_trade->GetMoney()));
497  _player->ModifyMoney(his_trade->GetMoney());
498  trader->ModifyMoney(-int64(his_trade->GetMoney()));
499  trader->ModifyMoney(my_trade->GetMoney());
500 
501  if (my_spell)
502  my_spell->prepare(&my_targets);
503 
504  if (his_spell)
505  his_spell->prepare(&his_targets);
506 
507  // cleanup
508  clearAcceptTradeMode(my_trade, his_trade);
509  delete _player->m_trade;
510  _player->m_trade = NULL;
511  delete trader->m_trade;
512  trader->m_trade = NULL;
513 
514  // desynchronized with the other saves here (SaveInventoryAndGoldToDB() not have own transaction guards)
516  _player->SaveInventoryAndGoldToDB(trans);
517  trader->SaveInventoryAndGoldToDB(trans);
519 
521  trader->GetSession()->SendTradeStatus(info);
522  SendTradeStatus(info);
523  }
524  else
525  {
527  trader->GetSession()->SendTradeStatus(info);
528  }
529 }
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:130
Definition: SpellInfo.h:326
SpellCastTargets m_targets
Definition: Spell.h:584
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
Definition: Spell.cpp:3732
Definition: SharedDefines.h:4652
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void SendTradeStatus(WorldPackets::Trade::TradeStatus &status)
Definition: TradeHandler.cpp:34
arena_t NULL
Definition: jemalloc_internal.h:624
Will ignore most target checks (mostly DBC target checks)
Definition: Unit.h:479
#define sLog
Definition: Log.h:154
uint64_t uint64
Definition: g3dmath.h:170
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
Item * m_CastItem
Definition: Spell.h:548
uint32 ItemID
Definition: TradePackets.h:145
Definition: SharedDefines.h:4660
Item * GetItem(TradeSlots slot) const
Definition: TradeData.cpp:27
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Item.h:127
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
Definition: SharedDefines.h:4657
Definition: Item.h:48
Definition: Item.h:77
Definition: Item.h:125
uint32 GetSpell() const
Definition: TradeData.h:49
Definition: TradeData.h:34
TradeSlots
Definition: TradeData.h:23
Definition: TradeData.h:27
Definition: Item.h:259
#define UI64FMTD
Definition: Define.h:137
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Player * GetTrader() const
Definition: TradeData.h:41
#define TRADE_DISTANCE
Definition: Object.h:37
Definition: SharedDefines.h:4651
Definition: Spell.h:170
static void setAcceptTradeMode(TradeData *myTrade, TradeData *hisTrade, Item **myItems, Item **hisItems)
Definition: TradeHandler.cpp:180
static void clearAcceptTradeMode(TradeData *myTrade, TradeData *hisTrade)
Definition: TradeHandler.cpp:205
void SetSpell(uint32 spell_id, Item *castItem=nullptr)
Definition: TradeData.cpp:81
int64_t int64
Definition: g3dmath.h:169
Definition: SharedDefines.h:4658
Definition: TradePackets.h:130
void moveItems(Item *myItems[], Item *hisItems[])
Definition: TradeHandler.cpp:97
SpellCastResult CheckCast(bool strict)
Definition: Spell.cpp:4739
Player * _player
Definition: WorldSession.h:1797
void SetTradeItemTarget(Player *caster)
Definition: Spell.cpp:310
uint32 GetServerStateIndex() const
Definition: TradeData.h:67
uint32 StateIndex
Definition: TradePackets.h:34
Definition: RBAC.h:63
::TradeStatus Status
Definition: TradePackets.h:137
uint8_t uint8
Definition: Define.h:152
bool IsAccepted() const
Definition: TradeData.h:58
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
bool FailureForYou
Definition: TradePackets.h:143
SpellCastResult
Definition: SharedDefines.h:1265
bool HasSpellCastItem() const
Definition: TradeData.h:53
Definition: UpdateFields.h:45
int32 BagResult
Definition: TradePackets.h:144
Definition: TradeData.h:26
Definition: SharedDefines.h:4656
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Item * GetSpellCastItem() const
Definition: TradeData.cpp:50
uint64 GetMoney() const
Definition: TradeData.h:55
Definition: SharedDefines.h:1538
void SetAccepted(bool state, bool forTrader=false)
Definition: TradeData.cpp:132
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleActivateTaxiOpcode ( WorldPackets::Taxi::ActivateTaxi activateTaxi)
161 {
162  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(activateTaxi.Vendor, UNIT_NPC_FLAG_FLIGHTMASTER);
163  if (!unit)
164  {
165  TC_LOG_DEBUG("network", "WORLD: HandleActivateTaxiOpcode - %s not found or you can't interact with it.", activateTaxi.Vendor.ToString().c_str());
166  return;
167  }
168 
169  uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
170  if (!curloc)
171  return;
172 
173  TaxiNodesEntry const* from = sTaxiNodesStore.LookupEntry(curloc);
174  TaxiNodesEntry const* to = sTaxiNodesStore.LookupEntry(activateTaxi.Node);
175  if (!to)
176  return;
177 
178  if (!GetPlayer()->isTaxiCheater())
179  {
180  if (!GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) || !GetPlayer()->m_taxi.IsTaximaskNodeKnown(activateTaxi.Node))
181  {
183  return;
184  }
185  }
186 
187  std::vector<uint32> nodes;
188  sTaxiPathGraph.GetCompleteNodeRoute(from, to, GetPlayer(), nodes);
189  GetPlayer()->ActivateTaxiPathTo(nodes, unit);
190 }
void SendActivateTaxiReply(ActivateTaxiReply reply)
Definition: TaxiHandler.cpp:192
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 Node
Definition: TaxiPackets.h:95
#define sObjectMgr
Definition: ObjectMgr.h:1567
float GetPositionY() const
Definition: Position.h:105
ObjectGuid Vendor
Definition: TaxiPackets.h:94
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
Definition: SharedDefines.h:4701
#define sTaxiPathGraph
Definition: TaxiPathGraph.h:65
Definition: DB2Structure.h:1324
float GetPositionX() const
Definition: Position.h:104
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", TaxiNodesFormat, HOTFIX_SEL_TAXI_NODES)
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:748

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddFriendOpcode ( WorldPackets::Social::AddFriend packet)
32 {
33  if (!normalizePlayerName(packet.Name))
34  return;
35 
36  TC_LOG_DEBUG("network", "WorldSession::HandleAddFriendOpcode: %s asked to add friend: %s",
37  GetPlayerInfo().c_str(), packet.Name.c_str());
38 
40  stmt->setString(0, packet.Name);
41 
42  _addFriendCallback.SetParam(std::move(packet.Notes));
44 }
void SetParam(ParamType value)
Definition: Callback.h:63
QueryCallback< PreparedQueryResult, std::string > _addFriendCallback
Definition: WorldSession.h:1734
std::string Notes
Definition: SocialPackets.h:102
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:56
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
std::string Name
Definition: SocialPackets.h:103
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddFriendOpcodeCallBack ( PreparedQueryResult  result,
std::string const friendNote 
)
47 {
48  if (!GetPlayer())
49  return;
50 
51  ObjectGuid friendGuid;
52  FriendsResult friendResult = FRIEND_NOT_FOUND;
53 
54  if (result)
55  {
56  Field* fields = result->Fetch();
57 
58  if (ObjectGuid::LowType lowGuid = fields[0].GetUInt64())
59  {
60  friendGuid = ObjectGuid::Create<HighGuid::Player>(lowGuid);
61  uint32 team = Player::TeamForRace(fields[1].GetUInt8());
62  uint32 friendAccountId = fields[2].GetUInt32();
63 
65  {
66  if (friendGuid == GetPlayer()->GetGUID())
67  friendResult = FRIEND_SELF;
68  else if (GetPlayer()->GetTeam() != team && !HasPermission(rbac::RBAC_PERM_TWO_SIDE_ADD_FRIEND))
69  friendResult = FRIEND_ENEMY;
70  else if (GetPlayer()->GetSocial()->HasFriend(friendGuid))
71  friendResult = FRIEND_ALREADY;
72  else
73  {
74  Player* playerFriend = ObjectAccessor::FindPlayer(friendGuid);
75  if (playerFriend && playerFriend->IsVisibleGloballyFor(GetPlayer()))
76  friendResult = FRIEND_ADDED_ONLINE;
77  else
78  friendResult = FRIEND_ADDED_OFFLINE;
79 
80  if (GetPlayer()->GetSocial()->AddToSocialList(friendGuid, SOCIAL_FLAG_FRIEND))
81  GetPlayer()->GetSocial()->SetFriendNote(friendGuid, friendNote);
82  else
83  friendResult = FRIEND_LIST_FULL;
84  }
85  }
86  }
87  }
88 
89  sSocialMgr->SendFriendStatus(GetPlayer(), friendResult, friendGuid);
90 }
Definition: RBAC.h:92
uint32 Realm
Definition: Realm.h:53
FriendsResult
Results of friend related commands.
Definition: SocialMgr.h:67
Definition: SocialMgr.h:77
Realm realm
Definition: World.cpp:3485
Class used to access individual fields of database query result.
Definition: Field.h:56
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SocialMgr.h:78
uint64 LowType
Definition: ObjectGuid.h:199
Definition: SocialMgr.h:75
static uint32 GetSecurity(uint32 accountId)
Definition: AccountMgr.cpp:284
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Battlenet::RealmHandle Id
Definition: Realm.h:86
Definition: SocialMgr.h:73
uint32_t uint32
Definition: Define.h:150
#define sSocialMgr
Definition: SocialMgr.h:160
static bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:390
uint32 GetUInt32() const
Definition: Field.h:146
Definition: SocialMgr.h:76
Definition: SocialMgr.h:70
Definition: ObjectGuid.h:189
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: SocialMgr.h:40
Definition: SocialMgr.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddIgnoreOpcode ( WorldPackets::Social::AddIgnore packet)
103 {
104  if (!normalizePlayerName(packet.Name))
105  return;
106 
107  TC_LOG_DEBUG("network", "WorldSession::HandleAddIgnoreOpcode: %s asked to Ignore: %s",
108  GetPlayerInfo().c_str(), packet.Name.c_str());
109 
111  stmt->setString(0, packet.Name);
112 
114 }
Definition: CharacterDatabase.h:36
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Definition: PreparedStatement.h:74
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::string Name
Definition: SocialPackets.h:134
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
PreparedQueryResultFuture _addIgnoreCallback
Definition: WorldSession.h:1731
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddIgnoreOpcodeCallBack ( PreparedQueryResult  result)
117 {
118  if (!GetPlayer())
119  return;
120 
121  ObjectGuid ignoreGuid;
122  FriendsResult ignoreResult = FRIEND_IGNORE_NOT_FOUND;
123 
124  if (result)
125  {
126  Field* fields = result->Fetch();
127 
128  if (ObjectGuid::LowType lowGuid = fields[0].GetUInt64())
129  {
130  ignoreGuid = ObjectGuid::Create<HighGuid::Player>(lowGuid);
131 
132  if (ignoreGuid == GetPlayer()->GetGUID()) //not add yourself
133  ignoreResult = FRIEND_IGNORE_SELF;
134  else if (GetPlayer()->GetSocial()->HasIgnore(ignoreGuid))
135  ignoreResult = FRIEND_IGNORE_ALREADY;
136  else
137  {
138  ignoreResult = FRIEND_IGNORE_ADDED;
139 
140  // ignore list full
141  if (!GetPlayer()->GetSocial()->AddToSocialList(ignoreGuid, SOCIAL_FLAG_IGNORED))
142  ignoreResult = FRIEND_IGNORE_FULL;
143  }
144  }
145  }
146 
147  sSocialMgr->SendFriendStatus(GetPlayer(), ignoreResult, ignoreGuid);
148 }
FriendsResult
Results of friend related commands.
Definition: SocialMgr.h:67
Definition: SocialMgr.h:82
Definition: SocialMgr.h:81
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: SocialMgr.h:41
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SocialMgr.h:83
uint64 LowType
Definition: ObjectGuid.h:199
Definition: SocialMgr.h:84
#define sSocialMgr
Definition: SocialMgr.h:160
Definition: SocialMgr.h:80
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddonRegisteredPrefixesOpcode ( WorldPackets::Chat::ChatRegisterAddonPrefixes packet)
923 {
924  // This is always sent after CMSG_CHAT_UNREGISTER_ALL_ADDON_PREFIXES
927  {
928  _filterAddonMessages = false;
929  return;
930  }
931 
932  _filterAddonMessages = true;
933 }
iterator begin()
Definition: PacketUtilities.h:83
bool _filterAddonMessages
Definition: WorldSession.h:1834
Array< std::string, MAX_PREFIXES > Prefixes
Definition: ChatPackets.h:271
std::vector< std::string > _registeredAddonPrefixes
Definition: WorldSession.h:1833
iterator end()
Definition: PacketUtilities.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAddToy ( WorldPackets::Toy::AddToy packet)
23 {
24  if (!packet.Guid)
25  return;
26 
27  Item* item = _player->GetItemByGuid(packet.Guid);
28  if (!item)
29  {
30  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
31  return;
32  }
33 
34  if (!sDB2Manager.IsToyItem(item->GetEntry()))
35  return;
36 
37  InventoryResult msg = _player->CanUseItem(item);
38  if (msg != EQUIP_ERR_OK)
39  {
40  _player->SendEquipError(msg, item, nullptr);
41  return;
42  }
43 
44  if (_collectionMgr->AddToy(item->GetEntry(), false))
45  _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
46 }
#define sDB2Manager
Definition: DB2Stores.h:224
Definition: Item.h:48
Definition: Item.h:71
ObjectGuid Guid
Definition: ToyPackets.h:37
Definition: Item.h:259
uint8 GetSlot() const
Definition: Item.h:329
std::unique_ptr< CollectionMgr > _collectionMgr
Definition: WorldSession.h:1845
Player * _player
Definition: WorldSession.h:1797
uint32 GetEntry() const
Definition: Object.h:107
InventoryResult
Definition: Item.h:46
uint8 GetBagSlot() const
Definition: Item.cpp:759

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAlterAppearance ( WorldPackets::Character::AlterApperance packet)
1411 {
1412  BarberShopStyleEntry const* bs_hair = sBarberShopStyleStore.LookupEntry(packet.NewHairStyle);
1413  if (!bs_hair || bs_hair->Type != 0 || bs_hair->Race != _player->getRace() || bs_hair->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER))
1414  return;
1415 
1416  BarberShopStyleEntry const* bs_facialHair = sBarberShopStyleStore.LookupEntry(packet.NewFacialHair);
1417  if (!bs_facialHair || bs_facialHair->Type != 2 || bs_facialHair->Race != _player->getRace() || bs_facialHair->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER))
1418  return;
1419 
1420  BarberShopStyleEntry const* bs_skinColor = sBarberShopStyleStore.LookupEntry(packet.NewSkinColor);
1421  if (bs_skinColor && (bs_skinColor->Type != 3 || bs_skinColor->Race != _player->getRace() || bs_skinColor->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)))
1422  return;
1423 
1424  BarberShopStyleEntry const* bs_face = sBarberShopStyleStore.LookupEntry(packet.NewFace);
1425  if (bs_face && (bs_face->Type != 4 || bs_face->Race != _player->getRace() || bs_face->Sex != _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER)))
1426  return;
1427 
1428  if (!Player::ValidateAppearance(_player->getRace(), _player->getClass(), _player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER),
1429  bs_hair->Data,
1430  packet.NewHairColor,
1431  bs_face ? bs_face->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID),
1432  bs_facialHair->Data,
1433  bs_skinColor ? bs_skinColor->Data : _player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID)))
1434  return;
1435 
1436  GameObject* go = _player->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_BARBER_CHAIR, 5.0f);
1437  if (!go)
1438  {
1440  return;
1441  }
1442 
1443  if (_player->GetStandState() != UnitStandStateType(UNIT_STAND_STATE_SIT_LOW_CHAIR + go->GetGOInfo()->barberChair.chairheight))
1444  {
1446  return;
1447  }
1448 
1449  uint32 cost = _player->GetBarberShopCost(bs_hair, packet.NewHairColor, bs_facialHair, bs_skinColor, bs_face);
1450 
1451  // 0 - ok
1452  // 1, 3 - not enough money
1453  // 2 - you have to sit on barber chair
1454  if (!_player->HasEnoughMoney((uint64)cost))
1455  {
1457  return;
1458  }
1459 
1461 
1462  _player->ModifyMoney(-int64(cost)); // it isn't free
1463  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_AT_BARBER, cost);
1464 
1467  _player->SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE, uint8(bs_facialHair->Data));
1468  if (bs_skinColor)
1469  _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID, uint8(bs_skinColor->Data));
1470  if (bs_face)
1471  _player->SetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID, uint8(bs_face->Data));
1472 
1473  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_VISIT_BARBER_SHOP, 1);
1474 
1475  _player->SetStandState(UNIT_STAND_STATE_STAND);
1476 }
struct GameObjectTemplate::@221::@255 barberChair
Definition: Unit.h:207
Definition: Player.h:587
Definition: Player.h:572
uint32 NewHairStyle
Definition: CharacterPackets.h:599
uint32 Data
Definition: DB2Structure.h:71
uint32 NewSkinColor
Definition: CharacterPackets.h:602
Definition: WorldSession.h:791
uint32 Type
Definition: DB2Structure.h:65
uint32 Race
Definition: DB2Structure.h:69
Definition: Player.h:573
Definition: UpdateFields.h:198
Definition: UpdateFields.h:197
Definition: DB2Structure.h:62
uint32 Sex
Definition: DB2Structure.h:70
UnitStandStateType
Definition: Unit.h:205
Definition: WorldSession.h:792
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: Unit.h:211
Definition: GameObject.h:880
void SendBarberShopResult(BarberShopResult result)
Definition: CharacterHandler.cpp:2555
Definition: Player.h:571
int64_t int64
Definition: g3dmath.h:169
uint8_t uint8
Definition: g3dmath.h:164
Definition: WorldSession.h:793
Player * _player
Definition: WorldSession.h:1797
uint32 NewFacialHair
Definition: CharacterPackets.h:601
uint32 NewHairColor
Definition: CharacterPackets.h:600
Definition: SharedDefines.h:2097
Definition: Player.h:579
DB2Storage< BarberShopStyleEntry > sBarberShopStyleStore("BarberShopStyle.db2", BarberShopStyleFormat, HOTFIX_SEL_BARBER_SHOP_STYLE)
uint32 NewFace
Definition: CharacterPackets.h:603
Definition: UpdateFields.h:196
Definition: Player.h:574

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAreaSpiritHealerQueryOpcode ( WorldPackets::Battleground::AreaSpiritHealerQuery areaSpiritHealerQuery)
644 {
645  Creature* unit = GetPlayer()->GetMap()->GetCreature(areaSpiritHealerQuery.HealerGuid);
646  if (!unit)
647  return;
648 
649  if (!unit->IsSpiritService()) // it's not spirit service
650  return;
651 
652  if (Battleground* bg = _player->GetBattleground())
653  sBattlegroundMgr->SendAreaSpiritHealerQueryOpcode(_player, bg, areaSpiritHealerQuery.HealerGuid);
654 
655  if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
656  bf->SendAreaSpiritHealerQueryOpcode(_player, areaSpiritHealerQuery.HealerGuid);
657 }
ObjectGuid HealerGuid
Definition: BattlegroundPackets.h:49
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Battlefield.h:196
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * _player
Definition: WorldSession.h:1797
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
Definition: Battleground.h:235
bool IsSpiritService() const
Definition: Unit.h:1579

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAreaSpiritHealerQueueOpcode ( WorldPackets::Battleground::AreaSpiritHealerQueue areaSpiritHealerQueue)
660 {
661  Creature* unit = GetPlayer()->GetMap()->GetCreature(areaSpiritHealerQueue.HealerGuid);
662  if (!unit)
663  return;
664 
665  if (!unit->IsSpiritService()) // it's not spirit service
666  return;
667 
668  if (Battleground* bg = _player->GetBattleground())
669  bg->AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, _player->GetGUID());
670 
671  if (Battlefield* bf = sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
672  bf->AddPlayerToResurrectQueue(areaSpiritHealerQueue.HealerGuid, _player->GetGUID());
673 }
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Battlefield.h:196
ObjectGuid HealerGuid
Definition: BattlegroundPackets.h:59
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * _player
Definition: WorldSession.h:1797
Definition: Battleground.h:235
bool IsSpiritService() const
Definition: Unit.h:1579

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAreaTriggerOpcode ( WorldPackets::Misc::AreaTrigger packet)
456 {
457  Player* player = GetPlayer();
458  if (player->IsInFlight())
459  {
460  TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (%s) in flight, ignore Area Trigger ID:%u",
461  player->GetName().c_str(), player->GetGUID().ToString().c_str(), packet.AreaTriggerID);
462  return;
463  }
464 
465  AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(packet.AreaTriggerID);
466  if (!atEntry)
467  {
468  TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (%s) send unknown (by DBC) Area Trigger ID:%u",
469  player->GetName().c_str(), player->GetGUID().ToString().c_str(), packet.AreaTriggerID);
470  return;
471  }
472 
473  if (!player->IsInAreaTriggerRadius(atEntry))
474  {
475  TC_LOG_DEBUG("network", "HandleAreaTriggerOpcode: Player '%s' (%s) too far, ignore Area Trigger ID: %u",
476  player->GetName().c_str(), player->GetGUID().ToString().c_str(), packet.AreaTriggerID);
477  return;
478  }
479 
480  if (player->isDebugAreaTriggers)
481  ChatHandler(player->GetSession()).PSendSysMessage(packet.Entered ? LANG_DEBUG_AREATRIGGER_ENTERED : LANG_DEBUG_AREATRIGGER_LEFT, packet.AreaTriggerID);
482 
483  if (sScriptMgr->OnAreaTrigger(player, atEntry, packet.Entered))
484  return;
485 
486  if (player->IsAlive())
487  {
488  if (std::unordered_set<uint32> const* quests = sObjectMgr->GetQuestsForAreaTrigger(packet.AreaTriggerID))
489  {
490  for (uint32 questId : *quests)
491  {
492  Quest const* qInfo = sObjectMgr->GetQuestTemplate(questId);
493  if (qInfo && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE)
494  {
495  for (uint8 j = 0; j < qInfo->Objectives.size(); ++j)
496  {
497  if (qInfo->Objectives[j].Type == QUEST_OBJECTIVE_AREATRIGGER)
498  {
499  player->SetQuestObjectiveData(qInfo, j, int32(true));
500  break;
501  }
502  }
503 
504  if (player->CanCompleteQuest(questId))
505  player->CompleteQuest(questId);
506  }
507  }
508  }
509  }
510 
511  if (sObjectMgr->IsTavernAreaTrigger(packet.AreaTriggerID))
512  {
513  // set resting flag we are in the inn
514  player->SetRestFlag(REST_FLAG_IN_TAVERN, atEntry->ID);
515 
516  if (sWorld->IsFFAPvPRealm())
517  player->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
518 
519  return;
520  }
521 
522  if (Battleground* bg = player->GetBattleground())
523  if (bg->GetStatus() == STATUS_IN_PROGRESS)
524  bg->HandleAreaTrigger(player, packet.AreaTriggerID, packet.Entered);
525 
526  if (OutdoorPvP* pvp = player->GetOutdoorPvP())
527  if (pvp->HandleAreaTrigger(_player, packet.AreaTriggerID, packet.Entered))
528  return;
529 
530  AreaTriggerStruct const* at = sObjectMgr->GetAreaTrigger(packet.AreaTriggerID);
531  if (!at)
532  return;
533 
534  bool teleported = false;
535  if (player->GetMapId() != at->target_mapId)
536  {
537  if (Map::EnterState denyReason = sMapMgr->PlayerCannotEnter(at->target_mapId, player, false))
538  {
539  bool reviveAtTrigger = false; // should we revive the player if he is trying to enter the correct instance?
540  switch (denyReason)
541  {
543  TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter map with id %d which has no entry", player->GetName().c_str(), at->target_mapId);
544  break;
546  TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter dungeon map %d but no instance template was found", player->GetName().c_str(), at->target_mapId);
547  break;
549  TC_LOG_DEBUG("maps", "MAP: Player '%s' attempted to enter instance map %d but the requested difficulty was not found", player->GetName().c_str(), at->target_mapId);
550  if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
551  player->SendTransferAborted(entry->ID, TRANSFER_ABORT_DIFFICULTY, player->GetDifficultyID(entry));
552  break;
554  TC_LOG_DEBUG("maps", "MAP: Player '%s' must be in a raid group to enter map %d", player->GetName().c_str(), at->target_mapId);
555  player->SendRaidGroupOnlyMessage(RAID_GROUP_ERR_ONLY, 0);
556  reviveAtTrigger = true;
557  break;
559  player->GetSession()->SendPacket(WorldPackets::Misc::AreaTriggerNoCorpse().Write());
560  TC_LOG_DEBUG("maps", "MAP: Player '%s' does not have a corpse in instance map %d and cannot enter", player->GetName().c_str(), at->target_mapId);
561  break;
563  if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId))
564  {
565  char const* mapName = entry->MapName_lang;
566  TC_LOG_DEBUG("maps", "MAP: Player '%s' cannot enter instance map '%s' because their permanent bind is incompatible with their group's", player->GetName().c_str(), mapName);
567  // is there a special opcode for this?
568  // @todo figure out how to get player localized difficulty string (e.g. "10 player", "Heroic" etc)
569  ChatHandler(player->GetSession()).PSendSysMessage(player->GetSession()->GetTrinityString(LANG_INSTANCE_BIND_MISMATCH), mapName);
570  }
571  reviveAtTrigger = true;
572  break;
574  player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_TOO_MANY_INSTANCES);
575  TC_LOG_DEBUG("maps", "MAP: Player '%s' cannot enter instance map %d because he has exceeded the maximum number of instances per hour.", player->GetName().c_str(), at->target_mapId);
576  reviveAtTrigger = true;
577  break;
579  player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_MAX_PLAYERS);
580  reviveAtTrigger = true;
581  break;
583  player->SendTransferAborted(at->target_mapId, TRANSFER_ABORT_ZONE_IN_COMBAT);
584  reviveAtTrigger = true;
585  break;
586  default:
587  break;
588  }
589 
590  if (reviveAtTrigger) // check if the player is touching the areatrigger leading to the map his corpse is on
591  if (!player->IsAlive() && player->HasCorpse())
592  if (player->GetCorpseLocation().GetMapId() == at->target_mapId)
593  {
594  player->ResurrectPlayer(0.5f);
595  player->SpawnCorpseBones();
596  }
597 
598  return;
599  }
600 
601  if (Group* group = player->GetGroup())
602  if (group->isLFGGroup() && player->GetMap()->IsDungeon())
603  teleported = player->TeleportToBGEntryPoint();
604  }
605 
606  if (!teleported)
607  player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT);
608 }
Definition: Battleground.h:159
Definition: ObjectMgr.h:400
Definition: UpdateFields.h:146
Definition: Language.h:1221
Definition: QuestDef.h:279
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerfmt)
Definition: Map.h:378
float target_Orientation
Definition: ObjectMgr.h:406
Definition: DBCStructure.h:830
Definition: Language.h:997
Definition: Unit.h:310
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4901
#define sWorld
Definition: World.h:887
uint32 ID
Definition: DBCStructure.h:76
bool Entered
Definition: MiscPackets.h:257
#define sObjectMgr
Definition: ObjectMgr.h:1567
float target_Y
Definition: ObjectMgr.h:404
Definition: QuestDef.h:230
Definition: MiscPackets.h:392
Definition: Map.h:375
uint32_t uint32
Definition: Define.h:150
int32 AreaTriggerID
Definition: MiscPackets.h:256
Definition: Language.h:1002
Definition: Map.h:382
Definition: Chat.h:56
Definition: OutdoorPvP.h:188
Player * _player
Definition: WorldSession.h:1797
DBCStorage< MapEntry > sMapStore(Mapfmt)
float target_Z
Definition: ObjectMgr.h:405
#define sMapMgr
Definition: MapManager.h:194
int32_t int32
Definition: g3dmath.h:167
Definition: QuestDef.h:113
uint8_t uint8
Definition: Define.h:152
Definition: Battleground.h:235
Definition: DBCStructure.h:74
EnterState
Definition: Map.h:371
#define sScriptMgr
Definition: ScriptMgr.h:837
QuestObjectives Objectives
Definition: QuestDef.h:454
Definition: Group.h:191
float target_X
Definition: ObjectMgr.h:403
uint32 target_mapId
Definition: ObjectMgr.h:402

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAttackStopOpcode ( WorldPackets::Combat::AttackStop packet)
65 {
66  GetPlayer()->AttackStop();
67 }
Player * GetPlayer() const
Definition: WorldSession.h:927

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAttackSwingOpcode ( WorldPackets::Combat::AttackSwing packet)

Client explicitly checks the following before sending CMSG_ATTACKSWING packet, so we'll place the same check here. Note that it might be possible to reuse this snippet in other places as well.

30 {
31  Unit* enemy = ObjectAccessor::GetUnit(*_player, packet.Victim);
32 
33  if (!enemy)
34  {
35  // stop attack state at client
36  SendAttackStop(nullptr);
37  return;
38  }
39 
40  if (!_player->IsValidAttackTarget(enemy))
41  {
42  // stop attack state at client
43  SendAttackStop(enemy);
44  return;
45  }
46 
50  if (Vehicle* vehicle = _player->GetVehicle())
51  {
52  VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(_player);
53  ASSERT(seat);
54  if (!(seat->Flags & VEHICLE_SEAT_FLAG_CAN_ATTACK))
55  {
56  SendAttackStop(enemy);
57  return;
58  }
59  }
60 
61  _player->Attack(enemy, true);
62 }
Definition: DBCStructure.h:1305
void SendAttackStop(Unit const *enemy)
Definition: CombatHandler.cpp:80
Definition: Vehicle.h:32
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Definition: DBCEnums.h:721
ObjectGuid Victim
Definition: CombatPackets.h:36
Player * _player
Definition: WorldSession.h:1797
#define ASSERT
Definition: Errors.h:55
uint32 Flags
Definition: DBCStructure.h:1308
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionHelloOpcode ( WorldPackets::AuctionHouse::AuctionHelloRequest packet)
34 {
35  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Guid, UNIT_NPC_FLAG_AUCTIONEER);
36  if (!unit)
37  {
38  TC_LOG_DEBUG("network", "WORLD: HandleAuctionHelloOpcode - Unit (%s) not found or you can't interact with him.", packet.Guid.ToString().c_str());
39  return;
40  }
41 
42  // remove fake death
43  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
44  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
45 
46  SendAuctionHello(packet.Guid, unit);
47 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendAuctionHello(ObjectGuid guid, Creature *unit)
Definition: AuctionHouseHandler.cpp:50
Definition: SpellAuraDefines.h:126
ObjectGuid Guid
Definition: AuctionHousePackets.h:88
Definition: Unit.h:550
Definition: Unit.h:756
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionListBidderItems ( WorldPackets::AuctionHouse::AuctionListBidderItems packet)
557 {
558  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
559  if (!creature)
560  {
561  TC_LOG_DEBUG("network", "WORLD: HandleAuctionListBidderItems - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
562  return;
563  }
564 
565  // remove fake death
566  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
567  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
568 
569  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
570 
572 
573  Player player = GetPlayer();
574  auctionHouse->BuildListBidderItems(result, player, result.TotalCount);
575  result.DesiredDelay = 300;
576  SendPacket(result.Write());
577 }
uint32 TotalCount
Definition: AuctionHousePackets.h:237
uint32 getFaction() const
Definition: Unit.h:1466
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:168
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:221
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 DesiredDelay
Definition: AuctionHousePackets.h:236
Definition: SpellAuraDefines.h:126
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Unit.h:550
void BuildListBidderItems(WorldPackets::AuctionHouse::AuctionListBidderItemsResult &packet, Player *player, uint32 &totalcount)
Definition: AuctionHouseMgr.cpp:625
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
Definition: Unit.h:756
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionListItems ( WorldPackets::AuctionHouse::AuctionListItems packet)
604 {
605  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
606  if (!creature)
607  {
608  TC_LOG_DEBUG("network", "WORLD: HandleAuctionListItems - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
609  return;
610  }
611 
612  // remove fake death
613  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
614  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
615 
616  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
617 
618  TC_LOG_DEBUG("auctionHouse", "Auctionhouse search (%s), searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
619  packet.Auctioneer.ToString().c_str(), packet.Name.c_str(), packet.MinLevel, packet.MaxLevel , packet.InvType, packet.ItemClass, packet.ItemSubclass, packet.Quality, packet.OnlyUsable);
620 
622 
623  // converting string that we try to find to lower case
624  std::wstring wsearchedname;
625  if (!Utf8toWStr(packet.Name, wsearchedname))
626  return;
627 
628  wstrToLower(wsearchedname);
629 
630  auctionHouse->BuildListAuctionItems(result, _player,
631  wsearchedname, packet.Offset, packet.MinLevel, packet.MaxLevel, packet.OnlyUsable,
632  packet.InvType, packet.ItemClass, packet.ItemSubclass, packet.Quality, result.TotalCount);
633 
634  result.DesiredDelay = 300;
635  result.OnlyUsable = packet.OnlyUsable;
636  SendPacket(result.Write());
637 }
uint8 MaxLevel
Definition: AuctionHousePackets.h:267
std::string Name
Definition: AuctionHousePackets.h:275
uint32 getFaction() const
Definition: Unit.h:1466
uint8 MinLevel
Definition: AuctionHousePackets.h:270
uint32 Offset
Definition: AuctionHousePackets.h:268
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
Definition: AuctionHousePackets.h:204
int32 ItemClass
Definition: AuctionHousePackets.h:269
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:265
int32 ItemSubclass
Definition: AuctionHousePackets.h:273
int32 InvType
Definition: AuctionHousePackets.h:271
void BuildListAuctionItems(WorldPackets::AuctionHouse::AuctionListItemsResult &packet, Player *player, std::wstring const &searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 inventoryType, uint32 itemClass, uint32 itemSubClass, uint32 quality, uint32 &totalcount)
Definition: AuctionHouseMgr.cpp:651
Definition: SpellAuraDefines.h:126
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool OnlyUsable
Definition: AuctionHousePackets.h:276
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
Definition: Unit.h:756
int32 Quality
Definition: AuctionHousePackets.h:272
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionListOwnerItems ( WorldPackets::AuctionHouse::AuctionListOwnerItems packet)
581 {
582  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
583  if (!creature)
584  {
585  TC_LOG_DEBUG("network", "WORLD: HandleAuctionListOwnerItems - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
586  return;
587  }
588 
589  // remove fake death
590  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
591  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
592 
593  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
594 
596 
597  auctionHouse->BuildListOwnerItems(result, _player, result.TotalCount);
598  result.DesiredDelay = 300;
599  SendPacket(result.Write());
600 }
uint32 TotalCount
Definition: AuctionHousePackets.h:225
uint32 getFaction() const
Definition: Unit.h:1466
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:248
Definition: AuctionHousePackets.h:217
void BuildListOwnerItems(WorldPackets::AuctionHouse::AuctionListOwnerItemsResult &packet, Player *player, uint32 &totalcount)
Definition: AuctionHouseMgr.cpp:638
Definition: SpellAuraDefines.h:126
uint32 DesiredDelay
Definition: AuctionHousePackets.h:224
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:209
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
Definition: Unit.h:756
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionListPendingSales ( WorldPackets::AuctionHouse::AuctionListPendingSales packet)
640 {
642  result.TotalNumRecords = 0;
643  SendPacket(result.Write());
644 }
int32 TotalNumRecords
Definition: AuctionHousePackets.h:288
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:267

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionPlaceBid ( WorldPackets::AuctionHouse::AuctionPlaceBid packet)
363 {
364  if (!packet.AuctionItemID || !packet.BidAmount)
365  return; // check for cheaters
366 
367  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
368  if (!creature)
369  {
370  TC_LOG_DEBUG("network", "WORLD: HandleAuctionPlaceBid - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
371  return;
372  }
373 
374  // remove fake death
375  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
376  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
377 
378  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
379 
380  AuctionEntry* auction = auctionHouse->GetAuction(packet.AuctionItemID);
381  Player* player = GetPlayer();
382 
383  if (!auction || auction->owner == player->GetGUID().GetCounter())
384  {
385  //you cannot bid your own auction:
387  return;
388  }
389 
390  // impossible have online own another character (use this for speedup check in case online owner)
391  ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(auction->owner);
392  Player* auction_owner = ObjectAccessor::FindPlayer(ownerGuid);
393  if (!auction_owner && ObjectMgr::GetPlayerAccountIdByGUID(ownerGuid) == player->GetSession()->GetAccountId())
394  {
395  //you cannot bid your another character auction:
397  return;
398  }
399 
400  // cheating
401  if (packet.BidAmount <= auction->bid || packet.BidAmount < auction->startbid)
402  return;
403 
404  // price too low for next bid if not buyout
405  if ((packet.BidAmount < auction->buyout || auction->buyout == 0) &&
406  packet.BidAmount < auction->bid + auction->GetAuctionOutBid())
407  {
408  // client already test it but just in case ...
410  return;
411  }
412 
413  if (!player->HasEnoughMoney(packet.BidAmount))
414  {
415  // client already test it but just in case ...
417  return;
418  }
419 
421 
422  if (packet.BidAmount < auction->buyout || auction->buyout == 0)
423  {
424  if (auction->bidder)
425  {
426  if (auction->bidder == player->GetGUID().GetCounter())
427  player->ModifyMoney(-int64(packet.BidAmount - auction->bid));
428  else
429  {
430  // mail to last bidder and return money
431  sAuctionMgr->SendAuctionOutbiddedMail(auction, packet.BidAmount, GetPlayer(), trans);
432  player->ModifyMoney(-int64(packet.BidAmount));
433  }
434  }
435  else
436  player->ModifyMoney(-int64(packet.BidAmount));
437 
438  auction->bidder = player->GetGUID().GetCounter();
439  auction->bid = packet.BidAmount;
440  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, packet.BidAmount);
441 
443  stmt->setUInt64(0, auction->bidder);
444  stmt->setUInt32(1, auction->bid);
445  stmt->setUInt32(2, auction->Id);
446  trans->Append(stmt);
447 
449 
450  // Not sure if we must send this now.
451  Player* owner = ObjectAccessor::FindConnectedPlayer(ObjectGuid::Create<HighGuid::Player>(auction->owner));
452  Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
453  if (owner && item)
454  owner->GetSession()->SendAuctionOwnerBidNotification(auction, item);
455  }
456  else
457  {
458  //buyout:
459  if (player->GetGUID().GetCounter() == auction->bidder)
460  player->ModifyMoney(-int64(auction->buyout - auction->bid));
461  else
462  {
463  player->ModifyMoney(-int64(auction->buyout));
464  if (auction->bidder) //buyout for bidded auction ..
465  sAuctionMgr->SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);
466  }
467  auction->bidder = player->GetGUID().GetCounter();
468  auction->bid = auction->buyout;
469  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
470 
472 
473  //- Mails must be under transaction control too to prevent data loss
474  sAuctionMgr->SendAuctionSalePendingMail(auction, trans);
475  sAuctionMgr->SendAuctionSuccessfulMail(auction, trans);
476  sAuctionMgr->SendAuctionWonMail(auction, trans);
477 
478  auction->DeleteFromDB(trans);
479 
480  sAuctionMgr->RemoveAItem(auction->itemGUIDLow);
481  auctionHouse->RemoveAuction(auction);
482  }
483 
484  player->SaveInventoryAndGoldToDB(trans);
486 }
bool RemoveAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:564
int64_t int64
Definition: Define.h:145
uint32 getFaction() const
Definition: Unit.h:1466
AuctionEntry * GetAuction(uint32 id) const
Definition: AuctionHouseMgr.h:116
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:154
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: AuctionHouseMgr.h:67
void DeleteFromDB(SQLTransaction &trans) const
Definition: AuctionHouseMgr.cpp:800
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
uint32 Id
Definition: AuctionHouseMgr.h:69
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: AuctionHouseMgr.h:41
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: AuctionHouseMgr.h:53
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
Definition: Item.h:259
uint32 startbid
Definition: AuctionHouseMgr.h:75
uint64 BidAmount
Definition: AuctionHousePackets.h:155
Definition: SpellAuraDefines.h:126
uint32 bid
Definition: AuctionHouseMgr.h:76
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void SendAuctionCommandResult(AuctionEntry *auction, uint32 Action, uint32 ErrorCode, uint32 bidError=0)
Notifies the client of the result of his last auction operation. It is called when the player bids...
Definition: AuctionHouseHandler.cpp:68
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 buyout
Definition: AuctionHouseMgr.h:77
int64_t int64
Definition: g3dmath.h:169
Definition: Unit.h:550
Definition: AuctionHouseMgr.h:43
Definition: AuctionHouseMgr.h:38
Definition: CharacterDatabase.h:124
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
Definition: Unit.h:756
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: AuctionHouseMgr.h:45
int32 AuctionItemID
Definition: AuctionHousePackets.h:156
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 GetAuctionOutBid() const
the sum of outbid is (1% from current bid)*5, if bid is very small, it is 1c
Definition: AuctionHouseMgr.cpp:794
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionRemoveItem ( WorldPackets::AuctionHouse::AuctionRemoveItem packet)
490 {
491  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
492  if (!creature)
493  {
494  TC_LOG_DEBUG("network", "WORLD: HandleAuctionRemoveItem - %s not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
495  return;
496  }
497 
498  // remove fake death
499  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
500  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
501 
502  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
503 
504  AuctionEntry* auction = auctionHouse->GetAuction(packet.AuctionItemID);
505  Player* player = GetPlayer();
506 
508  if (auction && auction->owner == player->GetGUID().GetCounter())
509  {
510  Item* item = sAuctionMgr->GetAItem(auction->itemGUIDLow);
511  if (item)
512  {
513  if (auction->bidder) // If we have a bidder, we have to send him the money he paid
514  {
515  uint32 auctionCut = auction->GetAuctionCut();
516  if (!player->HasEnoughMoney((uint64)auctionCut)) //player doesn't have enough money, maybe message needed
517  return;
518  sAuctionMgr->SendAuctionCancelledToBidderMail(auction, trans);
519  player->ModifyMoney(-int64(auctionCut));
520  }
521 
522  // item will deleted or added to received mail list
524  .AddItem(item)
525  .SendMailTo(trans, player, auction, MAIL_CHECK_MASK_COPIED);
526  }
527  else
528  {
529  TC_LOG_ERROR("network", "Auction id: %u got non existing item (item guid : " UI64FMTD ")!", auction->Id, auction->itemGUIDLow);
531  return;
532  }
533  }
534  else
535  {
537  //this code isn't possible ... maybe there should be assert
538  TC_LOG_ERROR("network", "CHEATER: %s tried to cancel auction (id: %u) of another player or auction is NULL", player->GetGUID().ToString().c_str(), packet.AuctionItemID);
539  return;
540  }
541 
542  //inform player, that auction is removed
544 
545  // Now remove the auction
546 
547  player->SaveInventoryAndGoldToDB(trans);
548  auction->DeleteFromDB(trans);
550 
551  sAuctionMgr->RemoveAItem(auction->itemGUIDLow);
552  auctionHouse->RemoveAuction(auction);
553 }
bool RemoveAuction(AuctionEntry *auction)
Definition: AuctionHouseMgr.cpp:564
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:178
uint32 getFaction() const
Definition: Unit.h:1466
AuctionEntry * GetAuction(uint32 id) const
Definition: AuctionHouseMgr.h:116
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: AuctionHouseMgr.h:67
void DeleteFromDB(SQLTransaction &trans) const
Definition: AuctionHouseMgr.cpp:800
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
static std::string BuildAuctionMailBody(uint64 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut)
Definition: AuctionHouseMgr.cpp:877
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:50
uint32 Id
Definition: AuctionHouseMgr.h:69
void SendMailTo(SQLTransaction &trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0)
Definition: Mail.cpp:173
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Mail.h:118
Definition: AuctionHouseMgr.h:40
std::string BuildAuctionMailSubject(MailAuctionAnswers response) const
Definition: AuctionHouseMgr.cpp:870
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
Definition: Item.h:259
#define UI64FMTD
Definition: Define.h:137
int32 AuctionItemID
Definition: AuctionHousePackets.h:179
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: AuctionHouseMgr.h:63
void SendAuctionCommandResult(AuctionEntry *auction, uint32 Action, uint32 ErrorCode, uint32 bidError=0)
Notifies the client of the result of his last auction operation. It is called when the player bids...
Definition: AuctionHouseHandler.cpp:68
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint32 GetAuctionCut() const
Definition: AuctionHouseMgr.cpp:787
uint32 buyout
Definition: AuctionHouseMgr.h:77
int64_t int64
Definition: g3dmath.h:169
Definition: Unit.h:550
Definition: AuctionHouseMgr.h:38
Definition: AuctionHouseMgr.h:52
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
Definition: AuctionHouseMgr.h:100
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:756
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 deposit
Definition: AuctionHouseMgr.h:80
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAuctionSellItem ( WorldPackets::AuctionHouse::AuctionSellItem packet)

- HARDCODED DB GUID, BAD BAD BAD

113 {
114  if (packet.Items.size() > MAX_AUCTION_ITEMS)
115  {
117  return;
118  }
119 
120  for (auto const& item : packet.Items)
121  if (!item.Guid || !item.UseCount || item.UseCount > 1000)
122  return;
123 
124  if (!packet.MinBid || !packet.RunTime)
125  return;
126 
127  if (packet.MinBid > MAX_MONEY_AMOUNT || packet.BuyoutPrice > MAX_MONEY_AMOUNT)
128  {
129  TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Player %s (%s) attempted to sell item with higher price than max gold amount.", _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
131  return;
132  }
133 
134 
135  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Auctioneer, UNIT_NPC_FLAG_AUCTIONEER);
136  if (!creature)
137  {
138  TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) not found or you can't interact with him.", packet.Auctioneer.ToString().c_str());
139  return;
140  }
141 
142  AuctionHouseEntry const* auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(creature->getFaction());
143  if (!auctionHouseEntry)
144  {
145  TC_LOG_DEBUG("network", "WORLD: HandleAuctionSellItem - Unit (%s) has wrong faction.", packet.Auctioneer.ToString().c_str());
146  return;
147  }
148 
149  packet.RunTime *= MINUTE;
150 
151  switch (packet.RunTime)
152  {
153  case 1 * MIN_AUCTION_TIME:
154  case 2 * MIN_AUCTION_TIME:
155  case 4 * MIN_AUCTION_TIME:
156  break;
157  default:
158  return;
159  }
160 
161  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
162  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
163 
164  uint32 finalCount = 0;
165  for (auto const& packetItem : packet.Items)
166  {
167  Item* item = _player->GetItemByGuid(packetItem.Guid);
168 
169  if (!item)
170  {
172  return;
173  }
174 
175  if (sAuctionMgr->GetAItem(item->GetGUID().GetCounter()) || !item->CanBeTraded() || item->IsNotEmptyBag() ||
177  item->GetCount() < packetItem.UseCount)
178  {
180  return;
181  }
182 
183  finalCount += packetItem.UseCount;
184  }
185 
186  if (packet.Items.empty())
187  {
189  return;
190  }
191 
192  if (!finalCount)
193  {
195  return;
196  }
197 
198  // check if there are 2 identical guids, in this case user is most likely cheating
199  for (uint32 i = 0; i < packet.Items.size() - 1; ++i)
200  {
201  for (uint32 j = i + 1; j < packet.Items.size(); ++j)
202  {
203  if (packet.Items[i].Guid == packet.Items[j].Guid)
204  {
206  return;
207  }
208  }
209  }
210 
211  for (auto const& packetItem : packet.Items)
212  {
213  Item* item = _player->GetItemByGuid(packetItem.Guid);
214 
215  if (item->GetMaxStackCount() < finalCount)
216  {
218  return;
219  }
220  }
221 
222  Item* item = _player->GetItemByGuid(packet.Items[0].Guid);
223 
224  uint32 auctionTime = uint32(packet.RunTime * sWorld->getRate(RATE_AUCTION_TIME));
225  AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
226 
227  uint32 deposit = sAuctionMgr->GetAuctionDeposit(auctionHouseEntry, packet.RunTime, item, finalCount);
228  if (!_player->HasEnoughMoney((uint64)deposit))
229  {
231  return;
232  }
233 
234  AuctionEntry* AH = new AuctionEntry();
235 
237  AH->auctioneer = UI64LIT(23442);
238  else
239  AH->auctioneer = packet.Auctioneer.GetCounter();
240 
241  // Required stack size of auction matches to current item stack size, just move item to auctionhouse
242  if (packet.Items.size() == 1 && item->GetCount() == packet.Items[0].UseCount)
243  {
245  {
246  sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
247  GetPlayerName().c_str(), GetAccountId(), item->GetTemplate()->GetDefaultLocaleName(), item->GetEntry(), item->GetCount());
248  }
249 
250  AH->Id = sObjectMgr->GenerateAuctionID();
251  AH->itemGUIDLow = item->GetGUID().GetCounter();
252  AH->itemEntry = item->GetEntry();
253  AH->itemCount = item->GetCount();
254  AH->owner = _player->GetGUID().GetCounter();
255  AH->startbid = packet.MinBid;
256  AH->bidder = UI64LIT(0);
257  AH->bid = 0;
258  AH->buyout = packet.BuyoutPrice;
259  AH->expire_time = time(NULL) + auctionTime;
260  AH->deposit = deposit;
261  AH->etime = packet.RunTime;
262  AH->auctionHouseEntry = auctionHouseEntry;
263 
264  TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: %s %s is selling item %s %s to auctioneer " UI64FMTD " with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u",
265  _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), item->GetGUID().ToString().c_str(), item->GetTemplate()->GetDefaultLocaleName(), AH->auctioneer, item->GetCount(), packet.MinBid, packet.BuyoutPrice, auctionTime, AH->GetHouseId());
266  sAuctionMgr->AddAItem(item);
267  auctionHouse->AddAuction(AH);
268  sAuctionMgr->PendingAuctionAdd(_player, AH);
269 
270  _player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
271 
273  item->DeleteFromInventoryDB(trans);
274  item->SaveToDB(trans);
275 
276  AH->SaveToDB(trans);
277  _player->SaveInventoryAndGoldToDB(trans);
279 
281 
282  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
283  }
284  else // Required stack size of auction does not match to current item stack size, clone item and set correct stack size
285  {
286  Item* newItem = item->CloneItem(finalCount, _player);
287  if (!newItem)
288  {
289  TC_LOG_ERROR("network", "CMSG_AUCTION_SELL_ITEM: Could not create clone of item %u", item->GetEntry());
291  delete AH;
292  return;
293  }
294 
296  {
297  sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: %u)",
298  GetPlayerName().c_str(), GetAccountId(), newItem->GetTemplate()->GetDefaultLocaleName(), newItem->GetEntry(), newItem->GetCount());
299  }
300 
301  AH->Id = sObjectMgr->GenerateAuctionID();
302  AH->itemGUIDLow = newItem->GetGUID().GetCounter();
303  AH->itemEntry = newItem->GetEntry();
304  AH->itemCount = newItem->GetCount();
305  AH->owner = _player->GetGUID().GetCounter();
306  AH->startbid = packet.MinBid;
307  AH->bidder = UI64LIT(0);
308  AH->bid = 0;
309  AH->buyout = packet.BuyoutPrice;
310  AH->expire_time = time(NULL) + auctionTime;
311  AH->deposit = deposit;
312  AH->etime = packet.RunTime;
313  AH->auctionHouseEntry = auctionHouseEntry;
314 
315  TC_LOG_INFO("network", "CMSG_AUCTION_SELL_ITEM: %s %s is selling %s %s to auctioneer " UI64FMTD " with count %u with initial bid " UI64FMTD " with buyout " UI64FMTD " and with time %u (in sec) in auctionhouse %u",
316  _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), newItem->GetGUID().ToString().c_str(), newItem->GetTemplate()->GetDefaultLocaleName(), AH->auctioneer, newItem->GetCount(), packet.MinBid, packet.BuyoutPrice, auctionTime, AH->GetHouseId());
317  sAuctionMgr->AddAItem(newItem);
318  auctionHouse->AddAuction(AH);
319  sAuctionMgr->PendingAuctionAdd(_player, AH);
320 
321  for (auto const& packetItem : packet.Items)
322  {
323  Item* item2 = _player->GetItemByGuid(packetItem.Guid);
324 
325  // Item stack count equals required count, ready to delete item - cloned item will be used for auction
326  if (item2->GetCount() == packetItem.UseCount)
327  {
328  _player->MoveItemFromInventory(item2->GetBagSlot(), item2->GetSlot(), true);
329 
331  item2->DeleteFromInventoryDB(trans);
332  item2->DeleteFromDB(trans);
334  delete item2;
335  }
336  else // Item stack count is bigger than required count, update item stack count and save to database - cloned item will be used for auction
337  {
338  item2->SetCount(item2->GetCount() - packetItem.UseCount);
339  item2->SetState(ITEM_CHANGED, _player);
340  _player->ItemRemovedQuestCheck(item2->GetEntry(), packetItem.UseCount);
341  item2->SendUpdateToPlayer(_player);
342 
344  item2->SaveToDB(trans);
346  }
347  }
348 
350  newItem->SaveToDB(trans);
351  AH->SaveToDB(trans);
352  _player->SaveInventoryAndGoldToDB(trans);
354 
356 
357  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
358  }
359 }
Definition: ItemTemplate.h:174
ObjectGuid Auctioneer
Definition: AuctionHousePackets.h:141
void SaveToDB(SQLTransaction &trans) const
Definition: AuctionHouseMgr.cpp:807
uint32 GetCount() const
Definition: Item.h:322
#define MAX_AUCTION_ITEMS
Definition: AuctionHouseMgr.h:34
Definition: UpdateFields.h:47
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
uint32 itemEntry
Definition: AuctionHouseMgr.h:72
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
uint64 const MAX_MONEY_AMOUNT
Definition: Player.cpp:130
uint32 itemCount
Definition: AuctionHouseMgr.h:73
std::vector< AuctionItemForSale > Items
Definition: AuctionHousePackets.h:144
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
uint32 getFaction() const
Definition: Unit.h:1466
uint32 GetMaxStackCount() const
Definition: Item.h:324
Item * CloneItem(uint32 count, Player const *player=NULL) const
Definition: Item.cpp:1095
ObjectGuid::LowType itemGUIDLow
Definition: AuctionHouseMgr.h:71
static void DeleteFromInventoryDB(SQLTransaction &trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:535
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: AuctionHouseMgr.h:42
#define UI64LIT(N)
Definition: Define.h:138
Definition: AuctionHouseMgr.h:67
arena_t NULL
Definition: jemalloc_internal.h:624
bool CanBeTraded(bool mail=false, bool trade=false) const
Definition: Item.cpp:769
#define sLog
Definition: Log.h:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: Creature.h:467
void SetCount(uint32 value)
Definition: Item.cpp:794
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
bool IsNotEmptyBag() const
Definition: Item.cpp:286
#define sObjectMgr
Definition: ObjectMgr.h:1567
AuctionHouseEntry const * auctionHouseEntry
Definition: AuctionHouseMgr.h:82
Definition: AuctionHouseMgr.h:51
Definition: Common.h:97
uint32 Id
Definition: AuctionHouseMgr.h:69
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: AuctionHouseMgr.h:41
virtual void SaveToDB(SQLTransaction &trans)
Definition: Item.cpp:311
Definition: AuctionHouseMgr.h:40
ObjectGuid::LowType owner
Definition: AuctionHouseMgr.h:74
Definition: Item.h:259
uint32 startbid
Definition: AuctionHouseMgr.h:75
#define UI64FMTD
Definition: Define.h:137
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
uint32 bid
Definition: AuctionHouseMgr.h:76
time_t expire_time
Definition: AuctionHouseMgr.h:78
Definition: World.h:432
void SendAuctionCommandResult(AuctionEntry *auction, uint32 Action, uint32 ErrorCode, uint32 bidError=0)
Notifies the client of the result of his last auction operation. It is called when the player bids...
Definition: AuctionHouseHandler.cpp:68
ObjectGuid::LowType bidder
Definition: AuctionHouseMgr.h:79
uint8 GetSlot() const
Definition: Item.h:329
uint64 MinBid
Definition: AuctionHousePackets.h:142
uint32 RunTime
Definition: AuctionHousePackets.h:143
uint32 buyout
Definition: AuctionHouseMgr.h:77
uint32 GetHouseId() const
Definition: AuctionHouseMgr.h:86
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
static void DeleteFromDB(SQLTransaction &trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:518
Definition: Unit.h:550
ObjectGuid::LowType auctioneer
Definition: AuctionHouseMgr.h:70
Player * _player
Definition: WorldSession.h:1797
Definition: AuctionHouseMgr.h:38
Definition: RBAC.h:63
#define sAuctionMgr
Definition: AuctionHouseMgr.h:199
uint32 etime
Definition: AuctionHouseMgr.h:81
uint32 GetFlags() const
Definition: ItemTemplate.h:656
Definition: AuctionHouseMgr.h:100
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: DB2Structure.h:53
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
uint64 BuyoutPrice
Definition: AuctionHousePackets.h:140
uint8 GetBagSlot() const
Definition: Item.cpp:759
Definition: Unit.h:756
#define MIN_AUCTION_TIME
Definition: AuctionHouseMgr.h:33
void SendUpdateToPlayer(Player *player)
Definition: Object.cpp:251
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 deposit
Definition: AuctionHouseMgr.h:80
static AuctionHouseEntry const * GetAuctionHouseEntry(uint32 factionTemplateId)
Definition: AuctionHouseMgr.cpp:516
LowType GetCounter() const
Definition: ObjectGuid.h:221
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutoBankItemOpcode ( WorldPackets::Bank::AutoBankItem packet)
26 {
27  TC_LOG_DEBUG("network", "STORAGE: receive bag = %u, slot = %u", packet.Bag, packet.Slot);
28 
29  if (!CanUseBank())
30  {
31  TC_LOG_ERROR("network", "WORLD: HandleAutoBankItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
32  return;
33  }
34 
35  Item* item = _player->GetItemByPos(packet.Bag, packet.Slot);
36  if (!item)
37  return;
38 
39  ItemPosCountVec dest;
40  InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, item, false);
41  if (msg != EQUIP_ERR_OK)
42  {
43  _player->SendEquipError(msg, item, NULL);
44  return;
45  }
46 
47  if (dest.size() == 1 && dest[0].pos == item->GetPos())
48  {
49  _player->SendEquipError(EQUIP_ERR_CANT_SWAP, item, NULL);
50  return;
51  }
52 
53  _player->RemoveItem(packet.Bag, packet.Slot, true);
54  _player->ItemRemovedQuestCheck(item->GetEntry(), item->GetCount());
55  _player->BankItem(dest, item, true);
56 }
uint32 GetCount() const
Definition: Item.h:322
Definition: Item.h:69
Definition: Unit.h:379
uint8 Bag
Definition: BankPackets.h:38
uint16 GetPos() const
Definition: Item.h:333
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:48
Definition: Unit.h:378
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
Definition: Item.h:259
Player * _player
Definition: WorldSession.h:1797
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
InventoryResult
Definition: Item.h:46
bool CanUseBank(ObjectGuid bankerGUID=ObjectGuid::Empty) const
Definition: ItemHandler.cpp:1256
uint8 Slot
Definition: BankPackets.h:39
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutoEquipItemOpcode ( WorldPackets::Item::AutoEquipItem autoEquipItem)
175 {
176  if (autoEquipItem.Inv.Items.size() != 1)
177  {
178  TC_LOG_ERROR("network", "HandleAutoEquipItemOpcode - Invalid itemCount (" SZFMTD ")", autoEquipItem.Inv.Items.size());
179  return;
180  }
181 
182  TC_LOG_DEBUG("network", "HandleAutoEquipItemOpcode: receive PackSlot: %u, Slot: %u",
183  autoEquipItem.PackSlot, autoEquipItem.Slot);
184 
185  Item* srcItem = _player->GetItemByPos(autoEquipItem.PackSlot, autoEquipItem.Slot);
186  if (!srcItem)
187  return; // only at cheat
188 
189  uint16 dest;
190  InventoryResult msg = _player->CanEquipItem(NULL_SLOT, dest, srcItem, !srcItem->IsBag());
191  if (msg != EQUIP_ERR_OK)
192  {
193  _player->SendEquipError(msg, srcItem);
194  return;
195  }
196 
197  uint16 src = srcItem->GetPos();
198  if (dest == src) // prevent equip in same slot, only at cheat
199  return;
200 
201  Item* dstItem = _player->GetItemByPos(dest);
202  if (!dstItem) // empty slot, simple case
203  {
204  _player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, true);
205  _player->EquipItem(dest, srcItem, true);
206  _player->AutoUnequipOffhandIfNeed();
207  }
208  else // have currently equipped item, not simple case
209  {
210  uint8 dstbag = dstItem->GetBagSlot();
211  uint8 dstslot = dstItem->GetSlot();
212 
213  msg = _player->CanUnequipItem(dest, !srcItem->IsBag());
214  if (msg != EQUIP_ERR_OK)
215  {
216  _player->SendEquipError(msg, dstItem);
217  return;
218  }
219 
220  // check dest->src move possibility
221  ItemPosCountVec sSrc;
222  uint16 eSrc = 0;
223  if (_player->IsInventoryPos(src))
224  {
225  msg = _player->CanStoreItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
226  if (msg != EQUIP_ERR_OK)
227  msg = _player->CanStoreItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
228  if (msg != EQUIP_ERR_OK)
229  msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
230  }
231  else if (_player->IsBankPos(src))
232  {
233  msg = _player->CanBankItem(autoEquipItem.PackSlot, autoEquipItem.Slot, sSrc, dstItem, true);
234  if (msg != EQUIP_ERR_OK)
235  msg = _player->CanBankItem(autoEquipItem.PackSlot, NULL_SLOT, sSrc, dstItem, true);
236  if (msg != EQUIP_ERR_OK)
237  msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, sSrc, dstItem, true);
238  }
239  else if (_player->IsEquipmentPos(src))
240  {
241  msg = _player->CanEquipItem(autoEquipItem.Slot, eSrc, dstItem, true);
242  if (msg == EQUIP_ERR_OK)
243  msg = _player->CanUnequipItem(eSrc, true);
244  }
245 
246  if (msg != EQUIP_ERR_OK)
247  {
248  _player->SendEquipError(msg, dstItem, srcItem);
249  return;
250  }
251 
252  // now do moves, remove...
253  _player->RemoveItem(dstbag, dstslot, false);
254  _player->RemoveItem(autoEquipItem.PackSlot, autoEquipItem.Slot, false);
255 
256  // add to dest
257  _player->EquipItem(dest, srcItem, true);
258 
259  // add to src
260  if (_player->IsInventoryPos(src))
261  _player->StoreItem(sSrc, dstItem, true);
262  else if (_player->IsBankPos(src))
263  _player->BankItem(sSrc, dstItem, true);
264  else if (_player->IsEquipmentPos(src))
265  _player->EquipItem(eSrc, dstItem, true);
266 
267  _player->AutoUnequipOffhandIfNeed();
268  }
269 }
Definition: Unit.h:379
#define SZFMTD
Definition: Define.h:143
uint16 GetPos() const
Definition: Item.h:333
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
InvUpdate Inv
Definition: ItemPackets.h:305
bool IsBag() const
Definition: Item.h:307
uint8 Slot
Definition: ItemPackets.h:304
uint8 PackSlot
Definition: ItemPackets.h:306
Definition: Item.h:48
Definition: Unit.h:378
Definition: Item.h:259
uint16_t uint16
Definition: Define.h:151
std::vector< InvItem > Items
Definition: ItemPackets.h:236
uint8 GetSlot() const
Definition: Item.h:329
Player * _player
Definition: WorldSession.h:1797
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
InventoryResult
Definition: Item.h:46
uint8 GetBagSlot() const
Definition: Item.cpp:759

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutoEquipItemSlotOpcode ( WorldPackets::Item::AutoEquipItemSlot autoEquipItemSlot)
114 {
115  // cheating attempt, client should never send opcode in that case
116  if (autoEquipItemSlot.Inv.Items.size() != 1 || !Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, autoEquipItemSlot.ItemDstSlot))
117  return;
118 
119  Item* item = _player->GetItemByGuid(autoEquipItemSlot.Item);
120  uint16 dstPos = autoEquipItemSlot.ItemDstSlot | (INVENTORY_SLOT_BAG_0 << 8);
121  uint16 srcPos = autoEquipItemSlot.Inv.Items[0].Slot | (uint32(autoEquipItemSlot.Inv.Items[0].ContainerSlot) << 8);
122 
123  if (!item || item->GetPos() != srcPos || srcPos == dstPos)
124  return;
125 
126  _player->SwapItem(srcPos, dstPos);
127 }
#define INVENTORY_SLOT_BAG_0
uint16 GetPos() const
Definition: Item.h:333
uint8 ItemDstSlot
Definition: ItemPackets.h:317
Definition: Item.h:259
ObjectGuid Item
Definition: ItemPackets.h:316
uint16_t uint16
Definition: Define.h:151
std::vector< InvItem > Items
Definition: ItemPackets.h:236
InvUpdate Inv
Definition: ItemPackets.h:318
Player * _player
Definition: WorldSession.h:1797
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutoStoreBagItemOpcode ( WorldPackets::Item::AutoStoreBagItem packet)
651 {
652  if (!packet.Inv.Items.empty())
653  {
654  TC_LOG_ERROR("network", "HandleAutoStoreBagItemOpcode - Invalid itemCount (" SZFMTD ")", packet.Inv.Items.size());
655  return;
656  }
657 
658  TC_LOG_DEBUG("network", "HandleAutoStoreBagItemOpcode: receive ContainerSlotA: %u, SlotA: %u, ContainerSlotB: %u",
659  packet.ContainerSlotA, packet.SlotA, packet.ContainerSlotB);
660 
661  Item* item = _player->GetItemByPos(packet.ContainerSlotA, packet.SlotA);
662  if (!item)
663  return;
664 
665  if (!_player->IsValidPos(packet.ContainerSlotB, NULL_SLOT, false)) // can be autostore pos
666  {
667  _player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
668  return;
669  }
670 
671  uint16 src = item->GetPos();
672 
673  // check unequip potability for equipped items and bank bags
674  if (_player->IsEquipmentPos(src) || _player->IsBagPos(src))
675  {
676  InventoryResult msg = _player->CanUnequipItem(src, !_player->IsBagPos(src));
677  if (msg != EQUIP_ERR_OK)
678  {
679  _player->SendEquipError(msg, item);
680  return;
681  }
682  }
683 
684  ItemPosCountVec dest;
685  InventoryResult msg = _player->CanStoreItem(packet.ContainerSlotB, NULL_SLOT, dest, item, false);
686  if (msg != EQUIP_ERR_OK)
687  {
688  _player->SendEquipError(msg, item);
689  return;
690  }
691 
692  // no-op: placed in same slot
693  if (dest.size() == 1 && dest[0].pos == src)
694  {
695  // just remove grey item state
696  _player->SendEquipError(EQUIP_ERR_INTERNAL_BAG_ERROR, item);
697  return;
698  }
699 
700  _player->RemoveItem(packet.ContainerSlotA, packet.SlotA, true);
701  _player->StoreItem(dest, item, true);
702 }
Definition: Unit.h:379
#define SZFMTD
Definition: Define.h:143
uint16 GetPos() const
Definition: Item.h:333
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
InvUpdate Inv
Definition: ItemPackets.h:329
Definition: Item.h:48
Definition: Item.h:88
Definition: Item.h:259
uint16_t uint16
Definition: Define.h:151
std::vector< InvItem > Items
Definition: ItemPackets.h:236
Definition: Item.h:51
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
InventoryResult
Definition: Item.h:46
uint8 ContainerSlotB
Definition: ItemPackets.h:328
uint8 SlotA
Definition: ItemPackets.h:331
uint8 ContainerSlotA
Definition: ItemPackets.h:330

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutoStoreBankItemOpcode ( WorldPackets::Bank::AutoStoreBankItem packet)
77 {
78  TC_LOG_DEBUG("network", "STORAGE: receive bag = %u, slot = %u", packet.Bag, packet.Slot);
79 
80  if (!CanUseBank())
81  {
82  TC_LOG_ERROR("network", "WORLD: HandleAutoStoreBankItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
83  return;
84  }
85 
86  Item* item = _player->GetItemByPos(packet.Bag, packet.Slot);
87  if (!item)
88  return;
89 
90  if (_player->IsBankPos(packet.Bag, packet.Slot)) // moving from bank to inventory
91  {
92  ItemPosCountVec dest;
93  InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, item, false);
94  if (msg != EQUIP_ERR_OK)
95  {
96  _player->SendEquipError(msg, item, NULL);
97  return;
98  }
99 
100  _player->RemoveItem(packet.Bag, packet.Slot, true);
101  if (Item const* storedItem = _player->StoreItem(dest, item, true))
102  _player->ItemAddedQuestCheck(storedItem->GetEntry(), storedItem->GetCount());
103 
104  }
105  else // moving from inventory to bank
106  {
107  ItemPosCountVec dest;
108  InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, item, false);
109  if (msg != EQUIP_ERR_OK)
110  {
111  _player->SendEquipError(msg, item, NULL);
112  return;
113  }
114 
115  _player->RemoveItem(packet.Bag, packet.Slot, true);
116  _player->BankItem(dest, item, true);
117  }
118 }
uint8 Bag
Definition: BankPackets.h:50
Definition: Unit.h:379
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:48
Definition: Unit.h:378
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
Definition: Item.h:259
uint8 Slot
Definition: BankPackets.h:51
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
InventoryResult
Definition: Item.h:46
bool CanUseBank(ObjectGuid bankerGUID=ObjectGuid::Empty) const
Definition: ItemHandler.cpp:1256
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleAutostoreLootItemOpcode ( WorldPackets::Loot::LootItem packet)
Todo:
Implement looting by LootObject guid
35 {
36  Player* player = GetPlayer();
37  ObjectGuid lguid = player->GetLootGUID();
38 
40  for (WorldPackets::Loot::LootRequest const& req : packet.Loot)
41  {
42  Loot* loot = NULL;
43 
44  if (lguid.IsGameObject())
45  {
46  GameObject* go = player->GetMap()->GetGameObject(lguid);
47 
48  // not check distance for GO in case owned GO (fishing bobber case, for example) or Fishing hole GO
49  if (!go || ((go->GetOwnerGUID() != _player->GetGUID() && go->GetGoType() != GAMEOBJECT_TYPE_FISHINGHOLE) && !go->IsWithinDistInMap(_player, INTERACTION_DISTANCE)))
50  {
51  player->SendLootRelease(lguid);
52  continue;
53  }
54 
55  loot = &go->loot;
56  }
57  else if (lguid.IsItem())
58  {
59  Item* pItem = player->GetItemByGuid(lguid);
60 
61  if (!pItem)
62  {
63  player->SendLootRelease(lguid);
64  continue;
65  }
66 
67  loot = &pItem->loot;
68  }
69  else if (lguid.IsCorpse())
70  {
71  Corpse* bones = ObjectAccessor::GetCorpse(*player, lguid);
72  if (!bones)
73  {
74  player->SendLootRelease(lguid);
75  continue;
76  }
77 
78  loot = &bones->loot;
79  }
80  else
81  {
82  Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
83 
84  bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
85  if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
86  {
87  player->SendLootError(lguid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL);
88  continue;
89  }
90 
91  loot = &creature->loot;
92  }
93 
94  // Since 6.x client sends loot starting from 1 hence the -1
95  player->StoreLootItem(req.LootListID-1, loot);
96 
97  // If player is removing the last LootItem, delete the empty container.
98  if (loot->isLooted() && lguid.IsItem())
99  player->GetSession()->DoLootRelease(lguid);
100  }
101 }
#define INTERACTION_DISTANCE
Definition: Object.h:34
Definition: SharedDefines.h:170
bool IsGameObject() const
Definition: ObjectGuid.h:252
Definition: Corpse.h:49
Map * GetMap() const
Definition: Object.h:543
uint8 LootListID
Definition: LootPackets.h:82
Definition: LootPackets.h:79
Loot loot
Definition: Creature.h:578
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool IsItem() const
Definition: ObjectGuid.h:251
Definition: LootMgr.h:314
bool IsAlive() const
Definition: Unit.h:1692
Definition: LootMgr.h:107
Definition: Item.h:259
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
Loot loot
Definition: GameObject.h:1007
Definition: GameObject.h:880
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
Definition: SharedDefines.h:2090
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
bool isLooted() const
Definition: LootMgr.h:375
Player * _player
Definition: WorldSession.h:1797
LootType loot_type
Definition: LootMgr.h:325
Definition: LootMgr.h:91
Loot loot
Definition: Corpse.h:76
Definition: LootMgr.h:106
std::vector< LootRequest > Loot
Definition: LootPackets.h:93
Definition: ObjectGuid.h:189
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
Loot loot
Definition: Item.h:367
bool IsCorpse() const
Definition: ObjectGuid.h:254

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBankerActivateOpcode ( WorldPackets::NPC::Hello packet)
59 {
60  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_BANKER);
61  if (!unit)
62  {
63  TC_LOG_ERROR("network", "WORLD: HandleBankerActivateOpcode - %s not found or you can not interact with him.", packet.Unit.ToString().c_str());
64  return;
65  }
66 
67  // remove fake death
68  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
69  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
70 
71  // set currentBankerGUID for other bank action
72 
73  SendShowBank(packet.Unit);
74 }
void SendShowBank(ObjectGuid guid)
Definition: BankHandler.cpp:165
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
Definition: Unit.h:752
Definition: Unit.h:550
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Unit
Definition: NPCPackets.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlefieldLeaveOpcode ( WorldPackets::Battleground::BattlefieldLeave battlefieldLeave)
419 {
420  // not allow leave battleground in combat
421  if (_player->IsInCombat())
422  if (Battleground* bg = _player->GetBattleground())
423  if (bg->GetStatus() != STATUS_WAIT_LEAVE)
424  return;
425 
426  _player->LeaveBattleground();
427 }
Player * _player
Definition: WorldSession.h:1797
Definition: Battleground.h:160
Definition: Battleground.h:235

+ Here is the caller graph for this function:

void WorldSession::HandleBattlefieldListOpcode ( WorldPackets::Battleground::BattlefieldListRequest battlefieldList)
243 {
244  BattlemasterListEntry const* battlemasterListEntry = sBattlemasterListStore.LookupEntry(battlefieldList.ListID);
245  if (!battlemasterListEntry)
246  {
247  TC_LOG_DEBUG("bg.battleground", "BattlegroundHandler: invalid bgtype (%u) with player (Name: %s, %s) received.", battlefieldList.ListID, _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
248  return;
249  }
250 
251  sBattlegroundMgr->SendBattlegroundList(_player, ObjectGuid::Empty, BattlegroundTypeId(battlefieldList.ListID));
252 }
BattlegroundTypeId
Definition: SharedDefines.h:4558
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListfmt)
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * _player
Definition: WorldSession.h:1797
int32 ListID
Definition: BattlegroundPackets.h:262
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
Definition: DBCStructure.h:114

+ Here is the caller graph for this function:

void WorldSession::HandleBattleFieldPortOpcode ( WorldPackets::Battleground::BattlefieldPort battlefieldPort)
255 {
256  if (!_player->InBattlegroundQueue())
257  {
258  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player not in queue!",
259  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite));
260  return;
261  }
262 
263  BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(battlefieldPort.Ticket.Id);
264  if (bgQueueTypeId == BATTLEGROUND_QUEUE_NONE)
265  {
266  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Invalid queueSlot!",
267  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite));
268  return;
269  }
270 
271  BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
272 
273  //we must use temporary variable, because GroupQueueInfo pointer can be deleted in BattlegroundQueue::RemovePlayer() function
274  GroupQueueInfo ginfo;
275  if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
276  {
277  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player not in queue (No player Group Info)!",
278  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite));
279  return;
280  }
281  // if action == 1, then player must have been invited to join
282  if (!ginfo.IsInvitedToBGInstanceGUID && battlefieldPort.AcceptedInvite)
283  {
284  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Player is not invited to any bg!",
285  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite));
286  return;
287  }
288 
289  BattlegroundTypeId bgTypeId = BattlegroundMgr::BGTemplateId(bgQueueTypeId);
290  // BGTemplateId returns BATTLEGROUND_AA when it is arena queue.
291  // Do instance id search as there is no AA bg instances.
292  Battleground* bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId == BATTLEGROUND_AA ? BATTLEGROUND_TYPE_NONE : bgTypeId);
293  if (!bg)
294  {
295  if (battlefieldPort.AcceptedInvite)
296  {
297  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u. Cant find BG with id %u!",
298  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite), ginfo.IsInvitedToBGInstanceGUID);
299  return;
300  }
301 
302  bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
303  if (!bg)
304  {
305  TC_LOG_ERROR("network", "BattlegroundHandler: bg_template not found for type id %u.", bgTypeId);
306  return;
307  }
308  }
309 
310  TC_LOG_DEBUG("bg.battleground", "CMSG_BATTLEFIELD_PORT %s Slot: %u, Unk: %u, Time: %u, AcceptedInvite: %u.",
311  GetPlayerInfo().c_str(), battlefieldPort.Ticket.Id, battlefieldPort.Ticket.Type, battlefieldPort.Ticket.Time, uint32(battlefieldPort.AcceptedInvite));
312 
313  // get real bg type
314  bgTypeId = bg->GetTypeID();
315 
316  // expected bracket entry
317  PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
318  if (!bracketEntry)
319  return;
320 
321  //some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it
322  if (battlefieldPort.AcceptedInvite && ginfo.ArenaType == 0)
323  {
324  //if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue
325  if (!_player->CanJoinToBattleground(bg))
326  {
327  //send bg command result to show nice message
329  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, battlefieldPort.Ticket.Id, 0, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
330  SendPacket(battlefieldPort.Write());
331  battlefieldPort.AcceptedInvite = false;
332  TC_LOG_DEBUG("bg.battleground", "Player %s (%s) has a deserter debuff, do not port him to battleground!", _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
333  }
334  //if player don't match battleground max level, then do not allow him to enter! (this might happen when player leveled up during his waiting in queue
335  if (_player->getLevel() > bg->GetMaxLevel())
336  {
337  TC_LOG_DEBUG("network", "Player %s (%s) has level (%u) higher than maxlevel (%u) of battleground (%u)! Do not port him to battleground!",
338  _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), _player->getLevel(), bg->GetMaxLevel(), bg->GetTypeID());
339  battlefieldPort.AcceptedInvite = false;
340  }
341  }
342 
343  if (battlefieldPort.AcceptedInvite)
344  {
345  // check Freeze debuff
346  if (_player->HasAura(9454))
347  return;
348 
349  if (!_player->IsInvitedForBattlegroundQueueType(bgQueueTypeId))
350  return; // cheating?
351 
352  if (!_player->InBattleground())
353  _player->SetBattlegroundEntryPoint();
354 
355  // resurrect the player
356  if (!_player->IsAlive())
357  {
358  _player->ResurrectPlayer(1.0f);
359  _player->SpawnCorpseBones();
360  }
361  // stop taxi flight at port
362  if (_player->IsInFlight())
363  {
364  _player->GetMotionMaster()->MovementExpired();
365  _player->CleanupAfterTaxiFlight();
366  }
367 
369  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, bg, _player, battlefieldPort.Ticket.Id, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), bg->GetArenaType());
370  SendPacket(battlefieldStatus.Write());
371 
372  // remove battleground queue status from BGmgr
373  bgQueue.RemovePlayer(_player->GetGUID(), false);
374  // this is still needed here if battleground "jumping" shouldn't add deserter debuff
375  // also this is required to prevent stuck at old battleground after SetBattlegroundId set to new
376  if (Battleground* currentBg = _player->GetBattleground())
377  currentBg->RemovePlayerAtLeave(_player->GetGUID(), false, true);
378 
379  // set the destination instance id
380  _player->SetBattlegroundId(bg->GetInstanceID(), bgTypeId);
381  // set the destination team
382  _player->SetBGTeam(ginfo.Team);
383 
384  // bg->HandleBeforeTeleportToBattleground(_player);
385  sBattlegroundMgr->SendToBattleground(_player, ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
386  // add only in HandleMoveWorldPortAck()
387  // bg->AddPlayer(_player, team);
388  TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%s) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
389  }
390  else // leave queue
391  {
392  // if player leaves rated arena match before match start, it is counted as he played but he lost
393  if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
394  {
395  ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ginfo.Team);
396  if (at)
397  {
398  TC_LOG_DEBUG("bg.battleground", "UPDATING memberLost's personal arena rating for %s by opponents rating: %u, because he has left queue!", _player->GetGUID().ToString().c_str(), ginfo.OpponentsTeamRating);
400  at->SaveToDB();
401  }
402  }
403 
405  battlefieldStatus.Ticket = battlefieldPort.Ticket;
406  SendPacket(battlefieldStatus.Write());
407 
408  _player->RemoveBattlegroundQueueId(bgQueueTypeId); // must be called this way, because if you move this call to queue->removeplayer, it causes bugs
409  bgQueue.RemovePlayer(_player->GetGUID(), true);
410  // player left queue, we should update it - do not update Arena Queue
411  if (!ginfo.ArenaType)
412  sBattlegroundMgr->ScheduleQueueUpdate(ginfo.ArenaMatchmakerRating, ginfo.ArenaType, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
413 
414  TC_LOG_DEBUG("bg.battleground", "Battleground: player %s (%s) left queue for bgtype %u, queue type %u.", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), bg->GetTypeID(), bgQueueTypeId);
415  }
416 }
int32 Id
Definition: LFGPackets.h:30
Definition: BattlegroundPackets.h:147
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
Definition: BattlegroundPackets.h:200
BattlegroundTypeId
Definition: SharedDefines.h:4558
uint32 OpponentsMatchmakerRating
Definition: BattlegroundQueue.h:55
WorldPackets::LFG::RideTicket Ticket
Definition: BattlegroundPackets.h:251
Definition: SharedDefines.h:4566
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:150
Definition: SharedDefines.h:4753
bool IsRated
Definition: BattlegroundQueue.h:46
uint32 Team
Definition: BattlegroundQueue.h:44
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool AcceptedInvite
Definition: BattlegroundPackets.h:252
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
Definition: BattlegroundQueue.cpp:414
void MemberLost(Player *player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange=-12)
Definition: ArenaTeam.cpp:653
uint8 GetArenaType() const
Definition: Battleground.h:281
uint8 ArenaType
Definition: BattlegroundQueue.h:47
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
Definition: BattlegroundQueue.cpp:283
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:760
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId)
Definition: BattlegroundMgr.cpp:667
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4734
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 GetMaxLevel() const
Definition: Battleground.h:275
uint32 GetInstanceID() const
Definition: Battleground.h:265
Definition: BattlegroundQueue.h:41
uint32 OpponentsTeamRating
Definition: BattlegroundQueue.h:54
void SaveToDB()
Definition: ArenaTeam.cpp:728
int32 Type
Definition: LFGPackets.h:31
uint32 ArenaMatchmakerRating
Definition: BattlegroundQueue.h:53
WorldPackets::LFG::RideTicket Ticket
Definition: BattlegroundPackets.h:154
Definition: ArenaTeam.h:112
Definition: BattlegroundQueue.h:75
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Player * _player
Definition: WorldSession.h:1797
Definition: DBCStructure.h:926
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
BattlegroundBracketId GetBracketId() const
Definition: DBCStructure.h:935
Definition: BattlegroundPackets.h:170
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
Definition: SharedDefines.h:4560
uint32 GetMapId() const
Definition: Battleground.h:352
Definition: Battleground.h:235
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 Time
Definition: LFGPackets.h:32
uint32 IsInvitedToBGInstanceGUID
Definition: BattlegroundQueue.h:51
WorldPacket const * Write() overridefinal
Definition: Packet.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlemasterHelloOpcode ( WorldPackets::NPC::Hello hello)
42 {
43  Creature* unit = GetPlayer()->GetMap()->GetCreature(hello.Unit);
44  if (!unit)
45  return;
46 
47  if (!unit->IsBattleMaster()) // it's not battlemaster
48  return;
49 
50  // Stop the npc if moving
51  unit->StopMoving();
52 
53  BattlegroundTypeId bgTypeId = sBattlegroundMgr->GetBattleMasterBG(unit->GetEntry());
54 
55  if (!_player->GetBGAccessByLevel(bgTypeId))
56  {
57  // temp, must be gossip message...
59  return;
60  }
61 
62  sBattlegroundMgr->SendBattlegroundList(_player, hello.Unit, bgTypeId);
63 }
BattlegroundTypeId
Definition: SharedDefines.h:4558
Definition: Language.h:717
bool IsBattleMaster() const
Definition: Unit.h:1570
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Player * _player
Definition: WorldSession.h:1797
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
uint32 GetEntry() const
Definition: Object.h:107
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
ObjectGuid Unit
Definition: NPCPackets.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlemasterJoinArena ( WorldPackets::Battleground::BattlemasterJoinArena packet)
491 {
492  // ignore if we already in BG or BG queue
493  if (_player->InBattleground())
494  return;
495 
496  uint8 arenatype = ArenaTeam::GetTypeBySlot(packet.TeamSizeIndex);
497 
498  //check existence
499  Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(BATTLEGROUND_AA);
500  if (!bg)
501  {
502  TC_LOG_ERROR("network", "Battleground: template bg (all arenas) not found");
503  return;
504  }
505 
507  {
509  return;
510  }
511 
512  BattlegroundTypeId bgTypeId = bg->GetTypeID();
513  BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, arenatype);
514  PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
515  if (!bracketEntry)
516  return;
517 
518  Group* grp = _player->GetGroup();
519  // no group found, error
520  if (!grp)
521  return;
522  if (grp->GetLeaderGUID() != _player->GetGUID())
523  return;
524 
525  uint32 ateamId = _player->GetArenaTeamId(packet.TeamSizeIndex);
526  // check real arenateam existence only here (if it was moved to group->CanJoin .. () then we would ahve to get it twice)
527  ArenaTeam* at = sArenaTeamMgr->GetArenaTeamById(ateamId);
528  if (!at)
529  {
530  _player->GetSession()->SendNotInArenaTeamPacket(arenatype);
531  return;
532  }
533 
534  // get the team rating for queuing
535  uint32 arenaRating = at->GetRating();
536  uint32 matchmakerRating = at->GetAverageMMR(grp);
537  // the arenateam id must match for everyone in the group
538 
539  if (arenaRating <= 0)
540  arenaRating = 1;
541 
542  BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
543 
544  uint32 avgTime = 0;
545  GroupQueueInfo* ginfo = nullptr;
546 
547  ObjectGuid errorGuid;
548  GroupJoinBattlegroundResult err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, arenatype, arenatype, true, packet.TeamSizeIndex, errorGuid);
549  if (!err)
550  {
551  TC_LOG_DEBUG("bg.battleground", "Battleground: arena team id %u, leader %s queued with matchmaker rating %u for type %u", _player->GetArenaTeamId(packet.TeamSizeIndex), _player->GetName().c_str(), matchmakerRating, arenatype);
552 
553  ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, arenatype, true, false, arenaRating, matchmakerRating, ateamId);
554  avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
555  }
556 
557  for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
558  {
559  Player* member = itr->GetSource();
560  if (!member)
561  continue;
562 
563  if (err)
564  {
566  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, arenatype, err, &errorGuid);
567  member->SendDirectMessage(battlefieldStatus.Write());
568  continue;
569  }
570 
571  // add to queue
572  uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
573 
575  sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, avgTime, arenatype, true);
576  member->SendDirectMessage(battlefieldStatus.Write());
577 
578  TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for arena as group bg queue type %u bg type %u, %s, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUID().ToString().c_str(), member->GetName().c_str());
579  }
580 
581  sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
582 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground const *bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot, ObjectGuid &errorGuid)
Definition: Group.cpp:1916
uint32 GetAverageMMR(Group *group) const
Definition: ArenaTeam.cpp:495
uint8 TeamSizeIndex
Definition: BattlegroundPackets.h:233
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
Definition: BattlegroundPackets.h:200
BattlegroundTypeId
Definition: SharedDefines.h:4558
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:177
Definition: SharedDefines.h:4566
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:189
Definition: BattlegroundPackets.h:185
uint32 GetRating() const
Definition: ArenaTeam.h:133
GroupQueueInfo * AddGroup(Player *leader, Group *group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId=0)
Definition: BattlegroundQueue.cpp:129
uint32 GetAverageQueueWaitTime(GroupQueueInfo *ginfo, BattlegroundBracketId bracket_id) const
Definition: BattlegroundQueue.cpp:261
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:760
Definition: DisableMgr.h:32
uint32_t uint32
Definition: Define.h:150
GroupReference * GetFirstMember()
Definition: Group.h:295
GroupReference * next()
Definition: GroupReference.h:37
Definition: BattlegroundQueue.h:41
Definition: Chat.h:56
Definition: ArenaTeam.h:112
Definition: BattlegroundQueue.h:75
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Player * _player
Definition: WorldSession.h:1797
Definition: DBCStructure.h:926
BattlegroundBracketId GetBracketId() const
Definition: DBCStructure.h:935
Definition: Language.h:752
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
uint8_t uint8
Definition: Define.h:152
BattlegroundTypeId GetTypeID(bool GetRandom=false) const
Definition: Battleground.h:263
uint32 GetMapId() const
Definition: Battleground.h:352
Definition: Battleground.h:235
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
static uint8 GetTypeBySlot(uint8 slot)
Definition: ArenaTeam.cpp:472
Definition: ObjectGuid.h:189
GroupJoinBattlegroundResult
Definition: SharedDefines.h:4750
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlemasterJoinOpcode ( WorldPackets::Battleground::BattlemasterJoin battlemasterJoin)
66 {
67  bool isPremade = false;
68  Group* grp = NULL;
69  uint32 bgTypeId_ = battlemasterJoin.QueueID & 0xFFFF;
70  if (!sBattlemasterListStore.LookupEntry(bgTypeId_))
71  {
72  TC_LOG_ERROR("network", "Battleground: invalid bgtype (%u) received. possible cheater? %s", bgTypeId_, _player->GetGUID().ToString().c_str());
73  return;
74  }
75 
77  {
79  return;
80  }
81 
82  BattlegroundTypeId bgTypeId = BattlegroundTypeId(bgTypeId_);
83 
84  // can do this, since it's battleground, not arena
85  BattlegroundQueueTypeId bgQueueTypeId = BattlegroundMgr::BGQueueTypeId(bgTypeId, 0);
87 
88  // ignore if player is already in BG
89  if (_player->InBattleground())
90  return;
91 
92  // get bg instance or bg template if instance not found
93  Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
94  if (!bg)
95  return;
96 
97  // expected bracket entry
98  PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
99  if (!bracketEntry)
100  return;
101 
103 
104  // check queue conditions
105  if (!battlemasterJoin.JoinAsGroup)
106  {
107  if (GetPlayer()->isUsingLfg())
108  {
110  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_LFG_CANT_USE_BATTLEGROUND);
111  SendPacket(battlefieldStatus.Write());
112  return;
113  }
114 
115  // check Deserter debuff
116  if (!_player->CanJoinToBattleground(bg))
117  {
119  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_GROUP_JOIN_BATTLEGROUND_DESERTERS);
120  SendPacket(battlefieldStatus.Write());
121  return;
122  }
123 
124  if (_player->GetBattlegroundQueueIndex(bgQueueTypeIdRandom) < PLAYER_MAX_BATTLEGROUND_QUEUES)
125  {
126  // player is already in random queue
128  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_RANDOM_BG);
129  SendPacket(battlefieldStatus.Write());
130  return;
131  }
132 
133  if (_player->InBattlegroundQueue() && bgTypeId == BATTLEGROUND_RB)
134  {
135  // player is already in queue, can't start random queue
137  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_IN_NON_RANDOM_BG);
138  SendPacket(battlefieldStatus.Write());
139  return;
140  }
141 
142  // check if already in queue
143  if (_player->GetBattlegroundQueueIndex(bgQueueTypeId) < PLAYER_MAX_BATTLEGROUND_QUEUES)
144  // player is already in this queue
145  return;
146 
147  // check if has free queue slots
148  if (!_player->HasFreeBattlegroundQueueId())
149  {
151  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, ERR_BATTLEGROUND_TOO_MANY_QUEUES);
152  SendPacket(battlefieldStatus.Write());
153  return;
154  }
155 
156  // check Freeze debuff
157  if (_player->HasAura(9454))
158  return;
159 
160  BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
161  GroupQueueInfo* ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
162 
163  uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
164  uint32 queueSlot = _player->AddBattlegroundQueueId(bgQueueTypeId);
165 
167  sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, false);
168  SendPacket(battlefieldStatus.Write());
169 
170  TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
171  bgQueueTypeId, bgTypeId, _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
172  }
173  else
174  {
175  grp = _player->GetGroup();
176 
177  if (!grp)
178  return;
179 
180  if (grp->GetLeaderGUID() != _player->GetGUID())
181  return;
182 
183  ObjectGuid errorGuid;
184  err = grp->CanJoinBattlegroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0, errorGuid);
185  isPremade = (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
186 
187  BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
188  GroupQueueInfo* ginfo = NULL;
189  uint32 avgTime = 0;
190 
191  if (!err)
192  {
193  TC_LOG_DEBUG("bg.battleground", "Battleground: the following players are joining as group:");
194  ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bracketEntry, 0, false, isPremade, 0, 0);
195  avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, bracketEntry->GetBracketId());
196  }
197 
198  for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
199  {
200  Player* member = itr->GetSource();
201  if (!member)
202  continue; // this should never happen
203 
204  if (err)
205  {
207  sBattlegroundMgr->BuildBattlegroundStatusFailed(&battlefieldStatus, bg, _player, 0, 0, err, &errorGuid);
208  member->SendDirectMessage(battlefieldStatus.Write());
209  continue;
210  }
211 
212  // add to queue
213  uint32 queueSlot = member->AddBattlegroundQueueId(bgQueueTypeId);
214 
216  sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, member, queueSlot, ginfo->JoinTime, avgTime, ginfo->ArenaType, true);
217  member->SendDirectMessage(battlefieldStatus.Write());
218  TC_LOG_DEBUG("bg.battleground", "Battleground: player joined queue for bg queue type %u bg type %u, %s, NAME %s",
219  bgQueueTypeId, bgTypeId, member->GetGUID().ToString().c_str(), member->GetName().c_str());
220  }
221  TC_LOG_DEBUG("bg.battleground", "Battleground: group end");
222  }
223 
224  sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
225 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
GroupJoinBattlegroundResult CanJoinBattlegroundQueue(Battleground const *bgOrTemplate, BattlegroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, bool isRated, uint32 arenaSlot, ObjectGuid &errorGuid)
Definition: Group.cpp:1916
uint32 GetMinPlayersPerTeam() const
Definition: Battleground.h:278
Definition: SharedDefines.h:4755
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
Definition: BattlegroundPackets.h:200
BattlegroundTypeId
Definition: SharedDefines.h:4558
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:177
Definition: SharedDefines.h:4752
Definition: SharedDefines.h:4767
Definition: SharedDefines.h:4753
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListfmt)
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:209
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition: BattlegroundMgr.cpp:623
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:189
Definition: BattlegroundPackets.h:185
GroupQueueInfo * AddGroup(Player *leader, Group *group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const *bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId=0)
Definition: BattlegroundQueue.cpp:129
uint64 QueueID
Definition: BattlegroundPackets.h:222
uint8 ArenaType
Definition: BattlegroundQueue.h:47
Definition: SharedDefines.h:4766
uint32 GetAverageQueueWaitTime(GroupQueueInfo *ginfo, BattlegroundBracketId bracket_id) const
Definition: BattlegroundQueue.cpp:261
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:760
Definition: DisableMgr.h:32
uint32_t uint32
Definition: Define.h:150
bool JoinAsGroup
Definition: BattlegroundPackets.h:220
Definition: Language.h:751
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
GroupReference * GetFirstMember()
Definition: Group.h:295
uint32 JoinTime
Definition: BattlegroundQueue.h:49
Definition: BattlegroundQueue.h:41
Definition: SharedDefines.h:4765
Definition: Chat.h:56
Definition: BattlegroundQueue.h:75
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Player * _player
Definition: WorldSession.h:1797
Definition: DBCStructure.h:926
uint32 GetMembersCount() const
Definition: Group.h:297
uint32 GetMaxPlayersPerTeam() const
Definition: Battleground.h:277
BattlegroundBracketId GetBracketId() const
Definition: DBCStructure.h:935
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
uint32 GetMapId() const
Definition: Battleground.h:352
Definition: Battleground.h:235
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
GroupJoinBattlegroundResult
Definition: SharedDefines.h:4750
Definition: SharedDefines.h:4573
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlenetRequest ( WorldPackets::Battlenet::Request request)
24 {
25  sServiceDispatcher.Dispatch(this, request.Method.GetServiceHash(), request.Method.Token, request.Method.GetMethodId(), std::move(request.Data));
26 }
uint32 GetMethodId() const
Definition: BattlenetPackets.h:36
uint32 Token
Definition: BattlenetPackets.h:33
#define sServiceDispatcher
Definition: ServiceDispatcher.h:66
MethodCall Method
Definition: BattlenetPackets.h:91
MessageBuffer Data
Definition: BattlenetPackets.h:92
uint32 GetServiceHash() const
Definition: BattlenetPackets.h:35

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlenetRequestRealmListTicket ( WorldPackets::Battlenet::RequestRealmListTicket requestRealmListTicket)
29 {
30  SetRealmListSecret(requestRealmListTicket.Secret);
31 
33  realmListTicket.Token = requestRealmListTicket.Token;
34  realmListTicket.Ticket << "WorldserverRealmListTicket";
35 
36  SendPacket(realmListTicket.Write());
37 }
void SetRealmListSecret(std::array< uint8, 32 > const &secret)
Definition: WorldSession.h:1708
WorldPacket const * Write() override
Definition: BattlenetPackets.cpp:63
uint32 Token
Definition: BattlenetPackets.h:102
std::array< uint8, 32 > Secret
Definition: BattlenetPackets.h:103
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ByteBuffer Ticket
Definition: BattlenetPackets.h:81
Definition: BattlenetPackets.h:72
uint32 Token
Definition: BattlenetPackets.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetDeletePet ( WorldPackets::BattlePet::BattlePetDeletePet battlePetDeletePet)
54 {
55  GetBattlePetMgr()->RemovePet(battlePetDeletePet.PetGuid);
56 }
void RemovePet(ObjectGuid guid)
Definition: BattlePetMgr.cpp:339
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
ObjectGuid PetGuid
Definition: BattlePetPackets.h:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetModifyName ( WorldPackets::BattlePet::BattlePetModifyName battlePetModifyName)
43 {
44  if (BattlePetMgr::BattlePet* pet = GetBattlePetMgr()->GetPet(battlePetModifyName.PetGuid))
45  {
46  pet->PacketInfo.Name = battlePetModifyName.Name;
47 
48  if (pet->SaveInfo != BATTLE_PET_NEW)
49  pet->SaveInfo = BATTLE_PET_CHANGED;
50  }
51 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
ObjectGuid PetGuid
Definition: BattlePetPackets.h:126
std::string Name
Definition: BattlePetPackets.h:127
Definition: BattlePetMgr.h:79
Definition: BattlePetMgr.h:86
Definition: BattlePetMgr.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetRequestJournal ( WorldPackets::BattlePet::BattlePetRequestJournal battlePetRequestJournal)
24 {
25  // TODO: Move this to BattlePetMgr::SendJournal() just to have all packets in one file
27  battlePetJournal.Trap = GetBattlePetMgr()->GetTrapLevel();
28 
29  for (auto itr : GetBattlePetMgr()->GetLearnedPets())
30  battlePetJournal.Pets.push_back(itr.PacketInfo);
31 
32  battlePetJournal.Slots = GetBattlePetMgr()->GetSlots();
33  SendPacket(battlePetJournal.Write());
34 }
std::vector< BattlePetSlot > Slots
Definition: BattlePetPackets.h:64
WorldPacket const * Write() override
Definition: BattlePetPackets.cpp:64
uint16 GetTrapLevel() const
Definition: BattlePetMgr.h:115
std::vector< BattlePet > Pets
Definition: BattlePetPackets.h:65
Definition: BattlePetPackets.h:56
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::vector< WorldPackets::BattlePet::BattlePetSlot > GetSlots() const
Definition: BattlePetMgr.h:117
uint16 Trap
Definition: BattlePetPackets.h:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetSetBattleSlot ( WorldPackets::BattlePet::BattlePetSetBattleSlot battlePetSetBattleSlot)
37 {
38  if (BattlePetMgr::BattlePet* pet = GetBattlePetMgr()->GetPet(battlePetSetBattleSlot.PetGuid))
39  GetBattlePetMgr()->GetSlot(battlePetSetBattleSlot.Slot)->Pet = pet->PacketInfo;
40 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
WorldPackets::BattlePet::BattlePetSlot * GetSlot(uint8 slot)
Definition: BattlePetMgr.h:110
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
BattlePet Pet
Definition: BattlePetPackets.h:50
uint8 Slot
Definition: BattlePetPackets.h:116
Definition: BattlePetMgr.h:86
ObjectGuid PetGuid
Definition: BattlePetPackets.h:115

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetSetFlags ( WorldPackets::BattlePet::BattlePetSetFlags battlePetSetFlags)
59 {
60  if (BattlePetMgr::BattlePet* pet = GetBattlePetMgr()->GetPet(battlePetSetFlags.PetGuid))
61  {
62  if (battlePetSetFlags.ControlType == 2) // 2 - apply
63  pet->PacketInfo.Flags |= battlePetSetFlags.Flags;
64  else // 3 - remove
65  pet->PacketInfo.Flags &= ~battlePetSetFlags.Flags;
66 
67  if (pet->SaveInfo != BATTLE_PET_NEW)
68  pet->SaveInfo = BATTLE_PET_CHANGED;
69  }
70 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
uint8 ControlType
Definition: BattlePetPackets.h:150
ObjectGuid PetGuid
Definition: BattlePetPackets.h:148
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
uint32 Flags
Definition: BattlePetPackets.h:149
Definition: BattlePetMgr.h:79
Definition: BattlePetMgr.h:86
Definition: BattlePetMgr.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBattlePetSummon ( WorldPackets::BattlePet::BattlePetSummon battlePetSummon)
78 {
79  GetBattlePetMgr()->SummonPet(battlePetSummon.PetGuid);
80 }
ObjectGuid PetGuid
Definition: BattlePetPackets.h:191
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
void SummonPet(ObjectGuid guid)
Definition: BattlePetMgr.cpp:437

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBeginTradeOpcode ( WorldPackets::Trade::BeginTrade beginTrade)
541 {
542  TradeData* my_trade = _player->m_trade;
543  if (!my_trade)
544  return;
545 
548  my_trade->GetTrader()->GetSession()->SendTradeStatus(info);
549  SendTradeStatus(info);
550 }
Definition: SharedDefines.h:4650
void SendTradeStatus(WorldPackets::Trade::TradeStatus &status)
Definition: TradeHandler.cpp:34
Definition: TradeData.h:34
Player * GetTrader() const
Definition: TradeData.h:41
Definition: TradePackets.h:130
Player * _player
Definition: WorldSession.h:1797
::TradeStatus Status
Definition: TradePackets.h:137

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBfEntryInviteResponse ( WorldPackets::Battlefield::BFMgrEntryInviteResponse bfMgrEntryInviteResponse)

Send by client on clicking in accept or refuse of invitation windows for join game.

130 {
131  Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrEntryInviteResponse.QueueID);
132  if (!bf)
133  return;
134 
135  // If player accept invitation
136  if (bfMgrEntryInviteResponse.AcceptedInvite)
137  {
139  }
140  else
141  {
142  if (_player->GetZoneId() == bf->GetZoneId())
143  bf->KickPlayerFromBattlefield(_player->GetGUID());
144  }
145 }
void PlayerAcceptInviteToWar(Player *player)
Definition: Battlefield.cpp:375
bool AcceptedInvite
Definition: BattlefieldPackets.h:48
Definition: Battlefield.h:196
uint64 QueueID
Definition: BattlefieldPackets.h:47
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * _player
Definition: WorldSession.h:1797
uint32 GetZoneId() const
Definition: Battlefield.h:235
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition: Battlefield.cpp:302

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBfQueueExitRequest ( WorldPackets::Battlefield::BFMgrQueueExitRequest bfMgrQueueExitRequest)
168 {
169  Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrQueueExitRequest.QueueID);
170  if (!bf)
171  return;
172 
174 }
Definition: Battlefield.h:196
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
void AskToLeaveQueue(Player *player)
Definition: Battlefield.cpp:368
Player * _player
Definition: WorldSession.h:1797
uint64 QueueID
Definition: BattlefieldPackets.h:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBfQueueInviteResponse ( WorldPackets::Battlefield::BFMgrQueueInviteResponse bfMgrQueueInviteResponse)

Send by client when he click on accept for queue.

153 {
154  Battlefield* bf = sBattlefieldMgr->GetBattlefieldByQueueId(bfMgrQueueInviteResponse.QueueID);
155  if (!bf)
156  return;
157 
158  if (bfMgrQueueInviteResponse.AcceptedInvite)
160 }
Definition: Battlefield.h:196
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * _player
Definition: WorldSession.h:1797
uint64 QueueID
Definition: BattlefieldPackets.h:75
bool AcceptedInvite
Definition: BattlefieldPackets.h:76
void PlayerAcceptInviteToQueue(Player *player)
Definition: Battlefield.cpp:359

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBinderActivateOpcode ( WorldPackets::NPC::Hello packet)
435 {
436  if (!GetPlayer()->IsInWorld() || !GetPlayer()->IsAlive())
437  return;
438 
439  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_INNKEEPER);
440  if (!unit)
441  {
442  TC_LOG_DEBUG("network", "WORLD: HandleBinderActivateOpcode - %s not found or you can not interact with him.", packet.Unit.ToString().c_str());
443  return;
444  }
445 
446  // remove fake death
447  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
448  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
449 
450  SendBindPoint(unit);
451 }
Definition: Unit.h:751
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendBindPoint(Creature *npc)
Definition: NPCHandler.cpp:453
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Unit
Definition: NPCPackets.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBlackMarketOpen ( WorldPackets::BlackMarket::BlackMarketOpen packet)
25 {
26  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Guid, UNIT_NPC_FLAG_BLACK_MARKET);
27  if (!unit)
28  {
29  TC_LOG_DEBUG("network", "WORLD: HandleBlackMarketHello - Unit (GUID: %s) not found or you can't interact with him.", packet.Guid.ToString().c_str());
30  return;
31  }
32 
33  // remove fake death
34  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
35  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
36 
37  SendBlackMarketOpenResult(packet.Guid, unit);
38 }
Definition: Unit.h:765
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
void SendBlackMarketOpenResult(ObjectGuid guid, Creature *auctioneer)
Definition: BlackMarketHandler.cpp:40
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Guid
Definition: BlackMarketPackets.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBugReportOpcode ( WorldPackets::Ticket::BugReport bugReport)
88 {
89  // Note: There is no way to trigger this with standard UI except /script ReportBug("text")
90  if (!sSupportMgr->GetBugSystemStatus())
91  return;
92 
94  stmt->setString(0, bugReport.Text);
95  stmt->setString(1, bugReport.DiagInfo);
97 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: PreparedStatement.h:74
std::string DiagInfo
Definition: TicketPackets.h:246
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
#define sSupportMgr
Definition: SupportMgr.h:296
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:325
std::string Text
Definition: TicketPackets.h:245

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBusyTradeOpcode ( WorldPackets::Trade::BusyTrade busyTrade)
47 {
48 }

+ Here is the caller graph for this function:

void WorldSession::HandleBuybackItem ( WorldPackets::Item::BuyBackItem packet)
452 {
453  TC_LOG_DEBUG("network", "WORLD: Received CMSG_BUYBACK_ITEM: Vendor %s, Slot: %u", packet.VendorGUID.ToString().c_str(), packet.Slot);
454 
455  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGUID, UNIT_NPC_FLAG_VENDOR);
456  if (!creature)
457  {
458  TC_LOG_DEBUG("network", "WORLD: HandleBuybackItem - Unit (%s) not found or you can not interact with him.", packet.VendorGUID.ToString().c_str());
460  return;
461  }
462 
463  // remove fake death
464  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
465  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
466 
467  Item* pItem = _player->GetItemFromBuyBackSlot(packet.Slot);
468  if (pItem)
469  {
470  uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + packet.Slot - BUYBACK_SLOT_START);
471  if (!_player->HasEnoughMoney(uint64(price)))
472  {
473  _player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry(), 0);
474  return;
475  }
476 
477  ItemPosCountVec dest;
478  InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
479  if (msg == EQUIP_ERR_OK)
480  {
481  _player->ModifyMoney(-(int32)price);
482  _player->RemoveItemFromBuyBackSlot(packet.Slot, false);
483  _player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
484  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, pItem->GetEntry(), pItem->GetCount());
485  _player->StoreItem(dest, pItem, true);
486  }
487  else
488  _player->SendEquipError(msg, pItem, NULL);
489  return;
490  }
491  else
492  _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, creature, 0, 0);
493 }
Definition: UpdateFields.h:270
uint32 GetCount() const
Definition: Item.h:322
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: Item.h:165
Definition: Unit.h:379
Definition: Unit.h:742
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Item.h:48
Definition: Unit.h:378
Definition: Item.h:150
Definition: Item.h:259
int32_t int32
Definition: Define.h:146
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
ObjectGuid VendorGUID
Definition: ItemPackets.h:63
Definition: Item.h:152
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
uint32 GetEntry() const
Definition: Object.h:107
uint32 Slot
Definition: ItemPackets.h:64
InventoryResult
Definition: Item.h:46
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBuyBankSlotOpcode ( WorldPackets::Bank::BuyBankSlot packet)
121 {
123  if (!CanUseBank(packet.Guid))
124  {
126  SendPacket(&data);
127  TC_LOG_ERROR("network", "WORLD: HandleBuyBankSlotOpcode - %s not found or you can't interact with him.", packet.Guid.ToString().c_str());
128  return;
129  }
130 
131  uint32 slot = _player->GetBankBagSlotCount();
132 
133  // next slot
134  ++slot;
135 
136  TC_LOG_INFO("network", "PLAYER: Buy bank bag slot, slot number = %u", slot);
137 
138  BankBagSlotPricesEntry const* slotEntry = sBankBagSlotPricesStore.LookupEntry(slot);
139 
140  if (!slotEntry)
141  {
143  SendPacket(&data);
144  return;
145  }
146 
147  uint32 price = slotEntry->Cost;
148 
149  if (!_player->HasEnoughMoney(uint64(price)))
150  {
152  SendPacket(&data);
153  return;
154  }
155 
156  _player->SetBankBagSlotCount(slot);
157  _player->ModifyMoney(-int64(price));
158 
159  data << uint32(ERR_BANKSLOT_OK);
160  SendPacket(&data);
161 
162  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_BUY_BANK_SLOT);
163 }
Definition: Player.h:96
Definition: DBCStructure.h:99
DBCStorage< BankBagSlotPricesEntry > sBankBagSlotPricesStore(BankBagSlotPricesfmt)
Definition: Opcodes.h:1652
Definition: DBCEnums.h:237
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: Player.h:97
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 Cost
Definition: DBCStructure.h:102
int64_t int64
Definition: g3dmath.h:169
Player * _player
Definition: WorldSession.h:1797
Definition: Player.h:95
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ObjectGuid Guid
Definition: BankPackets.h:61
uint32_t uint32
Definition: g3dmath.h:168
bool CanUseBank(ObjectGuid bankerGUID=ObjectGuid::Empty) const
Definition: ItemHandler.cpp:1256
Definition: WorldPacket.h:26
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Player.h:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBuyItemOpcode ( WorldPackets::Item::BuyItem packet)
496 {
497  // client expects count starting at 1, and we send vendorslot+1 to client already
498  if (packet.Muid > 0)
499  --packet.Muid;
500  else
501  return; // cheating
502 
503  switch (packet.ItemType)
504  {
506  {
507  Item* bagItem = _player->GetItemByGuid(packet.ContainerGUID);
508 
509  uint8 bag = NULL_BAG;
510  if (bagItem && bagItem->IsBag())
511  bag = bagItem->GetSlot();
512  else if (packet.ContainerGUID == GetPlayer()->GetGUID()) // The client sends the player guid when trying to store an item in the default backpack
513  bag = INVENTORY_SLOT_BAG_0;
514 
515  GetPlayer()->BuyItemFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID,
516  packet.Quantity, bag, packet.Slot);
517  break;
518  }
520  {
521  GetPlayer()->BuyCurrencyFromVendorSlot(packet.VendorGUID, packet.Muid, packet.Item.ItemID, packet.Quantity);
522  break;
523  }
524  default:
525  {
526  TC_LOG_DEBUG("network", "WORLD: received wrong itemType (%u) in HandleBuyItemOpcode", packet.ItemType);
527  break;
528  }
529  }
530 }
int32 Quantity
Definition: ItemPackets.h:79
#define INVENTORY_SLOT_BAG_0
ObjectGuid ContainerGUID
Definition: ItemPackets.h:80
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsBag() const
Definition: Item.h:307
ItemVendorType ItemType
Definition: ItemPackets.h:78
ItemInstance Item
Definition: ItemPackets.h:75
Definition: Unit.h:378
Definition: ItemTemplate.h:292
uint32 Slot
Definition: ItemPackets.h:77
Definition: Item.h:259
uint8 GetSlot() const
Definition: Item.h:329
Player * _player
Definition: WorldSession.h:1797
uint8_t uint8
Definition: Define.h:152
ObjectGuid VendorGUID
Definition: ItemPackets.h:74
uint32 Muid
Definition: ItemPackets.h:76
uint32 ItemID
Definition: ItemPackets.h:46
Definition: ItemTemplate.h:293

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleBuyStableSlot ( WorldPacket recvPacket)
708 {
709  ObjectGuid npcGUID;
710 
711  recvData >> npcGUID;
712 
713  if (!CheckStableMaster(npcGUID))
714  {
716  return;
717  }
718 
719  // remove fake death
720  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
721  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
722 
723  if (GetPlayer()->m_stableSlots < MAX_PET_STABLES)
724  {
725  /*StableSlotPricesEntry const* SlotPrice = sStableSlotPricesStore.LookupEntry(GetPlayer()->m_stableSlots+1);
726  if (_player->HasEnoughMoney(SlotPrice->Price))
727  {
728  ++GetPlayer()->m_stableSlots;
729  _player->ModifyMoney(-int32(SlotPrice->Price));
730  SendPetStableResult(STABLE_SUCCESS_BUY_SLOT);
731  }
732  else
733  SendPetStableResult(STABLE_ERR_MONEY);*/
734  }
735  else
737 }
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
Player * GetPlayer() const
Definition: WorldSession.h:927
#define MAX_PET_STABLES
Definition: PetDefines.h:29
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
Definition: ObjectGuid.h:189
bool CheckStableMaster(ObjectGuid guid)
Definition: PetHandler.cpp:434
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

void WorldSession::HandleCageBattlePet ( WorldPackets::BattlePet::CageBattlePet cageBattlePet)
73 {
74  GetBattlePetMgr()->CageBattlePet(cageBattlePet.PetGuid);
75 }
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
void CageBattlePet(ObjectGuid guid)
Definition: BattlePetMgr.cpp:387
ObjectGuid PetGuid
Definition: BattlePetPackets.h:160

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarAddEvent ( WorldPackets::Calendar::CalendarAddEvent calendarAddEvent)
152 {
153  ObjectGuid guid = _player->GetGUID();
154 
155  // prevent events in the past
156  // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
157  if (calendarAddEvent.EventInfo.Time < (time(NULL) - time_t(86400L)))
158  return;
159 
160  CalendarEvent* calendarEvent = new CalendarEvent(sCalendarMgr->GetFreeEventId(), guid, UI64LIT(0), CalendarEventType(calendarAddEvent.EventInfo.EventType), calendarAddEvent.EventInfo.TextureID,
161  calendarAddEvent.EventInfo.Time, calendarAddEvent.EventInfo.Flags, calendarAddEvent.EventInfo.Title, calendarAddEvent.EventInfo.Description, time_t(0));
162 
163  if (calendarEvent->IsGuildEvent() || calendarEvent->IsGuildAnnouncement())
164  if (Player* creator = ObjectAccessor::FindPlayer(guid))
165  calendarEvent->SetGuildId(creator->GetGuildId());
166 
167  if (calendarEvent->IsGuildAnnouncement())
168  {
170  // WARNING: By passing pointer to a local variable, the underlying method(s) must NOT perform any kind
171  // of storage of the pointer as it will lead to memory corruption
172  sCalendarMgr->AddInvite(calendarEvent, &invite);
173  }
174  else
175  {
176  SQLTransaction trans;
177  if (calendarAddEvent.EventInfo.Invites.size() > 1)
179 
180  for (uint32 i = 0; i < calendarAddEvent.EventInfo.Invites.size(); ++i)
181  {
182  CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEvent->GetEventId(), calendarAddEvent.EventInfo.Invites[i].Guid,
183  guid, CALENDAR_DEFAULT_RESPONSE_TIME, CalendarInviteStatus(calendarAddEvent.EventInfo.Invites[i].Status),
184  CalendarModerationRank(calendarAddEvent.EventInfo.Invites[i].Moderator), "");
185  sCalendarMgr->AddInvite(calendarEvent, invite, trans);
186  }
187 
188  if (calendarAddEvent.EventInfo.Invites.size() > 1)
190  }
191 
192  sCalendarMgr->AddEvent(calendarEvent, CALENDAR_SENDTYPE_ADD);
193 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
uint8 EventType
Definition: CalendarPackets.h:71
CalendarEventType
Definition: CalendarMgr.h:56
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
#define UI64LIT(N)
Definition: Define.h:138
arena_t NULL
Definition: jemalloc_internal.h:624
Array< CalendarAddEventInviteInfo, CALENDAR_MAX_INVITES > Invites
Definition: CalendarPackets.h:75
CalendarModerationRank
Definition: CalendarMgr.h:42
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: CalendarMgr.h:83
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint64 GetEventId() const
Definition: CalendarMgr.h:219
std::string Description
Definition: CalendarPackets.h:70
void SetGuildId(ObjectGuid::LowType guildId)
Definition: CalendarMgr.h:224
Definition: CalendarMgr.h:191
uint32_t uint32
Definition: Define.h:150
CalendarAddEventInfo EventInfo
Definition: CalendarPackets.h:86
int32 TextureID
Definition: CalendarPackets.h:72
bool IsGuildAnnouncement() const
Definition: CalendarMgr.h:246
uint32 Flags
Definition: CalendarPackets.h:74
Player * _player
Definition: WorldSession.h:1797
bool IsGuildEvent() const
Definition: CalendarMgr.h:245
Definition: CalendarMgr.h:52
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
time_t Time
Definition: CalendarPackets.h:73
CalendarInviteStatus
Definition: CalendarMgr.h:74
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:44
#define CALENDAR_DEFAULT_RESPONSE_TIME
Definition: CalendarMgr.h:129
Definition: CalendarMgr.h:131
std::string Title
Definition: CalendarPackets.h:69
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarComplain ( WorldPackets::Calendar::CalendarComplain calendarComplain)
464 {
465  ObjectGuid guid = _player->GetGUID();
466  TC_LOG_DEBUG("network", "CMSG_CALENDAR_COMPLAIN [%s] EventId ["
467  UI64FMTD "] guid [%s] InviteId [" UI64FMTD "]", guid.ToString().c_str(), calendarComplain.EventID,
468  calendarComplain.InvitedByGUID.ToString().c_str(), calendarComplain.InviteID);
469 
470  // what to do with complains?
471 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
ObjectGuid InvitedByGUID
Definition: CalendarPackets.h:579
#define UI64FMTD
Definition: Define.h:137
uint64 EventID
Definition: CalendarPackets.h:581
Player * _player
Definition: WorldSession.h:1797
Definition: ObjectGuid.h:189
uint64 InviteID
Definition: CalendarPackets.h:580
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarCopyEvent ( WorldPackets::Calendar::CalendarCopyEvent calendarCopyEvent)
230 {
231  ObjectGuid guid = _player->GetGUID();
232 
233  // prevent events in the past
234  // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
235  if (calendarCopyEvent.Date < (time(NULL) - time_t(86400L)))
236  return;
237 
238  if (CalendarEvent* oldEvent = sCalendarMgr->GetEvent(calendarCopyEvent.EventID))
239  {
240  CalendarEvent* newEvent = new CalendarEvent(*oldEvent, sCalendarMgr->GetFreeEventId());
241  newEvent->SetDate(calendarCopyEvent.Date);
242  sCalendarMgr->AddEvent(newEvent, CALENDAR_SENDTYPE_COPY);
243 
244  CalendarInviteStore invites = sCalendarMgr->GetEventInvites(calendarCopyEvent.EventID);
245  SQLTransaction trans;
246  if (invites.size() > 1)
248 
249  for (CalendarInviteStore::const_iterator itr = invites.begin(); itr != invites.end(); ++itr)
250  sCalendarMgr->AddInvite(newEvent, new CalendarInvite(**itr, sCalendarMgr->GetFreeInviteId(), newEvent->GetEventId()), trans);
251 
252  if (invites.size() > 1)
254  // Should we change owner when somebody makes a copy of event owned by another person?
255  }
256  else
257  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
258 }
uint64 EventID
Definition: CalendarPackets.h:132
#define sCalendarMgr
Definition: CalendarMgr.h:334
Definition: CalendarMgr.h:53
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
arena_t NULL
Definition: jemalloc_internal.h:624
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint64 GetEventId() const
Definition: CalendarMgr.h:219
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:267
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
Player * _player
Definition: WorldSession.h:1797
void SetDate(time_t date)
Definition: CalendarMgr.h:239
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:131
time_t Date
Definition: CalendarPackets.h:133
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventInvite ( WorldPackets::Calendar::CalendarEventInvite calendarEventInvite)
261 {
262  ObjectGuid playerGuid = _player->GetGUID();
263 
264  ObjectGuid inviteeGuid;
265  uint32 inviteeTeam = 0;
266  ObjectGuid::LowType inviteeGuildId = UI64LIT(0);
267 
268  if (Player* player = ObjectAccessor::FindConnectedPlayerByName(calendarEventInvite.Name))
269  {
270  // Invitee is online
271  inviteeGuid = player->GetGUID();
272  inviteeTeam = player->GetTeam();
273  inviteeGuildId = player->GetGuildId();
274  }
275  else
276  {
277  // Invitee offline, get data from database
279  stmt->setString(0, calendarEventInvite.Name);
280  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
281  {
282  Field* fields = result->Fetch();
283  inviteeGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
284  inviteeTeam = Player::TeamForRace(fields[1].GetUInt8());
285  inviteeGuildId = Player::GetGuildIdFromDB(inviteeGuid);
286  }
287  }
288 
289  if (!inviteeGuid)
290  {
291  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_PLAYER_NOT_FOUND);
292  return;
293  }
294 
295  if (_player->GetTeam() != inviteeTeam && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CALENDAR))
296  {
297  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NOT_ALLIED);
298  return;
299  }
300 
301  if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
302  {
303  Field* fields = result->Fetch();
304  if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
305  {
306  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, calendarEventInvite.Name.c_str());
307  return;
308  }
309  }
310 
311  if (!calendarEventInvite.Creating)
312  {
313  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventInvite.EventID))
314  {
315  if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == inviteeGuildId)
316  {
317  // we can't invite guild members to guild events
318  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
319  return;
320  }
321 
322  CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEventInvite.EventID, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
323  sCalendarMgr->AddInvite(calendarEvent, invite);
324  }
325  else
326  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_EVENT_INVALID);
327  }
328  else
329  {
330  if (calendarEventInvite.IsSignUp && inviteeGuildId == _player->GetGuildId())
331  {
332  sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_NO_GUILD_INVITES);
333  return;
334  }
335 
336  CalendarInvite invite(sCalendarMgr->GetFreeInviteId(), 0L, inviteeGuid, playerGuid, CALENDAR_DEFAULT_RESPONSE_TIME, CALENDAR_STATUS_INVITED, CALENDAR_RANK_PLAYER, "");
337  sCalendarMgr->SendCalendarEventInvite(invite);
338  }
339 }
bool Creating
Definition: CalendarPackets.h:269
#define sCalendarMgr
Definition: CalendarMgr.h:334
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
std::string Name
Definition: CalendarPackets.h:271
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: CalendarMgr.h:101
TC_GAME_API Player * FindConnectedPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:240
Definition: CalendarMgr.h:103
Definition: CalendarMgr.h:121
#define UI64LIT(N)
Definition: Define.h:138
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: SocialMgr.h:41
#define sWorld
Definition: World.h:887
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:56
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
bool IsSignUp
Definition: CalendarPackets.h:268
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
Definition: CalendarMgr.h:102
Definition: CalendarMgr.h:76
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:44
#define CALENDAR_DEFAULT_RESPONSE_TIME
Definition: CalendarMgr.h:129
uint64 EventID
Definition: CalendarPackets.h:270
Definition: CalendarMgr.h:131
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventModeratorStatus ( WorldPackets::Calendar::CalendarEventModeratorStatus calendarEventModeratorStatus)
441 {
442  ObjectGuid guid = _player->GetGUID();
443 
444  TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_MODERATOR_STATUS [%s] EventID ["
445  UI64FMTD "] ModeratorID [" UI64FMTD "], Invitee ([%s] InviteID: ["
446  UI64FMTD "], Status %u", guid.ToString().c_str(), calendarEventModeratorStatus.EventID, calendarEventModeratorStatus.ModeratorID, calendarEventModeratorStatus.Guid.ToString().c_str(), calendarEventModeratorStatus.InviteID, calendarEventModeratorStatus.Status);
447 
448  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventModeratorStatus.EventID))
449  {
450  if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventModeratorStatus.InviteID))
451  {
452  invite->SetRank(CalendarModerationRank(calendarEventModeratorStatus.Status));
453  sCalendarMgr->UpdateInvite(invite);
454  sCalendarMgr->SendCalendarEventModeratorStatusAlert(*calendarEvent, *invite);
455  }
456  else
457  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct?
458  }
459  else
460  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
461 }
uint64 ModeratorID
Definition: CalendarPackets.h:459
uint8 Status
Definition: CalendarPackets.h:460
#define sCalendarMgr
Definition: CalendarMgr.h:334
Definition: CalendarMgr.h:117
uint64 InviteID
Definition: CalendarPackets.h:458
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
CalendarModerationRank
Definition: CalendarMgr.h:42
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
#define UI64FMTD
Definition: Define.h:137
uint64 EventID
Definition: CalendarPackets.h:457
Player * _player
Definition: WorldSession.h:1797
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:131
ObjectGuid Guid
Definition: CalendarPackets.h:456
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventRemoveInvite ( WorldPackets::Calendar::CalendarRemoveInvite calendarRemoveInvite)
394 {
395  ObjectGuid guid = _player->GetGUID();
396 
397  TC_LOG_DEBUG("network", "CMSG_CALENDAR_REMOVE_INVITE [%s] EventId [" UI64FMTD
398  "], ownerInviteId [" UI64FMTD "], Invitee ([%s] id: [" UI64FMTD "])",
399  guid.ToString().c_str(), calendarRemoveInvite.EventID, calendarRemoveInvite.ModeratorID, calendarRemoveInvite.Guid.ToString().c_str(), calendarRemoveInvite.InviteID);
400 
401  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarRemoveInvite.EventID))
402  {
403  if (calendarEvent->GetOwnerGUID() == calendarRemoveInvite.Guid)
404  {
405  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_DELETE_CREATOR_FAILED);
406  return;
407  }
408 
409  sCalendarMgr->RemoveInvite(calendarRemoveInvite.InviteID, calendarRemoveInvite.EventID, guid);
410  }
411  else
412  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE);
413 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
uint64 ModeratorID
Definition: CalendarPackets.h:419
ObjectGuid Guid
Definition: CalendarPackets.h:417
Definition: CalendarMgr.h:117
Definition: CalendarMgr.h:111
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint64 InviteID
Definition: CalendarPackets.h:420
Definition: CalendarMgr.h:191
#define UI64FMTD
Definition: Define.h:137
Player * _player
Definition: WorldSession.h:1797
Definition: ObjectGuid.h:189
uint64 EventID
Definition: CalendarPackets.h:418
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventRsvp ( WorldPackets::Calendar::CalendarEventRSVP calendarEventRSVP)
365 {
366  ObjectGuid guid = _player->GetGUID();
367 
368  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventRSVP.EventID))
369  {
370  // I think we still should be able to remove self from locked events
371  if (calendarEventRSVP.Status != CALENDAR_STATUS_REMOVED && calendarEvent->IsLocked())
372  {
373  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_LOCKED);
374  return;
375  }
376 
377  if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventRSVP.InviteID))
378  {
379  invite->SetStatus(CalendarInviteStatus(calendarEventRSVP.Status));
380  invite->SetResponseTime(time(NULL));
381 
382  sCalendarMgr->UpdateInvite(invite);
383  sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite);
384  sCalendarMgr->SendCalendarClearPendingAction(guid);
385  }
386  else
387  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct?
388  }
389  else
390  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
391 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
Definition: CalendarMgr.h:117
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CalendarMgr.h:110
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
uint64 InviteID
Definition: CalendarPackets.h:281
Player * _player
Definition: WorldSession.h:1797
uint8 Status
Definition: CalendarPackets.h:283
CalendarInviteStatus
Definition: CalendarMgr.h:74
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:131
Definition: CalendarMgr.h:85
uint64 EventID
Definition: CalendarPackets.h:282

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventSignup ( WorldPackets::Calendar::CalendarEventSignUp calendarEventSignUp)
342 {
343  ObjectGuid guid = _player->GetGUID();
344 
345  TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_SIGNUP [%s] EventId [" UI64FMTD "] Tentative %u", guid.ToString().c_str(), calendarEventSignUp.EventID, calendarEventSignUp.Tentative);
346 
347  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventSignUp.EventID))
348  {
349  if (calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() != _player->GetGuildId())
350  {
351  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_GUILD_PLAYER_NOT_IN_GUILD);
352  return;
353  }
354 
356  CalendarInvite* invite = new CalendarInvite(sCalendarMgr->GetFreeInviteId(), calendarEventSignUp.EventID, guid, guid, time(NULL), status, CALENDAR_RANK_PLAYER, "");
357  sCalendarMgr->AddInvite(calendarEvent, invite);
358  sCalendarMgr->SendCalendarClearPendingAction(guid);
359  }
360  else
361  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
362 }
Definition: CalendarMgr.h:84
#define sCalendarMgr
Definition: CalendarMgr.h:334
Definition: CalendarMgr.h:99
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: CalendarMgr.h:82
bool Tentative
Definition: CalendarPackets.h:406
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
#define UI64FMTD
Definition: Define.h:137
uint64 EventID
Definition: CalendarPackets.h:407
Player * _player
Definition: WorldSession.h:1797
CalendarInviteStatus
Definition: CalendarMgr.h:74
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:44
Definition: CalendarMgr.h:131
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarEventStatus ( WorldPackets::Calendar::CalendarEventStatus calendarEventStatus)
416 {
417  ObjectGuid guid = _player->GetGUID();
418 
419  TC_LOG_DEBUG("network", "CMSG_CALENDAR_EVENT_STATUS [%s] EventId ["
420  UI64FMTD "] ownerInviteId [" UI64FMTD "], Invitee ([%s] id: ["
421  UI64FMTD "], status %u", guid.ToString().c_str(), calendarEventStatus.EventID, calendarEventStatus.ModeratorID, calendarEventStatus.Guid.ToString().c_str(), calendarEventStatus.InviteID, calendarEventStatus.Status);
422 
423  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarEventStatus.EventID))
424  {
425  if (CalendarInvite* invite = sCalendarMgr->GetInvite(calendarEventStatus.InviteID))
426  {
427  invite->SetStatus((CalendarInviteStatus)calendarEventStatus.Status);
428 
429  sCalendarMgr->UpdateInvite(invite);
430  sCalendarMgr->SendCalendarEventStatus(*calendarEvent, *invite);
431  sCalendarMgr->SendCalendarClearPendingAction(calendarEventStatus.Guid);
432  }
433  else
434  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_NO_INVITE); // correct?
435  }
436  else
437  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
438 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
Definition: CalendarMgr.h:117
uint8 Status
Definition: CalendarPackets.h:434
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint64 ModeratorID
Definition: CalendarPackets.h:432
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
#define UI64FMTD
Definition: Define.h:137
uint64 InviteID
Definition: CalendarPackets.h:433
Player * _player
Definition: WorldSession.h:1797
ObjectGuid Guid
Definition: CalendarPackets.h:430
CalendarInviteStatus
Definition: CalendarMgr.h:74
Definition: ObjectGuid.h:189
Definition: CalendarMgr.h:131
uint64 EventID
Definition: CalendarPackets.h:431
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarGetCalendar ( WorldPackets::Calendar::CalendarGetCalendar calendarGetCalendar)
52 {
53  ObjectGuid guid = _player->GetGUID();
54  time_t currTime = time(NULL);
55 
57  packet.ServerNow = currTime;
58  packet.RaidOrigin = 1135753200; // Constant date, unk (28.12.2005 07:00)
59  packet.ServerTime = currTime;
60 
61  CalendarInviteStore playerInvites = sCalendarMgr->GetPlayerInvites(guid);
62  for (auto const& invite : playerInvites)
63  {
65  inviteInfo.EventID = invite->GetEventId();
66  inviteInfo.InviteID = invite->GetInviteId();
67  inviteInfo.InviterGuid = invite->GetSenderGUID();
68  inviteInfo.Status = invite->GetStatus();
69  inviteInfo.Moderator = invite->GetRank();
70  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(invite->GetEventId()))
71  inviteInfo.InviteType = calendarEvent->IsGuildEvent() && calendarEvent->GetGuildId() == _player->GetGuildId();
72 
73  packet.Invites.push_back(inviteInfo);
74  }
75 
76  CalendarEventStore playerEvents = sCalendarMgr->GetPlayerEvents(guid);
77  for (auto const& event : playerEvents)
78  {
80  eventInfo.EventID = event->GetEventId();
81  eventInfo.Date = event->GetDate();
82  Guild* guild = sGuildMgr->GetGuildById(event->GetGuildId());
83  eventInfo.EventGuildID = guild ? guild->GetGUID() : ObjectGuid::Empty;
84  eventInfo.EventName = event->GetTitle();
85  eventInfo.EventType = event->GetType();
86  eventInfo.Flags = event->GetFlags();
87  eventInfo.OwnerGuid = event->GetOwnerGUID();
88  eventInfo.TextureID = event->GetTextureId();
89 
90  packet.Events.push_back(eventInfo);
91  }
92 
93  for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
94  {
95  Player::BoundInstancesMap boundInstances = _player->GetBoundInstances(Difficulty(i));
96  for (auto const& boundInstance : boundInstances)
97  {
98  if (boundInstance.second.perm)
99  {
101 
102  InstanceSave const* save = boundInstance.second.save;
103  lockoutInfo.MapID = save->GetMapId();
104  lockoutInfo.DifficultyID = save->GetDifficultyID();
105  lockoutInfo.ExpireTime = save->GetResetTime() - currTime;
106  lockoutInfo.InstanceID = save->GetInstanceId(); // instance save id as unique instance copy id
107 
108  packet.RaidLockouts.push_back(lockoutInfo);
109  }
110  }
111  }
112 
113  std::set<uint32> sentMaps;
114  ResetTimeByMapDifficultyMap const& resets = sInstanceSaveMgr->GetResetTimeMap();
115  for (auto const& reset : resets)
116  {
117  uint32 mapID = PAIR64_LOPART(reset.first);
118  if (sentMaps.find(mapID) != sentMaps.end())
119  continue;
120 
121  MapEntry const* mapEntry = sMapStore.LookupEntry(mapID);
122  if (!mapEntry || !mapEntry->IsRaid())
123  continue;
124 
125  sentMaps.insert(mapID);
127  resetInfo.MapID = mapID;
128  resetInfo.Duration = reset.second - currTime;
129  resetInfo.Offset = 0; // Never seen anything else in sniffs - still unknown
130 
131  packet.RaidResets.push_back(resetInfo);
132  }
133 
134  SendPacket(packet.Write());
135 }
Difficulty
Definition: DBCEnums.h:402
#define sCalendarMgr
Definition: CalendarMgr.h:334
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: CalendarPackets.h:190
std::unordered_map< uint64, time_t > ResetTimeByMapDifficultyMap
Definition: InstanceSaveMgr.h:148
uint64 InstanceID
Definition: CalendarPackets.h:165
int32 MapID
Definition: CalendarPackets.h:173
uint64 EventID
Definition: CalendarPackets.h:180
#define sGuildMgr
Definition: GuildMgr.h:61
int32 TextureID
Definition: CalendarPackets.h:185
ObjectGuid InviterGuid
Definition: CalendarPackets.h:157
Definition: DBCEnums.h:426
Definition: DBCStructure.h:830
arena_t NULL
Definition: jemalloc_internal.h:624
int32 Offset
Definition: CalendarPackets.h:175
uint64 EventID
Definition: CalendarPackets.h:155
uint8 Moderator
Definition: CalendarPackets.h:159
std::set< CalendarEvent * > CalendarEventStore
Definition: CalendarMgr.h:268
std::string EventName
Definition: CalendarPackets.h:181
std::vector< CalendarInvite * > CalendarInviteStore
Definition: CalendarMgr.h:267
int32 MapID
Definition: CalendarPackets.h:166
uint32 PAIR64_LOPART(uint64 x)
Definition: ObjectDefines.h:44
std::vector< CalendarSendCalendarRaidLockoutInfo > RaidLockouts
Definition: CalendarPackets.h:201
Definition: CalendarMgr.h:191
time_t Date
Definition: CalendarPackets.h:183
uint32_t uint32
Definition: Define.h:150
uint32 DifficultyID
Definition: CalendarPackets.h:167
ObjectGuid GetGUID() const
Definition: Guild.h:764
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
time_t ServerNow
Definition: CalendarPackets.h:199
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:239
Definition: InstanceSaveMgr.h:44
bool IsRaid() const
Definition: DBCStructure.h:860
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:243
uint32 GetMapId() const
Definition: InstanceSaveMgr.h:65
ObjectGuid EventGuildID
Definition: CalendarPackets.h:186
std::vector< CalendarSendCalendarInviteInfo > Invites
Definition: CalendarPackets.h:200
uint32 Flags
Definition: CalendarPackets.h:184
Difficulty GetDifficultyID() const
Definition: InstanceSaveMgr.h:121
std::vector< CalendarSendCalendarRaidResetInfo > RaidResets
Definition: CalendarPackets.h:202
Player * _player
Definition: WorldSession.h:1797
DBCStorage< MapEntry > sMapStore(Mapfmt)
std::vector< CalendarSendCalendarEventInfo > Events
Definition: CalendarPackets.h:203
ObjectGuid OwnerGuid
Definition: CalendarPackets.h:187
uint8_t uint8
Definition: Define.h:152
uint8 EventType
Definition: CalendarPackets.h:182
Definition: ObjectGuid.h:189
time_t ExpireTime
Definition: CalendarPackets.h:168
uint8 InviteType
Definition: CalendarPackets.h:160
uint32 Duration
Definition: CalendarPackets.h:174
Definition: Guild.h:320
uint32 GetInstanceId() const
Definition: InstanceSaveMgr.h:64
time_t RaidOrigin
Definition: CalendarPackets.h:197
time_t ServerTime
Definition: CalendarPackets.h:198
time_t GetResetTime() const
Definition: InstanceSaveMgr.h:74
uint64 InviteID
Definition: CalendarPackets.h:156
uint8 Status
Definition: CalendarPackets.h:158

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarGetEvent ( WorldPackets::Calendar::CalendarGetEvent calendarGetEvent)
138 {
139  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarGetEvent.EventID))
140  sCalendarMgr->SendCalendarEvent(_player->GetGUID(), *calendarEvent, CALENDAR_SENDTYPE_GET);
141  else
142  sCalendarMgr->SendCalendarCommandResult(_player->GetGUID(), CALENDAR_ERROR_EVENT_INVALID);
143 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
uint64 EventID
Definition: CalendarPackets.h:45
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
Player * _player
Definition: WorldSession.h:1797
Definition: CalendarMgr.h:51

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarGetNumPending ( WorldPackets::Calendar::CalendarGetNumPending calendarGetNumPending)
474 {
475  ObjectGuid guid = _player->GetGUID();
476  uint32 pending = sCalendarMgr->GetPlayerNumPending(guid);
477 
478  TC_LOG_DEBUG("network", "CMSG_CALENDAR_GET_NUM_PENDING: [%s] Pending: %u", guid.ToString().c_str(), pending);
479 
481 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
Definition: CalendarPackets.h:380
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarGuildFilter ( WorldPackets::Calendar::CalendarGuildFilter calendarGuildFilter)
146 {
147  if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId()))
148  guild->MassInviteToEvent(this, calendarGuildFilter.MinLevel, calendarGuildFilter.MaxLevel, calendarGuildFilter.MaxRankOrder);
149 }
uint8 MaxRankOrder
Definition: CalendarPackets.h:57
#define sGuildMgr
Definition: GuildMgr.h:61
uint8 MinLevel
Definition: CalendarPackets.h:55
Player * _player
Definition: WorldSession.h:1797
uint8 MaxLevel
Definition: CalendarPackets.h:56
Definition: Guild.h:320

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarRemoveEvent ( WorldPackets::Calendar::CalendarRemoveEvent calendarRemoveEvent)
224 {
225  ObjectGuid guid = _player->GetGUID();
226  sCalendarMgr->RemoveEvent(calendarRemoveEvent.EventID, guid);
227 }
#define sCalendarMgr
Definition: CalendarMgr.h:334
uint64 EventID
Definition: CalendarPackets.h:120
Player * _player
Definition: WorldSession.h:1797
Definition: ObjectGuid.h:189

+ Here is the caller graph for this function:

void WorldSession::HandleCalendarUpdateEvent ( WorldPackets::Calendar::CalendarUpdateEvent calendarUpdateEvent)
196 {
197  ObjectGuid guid = _player->GetGUID();
198  time_t oldEventTime = time_t(0);
199 
200  // prevent events in the past
201  // To Do: properly handle timezones and remove the "- time_t(86400L)" hack
202  if (calendarUpdateEvent.EventInfo.Time < (time(NULL) - time_t(86400L)))
203  return;
204 
205  if (CalendarEvent* calendarEvent = sCalendarMgr->GetEvent(calendarUpdateEvent.EventInfo.EventID))
206  {
207  oldEventTime = calendarEvent->GetDate();
208 
209  calendarEvent->SetType(CalendarEventType(calendarUpdateEvent.EventInfo.EventType));
210  calendarEvent->SetFlags(calendarUpdateEvent.EventInfo.Flags);
211  calendarEvent->SetDate(calendarUpdateEvent.EventInfo.Time);
212  calendarEvent->SetTextureId(calendarUpdateEvent.EventInfo.TextureID);
213  calendarEvent->SetTitle(calendarUpdateEvent.EventInfo.Title);
214  calendarEvent->SetDescription(calendarUpdateEvent.EventInfo.Description);
215 
216  sCalendarMgr->UpdateEvent(calendarEvent);
217  sCalendarMgr->SendCalendarEventUpdateAlert(*calendarEvent, oldEventTime);
218  }
219  else
220  sCalendarMgr->SendCalendarCommandResult(guid, CALENDAR_ERROR_EVENT_INVALID);
221 }
uint32 TextureID
Definition: CalendarPackets.h:96
#define sCalendarMgr
Definition: CalendarMgr.h:334
CalendarEventType
Definition: CalendarMgr.h:56
arena_t NULL
Definition: jemalloc_internal.h:624
CalendarUpdateEventInfo EventInfo
Definition: CalendarPackets.h:109
uint32 Flags
Definition: CalendarPackets.h:98
uint8 EventType
Definition: CalendarPackets.h:95
std::string Description
Definition: CalendarPackets.h:94
Definition: CalendarMgr.h:191
Definition: CalendarMgr.h:96
time_t Time
Definition: CalendarPackets.h:97
uint64 EventID
Definition: CalendarPackets.h:91
Player * _player
Definition: WorldSession.h:1797
std::string Title
Definition: CalendarPackets.h:93
Definition: ObjectGuid.h:189

+ Here is the caller graph for this function:

void WorldSession::HandleCancelAuraOpcode ( WorldPackets::Spells::CancelAura cancelAura)
317 {
318  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cancelAura.SpellID);
319  if (!spellInfo)
320  return;
321 
322  // not allow remove spells with attr SPELL_ATTR0_CANT_CANCEL
323  if (spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL))
324  return;
325 
326  // channeled spell case (it currently cast then)
327  if (spellInfo->IsChanneled())
328  {
329  if (Spell* curSpell = _player->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
330  if (curSpell->GetSpellInfo()->Id == uint32(cancelAura.SpellID))
331  _player->InterruptSpell(CURRENT_CHANNELED_SPELL);
332  return;
333  }
334 
335  // non channeled case:
336  // don't allow remove non positive spells
337  // don't allow cancelling passive auras (some of them are visible)
338  if (!spellInfo->IsPositive() || spellInfo->IsPassive())
339  return;
340 
341  _player->RemoveOwnedAura(cancelAura.SpellID, cancelAura.CasterGUID, 0, AURA_REMOVE_BY_CANCEL);
342 
343  // If spell being removed is a resource tracker, see if player was tracking both (herbs / minerals) and remove the other
345  {
346  Unit::AuraEffectList const& auraEffects = _player->GetAuraEffectsByType(SPELL_AURA_TRACK_RESOURCES);
347  if (!auraEffects.empty())
348  {
349  // Build list of spell IDs to cancel. Trying to cancel the aura while iterating
350  // over AuraEffectList caused "incompatible iterator" errors on second pass
351  std::list<uint32> spellIDs;
352 
353  for (Unit::AuraEffectList::const_iterator auraEffect = auraEffects.begin(); auraEffect != auraEffects.end(); ++auraEffect)
354  spellIDs.push_back((*auraEffect)->GetId());
355 
356  // Remove all auras related to resource tracking (only Herbs and Minerals in 3.3.5a)
357  for (std::list<uint32>::iterator it = spellIDs.begin(); it != spellIDs.end(); ++it)
358  _player->RemoveOwnedAura(*it, cancelAura.CasterGUID, 0, AURA_REMOVE_BY_CANCEL);
359  }
360  }
361 }
Definition: DBCEnums.h:404
bool IsPassive() const
Definition: SpellInfo.cpp:1403
bool IsChanneled() const
Definition: SpellInfo.cpp:1514
Definition: SpellInfo.h:326
int32 SpellID
Definition: SpellPackets.h:39
Definition: Unit.h:1110
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
#define sWorld
Definition: World.h:887
Definition: World.h:174
Definition: Unit.h:452
bool HasAura(uint32 difficulty, AuraType aura) const
Definition: SpellInfo.cpp:1193
ObjectGuid CasterGUID
Definition: SpellPackets.h:38
bool IsPositive() const
Definition: SpellInfo.cpp:1495
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SharedDefines.h:387
Definition: SpellAuraDefines.h:105
Player * _player
Definition: WorldSession.h:1797
uint32_t uint32
Definition: g3dmath.h:168
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCancelAutoRepeatSpellOpcode ( WorldPackets::Spells::CancelAutoRepeatSpell cancelAutoRepeatSpell)
414 {
415  // may be better send SMSG_CANCEL_AUTO_REPEAT?
416  // cancel and prepare for deleting
417  _player->InterruptSpell(CURRENT_AUTOREPEAT_SPELL);
418 }
Definition: Unit.h:1111
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleCancelCastOpcode ( WorldPackets::Spells::CancelCast packet)
311 {
312  if (_player->IsNonMeleeSpellCast(false))
313  _player->InterruptNonMeleeSpells(false, packet.SpellID, false);
314 }
uint32 SpellID
Definition: SpellPackets.h:661
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleCancelChanneling ( WorldPackets::Spells::CancelChannelling cancelChanneling)
421 {
422  // ignore for remote control state (for player case)
423  Unit* mover = _player->m_mover;
424  if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER)
425  return;
426 
428 }
Definition: Unit.h:1110
TypeID GetTypeId() const
Definition: Object.h:113
void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed=true, bool withInstant=true)
Definition: Unit.cpp:2849
Definition: ObjectGuid.h:33
Player * _player
Definition: WorldSession.h:1797
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCancelGrowthAuraOpcode ( WorldPackets::Spells::CancelGrowthAura cancelGrowthAura)
396 {
397  _player->RemoveAurasByType(SPELL_AURA_MOD_SCALE, [](AuraApplication const* aurApp)
398  {
399  SpellInfo const* spellInfo = aurApp->GetBase()->GetSpellInfo();
400  return !spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) && spellInfo->IsPositive() && !spellInfo->IsPassive();
401  });
402 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SpellInfo.h:326
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
bool IsPositive() const
Definition: SpellInfo.cpp:1495
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SpellAuraDefines.h:121
Definition: SharedDefines.h:387
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCancelMountAuraOpcode ( WorldPackets::Spells::CancelMountAura cancelMountAura)
405 {
406  _player->RemoveAurasByType(SPELL_AURA_MOUNTED, [](AuraApplication const* aurApp)
407  {
408  SpellInfo const* spellInfo = aurApp->GetBase()->GetSpellInfo();
409  return !spellInfo->HasAttribute(SPELL_ATTR0_CANT_CANCEL) && spellInfo->IsPositive() && !spellInfo->IsPassive();
410  });
411 }
SpellInfo const * GetSpellInfo() const
Definition: SpellAuras.h:130
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SpellInfo.h:326
Aura * GetBase() const
Definition: SpellAuras.h:75
Definition: SpellAuras.h:50
bool IsPositive() const
Definition: SpellInfo.cpp:1495
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
Definition: SharedDefines.h:387
Player * _player
Definition: WorldSession.h:1797
Definition: SpellAuraDefines.h:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCancelTempEnchantmentOpcode ( WorldPackets::Item::CancelTempEnchantment cancelTempEnchantment)
1055 {
1056  // apply only to equipped item
1057  if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, cancelTempEnchantment.Slot))
1058  return;
1059 
1060  Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, cancelTempEnchantment.Slot);
1061 
1062  if (!item)
1063  return;
1064 
1066  return;
1067 
1068  GetPlayer()->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false);
1070 }
#define INVENTORY_SLOT_BAG_0
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Item.h:175
Definition: Item.h:259
void ClearEnchantment(EnchantmentSlot slot)
Definition: Item.cpp:946
int32 Slot
Definition: ItemPackets.h:443
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCancelTradeOpcode ( WorldPackets::Trade::CancelTrade cancelTrade)
563 {
564  // sent also after LOGOUT COMPLETE
565  if (_player) // needed because STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT
566  _player->TradeCancel(true);
567 }
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleCanDuel ( WorldPackets::Duel::CanDuel packet)
30 {
32 
33  if (!player)
34  return;
35 
37  response.TargetGUID = packet.TargetGUID;
38  response.Result = !player->duel;
39  SendPacket(response.Write());
40 
41  if (response.Result)
42  {
43  if (_player->IsMounted())
44  _player->CastSpell(player, SPELL_MOUNTED_DUEL);
45  else
46  _player->CastSpell(player, SPELL_DUEL);
47  }
48 }
ObjectGuid TargetGUID
Definition: DuelPackets.h:45
bool Result
Definition: DuelPackets.h:46
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: DuelPackets.cpp:25
#define SPELL_MOUNTED_DUEL
Definition: DuelHandler.cpp:27
Definition: DuelPackets.h:38
Player * _player
Definition: WorldSession.h:1797
ObjectGuid TargetGUID
Definition: DuelPackets.h:35
#define SPELL_DUEL
Definition: DuelHandler.cpp:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCastSpellOpcode ( WorldPackets::Spells::CastSpell castRequest)
246 {
247  // ignore for remote control state (for player case)
248  Unit* mover = _player->m_mover;
249  if (mover != _player && mover->GetTypeId() == TYPEID_PLAYER)
250  return;
251 
252  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cast.Cast.SpellID);
253  if (!spellInfo)
254  {
255  TC_LOG_ERROR("network", "WORLD: unknown spell id %u", cast.Cast.SpellID);
256  return;
257  }
258 
259  if (spellInfo->IsPassive())
260  return;
261 
262  Unit* caster = mover;
263  if (caster->GetTypeId() == TYPEID_UNIT && !caster->ToCreature()->HasSpell(spellInfo->Id))
264  {
265  // If the vehicle creature does not have the spell but it allows the passenger to cast own spells
266  // change caster to player and let him cast
267  if (!_player->IsOnVehicle(caster) || spellInfo->CheckVehicle(_player) != SPELL_CAST_OK)
268  return;
269 
270  caster = _player;
271  }
272 
273  // check known spell or raid marker spell (which not requires player to know it)
274  if (caster->GetTypeId() == TYPEID_PLAYER && !caster->ToPlayer()->HasActiveSpell(spellInfo->Id) && !spellInfo->HasEffect(SPELL_EFFECT_CHANGE_RAID_MARKER) && !spellInfo->HasAttribute(SPELL_ATTR8_RAID_MARKER))
275  return;
276 
277  // Check possible spell cast overrides
278  spellInfo = caster->GetCastSpellInfo(spellInfo);
279 
280  // Client is resending autoshot cast opcode when other spell is cast during shoot rotation
281  // Skip it to prevent "interrupt" message
283  && caster->GetCurrentSpell(CURRENT_AUTOREPEAT_SPELL)->m_spellInfo == spellInfo)
284  return;
285 
286  // can't use our own spells when we're in possession of another unit,
287  if (_player->isPossessing())
288  return;
289 
290  // client provided targets
291  SpellCastTargets targets(caster, cast.Cast);
292 
293  // auto-selection buff level base at target level (in spellInfo)
294  if (targets.GetUnitTarget())
295  {
296  SpellInfo const* actualSpellInfo = spellInfo->GetAuraRankForLevel(targets.GetUnitTarget()->getLevel());
297 
298  // if rank not found then function return NULL but in explicit cast case original spell can be cast and later failed with appropriate error message
299  if (actualSpellInfo)
300  spellInfo = actualSpellInfo;
301  }
302 
303  Spell* spell = new Spell(caster, spellInfo, TRIGGERED_NONE, ObjectGuid::Empty, false);
304  spell->m_cast_count = cast.Cast.CastID; // set count of casts
305  spell->m_misc.Raw.Data[0] = cast.Cast.Misc[0];
306  spell->m_misc.Raw.Data[1] = cast.Cast.Misc[1];
307  spell->prepare(&targets);
308 }
union Spell::@326 m_misc
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
uint32 Id
Definition: SpellInfo.h:329
SpellInfo const * GetAuraRankForLevel(uint8 level) const
Definition: SpellInfo.cpp:2778
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
bool IsPassive() const
Definition: SpellInfo.cpp:1403
Definition: SpellInfo.h:326
struct Spell::@326::@328 Raw
Definition: ObjectGuid.h:32
bool IsAutoRepeatRangedSpell() const
Definition: SpellInfo.cpp:1535
bool HasSpell(uint32 spellID) const override
Definition: Creature.cpp:2337
virtual SpellInfo const * GetCastSpellInfo(SpellInfo const *spellInfo) const
Definition: Unit.cpp:16483
Definition: SharedDefines.h:1116
Definition: Unit.h:1111
Player * ToPlayer()
Definition: Object.h:191
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
TypeID GetTypeId() const
Definition: Object.h:113
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
#define sSpellMgr
Definition: SpellMgr.h:756
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
bool HasEffect(uint32 difficulty, SpellEffectName effect) const
Definition: SpellInfo.cpp:1169
Definition: Spell.h:170
Definition: ObjectGuid.h:33
Player * _player
Definition: WorldSession.h:1797
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:670
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
SpellCastResult CheckVehicle(Unit const *caster) const
Definition: SpellInfo.cpp:2061
uint8 m_cast_count
Definition: Spell.h:552
Definition: Unit.h:1305
Definition: SharedDefines.h:1538
Definition: Unit.h:460
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChangeSubGroupOpcode ( WorldPackets::Party::ChangeSubGroup packet)
483 {
484  // we will get correct pointer for group here, so we don't have to check if group is BG raid
485  Group* group = GetPlayer()->GetGroup();
486  if (!group)
487  return;
488 
489  if (packet.NewSubGroup >= MAX_RAID_SUBGROUPS)
490  return;
491 
492  ObjectGuid senderGuid = GetPlayer()->GetGUID();
493  if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid))
494  return;
495 
496  if (!group->HasFreeSlotSubGroup(packet.NewSubGroup))
497  return;
498 
499  group->ChangeMembersGroup(packet.TargetGUID, packet.NewSubGroup);
500 }
uint8 NewSubGroup
Definition: PartyPackets.h:572
void ChangeMembersGroup(ObjectGuid guid, uint8 group)
Definition: Group.cpp:1746
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid TargetGUID
Definition: PartyPackets.h:570
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
bool HasFreeSlotSubGroup(uint8 subgroup) const
Definition: Group.cpp:2608
#define MAX_RAID_SUBGROUPS
Definition: Group.h:44
Definition: ObjectGuid.h:189
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<void(Channel::*)(Player const *) CommandFunction>
void WorldSession::HandleChannelCommand ( WorldPackets::Channel::ChannelPlayerCommand packet)
75 {
76  TC_LOG_DEBUG("chat.system", "%s %s ChannelName: %s",
77  GetOpcodeNameForLogging(packet.GetOpcode()).c_str(), GetPlayerInfo().c_str(), packet.ChannelName.c_str());
78 
79  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(GetPlayer()->GetTeam()))
80  if (Channel* channel = cMgr->GetChannel(packet.ChannelName, GetPlayer()))
81  (channel->*CommandFunction)(GetPlayer());
82 }
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Channel.h:126
std::string ChannelName
Definition: ChannelPackets.h:176
OpcodeClient GetOpcode() const
Definition: Packet.h:72
Definition: ChannelMgr.h:27
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

template<void(Channel::*)(Player const *, std::string const &) CommandFunction>
void WorldSession::HandleChannelPlayerCommand ( WorldPackets::Channel::ChannelPlayerCommand packet)
86 {
87  if (packet.Name.length() >= MAX_CHANNEL_NAME_STR)
88  {
89  TC_LOG_DEBUG("chat.system", "%s %s ChannelName: %s, Name: %s, Name too long.",
90  GetOpcodeNameForLogging(packet.GetOpcode()).c_str(), GetPlayerInfo().c_str(), packet.ChannelName.c_str(), packet.Name.c_str());
91  return;
92  }
93 
94  TC_LOG_DEBUG("chat.system", "%s %s ChannelName: %s, Name: %s",
95  GetOpcodeNameForLogging(packet.GetOpcode()).c_str(), GetPlayerInfo().c_str(), packet.ChannelName.c_str(), packet.Name.c_str());
96 
97  if (!normalizePlayerName(packet.Name))
98  return;
99 
100  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(GetPlayer()->GetTeam()))
101  if (Channel* channel = cMgr->GetChannel(packet.ChannelName, GetPlayer()))
102  (channel->*CommandFunction)(GetPlayer(), packet.Name);
103 }
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Channel.h:126
std::string Name
Definition: ChannelPackets.h:177
std::string ChannelName
Definition: ChannelPackets.h:176
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
OpcodeClient GetOpcode() const
Definition: Packet.h:72
Definition: ChannelMgr.h:27
#define MAX_CHANNEL_NAME_STR
Definition: ChannelMgr.h:24
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

void WorldSession::HandleCharCreateCallback ( PreparedQueryResult  result,
WorldPackets::Character::CharacterCreateInfo createInfo 
)

This is a series of callbacks executed consecutively as a result from the database becomes available. This is much more efficient than synchronous requests on packet handler, and much less DoS prone. It also prevents data synchronisation errors.

Todo:
what to if account already has characters of both races?
Todo:
check if cinematic already shown? (already logged in?; cinematic field)
503 {
508  switch (_charCreateCallback.GetStage())
509  {
510  case 0:
511  {
512  if (result)
513  {
516  return;
517  }
518 
519  ASSERT(_charCreateCallback.GetParam().get() == createInfo);
520 
522  stmt->setUInt32(0, GetAccountId());
523 
527  break;
528  }
529  case 1:
530  {
531  uint64 acctCharCount = 0;
532  if (result)
533  {
534  Field* fields = result->Fetch();
535  acctCharCount = uint64(fields[0].GetDouble());
536  }
537 
538  if (acctCharCount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_ACCOUNT))
539  {
542  return;
543  }
544 
545  ASSERT(_charCreateCallback.GetParam().get() == createInfo);
546 
548  stmt->setUInt32(0, GetAccountId());
549 
553  break;
554  }
555  case 2:
556  {
557  if (result)
558  {
559  Field* fields = result->Fetch();
560  createInfo->CharCount = uint8(fields[0].GetUInt64()); // SQL's COUNT() returns uint64 but it will always be less than uint8.Max
561 
562  if (createInfo->CharCount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM))
563  {
566  return;
567  }
568  }
569 
570  bool allowTwoSideAccounts = !sWorld->IsPvPRealm() || HasPermission(rbac::RBAC_PERM_TWO_SIDE_CHARACTER_CREATION);
571  uint32 skipCinematics = sWorld->getIntConfig(CONFIG_SKIP_CINEMATICS);
572 
574 
575  if (!allowTwoSideAccounts || skipCinematics == 1 || createInfo->Class == CLASS_DEATH_KNIGHT)
576  {
578  stmt->setUInt32(0, GetAccountId());
579  stmt->setUInt32(1, (skipCinematics == 1 || createInfo->Class == CLASS_DEATH_KNIGHT) ? 10 : 1);
582  return;
583  }
584 
586  HandleCharCreateCallback(PreparedQueryResult(NULL), createInfo); // Will jump to case 3
587  break;
588  }
589  case 3:
590  {
591  bool haveSameRace = false;
593  bool hasHeroicReqLevel = (heroicReqLevel == 0);
594  bool allowTwoSideAccounts = !sWorld->IsPvPRealm() || HasPermission(rbac::RBAC_PERM_TWO_SIDE_CHARACTER_CREATION);
595  uint32 skipCinematics = sWorld->getIntConfig(CONFIG_SKIP_CINEMATICS);
597 
598  if (result)
599  {
600  uint32 team = Player::TeamForRace(createInfo->Race);
601  uint32 freeHeroicSlots = sWorld->getIntConfig(CONFIG_HEROIC_CHARACTERS_PER_REALM);
602 
603  Field* field = result->Fetch();
604  uint8 accRace = field[1].GetUInt8();
605 
606  if (checkHeroicReqs)
607  {
608  uint8 accClass = field[2].GetUInt8();
609  if (accClass == CLASS_DEATH_KNIGHT)
610  {
611  if (freeHeroicSlots > 0)
612  --freeHeroicSlots;
613 
614  if (freeHeroicSlots == 0)
615  {
618  return;
619  }
620  }
621 
622  if (!hasHeroicReqLevel)
623  {
624  uint8 accLevel = field[0].GetUInt8();
625  if (accLevel >= heroicReqLevel)
626  hasHeroicReqLevel = true;
627  }
628  }
629 
630  // need to check team only for first character
632  if (!allowTwoSideAccounts)
633  {
634  uint32 accTeam = 0;
635  if (accRace > 0)
636  accTeam = Player::TeamForRace(accRace);
637 
638  if (accTeam != team)
639  {
642  return;
643  }
644  }
645 
646  // search same race for cinematic or same class if need
648  while ((skipCinematics == 1 && !haveSameRace) || createInfo->Class == CLASS_DEATH_KNIGHT)
649  {
650  if (!result->NextRow())
651  break;
652 
653  field = result->Fetch();
654  accRace = field[1].GetUInt8();
655 
656  if (!haveSameRace)
657  haveSameRace = createInfo->Race == accRace;
658 
659  if (checkHeroicReqs)
660  {
661  uint8 acc_class = field[2].GetUInt8();
662  if (acc_class == CLASS_DEATH_KNIGHT)
663  {
664  if (freeHeroicSlots > 0)
665  --freeHeroicSlots;
666 
667  if (freeHeroicSlots == 0)
668  {
671  return;
672  }
673  }
674 
675  if (!hasHeroicReqLevel)
676  {
677  uint8 acc_level = field[0].GetUInt8();
678  if (acc_level >= heroicReqLevel)
679  hasHeroicReqLevel = true;
680  }
681  }
682  }
683  }
684 
685  if (checkHeroicReqs && !hasHeroicReqLevel)
686  {
689  return;
690  }
691 
692  Player newChar(this);
693  newChar.GetMotionMaster()->Initialize();
694  if (!newChar.Create(sObjectMgr->GetGenerator<HighGuid::Player>().Generate(), createInfo))
695  {
696  // Player not create (race/class/etc problem?)
697  newChar.CleanupsBeforeDelete();
698 
701  return;
702  }
703 
704  if ((haveSameRace && skipCinematics == 1) || skipCinematics == 2)
705  newChar.setCinematic(1); // not show intro
706 
707  newChar.SetAtLoginFlag(AT_LOGIN_FIRST); // First login
708 
709  // Player created, save it now
710  newChar.SaveToDB(true);
711  createInfo->CharCount += 1;
712 
714 
716  stmt->setUInt32(0, GetAccountId());
717  stmt->setUInt32(1, realm.Id.Realm);
718  trans->Append(stmt);
719 
721  stmt->setUInt32(0, createInfo->CharCount);
722  stmt->setUInt32(1, GetAccountId());
723  stmt->setUInt32(2, realm.Id.Realm);
724  trans->Append(stmt);
725 
727 
728  if (createInfo->TemplateSet)
729  {
731  {
732  if (CharacterTemplate const* charTemplate = sObjectMgr->GetCharacterTemplate(*createInfo->TemplateSet))
733  {
734  if (charTemplate->Level != 1)
735  {
737  stmt->setUInt8(0, uint8(charTemplate->Level));
738  stmt->setUInt64(1, newChar.GetGUID().GetCounter());
740  }
741  }
742  }
743  else
744  TC_LOG_WARN("cheat", "Account: %u (IP: %s) tried to use a character template without given permission. Possible cheating attempt.", GetAccountId(), GetRemoteAddress().c_str());
745  }
746 
748 
749  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Create Character: %s %s", GetAccountId(), GetRemoteAddress().c_str(), createInfo->Name.c_str(), newChar.GetGUID().ToString().c_str());
750  sScriptMgr->OnPlayerCreate(&newChar);
751  sWorld->AddCharacterInfo(newChar.GetGUID(), GetAccountId(), newChar.GetName(), newChar.GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER), newChar.getRace(), newChar.getClass(), newChar.getLevel(), false);
752 
753  newChar.CleanupsBeforeDelete();
755  break;
756  }
757  }
758 }
Definition: Player.h:587
uint32 Realm
Definition: Realm.h:53
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: World.h:234
Definition: SharedDefines.h:4466
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: SharedDefines.h:172
Definition: SharedDefines.h:4453
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterCreateInfo >, true > _charCreateCallback
Definition: WorldSession.h:1738
std::string Name
Definition: CharacterPackets.h:53
Realm realm
Definition: World.cpp:3485
Class used to access individual fields of database query result.
Definition: Field.h:56
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
uint8 Class
Definition: CharacterPackets.h:44
Definition: CharacterDatabase.h:39
arena_t NULL
Definition: jemalloc_internal.h:624
uint64_t uint64
Definition: g3dmath.h:170
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
ParamType GetParam()
Definition: Callback.h:68
Definition: SharedDefines.h:4454
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: UpdateFields.h:198
uint8 GetUInt8() const
Definition: Field.h:70
Definition: LoginDatabase.h:58
Definition: SharedDefines.h:4460
uint8 Race
User specified variables.
Definition: CharacterPackets.h:43
Definition: SharedDefines.h:4459
Battlenet::RealmHandle Id
Definition: Realm.h:86
Definition: World.h:230
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
Definition: LoginDatabase.h:56
Definition: CharacterDatabase.h:345
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:40
void NextStage()
Advances the callback chain to the next stage, so upper level code can act on its results accordingly...
Definition: Callback.h:83
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8 GetStage()
Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid)
Definition: Callback.h:92
Definition: SharedDefines.h:4465
Definition: SharedDefines.h:4458
Definition: ObjectMgr.h:614
uint8_t uint8
Definition: g3dmath.h:164
void Reset()
Resets all underlying variables (param, result and stage)
Definition: Callback.h:98
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sScriptMgr
Definition: ScriptMgr.h:837
Optional< int32 > TemplateSet
Definition: CharacterPackets.h:52
void HandleCharCreateCallback(PreparedQueryResult result, WorldPackets::Character::CharacterCreateInfo *createInfo)
Definition: CharacterHandler.cpp:502
Definition: World.h:231
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: SharedDefines.h:4456
Definition: LoginDatabase.h:59
uint8 CharCount
Server side data.
Definition: CharacterPackets.h:56
void FreeResult()
Definition: Callback.h:58
void SendCharCreate(ResponseCodes result)
Definition: CharacterHandler.cpp:2481
Definition: World.h:232
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharCreateOpcode ( WorldPackets::Character::CreateCharacter charCreate)
374 {
376  {
377  if (uint32 mask = sWorld->getIntConfig(CONFIG_CHARACTER_CREATING_DISABLED))
378  {
379  bool disabled = false;
380 
381  switch (Player::TeamIdForRace(charCreate.CreateInfo->Race))
382  {
383  case TEAM_ALLIANCE:
384  disabled = (mask & (1 << 0)) != 0;
385  break;
386  case TEAM_HORDE:
387  disabled = (mask & (1 << 1)) != 0;
388  break;
389  case TEAM_NEUTRAL:
390  disabled = (mask & (1 << 2)) != 0;
391  break;
392  }
393 
394  if (disabled)
395  {
397  return;
398  }
399  }
400  }
401 
402  ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(charCreate.CreateInfo->Class);
403  if (!classEntry)
404  {
405  TC_LOG_ERROR("network", "Class (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", charCreate.CreateInfo->Class, GetAccountId());
407  return;
408  }
409 
410  ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(charCreate.CreateInfo->Race);
411  if (!raceEntry)
412  {
413  TC_LOG_ERROR("network", "Race (%u) not found in DBC while creating new char for account (ID: %u): wrong DBC files or cheater?", charCreate.CreateInfo->Race, GetAccountId());
415  return;
416  }
417 
418  // prevent character creating Expansion race without Expansion account
419  uint8 raceExpansionRequirement = sObjectMgr->GetRaceExpansionRequirement(charCreate.CreateInfo->Race);
420  if (raceExpansionRequirement > GetExpansion())
421  {
422  TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", GetExpansion(), GetAccountId(), raceExpansionRequirement, charCreate.CreateInfo->Race);
424  return;
425  }
426 
427  // prevent character creating Expansion class without Expansion account
428  uint8 classExpansionRequirement = sObjectMgr->GetClassExpansionRequirement(charCreate.CreateInfo->Class);
429  if (classExpansionRequirement > GetExpansion())
430  {
431  TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", GetExpansion(), GetAccountId(), classExpansionRequirement, charCreate.CreateInfo->Class);
433  return;
434  }
435 
437  {
438  uint32 raceMaskDisabled = sWorld->getIntConfig(CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK);
439  if ((1 << (charCreate.CreateInfo->Race - 1)) & raceMaskDisabled)
440  {
442  return;
443  }
444  }
445 
447  {
448  uint32 classMaskDisabled = sWorld->getIntConfig(CONFIG_CHARACTER_CREATING_DISABLED_CLASSMASK);
449  if ((1 << (charCreate.CreateInfo->Class - 1)) & classMaskDisabled)
450  {
452  return;
453  }
454  }
455 
456  // prevent character creating with invalid name
457  if (!normalizePlayerName(charCreate.CreateInfo->Name))
458  {
459  TC_LOG_ERROR("network", "Account:[%d] but tried to Create character with empty [name] ", GetAccountId());
461  return;
462  }
463 
464  // check name limitations
466  if (res != CHAR_NAME_SUCCESS)
467  {
468  SendCharCreate(res);
469  return;
470  }
471 
473  {
475  return;
476  }
477 
479  {
480  // speedup check for heroic class disabled case
481  if (!sWorld->getIntConfig(CONFIG_HEROIC_CHARACTERS_PER_REALM))
482  {
484  return;
485  }
486 
487  // speedup check for heroic class disabled case
489  {
491  return;
492  }
493  }
494 
496  stmt->setString(0, charCreate.CreateInfo->Name);
497 
500 }
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
void SetParam(ParamType value)
Definition: Callback.h:63
Definition: SharedDefines.h:4466
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesfmt)
Definition: SharedDefines.h:172
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesfmt)
Definition: DBCStructure.h:204
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterCreateInfo >, true > _charCreateCallback
Definition: WorldSession.h:1738
Definition: SharedDefines.h:4455
Definition: SharedDefines.h:4457
Definition: SharedDefines.h:4507
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: SharedDefines.h:4505
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: SharedDefines.h:4513
Definition: SharedDefines.h:994
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: DBCStructure.h:181
Definition: SharedDefines.h:4463
uint8 GetExpansion() const
Definition: WorldSession.h:934
Definition: CharacterDatabase.h:37
Definition: SharedDefines.h:4464
ResponseCodes
Definition: SharedDefines.h:4422
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:992
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: SharedDefines.h:4465
Definition: World.h:227
std::shared_ptr< CharacterCreateInfo > CreateInfo
Definition: CharacterPackets.h:198
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
Definition: SharedDefines.h:993
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: World.h:235
void SendCharCreate(ResponseCodes result)
Definition: CharacterHandler.cpp:2481
Definition: World.h:232

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharCustomizeCallback ( PreparedQueryResult  result,
WorldPackets::Character::CharCustomizeInfo customizeInfo 
)
Todo:
: make async

Customize

Name Change and update atLogin flags

1518 {
1519  ASSERT(_charCustomizeCallback.GetParam().get() == customizeInfo);
1520 
1521  if (!result)
1522  {
1523  SendCharCustomize(CHAR_CREATE_ERROR, customizeInfo);
1524  return;
1525  }
1526 
1527  Field* fields = result->Fetch();
1528 
1529  std::string oldName = fields[0].GetString();
1530  uint8 plrRace = fields[1].GetUInt8();
1531  uint8 plrClass = fields[2].GetUInt8();
1532  uint8 plrGender = fields[3].GetUInt8();
1533  uint16 atLoginFlags = fields[4].GetUInt16();
1534 
1535  if (!Player::ValidateAppearance(plrRace, plrClass, plrGender, customizeInfo->HairStyleID, customizeInfo->HairColorID, customizeInfo->FaceID, customizeInfo->FacialHairStyleID, customizeInfo->SkinID, true))
1536  {
1537  SendCharCustomize(CHAR_CREATE_ERROR, customizeInfo);
1538  return;
1539  }
1540 
1541  if (!(atLoginFlags & AT_LOGIN_CUSTOMIZE))
1542  {
1543  SendCharCustomize(CHAR_CREATE_ERROR, customizeInfo);
1544  return;
1545  }
1546 
1547  atLoginFlags &= ~AT_LOGIN_CUSTOMIZE;
1548 
1549  // prevent character rename to invalid name
1550  if (!normalizePlayerName(customizeInfo->CharName))
1551  {
1552  SendCharCustomize(CHAR_NAME_NO_NAME, customizeInfo);
1553  return;
1554  }
1555 
1557  if (res != CHAR_NAME_SUCCESS)
1558  {
1559  SendCharCustomize(res, customizeInfo);
1560  return;
1561  }
1562 
1563  // check name limitations
1565  {
1566  SendCharCustomize(CHAR_NAME_RESERVED, customizeInfo);
1567  return;
1568  }
1569 
1570  // character with this name already exist
1572  ObjectGuid newGuid = ObjectMgr::GetPlayerGUIDByName(customizeInfo->CharName);
1573  if (!newGuid.IsEmpty())
1574  {
1575  if (newGuid != customizeInfo->CharGUID)
1576  {
1578  return;
1579  }
1580  }
1581 
1582  PreparedStatement* stmt = nullptr;
1584 
1585  ObjectGuid::LowType lowGuid = customizeInfo->CharGUID.GetCounter();
1586 
1588  {
1590 
1591  stmt->setUInt8(0, customizeInfo->SexID);
1592  stmt->setUInt8(1, customizeInfo->SkinID);
1593  stmt->setUInt8(2, customizeInfo->FaceID);
1594  stmt->setUInt8(3, customizeInfo->HairStyleID);
1595  stmt->setUInt8(4, customizeInfo->HairColorID);
1596  stmt->setUInt8(5, customizeInfo->FacialHairStyleID);
1597  stmt->setUInt64(6, lowGuid);
1598 
1599  trans->Append(stmt);
1600  }
1601 
1603  {
1605  stmt->setString(0, customizeInfo->CharName);
1606  stmt->setUInt16(1, atLoginFlags);
1607  stmt->setUInt64(2, lowGuid);
1608 
1609  trans->Append(stmt);
1610 
1612  stmt->setUInt64(0, lowGuid);
1613 
1614  trans->Append(stmt);
1615  }
1616 
1618 
1619  sWorld->UpdateCharacterInfo(customizeInfo->CharGUID, customizeInfo->CharName, customizeInfo->SexID);
1620 
1621  SendCharCustomize(RESPONSE_SUCCESS, customizeInfo);
1622 
1623  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s), Character[%s] (%s) Customized to: %s",
1624  GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), customizeInfo->CharGUID.ToString().c_str(), customizeInfo->CharName.c_str());
1625 }
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
uint8 FaceID
Definition: CharacterPackets.h:68
std::string CharName
Definition: CharacterPackets.h:71
Definition: CharacterDatabase.h:429
uint8 HairColorID
Definition: CharacterPackets.h:72
Class used to access individual fields of database query result.
Definition: Field.h:56
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: SharedDefines.h:4507
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: SharedDefines.h:4505
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
ParamType GetParam()
Definition: Callback.h:68
Definition: SharedDefines.h:4513
Definition: SharedDefines.h:4454
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint8 FacialHairStyleID
Definition: CharacterPackets.h:73
uint8 GetUInt8() const
Definition: Field.h:70
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
uint8 SkinID
Definition: CharacterPackets.h:74
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharCustomizeInfo > > _charCustomizeCallback
Definition: WorldSession.h:1740
ResponseCodes
Definition: SharedDefines.h:4422
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
Definition: CharacterDatabase.h:363
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint16_t uint16
Definition: Define.h:151
ObjectGuid CharGUID
Definition: CharacterPackets.h:69
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:357
Definition: SharedDefines.h:4424
void SendCharCustomize(ResponseCodes result, WorldPackets::Character::CharCustomizeInfo const *customizeInfo)
Definition: CharacterHandler.cpp:2508
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8 HairStyleID
Definition: CharacterPackets.h:67
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
Definition: ObjectGuid.h:189
uint8 SexID
Definition: CharacterPackets.h:70
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
std::string GetString() const
Definition: Field.h:276
Definition: SharedDefines.h:4456
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharCustomizeOpcode ( WorldPackets::Character::CharCustomize packet)
1501 {
1502  if (!IsLegitCharacterForAccount(packet.CustomizeInfo->CharGUID))
1503  {
1504  TC_LOG_ERROR("network", "Account %u, IP: %s tried to customise %s, but it does not belong to their account!",
1505  GetAccountId(), GetRemoteAddress().c_str(), packet.CustomizeInfo->CharGUID.ToString().c_str());
1506  KickPlayer();
1507  return;
1508  }
1509 
1511  stmt->setUInt64(0, packet.CustomizeInfo->CharGUID.GetCounter());
1512 
1515 }
void SetParam(ParamType value)
Definition: Callback.h:63
bool IsLegitCharacterForAccount(ObjectGuid lowGUID)
Definition: WorldSession.h:1787
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
Definition: PreparedStatement.h:74
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharCustomizeInfo > > _charCustomizeCallback
Definition: WorldSession.h:1740
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:389
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
std::shared_ptr< CharCustomizeInfo > CustomizeInfo
Definition: CharacterPackets.h:274

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharDeleteOpcode ( WorldPackets::Character::CharDelete charDelete)
761 {
762  // Initiating
763  uint32 initAccountId = GetAccountId();
764 
765  // can't delete loaded character
766  if (ObjectAccessor::FindPlayer(charDelete.Guid))
767  {
768  sScriptMgr->OnPlayerFailedDelete(charDelete.Guid, initAccountId);
769  return;
770  }
771 
772  // is guild leader
773  if (sGuildMgr->GetGuildByLeader(charDelete.Guid))
774  {
775  sScriptMgr->OnPlayerFailedDelete(charDelete.Guid, initAccountId);
777  return;
778  }
779 
780  // is arena team captain
781  if (sArenaTeamMgr->GetArenaTeamByCaptain(charDelete.Guid))
782  {
783  sScriptMgr->OnPlayerFailedDelete(charDelete.Guid, initAccountId);
785  return;
786  }
787 
788  uint32 accountId = 0;
789  uint8 level = 0;
790  std::string name;
791 
793  stmt->setUInt64(0, charDelete.Guid.GetCounter());
794 
795  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
796  {
797  Field* fields = result->Fetch();
798  accountId = fields[0].GetUInt32();
799  name = fields[1].GetString();
800  level = fields[2].GetUInt8();
801  }
802 
803  // prevent deleting other players' characters using cheating tools
804  if (accountId != initAccountId)
805  {
806  sScriptMgr->OnPlayerFailedDelete(charDelete.Guid, initAccountId);
807  return;
808  }
809 
810  TC_LOG_INFO("entities.player.character", "Account: %u, IP: %s deleted character: %s, %s, Level: %u", accountId, GetRemoteAddress().c_str(), name.c_str(), charDelete.Guid.ToString().c_str(), level);
811 
812  // To prevent hook failure, place hook before removing reference from DB
813  sScriptMgr->OnPlayerDelete(charDelete.Guid, initAccountId); // To prevent race conditioning, but as it also makes sense, we hand the accountId over for successful delete.
814  // Shouldn't interfere with character deletion though
815 
816  if (sLog->ShouldLog("entities.player.dump", LOG_LEVEL_INFO)) // optimize GetPlayerDump call
817  {
818  std::string dump;
819  if (PlayerDumpWriter().GetDump(charDelete.Guid.GetCounter(), dump))
820  sLog->outCharDump(dump.c_str(), accountId, charDelete.Guid.GetCounter(), name.c_str());
821  }
822 
823  sGuildFinderMgr->RemoveAllMembershipRequestsFromPlayer(charDelete.Guid);
824  sCalendarMgr->RemoveAllPlayerEventsAndInvites(charDelete.Guid);
825  Player::DeleteFromDB(charDelete.Guid, accountId);
826 
828 }
Definition: SharedDefines.h:4482
#define sCalendarMgr
Definition: CalendarMgr.h:334
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: Appender.h:36
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: PlayerDump.h:78
#define sLog
Definition: Log.h:154
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
uint8 GetUInt8() const
Definition: Field.h:70
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: CharacterDatabase.h:156
void SendCharDelete(ResponseCodes result)
Definition: CharacterHandler.cpp:2489
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4483
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid Guid
Guid of the character to delete.
Definition: CharacterPackets.h:218
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: SharedDefines.h:4479
uint32 GetUInt32() const
Definition: Field.h:146
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
#define sScriptMgr
Definition: ScriptMgr.h:837
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
std::string GetString() const
Definition: Field.h:276
bool GetDump(ObjectGuid::LowType guid, std::string &dump)
Definition: PlayerDump.cpp:350
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharEnum ( PreparedQueryResult  result)
266 {
268  charEnum.Success = true;
269  charEnum.IsDeletedCharacters = false;
270 
271  _legitCharacters.clear();
272 
273  if (result)
274  {
275  do
276  {
277  Field* fields = result->Fetch();
279 
280  TC_LOG_INFO("network", "Loading char guid %s from account %u.", charInfo.Guid.ToString().c_str(), GetAccountId());
281 
282  if (!Player::ValidateAppearance(charInfo.Race, charInfo.Class, charInfo.Sex, charInfo.HairStyle, charInfo.HairColor, charInfo.Face, charInfo.FacialHair, charInfo.Skin))
283  {
284  TC_LOG_ERROR("entities.player.loading", "Player %s has wrong Appearance values (Hair/Skin/Color), forcing recustomize", charInfo.Guid.ToString().c_str());
285 
286  if (!(charInfo.CustomizationFlag == CHAR_CUSTOMIZE_FLAG_CUSTOMIZE))
287  {
289  stmt->setUInt16(0, uint16(AT_LOGIN_CUSTOMIZE));
290  stmt->setUInt64(1, charInfo.Guid.GetCounter());
292  charInfo.CustomizationFlag = CHAR_CUSTOMIZE_FLAG_CUSTOMIZE;
293  }
294  }
295 
296  // Do not allow locked characters to login
298  _legitCharacters.insert(charInfo.Guid);
299 
300  if (!sWorld->HasCharacterInfo(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
301  sWorld->AddCharacterInfo(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.Race, charInfo.Class, charInfo.Level, false);
302 
303  charEnum.Characters.emplace_back(charInfo);
304  }
305  while (result->NextRow());
306  }
307 
308  SendPacket(charEnum.Write());
309 }
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:116
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::list< CharacterInfo > Characters
all characters on the list
Definition: CharacterPackets.h:174
bool IsDeletedCharacters
used for character undelete list
Definition: CharacterPackets.h:172
Definition: SharedDefines.h:916
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
uint16_t uint16
Definition: g3dmath.h:166
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:322
bool Success
Definition: CharacterPackets.h:171
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterPackets.h:101
GuidSet _legitCharacters
Definition: WorldSession.h:1794
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:894
Definition: SharedDefines.h:929

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharEnumOpcode ( WorldPackets::Character::EnumCharacters )

get all the data necessary for loading all characters (along with their pets) on the account

312 {
313  // remove expired bans
316 
318 
319  if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
321  else
323 
324  stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
325  stmt->setUInt32(1, GetAccountId());
326 
329 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void SetParam(ParamType value)
Definition: Callback.h:63
Definition: World.h:133
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:51
Definition: PetDefines.h:35
Definition: CharacterDatabase.h:52
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
QueryCallback< PreparedQueryResult, bool > _charEnumCallback
Definition: WorldSession.h:1733
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
Definition: CharacterDatabase.h:35

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharRaceOrFactionChangeCallback ( PreparedQueryResult  result,
WorldPackets::Character::CharRaceOrFactionChangeInfo factionChangeInfo 
)
Todo:
: make this part async
1730 {
1731  ASSERT(_charFactionChangeCallback.GetParam().get() == factionChangeInfo);
1732 
1733  if (!result)
1734  {
1735  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
1736  return;
1737  }
1738 
1739  // get the players old (at this moment current) race
1740  CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(factionChangeInfo->Guid);
1741  if (!characterInfo)
1742  {
1743  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
1744  return;
1745  }
1746 
1747  uint8 oldRace = characterInfo->Race;
1748  uint8 playerClass = characterInfo->Class;
1749  uint8 level = characterInfo->Level;
1750 
1751  if (!sObjectMgr->GetPlayerInfo(factionChangeInfo->RaceID, playerClass))
1752  {
1753  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
1754  return;
1755  }
1756 
1757  Field* fields = result->Fetch();
1758  uint16 atLoginFlags = fields[0].GetUInt16();
1759  std::string knownTitlesStr = fields[1].GetString();
1760 
1761  uint16 usedLoginFlag = (factionChangeInfo->FactionChange ? AT_LOGIN_CHANGE_FACTION : AT_LOGIN_CHANGE_RACE);
1762  if (!(atLoginFlags & usedLoginFlag))
1763  {
1764  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
1765  return;
1766  }
1767 
1768  TeamId newTeamId = Player::TeamIdForRace(factionChangeInfo->RaceID);
1769  if (newTeamId == TEAM_NEUTRAL)
1770  {
1772  return;
1773  }
1774 
1775  if (factionChangeInfo->FactionChange == (Player::TeamIdForRace(oldRace) == newTeamId))
1776  {
1778  return;
1779  }
1780 
1782  {
1783  uint32 raceMaskDisabled = sWorld->getIntConfig(CONFIG_CHARACTER_CREATING_DISABLED_RACEMASK);
1784  if ((1 << (factionChangeInfo->RaceID - 1)) & raceMaskDisabled)
1785  {
1786  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
1787  return;
1788  }
1789  }
1790 
1791  // prevent character rename to invalid name
1792  if (!normalizePlayerName(factionChangeInfo->Name))
1793  {
1794  SendCharFactionChange(CHAR_NAME_NO_NAME, factionChangeInfo);
1795  return;
1796  }
1797 
1798  ResponseCodes res = ObjectMgr::CheckPlayerName(factionChangeInfo->Name, GetSessionDbcLocale(), true);
1799  if (res != CHAR_NAME_SUCCESS)
1800  {
1801  SendCharFactionChange(res, factionChangeInfo);
1802  return;
1803  }
1804 
1805  // check name limitations
1806  if (!HasPermission(rbac::RBAC_PERM_SKIP_CHECK_CHARACTER_CREATION_RESERVEDNAME) && sObjectMgr->IsReservedName(factionChangeInfo->Name))
1807  {
1808  SendCharFactionChange(CHAR_NAME_RESERVED, factionChangeInfo);
1809  return;
1810  }
1811 
1812  // character with this name already exist
1813  ObjectGuid newGuid = ObjectMgr::GetPlayerGUIDByName(factionChangeInfo->Name);
1814  if (!newGuid.IsEmpty())
1815  {
1816  if (newGuid != factionChangeInfo->Guid)
1817  {
1818  SendCharFactionChange(CHAR_CREATE_NAME_IN_USE, factionChangeInfo);
1819  return;
1820  }
1821  }
1822 
1823  if (sArenaTeamMgr->GetArenaTeamByCaptain(factionChangeInfo->Guid))
1824  {
1826  return;
1827  }
1828 
1829  // All checks are fine, deal with race change now
1830  ObjectGuid::LowType lowGuid = factionChangeInfo->Guid.GetCounter();
1831 
1832  PreparedStatement* stmt = nullptr;
1834 
1835  // resurrect the character in case he's dead
1836  Player::OfflineResurrect(factionChangeInfo->Guid, trans);
1837 
1838  // Name Change and update atLogin flags
1839  {
1840  CharacterDatabase.EscapeString(factionChangeInfo->Name);
1841 
1843  stmt->setString(0, factionChangeInfo->Name);
1844  stmt->setUInt16(1, uint16((atLoginFlags | AT_LOGIN_RESURRECT) & ~usedLoginFlag));
1845  stmt->setUInt64(2, lowGuid);
1846 
1847  trans->Append(stmt);
1848 
1850  stmt->setUInt64(0, lowGuid);
1851 
1852  trans->Append(stmt);
1853  }
1854 
1855  // Customize
1856  {
1857  if (!factionChangeInfo->SkinID)
1858  factionChangeInfo->SkinID = fields[2].GetUInt8();
1859 
1860  if (!factionChangeInfo->FaceID)
1861  factionChangeInfo->FaceID = fields[3].GetUInt8();
1862 
1863  if (!factionChangeInfo->HairStyleID)
1864  factionChangeInfo->HairStyleID = fields[4].GetUInt8();
1865 
1866  if (!factionChangeInfo->HairColorID)
1867  factionChangeInfo->HairColorID = fields[5].GetUInt8();
1868 
1869  if (!factionChangeInfo->FacialHairStyleID)
1870  factionChangeInfo->FacialHairStyleID = fields[6].GetUInt8();
1871 
1873  stmt->setUInt8(0, factionChangeInfo->SexID);
1874  stmt->setUInt8(1, *factionChangeInfo->SkinID);
1875  stmt->setUInt8(2, *factionChangeInfo->FaceID);
1876  stmt->setUInt8(3, *factionChangeInfo->HairStyleID);
1877  stmt->setUInt8(4, *factionChangeInfo->HairColorID);
1878  stmt->setUInt8(5, *factionChangeInfo->FacialHairStyleID);
1879  stmt->setUInt64(6, lowGuid);
1880 
1881  trans->Append(stmt);
1882  }
1883 
1884  // Race Change
1885  {
1887  stmt->setUInt8(0, factionChangeInfo->RaceID);
1888  stmt->setUInt64(1, lowGuid);
1889 
1890  trans->Append(stmt);
1891  }
1892 
1893  sWorld->UpdateCharacterInfo(factionChangeInfo->Guid, factionChangeInfo->Name, factionChangeInfo->SexID, factionChangeInfo->RaceID);
1894 
1895  if (oldRace != factionChangeInfo->RaceID)
1896  {
1897  // Switch Languages
1898  // delete all languages first
1900  stmt->setUInt64(0, lowGuid);
1901  trans->Append(stmt);
1902 
1903  // Now add them back
1905  stmt->setUInt64(0, lowGuid);
1906 
1907  // Faction specific languages
1908  if (newTeamId == TEAM_HORDE)
1909  stmt->setUInt16(1, 109);
1910  else
1911  stmt->setUInt16(1, 98);
1912 
1913  trans->Append(stmt);
1914 
1915  // Race specific languages
1916  if (factionChangeInfo->RaceID != RACE_ORC && factionChangeInfo->RaceID != RACE_HUMAN)
1917  {
1919  stmt->setUInt64(0, lowGuid);
1920 
1921  switch (factionChangeInfo->RaceID)
1922  {
1923  case RACE_DWARF:
1924  stmt->setUInt16(1, 111);
1925  break;
1926  case RACE_DRAENEI:
1927  stmt->setUInt16(1, 759);
1928  break;
1929  case RACE_GNOME:
1930  stmt->setUInt16(1, 313);
1931  break;
1932  case RACE_NIGHTELF:
1933  stmt->setUInt16(1, 113);
1934  break;
1935  case RACE_WORGEN:
1936  stmt->setUInt16(1, 791);
1937  break;
1938  case RACE_UNDEAD_PLAYER:
1939  stmt->setUInt16(1, 673);
1940  break;
1941  case RACE_TAUREN:
1942  stmt->setUInt16(1, 115);
1943  break;
1944  case RACE_TROLL:
1945  stmt->setUInt16(1, 315);
1946  break;
1947  case RACE_BLOODELF:
1948  stmt->setUInt16(1, 137);
1949  break;
1950  case RACE_GOBLIN:
1951  stmt->setUInt16(1, 792);
1952  break;
1953  }
1954 
1955  trans->Append(stmt);
1956  }
1957 
1958  // Team Conversion
1959  if (factionChangeInfo->FactionChange)
1960  {
1961  // Delete all Flypaths
1963  stmt->setUInt64(0, lowGuid);
1964  trans->Append(stmt);
1965 
1966  if (level > 7)
1967  {
1968  // Update Taxi path
1969  // this doesn't seem to be 100% blizzlike... but it can't really be helped.
1970  std::ostringstream taximaskstream;
1971  TaxiMask const& factionMask = newTeamId == TEAM_HORDE ? sHordeTaxiNodesMask : sAllianceTaxiNodesMask;
1972  for (uint8 i = 0; i < TaxiMaskSize; ++i)
1973  {
1974  // i = (315 - 1) / 8 = 39
1975  // m = 1 << ((315 - 1) % 8) = 4
1976  uint8 deathKnightExtraNode = playerClass != CLASS_DEATH_KNIGHT || i != 39 ? 0 : 4;
1977  taximaskstream << uint32(factionMask[i] | deathKnightExtraNode) << ' ';
1978  }
1979 
1981  stmt->setString(0, taximaskstream.str());
1982  stmt->setUInt64(1, lowGuid);
1983  trans->Append(stmt);
1984  }
1985 
1987  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
1988  {
1989  // Reset guild
1991  stmt->setUInt64(0, lowGuid);
1992 
1993  if (PreparedQueryResult memberResult = CharacterDatabase.Query(stmt))
1994  if (Guild* guild = sGuildMgr->GetGuildById(memberResult->Fetch()[0].GetUInt64()))
1995  guild->DeleteMember(factionChangeInfo->Guid, false, false, true);
1996 
1997  Player::LeaveAllArenaTeams(factionChangeInfo->Guid);
1998  }
1999 
2001  {
2002  // Delete Friend List
2004  stmt->setUInt64(0, lowGuid);
2005  trans->Append(stmt);
2006 
2008  stmt->setUInt64(0, lowGuid);
2009  trans->Append(stmt);
2010  }
2011 
2012  // Reset homebind and position
2014  stmt->setUInt64(0, lowGuid);
2015  trans->Append(stmt);
2016 
2018  stmt->setUInt64(0, lowGuid);
2019 
2020  WorldLocation loc;
2021  uint16 zoneId = 0;
2022  if (newTeamId == TEAM_ALLIANCE)
2023  {
2024  loc.WorldRelocate(0, -8867.68f, 673.373f, 97.9034f, 0.0f);
2025  zoneId = 1519;
2026  }
2027  else
2028  {
2029  loc.WorldRelocate(1, 1633.33f, -4439.11f, 15.7588f, 0.0f);
2030  zoneId = 1637;
2031  }
2032 
2033  stmt->setUInt16(1, loc.GetMapId());
2034  stmt->setUInt16(2, zoneId);
2035  stmt->setFloat(3, loc.GetPositionX());
2036  stmt->setFloat(4, loc.GetPositionY());
2037  stmt->setFloat(5, loc.GetPositionZ());
2038  trans->Append(stmt);
2039 
2040  Player::SavePositionInDB(loc, zoneId, factionChangeInfo->Guid, trans);
2041 
2042  // Achievement conversion
2043  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeAchievements.begin(); it != sObjectMgr->FactionChangeAchievements.end(); ++it)
2044  {
2045  uint32 achiev_alliance = it->first;
2046  uint32 achiev_horde = it->second;
2047 
2049  stmt->setUInt16(0, uint16(newTeamId == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
2050  stmt->setUInt64(1, lowGuid);
2051  trans->Append(stmt);
2052 
2054  stmt->setUInt16(0, uint16(newTeamId == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
2055  stmt->setUInt16(1, uint16(newTeamId == TEAM_ALLIANCE ? achiev_horde : achiev_alliance));
2056  stmt->setUInt64(2, lowGuid);
2057  trans->Append(stmt);
2058  }
2059 
2060  // Item conversion
2061  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeItems.begin(); it != sObjectMgr->FactionChangeItems.end(); ++it)
2062  {
2063  uint32 item_alliance = it->first;
2064  uint32 item_horde = it->second;
2065 
2067  stmt->setUInt32(0, (newTeamId == TEAM_ALLIANCE ? item_alliance : item_horde));
2068  stmt->setUInt32(1, (newTeamId == TEAM_ALLIANCE ? item_horde : item_alliance));
2069  stmt->setUInt64(2, lowGuid);
2070  trans->Append(stmt);
2071  }
2072 
2073  // Delete all current quests
2075  stmt->setUInt64(0, lowGuid);
2076  trans->Append(stmt);
2077 
2078  // Quest conversion
2079  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeQuests.begin(); it != sObjectMgr->FactionChangeQuests.end(); ++it)
2080  {
2081  uint32 quest_alliance = it->first;
2082  uint32 quest_horde = it->second;
2083 
2085  stmt->setUInt64(0, lowGuid);
2086  stmt->setUInt32(1, (newTeamId == TEAM_ALLIANCE ? quest_alliance : quest_horde));
2087  trans->Append(stmt);
2088 
2090  stmt->setUInt32(0, (newTeamId == TEAM_ALLIANCE ? quest_alliance : quest_horde));
2091  stmt->setUInt32(1, (newTeamId == TEAM_ALLIANCE ? quest_horde : quest_alliance));
2092  stmt->setUInt64(2, lowGuid);
2093  trans->Append(stmt);
2094  }
2095 
2096  // Mark all rewarded quests as "active" (will count for completed quests achievements)
2098  stmt->setUInt64(0, lowGuid);
2099  trans->Append(stmt);
2100 
2101  // Disable all old-faction specific quests
2102  {
2103  ObjectMgr::QuestMap const& questTemplates = sObjectMgr->GetQuestTemplates();
2104  for (ObjectMgr::QuestMap::const_iterator iter = questTemplates.begin(); iter != questTemplates.end(); ++iter)
2105  {
2106  Quest const* quest = iter->second;
2107  uint32 newRaceMask = (newTeamId == TEAM_ALLIANCE) ? RACEMASK_ALLIANCE : RACEMASK_HORDE;
2108  if (quest->GetAllowableRaces() != -1 && !(quest->GetAllowableRaces() & newRaceMask))
2109  {
2111  stmt->setUInt64(0, lowGuid);
2112  stmt->setUInt32(1, quest->GetQuestId());
2113  trans->Append(stmt);
2114  }
2115  }
2116  }
2117 
2118  // Spell conversion
2119  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeSpells.begin(); it != sObjectMgr->FactionChangeSpells.end(); ++it)
2120  {
2121  uint32 spell_alliance = it->first;
2122  uint32 spell_horde = it->second;
2123 
2125  stmt->setUInt32(0, (newTeamId == TEAM_ALLIANCE ? spell_alliance : spell_horde));
2126  stmt->setUInt64(1, lowGuid);
2127  trans->Append(stmt);
2128 
2130  stmt->setUInt32(0, (newTeamId == TEAM_ALLIANCE ? spell_alliance : spell_horde));
2131  stmt->setUInt32(1, (newTeamId == TEAM_ALLIANCE ? spell_horde : spell_alliance));
2132  stmt->setUInt64(2, lowGuid);
2133  trans->Append(stmt);
2134  }
2135 
2136  // Reputation conversion
2137  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeReputation.begin(); it != sObjectMgr->FactionChangeReputation.end(); ++it)
2138  {
2139  uint32 reputation_alliance = it->first;
2140  uint32 reputation_horde = it->second;
2141  uint32 newReputation = (newTeamId == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde;
2142  uint32 oldReputation = (newTeamId == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance;
2143 
2144  // select old standing set in db
2146  stmt->setUInt32(0, oldReputation);
2147  stmt->setUInt64(1, lowGuid);
2148 
2149  if (PreparedQueryResult reputationResult = CharacterDatabase.Query(stmt))
2150  {
2151  fields = reputationResult->Fetch();
2152  int32 oldDBRep = fields[0].GetInt32();
2153  FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation);
2154 
2155  // old base reputation
2156  int32 oldBaseRep = sObjectMgr->GetBaseReputationOf(factionEntry, oldRace, playerClass);
2157 
2158  // new base reputation
2159  int32 newBaseRep = sObjectMgr->GetBaseReputationOf(sFactionStore.LookupEntry(newReputation), factionChangeInfo->RaceID, playerClass);
2160 
2161  // final reputation shouldnt change
2162  int32 FinalRep = oldDBRep + oldBaseRep;
2163  int32 newDBRep = FinalRep - newBaseRep;
2164 
2166  stmt->setUInt32(0, newReputation);
2167  stmt->setUInt64(1, lowGuid);
2168  trans->Append(stmt);
2169 
2171  stmt->setUInt16(0, uint16(newReputation));
2172  stmt->setInt32(1, newDBRep);
2173  stmt->setUInt16(2, uint16(oldReputation));
2174  stmt->setUInt64(3, lowGuid);
2175  trans->Append(stmt);
2176  }
2177  }
2178 
2179  // Title conversion
2180  if (!knownTitlesStr.empty())
2181  {
2182  uint32 const ktcount = KNOWN_TITLES_SIZE * 2;
2183  uint32 knownTitles[ktcount];
2184  Tokenizer tokens(knownTitlesStr, ' ', ktcount);
2185 
2186  if (tokens.size() != ktcount)
2187  {
2188  SendCharFactionChange(CHAR_CREATE_ERROR, factionChangeInfo);
2189  return;
2190  }
2191 
2192  for (uint32 index = 0; index < ktcount; ++index)
2193  knownTitles[index] = atoul(tokens[index]);
2194 
2195  for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->FactionChangeTitles.begin(); it != sObjectMgr->FactionChangeTitles.end(); ++it)
2196  {
2197  uint32 title_alliance = it->first;
2198  uint32 title_horde = it->second;
2199 
2200  CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance);
2201  CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde);
2202  // new team
2203  if (newTeamId == TEAM_ALLIANCE)
2204  {
2205  uint32 maskID = htitleInfo->MaskID;
2206  uint32 index = maskID / 32;
2207  uint32 old_flag = 1 << (maskID % 32);
2208  uint32 new_flag = 1 << (atitleInfo->MaskID % 32);
2209  if (knownTitles[index] & old_flag)
2210  {
2211  knownTitles[index] &= ~old_flag;
2212  // use index of the new title
2213  knownTitles[atitleInfo->MaskID / 32] |= new_flag;
2214  }
2215  }
2216  else
2217  {
2218  uint32 maskID = atitleInfo->MaskID;
2219  uint32 index = maskID / 32;
2220  uint32 old_flag = 1 << (maskID % 32);
2221  uint32 new_flag = 1 << (htitleInfo->MaskID % 32);
2222  if (knownTitles[index] & old_flag)
2223  {
2224  knownTitles[index] &= ~old_flag;
2225  // use index of the new title
2226  knownTitles[htitleInfo->MaskID / 32] |= new_flag;
2227  }
2228  }
2229 
2230  std::ostringstream ss;
2231  for (uint32 index = 0; index < ktcount; ++index)
2232  ss << knownTitles[index] << ' ';
2233 
2235  stmt->setString(0, ss.str());
2236  stmt->setUInt64(1, lowGuid);
2237  trans->Append(stmt);
2238 
2239  // unset any currently chosen title
2241  stmt->setUInt64(0, lowGuid);
2242  trans->Append(stmt);
2243  }
2244  }
2245  }
2246  }
2247 
2249 
2250  TC_LOG_DEBUG("entities.player", "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), GetRemoteAddress().c_str(), oldRace, factionChangeInfo->RaceID);
2251 
2252  SendCharFactionChange(RESPONSE_SUCCESS, factionChangeInfo);
2253 }
Definition: CharacterDatabase.h:435
Definition: CharacterDatabase.h:106
Definition: CharacterDatabase.h:433
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
Definition: CharacterDatabase.h:445
Definition: Position.h:228
Definition: SharedDefines.h:110
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharRaceOrFactionChangeInfo > > _charFactionChangeCallback
Definition: WorldSession.h:1741
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: CharacterDatabase.h:440
Definition: SharedDefines.h:172
Definition: SharedDefines.h:105
Definition: QuestDef.h:279
Definition: CharacterDatabase.h:485
#define TaxiMaskSize
Definition: DB2Structure.h:1452
Definition: CharacterDatabase.h:429
Definition: DBCStructure.h:162
Definition: CharacterDatabase.h:436
Definition: Util.h:45
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: CharacterDatabase.h:446
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
Definition: SharedDefines.h:4470
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
TaxiMask sHordeTaxiNodesMask
Definition: DB2Stores.cpp:136
int32 GetAllowableRaces() const
Definition: QuestDef.h:313
Definition: SharedDefines.h:4507
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: SharedDefines.h:112
Definition: CharacterDatabase.h:448
Definition: SharedDefines.h:4505
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: CharacterDatabase.h:278
Definition: CharacterDatabase.h:488
#define sWorld
Definition: World.h:887
Definition: CharacterDatabase.h:486
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
Definition: CharacterDatabase.h:431
uint64 LowType
Definition: ObjectGuid.h:199
Definition: SharedDefines.h:108
Definition: CharacterDatabase.h:442
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint16_t uint16
Definition: g3dmath.h:166
uint32 MaskID
Definition: DBCStructure.h:168
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:444
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesfmt)
ParamType GetParam()
Definition: Callback.h:68
Definition: SharedDefines.h:4513
Definition: SharedDefines.h:994
Definition: SharedDefines.h:107
Definition: SharedDefines.h:4454
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint8 GetUInt8() const
Definition: Field.h:70
Definition: CharacterDatabase.h:449
Definition: SharedDefines.h:106
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
uint8 Level
Definition: World.h:539
uint8 Race
Definition: World.h:537
Definition: SharedDefines.h:4473
Definition: CharacterDatabase.h:276
Definition: SharedDefines.h:104
unsigned long atoul(char const *str)
Definition: Common.h:90
uint32 GetQuestId() const
Definition: QuestDef.h:304
Definition: CharacterDatabase.h:439
std::unordered_map< uint32, Quest * > QuestMap
Definition: ObjectMgr.h:721
TaxiMask sAllianceTaxiNodesMask
Definition: DB2Stores.cpp:137
Optional< uint8 > HairStyleID
Definition: CharacterPackets.h:88
float GetPositionY() const
Definition: Position.h:105
Optional< uint8 > HairColorID
Definition: CharacterPackets.h:79
Definition: World.h:532
Definition: SharedDefines.h:123
std::string Name
Definition: CharacterPackets.h:86
Definition: CharacterDatabase.h:434
ResponseCodes
Definition: SharedDefines.h:4422
Definition: CharacterDatabase.h:363
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
#define RACEMASK_HORDE
Definition: SharedDefines.h:161
float GetPositionZ() const
Definition: Position.h:106
int32_t int32
Definition: Define.h:146
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
Definition: CharacterDatabase.h:438
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
void SendCharFactionChange(ResponseCodes result, WorldPackets::Character::CharRaceOrFactionChangeInfo const *factionChangeInfo)
Definition: CharacterHandler.cpp:2524
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:102
void EscapeString(std::string &str)
Apply escape string'ing for current collation. (utf8)
Definition: DatabaseWorkerPool.cpp:231
uint16_t uint16
Definition: Define.h:151
#define RACEMASK_ALLIANCE
Definition: SharedDefines.h:152
Definition: SharedDefines.h:992
bool FactionChange
Definition: CharacterPackets.h:85
uint32 GetMapId() const
Definition: Position.h:254
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: SharedDefines.h:4472
void setInt32(const uint8 index, const int32 value)
Definition: PreparedStatement.cpp:151
TeamId
Definition: SharedDefines.h:990
Definition: CharacterDatabase.h:447
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: CharacterDatabase.h:357
std::array< uint8, TaxiMaskSize > TaxiMask
Definition: DB2Structure.h:1453
uint8 RaceID
Definition: CharacterPackets.h:80
Definition: SharedDefines.h:4424
Definition: CharacterDatabase.h:443
Definition: DBCStructure.h:405
Definition: SharedDefines.h:103
Definition: CharacterDatabase.h:432
int32 GetInt32() const
Definition: Field.h:165
Definition: CharacterDatabase.h:487
Optional< uint8 > FaceID
Definition: CharacterPackets.h:87
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Optional< uint8 > FacialHairStyleID
Definition: CharacterPackets.h:83
void setFloat(const uint8 index, const float value)
Definition: PreparedStatement.cpp:169
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
Definition: SharedDefines.h:109
#define ASSERT
Definition: Errors.h:55
Definition: CharacterDatabase.h:441
uint8 Class
Definition: World.h:536
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: SharedDefines.h:111
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
uint8 SexID
Definition: CharacterPackets.h:81
#define KNOWN_TITLES_SIZE
float GetPositionX() const
Definition: Position.h:104
ObjectGuid Guid
Definition: CharacterPackets.h:84
Definition: SharedDefines.h:993
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: Guild.h:320
std::string GetString() const
Definition: Field.h:276
Optional< uint8 > SkinID
Definition: CharacterPackets.h:82
Definition: SharedDefines.h:4456
void WorldRelocate(WorldLocation const &loc)
Definition: Position.h:237
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: SharedDefines.h:4468
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharRaceOrFactionChangeOpcode ( WorldPackets::Character::CharRaceOrFactionChange packet)
1713 {
1715  {
1716  TC_LOG_ERROR("network", "Account %u, IP: %s tried to factionchange character %s, but it does not belong to their account!",
1717  GetAccountId(), GetRemoteAddress().c_str(), packet.RaceOrFactionChangeInfo->Guid.ToString().c_str());
1718  KickPlayer();
1719  return;
1720  }
1721 
1723  stmt->setUInt64(0, packet.RaceOrFactionChangeInfo->Guid.GetCounter());
1724 
1727 }
void SetParam(ParamType value)
Definition: Callback.h:63
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharRaceOrFactionChangeInfo > > _charFactionChangeCallback
Definition: WorldSession.h:1741
Definition: CharacterDatabase.h:390
bool IsLegitCharacterForAccount(ObjectGuid lowGUID)
Definition: WorldSession.h:1787
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
Definition: PreparedStatement.h:74
std::shared_ptr< CharRaceOrFactionChangeInfo > RaceOrFactionChangeInfo
Definition: CharacterPackets.h:298
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharRenameCallBack ( PreparedQueryResult  result,
WorldPackets::Character::CharacterRenameInfo renameInfo 
)
1301 {
1302  ASSERT(_charRenameCallback.GetParam().get() == renameInfo);
1303 
1304  if (!result)
1305  {
1306  SendCharRename(CHAR_CREATE_ERROR, renameInfo);
1307  return;
1308  }
1309 
1310  Field* fields = result->Fetch();
1311 
1312  std::string oldName = fields[0].GetString();
1313  uint16 atLoginFlags = fields[1].GetUInt16();
1314 
1315  if (!(atLoginFlags & AT_LOGIN_RENAME))
1316  {
1317  SendCharRename(CHAR_CREATE_ERROR, renameInfo);
1318  return;
1319  }
1320 
1321  atLoginFlags &= ~AT_LOGIN_RENAME;
1322 
1324  ObjectGuid::LowType lowGuid = renameInfo->Guid.GetCounter();
1325 
1326  // Update name and at_login flag in the db
1328  stmt->setString(0, renameInfo->NewName);
1329  stmt->setUInt16(1, atLoginFlags);
1330  stmt->setUInt64(2, lowGuid);
1331 
1332  trans->Append(stmt);
1333 
1334  // Removed declined name from db
1336  stmt->setUInt64(0, lowGuid);
1337 
1338  trans->Append(stmt);
1339 
1341 
1342  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) Changed name to: %s",
1343  GetAccountId(), GetRemoteAddress().c_str(), oldName.c_str(), renameInfo->Guid.ToString().c_str(), renameInfo->NewName.c_str());
1344 
1345  SendCharRename(RESPONSE_SUCCESS, renameInfo);
1346 
1347  sWorld->UpdateCharacterInfo(renameInfo->Guid, renameInfo->NewName);
1348 }
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterRenameInfo > > _charRenameCallback
Definition: WorldSession.h:1739
Definition: CharacterDatabase.h:429
ObjectGuid Guid
Definition: CharacterPackets.h:62
Class used to access individual fields of database query result.
Definition: Field.h:56
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
uint64 LowType
Definition: ObjectGuid.h:199
void SendCharRename(ResponseCodes result, WorldPackets::Character::CharacterRenameInfo const *renameInfo)
Definition: CharacterHandler.cpp:2497
Definition: PreparedStatement.h:74
ParamType GetParam()
Definition: Callback.h:68
Definition: SharedDefines.h:4454
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint16_t uint16
Definition: Define.h:151
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:357
Definition: SharedDefines.h:4424
std::string NewName
Definition: CharacterPackets.h:61
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
#define ASSERT
Definition: Errors.h:55
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
std::string GetString() const
Definition: Field.h:276
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharRenameOpcode ( WorldPackets::Character::CharacterRenameRequest request)
1261 {
1262  if (!IsLegitCharacterForAccount(request.RenameInfo->Guid))
1263  {
1264  TC_LOG_ERROR("network", "Account %u, IP: %s tried to rename character %s, but it does not belong to their account!",
1265  GetAccountId(), GetRemoteAddress().c_str(), request.RenameInfo->Guid.ToString().c_str());
1266  KickPlayer();
1267  return;
1268  }
1269 
1270  // prevent character rename to invalid name
1271  if (!normalizePlayerName(request.RenameInfo->NewName))
1272  {
1274  return;
1275  }
1276 
1278  if (res != CHAR_NAME_SUCCESS)
1279  {
1280  SendCharRename(res, request.RenameInfo.get());
1281  return;
1282  }
1283 
1284  // check name limitations
1286  {
1288  return;
1289  }
1290 
1291  // Ensure that there is no character with the desired new name
1293  stmt->setUInt64(0, request.RenameInfo->Guid.GetCounter());
1294  stmt->setString(1, request.RenameInfo->NewName);
1295 
1298 }
static ResponseCodes CheckPlayerName(std::string const &name, LocaleConstant locale, bool create=false)
Definition: ObjectMgr.cpp:7580
void SetParam(ParamType value)
Definition: Callback.h:63
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterRenameInfo > > _charRenameCallback
Definition: WorldSession.h:1739
bool IsLegitCharacterForAccount(ObjectGuid lowGUID)
Definition: WorldSession.h:1787
Definition: SharedDefines.h:4507
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: SharedDefines.h:4505
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
#define sObjectMgr
Definition: ObjectMgr.h:1567
void SendCharRename(ResponseCodes result, WorldPackets::Character::CharacterRenameInfo const *renameInfo)
Definition: CharacterHandler.cpp:2497
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:55
Definition: SharedDefines.h:4513
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
ResponseCodes
Definition: SharedDefines.h:4422
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
std::shared_ptr< CharacterRenameInfo > RenameInfo
Definition: CharacterPackets.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharUndeleteCallback ( PreparedQueryResult  result,
WorldPackets::Character::CharacterUndeleteInfo undeleteInfo 
)

This is a series of callbacks executed consecutively as a result from the database becomes available. This is much more efficient than synchronous requests on packet handler. It also prevents data synchronisation errors.

Todo:
: add more safety checks
  • max char count per account
  • max heroic char count
  • team violation
2366 {
2372  ASSERT(_charUndeleteCallback.GetParam().get() == undeleteInfo);
2373 
2374  switch (_charUndeleteCallback.GetStage())
2375  {
2376  case 1:
2377  {
2378  if (result)
2379  {
2380  uint32 lastUndelete = result->Fetch()[0].GetUInt32();
2382  if (lastUndelete && (lastUndelete + maxCooldown > time(nullptr)))
2383  {
2386  return;
2387  }
2388  }
2389 
2391  stmt->setUInt64(0, undeleteInfo->CharacterGuid.GetCounter());
2392 
2396  break;
2397  }
2398  case 2:
2399  {
2400  if (!result)
2401  {
2404  return;
2405  }
2406 
2407  Field* fields = result->Fetch();
2408  undeleteInfo->Name = fields[1].GetString();
2409  uint32 account = fields[2].GetUInt32();
2410 
2411  if (account != GetAccountId())
2412  {
2415  return;
2416  }
2417 
2419  stmt->setString(0, undeleteInfo->Name);
2420 
2424  break;
2425  }
2426  case 3:
2427  {
2428  if (result)
2429  {
2432  return;
2433  }
2434 
2439 
2441  stmt->setUInt32(0, GetAccountId());
2442 
2446  break;
2447  }
2448  case 4:
2449  {
2450  if (result)
2451  {
2452  Field* fields = result->Fetch();
2453 
2454  if (fields[0].GetUInt64() >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM)) // SQL's COUNT() returns uint64 but it will always be less than uint8.Max
2455  {
2458  return;
2459  }
2460  }
2461 
2463  stmt->setString(0, undeleteInfo->Name);
2464  stmt->setUInt32(1, GetAccountId());
2465  stmt->setUInt64(2, undeleteInfo->CharacterGuid.GetCounter());
2466  CharacterDatabase.Execute(stmt);
2467 
2469  stmt->setUInt32(0, GetBattlenetAccountId());
2470  LoginDatabase.Execute(stmt);
2471 
2472  sWorld->UpdateCharacterInfoDeleted(undeleteInfo->CharacterGuid, false, &undeleteInfo->Name);
2473 
2476  break;
2477  }
2478  }
2479 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: SharedDefines.h:4524
Class used to access individual fields of database query result.
Definition: Field.h:56
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterUndeleteInfo >, true > _charUndeleteCallback
Definition: WorldSession.h:1743
ObjectGuid CharacterGuid
User specified variables.
Definition: CharacterPackets.h:94
std::string Name
Server side data.
Definition: CharacterPackets.h:98
Definition: SharedDefines.h:4529
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
Definition: CharacterDatabase.h:39
Definition: LoginDatabase.h:133
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: CharacterDatabase.h:343
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
ParamType GetParam()
Definition: Callback.h:68
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: CharacterDatabase.h:37
uint32_t uint32
Definition: Define.h:150
void SendUndeleteCharacterResponse(CharacterUndeleteResult result, WorldPackets::Character::CharacterUndeleteInfo const *undeleteInfo)
Definition: CharacterHandler.cpp:2572
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: SharedDefines.h:4525
void NextStage()
Advances the callback chain to the next stage, so upper level code can act on its results accordingly...
Definition: Callback.h:83
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8 GetStage()
Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid)
Definition: Callback.h:92
void Reset()
Resets all underlying variables (param, result and stage)
Definition: Callback.h:98
uint32 GetUInt32() const
Definition: Field.h:146
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
#define ASSERT
Definition: Errors.h:55
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:377
Definition: World.h:231
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
std::string GetString() const
Definition: Field.h:276
LowType GetCounter() const
Definition: ObjectGuid.h:221
void FreeResult()
Definition: Callback.h:58
Definition: SharedDefines.h:4526

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharUndeleteEnum ( PreparedQueryResult  result)
332 {
334  charEnum.Success = true;
335  charEnum.IsDeletedCharacters = true;
336 
337  if (result)
338  {
339  do
340  {
341  Field* fields = result->Fetch();
343 
344  TC_LOG_INFO("network", "Loading undeleted char guid %s from account %u.", charInfo.Guid.ToString().c_str(), GetAccountId());
345 
346  if (!sWorld->HasCharacterInfo(charInfo.Guid)) // This can happen if characters are inserted into the database manually. Core hasn't loaded name data yet.
347  sWorld->AddCharacterInfo(charInfo.Guid, GetAccountId(), charInfo.Name, charInfo.Sex, charInfo.Race, charInfo.Class, charInfo.Level, true);
348 
349  charEnum.Characters.emplace_back(charInfo);
350  }
351  while (result->NextRow());
352  }
353 
354  SendPacket(charEnum.Write());
355 }
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:116
std::list< CharacterInfo > Characters
all characters on the list
Definition: CharacterPackets.h:174
bool IsDeletedCharacters
used for character undelete list
Definition: CharacterPackets.h:172
Class used to access individual fields of database query result.
Definition: Field.h:56
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
bool Success
Definition: CharacterPackets.h:171
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: CharacterPackets.h:101
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharUndeleteEnumOpcode ( WorldPackets::Character::EnumCharacters )

get all the data necessary for loading all undeleted characters (along with their pets) on the account

358 {
360  PreparedStatement* stmt = nullptr;
361  if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
363  else
365 
366  stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
367  stmt->setUInt32(1, GetAccountId());
368 
371 }
void SetParam(ParamType value)
Definition: Callback.h:63
Definition: CharacterDatabase.h:54
Definition: World.h:133
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
uint32 GetAccountId() const
Definition: WorldSession.h:922
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: PetDefines.h:35
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: CharacterDatabase.h:53
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
QueryCallback< PreparedQueryResult, bool > _charEnumCallback
Definition: WorldSession.h:1733
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCharUndeleteOpcode ( WorldPackets::Character::UndeleteCharacter undeleteInfo)
2350 {
2352  {
2354  return;
2355  }
2356 
2358  stmt->setUInt32(0, GetBattlenetAccountId());
2359 
2363 }
void SetParam(ParamType value)
Definition: Callback.h:63
Definition: SharedDefines.h:4527
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterUndeleteInfo >, true > _charUndeleteCallback
Definition: WorldSession.h:1743
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: LoginDatabase.h:132
void SendUndeleteCharacterResponse(CharacterUndeleteResult result, WorldPackets::Character::CharacterUndeleteInfo const *undeleteInfo)
Definition: CharacterHandler.cpp:2572
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void NextStage()
Advances the callback chain to the next stage, so upper level code can act on its results accordingly...
Definition: Callback.h:83
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
std::shared_ptr< CharacterUndeleteInfo > UndeleteInfo
Definition: CharacterPackets.h:374
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatAddonMessage ( ChatMsg  type,
std::string  prefix,
std::string  text,
std::string  target = "" 
)
432 {
433  Player* sender = GetPlayer();
434 
435  if (prefix.empty() || prefix.length() > 16)
436  return;
437 
438  // Disabled addon channel?
439  if (!sWorld->getBoolConfig(CONFIG_ADDON_CHANNEL))
440  return;
441 
442  switch (type)
443  {
444  case CHAT_MSG_GUILD:
445  case CHAT_MSG_OFFICER:
446  {
447  if (sender->GetGuildId())
448  if (Guild* guild = sGuildMgr->GetGuildById(sender->GetGuildId()))
449  guild->BroadcastAddonToGuild(this, type == CHAT_MSG_OFFICER, text, prefix);
450  break;
451  }
452  case CHAT_MSG_WHISPER:
453  {
454  if (!normalizePlayerName(target))
455  break;
456 
457  Player* receiver = ObjectAccessor::FindPlayerByName(target);
458  if (!receiver)
459  break;
460 
461  sender->WhisperAddon(text, prefix, receiver);
462  break;
463  }
464  // Messages sent to "RAID" while in a party will get delivered to "PARTY"
465  case CHAT_MSG_PARTY:
466  case CHAT_MSG_RAID:
468  {
469  Group* group = nullptr;
470  int32 subGroup = -1;
471  if (type != CHAT_MSG_INSTANCE_CHAT)
472  group = sender->GetOriginalGroup();
473 
474  if (!group)
475  {
476  group = sender->GetGroup();
477  if (!group)
478  break;
479 
480  if (type == CHAT_MSG_PARTY)
481  subGroup = sender->GetSubGroup();
482  }
483 
485  packet.Initialize(type, LANG_ADDON, sender, nullptr, text, 0, "", DEFAULT_LOCALE, prefix);
486  group->BroadcastAddonMessagePacket(packet.Write(), prefix, true, subGroup, sender->GetGUID());
487  break;
488  }
489  case CHAT_MSG_CHANNEL:
490  {
491  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(sender->GetTeam()))
492  if (Channel* chn = cMgr->GetChannel(target, sender, false))
493  chn->Say(sender->GetGUID(), text.c_str(), uint32(LANG_ADDON));
494  break;
495  }
496  default:
497  {
498  TC_LOG_ERROR("misc", "HandleAddonMessagechatOpcode: unknown addon message type %u", type);
499  break;
500  }
501  }
502 }
Definition: SharedDefines.h:4234
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
Definition: SharedDefines.h:4238
#define sGuildMgr
Definition: GuildMgr.h:61
Definition: ChatPackets.h:150
Definition: SharedDefines.h:4248
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
void BroadcastAddonMessagePacket(WorldPacket const *packet, const std::string &prefix, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignore=ObjectGuid::Empty)
Definition: Group.cpp:1683
Definition: Channel.h:126
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: SharedDefines.h:4236
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
int32_t int32
Definition: Define.h:146
Definition: SharedDefines.h:4235
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:220
Definition: SharedDefines.h:4233
Definition: ChannelMgr.h:27
Definition: World.h:101
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: Guild.h:320
#define DEFAULT_LOCALE
Definition: Common.h:134
Definition: Group.h:191
Definition: SharedDefines.h:4297
Definition: SharedDefines.h:985

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatAddonMessageChannelOpcode ( WorldPackets::Chat::ChatAddonMessageChannel chatAddonMessageChannel)
427 {
428  HandleChatAddonMessage(CHAT_MSG_CHANNEL, chatAddonMessageChannel.Prefix, chatAddonMessageChannel.Text, chatAddonMessageChannel.Target);
429 }
Definition: SharedDefines.h:4248
void HandleChatAddonMessage(ChatMsg type, std::string prefix, std::string text, std::string target="")
Definition: ChatHandler.cpp:431
std::string Text
Definition: ChatPackets.h:114
std::string Prefix
Definition: ChatPackets.h:116
std::string Target
Definition: ChatPackets.h:115

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatAddonMessageOpcode ( WorldPackets::Chat::ChatAddonMessage chatAddonMessage)
393 {
394  ChatMsg type;
395 
396  switch (chatAddonMessage.GetOpcode())
397  {
399  type = CHAT_MSG_GUILD;
400  break;
402  type = CHAT_MSG_OFFICER;
403  break;
405  type = CHAT_MSG_PARTY;
406  break;
408  type = CHAT_MSG_RAID;
409  break;
411  type = CHAT_MSG_INSTANCE_CHAT;
412  break;
413  default:
414  TC_LOG_ERROR("network", "HandleChatAddonMessageOpcode: Unknown addon chat opcode (%u)", chatAddonMessage.GetOpcode());
415  return;
416  }
417 
418  HandleChatAddonMessage(type, chatAddonMessage.Prefix, chatAddonMessage.Text);
419 }
Definition: SharedDefines.h:4234
Definition: Opcodes.h:168
Definition: Opcodes.h:166
ChatMsg
Definition: SharedDefines.h:4228
void HandleChatAddonMessage(ChatMsg type, std::string prefix, std::string text, std::string target="")
Definition: ChatHandler.cpp:431
std::string Prefix
Definition: ChatPackets.h:89
Definition: SharedDefines.h:4236
OpcodeClient GetOpcode() const
Definition: Packet.h:72
Definition: SharedDefines.h:4235
Definition: Opcodes.h:167
Definition: SharedDefines.h:4233
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string Text
Definition: ChatPackets.h:90
Definition: Opcodes.h:169
Definition: SharedDefines.h:4297
Definition: Opcodes.h:165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatAddonMessageWhisperOpcode ( WorldPackets::Chat::ChatAddonMessageWhisper chatAddonMessageWhisper)
422 {
423  HandleChatAddonMessage(CHAT_MSG_WHISPER, chatAddonMessageWhisper.Prefix, chatAddonMessageWhisper.Text, chatAddonMessageWhisper.Target);
424 }
Definition: SharedDefines.h:4238
std::string Text
Definition: ChatPackets.h:103
std::string Prefix
Definition: ChatPackets.h:101
void HandleChatAddonMessage(ChatMsg type, std::string prefix, std::string text, std::string target="")
Definition: ChatHandler.cpp:431
std::string Target
Definition: ChatPackets.h:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatIgnoredOpcode ( WorldPackets::Chat::ChatReportIgnored chatReportIgnored)
639 {
640  Player* player = ObjectAccessor::FindConnectedPlayer(chatReportIgnored.IgnoredGUID);
641  if (!player || !player->GetSession())
642  return;
643 
646  player->SendDirectMessage(packet.Write());
647 }
ObjectGuid IgnoredGUID
Definition: ChatPackets.h:300
Definition: SharedDefines.h:961
Definition: ChatPackets.h:150
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: SharedDefines.h:4256

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessage ( ChatMsg  type,
uint32  lang,
std::string  msg,
std::string  target = "" 
)
Todo:
implement cross realm whispers (someday)
96 {
97  Player* sender = GetPlayer();
98 
99  if (lang == LANG_UNIVERSAL && type != CHAT_MSG_EMOTE)
100  {
101  TC_LOG_ERROR("network", "CMSG_MESSAGECHAT: Possible hacking-attempt: %s tried to send a message in universal language", GetPlayerInfo().c_str());
103  return;
104  }
105 
106  // prevent talking at unknown language (cheating)
107  LanguageDesc const* langDesc = GetLanguageDescByID(lang);
108  if (!langDesc)
109  {
111  return;
112  }
113 
114  if (langDesc->skill_id != 0 && !sender->HasSkill(langDesc->skill_id))
115  {
116  // also check SPELL_AURA_COMPREHEND_LANGUAGE (client offers option to speak in that language)
117  Unit::AuraEffectList const& langAuras = sender->GetAuraEffectsByType(SPELL_AURA_COMPREHEND_LANGUAGE);
118  bool foundAura = false;
119  for (Unit::AuraEffectList::const_iterator i = langAuras.begin(); i != langAuras.end(); ++i)
120  {
121  if ((*i)->GetMiscValue() == int32(lang))
122  {
123  foundAura = true;
124  break;
125  }
126  }
127  if (!foundAura)
128  {
130  return;
131  }
132  }
133 
134  // send in universal language if player in .gm on mode (ignore spell effects)
135  if (sender->IsGameMaster())
136  lang = LANG_UNIVERSAL;
137  else
138  {
139  // send in universal language in two side iteration allowed mode
141  lang = LANG_UNIVERSAL;
142  else
143  {
144  switch (type)
145  {
146  case CHAT_MSG_PARTY:
147  case CHAT_MSG_RAID:
149  // allow two side chat at group channel if two side group allowed
151  lang = LANG_UNIVERSAL;
152  break;
153  case CHAT_MSG_GUILD:
154  case CHAT_MSG_OFFICER:
155  // allow two side chat at guild channel if two side guild allowed
157  lang = LANG_UNIVERSAL;
158  break;
159  default:
160  break;
161  }
162  }
163 
164  // but overwrite it by SPELL_AURA_MOD_LANGUAGE auras (only single case used)
165  Unit::AuraEffectList const& ModLangAuras = sender->GetAuraEffectsByType(SPELL_AURA_MOD_LANGUAGE);
166  if (!ModLangAuras.empty())
167  lang = ModLangAuras.front()->GetMiscValue();
168  }
169 
170  if (!sender->CanSpeak())
171  {
172  std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
174  return;
175  }
176 
177  if (sender->HasAura(GM_SILENCE_AURA) && type != CHAT_MSG_WHISPER)
178  {
179  SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str());
180  return;
181  }
182 
183  if (msg.empty())
184  return;
185 
186  if (ChatHandler(this).ParseCommands(msg.c_str()))
187  return;
188 
189  // Strip invisible characters for non-addon messages
190  if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
192 
193  if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) && !ChatHandler(this).isValidChatMessage(msg.c_str()))
194  {
195  TC_LOG_ERROR("network", "Player %s (%s) sent a chatmessage with an invalid link: %s", GetPlayer()->GetName().c_str(),
196  GetPlayer()->GetGUID().ToString().c_str(), msg.c_str());
197 
199  KickPlayer();
200 
201  return;
202  }
203 
204  switch (type)
205  {
206  case CHAT_MSG_SAY:
207  case CHAT_MSG_EMOTE:
208  case CHAT_MSG_YELL:
209  {
210  // Prevent cheating
211  if (!sender->IsAlive())
212  return;
213 
214  if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ))
215  {
217  return;
218  }
219 
220  if (type == CHAT_MSG_SAY)
221  sender->Say(msg, Language(lang));
222  else if (type == CHAT_MSG_EMOTE)
223  sender->TextEmote(msg);
224  else if (type == CHAT_MSG_YELL)
225  sender->Yell(msg, Language(lang));
226  break;
227  }
228  case CHAT_MSG_WHISPER:
229  {
232 
233  if (!normalizePlayerName(extName.Name))
234  {
236  break;
237  }
238 
240  if (!receiver || (lang != LANG_ADDON && !receiver->isAcceptWhispers() && receiver->GetSession()->HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS) && !receiver->IsInWhisperWhiteList(sender->GetGUID())))
241  {
243  return;
244  }
245  if (!sender->IsGameMaster() && sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))
246  {
248  return;
249  }
250 
251  if (GetPlayer()->GetTeam() != receiver->GetTeam() && !HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_CHAT) && !receiver->IsInWhisperWhiteList(sender->GetGUID()))
252  {
254  return;
255  }
256 
257  if (GetPlayer()->HasAura(1852) && !receiver->IsGameMaster())
258  {
260  return;
261  }
262 
263  // If player is a Gamemaster and doesn't accept whisper, we auto-whitelist every player that the Gamemaster is talking to
264  // We also do that if a player is under the required level for whispers.
265  if (receiver->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ) ||
266  (HasPermission(rbac::RBAC_PERM_CAN_FILTER_WHISPERS) && !sender->isAcceptWhispers() && !sender->IsInWhisperWhiteList(receiver->GetGUID())))
267  sender->AddWhisperWhiteList(receiver->GetGUID());
268 
269  GetPlayer()->Whisper(msg, Language(lang), receiver);
270  break;
271  }
272  case CHAT_MSG_PARTY:
273  {
274  // if player is in battleground, he cannot say to battleground members by /p
275  Group* group = GetPlayer()->GetOriginalGroup();
276  if (!group)
277  {
278  group = sender->GetGroup();
279  if (!group || group->isBGGroup())
280  return;
281  }
282 
283  if (group->IsLeader(GetPlayer()->GetGUID()))
284  type = CHAT_MSG_PARTY_LEADER;
285 
286  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
287 
289  packet.Initialize(ChatMsg(type), Language(lang), sender, nullptr, msg);
290  group->BroadcastPacket(packet.Write(), false, group->GetMemberGroup(GetPlayer()->GetGUID()));
291  break;
292  }
293  case CHAT_MSG_GUILD:
294  {
295  if (GetPlayer()->GetGuildId())
296  {
297  if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
298  {
299  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
300 
301  guild->BroadcastToGuild(this, false, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
302  }
303  }
304  break;
305  }
306  case CHAT_MSG_OFFICER:
307  {
308  if (GetPlayer()->GetGuildId())
309  {
310  if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
311  {
312  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
313 
314  guild->BroadcastToGuild(this, true, msg, lang == LANG_ADDON ? LANG_ADDON : LANG_UNIVERSAL);
315  }
316  }
317  break;
318  }
319  case CHAT_MSG_RAID:
320  {
321  Group* group = GetPlayer()->GetGroup();
322  if (!group || !group->isRaidGroup() || group->isBGGroup())
323  return;
324 
325  if (group->IsLeader(GetPlayer()->GetGUID()))
326  type = CHAT_MSG_RAID_LEADER;
327 
328  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
329 
331  packet.Initialize(ChatMsg(type), Language(lang), sender, nullptr, msg);
332  group->BroadcastPacket(packet.Write(), false);
333  break;
334  }
336  {
337  Group* group = GetPlayer()->GetGroup();
338  if (!group || !group->isRaidGroup() || !(group->IsLeader(GetPlayer()->GetGUID()) || group->IsAssistant(GetPlayer()->GetGUID())) || group->isBGGroup())
339  return;
340 
341  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
342 
344  //in battleground, raid warning is sent only to players in battleground - code is ok
345  packet.Initialize(CHAT_MSG_RAID_WARNING, Language(lang), sender, NULL, msg);
346  group->BroadcastPacket(packet.Write(), false);
347  break;
348  }
349  case CHAT_MSG_CHANNEL:
350  {
352  {
353  if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ))
354  {
356  return;
357  }
358  }
359 
360  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(sender->GetTeam()))
361  {
362  if (Channel* chn = cMgr->GetChannel(target, sender))
363  {
364  sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
365  chn->Say(sender->GetGUID(), msg.c_str(), lang);
366  }
367  }
368  break;
369  }
371  {
372  Group* group = GetPlayer()->GetGroup();
373  if (!group)
374  return;
375 
376  if (group->IsLeader(GetPlayer()->GetGUID()))
378 
379  sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, group);
380 
382  packet.Initialize(ChatMsg(type), Language(lang), sender, nullptr, msg);
383  group->BroadcastPacket(packet.Write(), false);
384  break;
385  }
386  default:
387  TC_LOG_ERROR("network", "CHAT: unknown message type %u, lang: %u", type, lang);
388  break;
389  }
390 }
Definition: SharedDefines.h:4234
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
Definition: SharedDefines.h:4280
Definition: SharedDefines.h:4238
Definition: SharedDefines.h:961
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
Definition: Util.cpp:109
bool isRaidGroup() const
Definition: Group.cpp:2509
Definition: Language.h:1151
#define sGuildMgr
Definition: GuildMgr.h:61
void SendChatPlayerNotfoundNotice(std::string const &name)
Definition: ChatHandler.cpp:649
Definition: Language.h:772
Definition: ObjectMgr.h:651
TC_GAME_API Player * FindConnectedPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:240
Definition: SpellAuraDefines.h:304
Definition: SharedDefines.h:4241
std::list< AuraEffect * > AuraEffectList
Definition: Unit.h:1322
Definition: ChatPackets.h:150
ChatMsg
Definition: SharedDefines.h:4228
arena_t NULL
Definition: jemalloc_internal.h:624
std::string Name
Definition: ObjectMgr.h:654
Definition: SharedDefines.h:4248
Definition: Language.h:773
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
Definition: Channel.h:126
Definition: Language.h:1137
Definition: ObjectMgr.h:660
Definition: Language.h:706
WorldPacket const * Write() override
Definition: ChatPackets.cpp:162
Definition: SharedDefines.h:4271
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
Definition: World.h:290
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Language
Definition: SharedDefines.h:959
string ToString(int i)
Definition: strutil.h:491
time_t m_muteTime
Definition: WorldSession.h:1056
uint32 skill_id
Definition: ObjectMgr.h:664
Definition: SharedDefines.h:4236
void Initialize(ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
Definition: ChatPackets.cpp:104
Definition: SharedDefines.h:4298
bool isBGGroup() const
Definition: Group.cpp:2514
Definition: SharedDefines.h:4235
ExtendedPlayerName ExtractExtendedPlayerName(std::string const &name)
Definition: ObjectMgr.cpp:155
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: SharedDefines.h:4237
#define GM_SILENCE_AURA
Definition: SharedDefines.h:4303
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition: ObjectMgr.cpp:192
Definition: Chat.h:56
Definition: SharedDefines.h:4233
Definition: World.h:291
Definition: ChannelMgr.h:27
Definition: Language.h:1136
uint8 GetMemberGroup(ObjectGuid guid) const
Definition: Group.cpp:2613
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
int32_t int32
Definition: g3dmath.h:167
Definition: Language.h:1138
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignoredPlayer=ObjectGuid::Empty)
Definition: Group.cpp:1698
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:4232
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: Guild.h:320
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: SharedDefines.h:4270
bool isValidChatMessage(const char *msg)
Definition: Chat.cpp:424
Definition: World.h:289
Definition: Group.h:191
Definition: SharedDefines.h:4297
Definition: SpellAuraDefines.h:135
bool ParseCommands(const char *text)
Definition: Chat.cpp:387
Definition: SharedDefines.h:985
void stripLineInvisibleChars(std::string &str)
Definition: Util.cpp:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageAFKOpcode ( WorldPackets::Chat::ChatMessageAFK chatMessageAFK)
505 {
506  Player* sender = GetPlayer();
507 
508  if (sender->IsInCombat())
509  return;
510 
511  if (sender->HasAura(GM_SILENCE_AURA))
512  {
513  SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str());
514  return;
515  }
516 
517  if (sender->isAFK()) // Already AFK
518  {
519  if (chatMessageAFK.Text.empty())
520  sender->ToggleAFK(); // Remove AFK
521  else
522  sender->autoReplyMsg = chatMessageAFK.Text; // Update message
523  }
524  else // New AFK mode
525  {
526  sender->autoReplyMsg = chatMessageAFK.Text.empty() ? GetTrinityString(LANG_PLAYER_AFK_DEFAULT) : chatMessageAFK.Text;
527 
528  if (sender->isDND())
529  sender->ToggleDND();
530 
531  sender->ToggleAFK();
532  }
533 
534  sScriptMgr->OnPlayerChat(sender, CHAT_MSG_AFK, LANG_UNIVERSAL, chatMessageAFK.Text);
535 }
Definition: SharedDefines.h:961
std::string Text
Definition: ChatPackets.h:136
Definition: Language.h:1151
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4254
Definition: Language.h:711
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Text
Definition: boss_ascendant_lord_obsidius.cpp:22
#define GM_SILENCE_AURA
Definition: SharedDefines.h:4303
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageChannelOpcode ( WorldPackets::Chat::ChatMessageChannel chatMessageChannel)
86 {
87  HandleChatMessage(CHAT_MSG_CHANNEL, chatMessageChannel.Language, chatMessageChannel.Text, chatMessageChannel.Target);
88 }
Definition: SharedDefines.h:4248
std::string Text
Definition: ChatPackets.h:73
std::string Target
Definition: ChatPackets.h:74
int32 Language
Definition: ChatPackets.h:72
void HandleChatMessage(ChatMsg type, uint32 lang, std::string msg, std::string target="")
Definition: ChatHandler.cpp:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageDNDOpcode ( WorldPackets::Chat::ChatMessageDND chatMessageDND)
538 {
539  Player* sender = GetPlayer();
540 
541  if (sender->IsInCombat())
542  return;
543 
544  if (sender->HasAura(GM_SILENCE_AURA))
545  {
546  SendNotification(GetTrinityString(LANG_GM_SILENCE), sender->GetName().c_str());
547  return;
548  }
549 
550  if (sender->isDND()) // Already DND
551  {
552  if (chatMessageDND.Text.empty())
553  sender->ToggleDND(); // Remove DND
554  else
555  sender->autoReplyMsg = chatMessageDND.Text; // Update message
556  }
557  else // New DND mode
558  {
559  sender->autoReplyMsg = chatMessageDND.Text.empty() ? GetTrinityString(LANG_PLAYER_DND_DEFAULT) : chatMessageDND.Text;
560 
561  if (sender->isAFK())
562  sender->ToggleAFK();
563 
564  sender->ToggleDND();
565  }
566 
567  sScriptMgr->OnPlayerChat(sender, CHAT_MSG_DND, LANG_UNIVERSAL, chatMessageDND.Text);
568 }
Definition: SharedDefines.h:961
Definition: Language.h:1151
Definition: Language.h:710
Player * GetPlayer() const
Definition: WorldSession.h:927
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Text
Definition: boss_ascendant_lord_obsidius.cpp:22
std::string Text
Definition: ChatPackets.h:126
Definition: SharedDefines.h:4255
#define GM_SILENCE_AURA
Definition: SharedDefines.h:4303
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageEmoteOpcode ( WorldPackets::Chat::ChatMessageEmote chatMessageEmote)
91 {
93 }
Definition: SharedDefines.h:961
Definition: SharedDefines.h:4241
std::string Text
Definition: ChatPackets.h:146
void HandleChatMessage(ChatMsg type, uint32 lang, std::string msg, std::string target="")
Definition: ChatHandler.cpp:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageOpcode ( WorldPackets::Chat::ChatMessage chatMessage)
43 {
44  ChatMsg type;
45 
46  switch (chatMessage.GetOpcode())
47  {
49  type = CHAT_MSG_SAY;
50  break;
52  type = CHAT_MSG_YELL;
53  break;
55  type = CHAT_MSG_GUILD;
56  break;
58  type = CHAT_MSG_OFFICER;
59  break;
61  type = CHAT_MSG_PARTY;
62  break;
64  type = CHAT_MSG_RAID;
65  break;
67  type = CHAT_MSG_RAID_WARNING;
68  break;
71  break;
72  default:
73  TC_LOG_ERROR("network", "HandleMessagechatOpcode : Unknown chat opcode (%u)", chatMessage.GetOpcode());
74  return;
75  }
76 
77  HandleChatMessage(type, chatMessage.Language, chatMessage.Text);
78 }
Definition: SharedDefines.h:4234
Definition: Opcodes.h:204
Definition: Opcodes.h:207
ChatMsg
Definition: SharedDefines.h:4228
Definition: Opcodes.h:200
Definition: Opcodes.h:202
Definition: SharedDefines.h:4271
Definition: SharedDefines.h:4236
OpcodeClient GetOpcode() const
Definition: Packet.h:72
Definition: SharedDefines.h:4235
Definition: Opcodes.h:203
Definition: SharedDefines.h:4237
Definition: SharedDefines.h:4233
Definition: Opcodes.h:199
Definition: Opcodes.h:205
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:4232
std::string Text
Definition: ChatPackets.h:47
void HandleChatMessage(ChatMsg type, uint32 lang, std::string msg, std::string target="")
Definition: ChatHandler.cpp:95
Definition: Opcodes.h:201
int32 Language
Definition: ChatPackets.h:48
Definition: SharedDefines.h:4297

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleChatMessageWhisperOpcode ( WorldPackets::Chat::ChatMessageWhisper chatMessageWhisper)
81 {
82  HandleChatMessage(CHAT_MSG_WHISPER, chatMessageWhisper.Language, chatMessageWhisper.Text, chatMessageWhisper.Target);
83 }
Definition: SharedDefines.h:4238
int32 Language
Definition: ChatPackets.h:59
std::string Text
Definition: ChatPackets.h:60
std::string Target
Definition: ChatPackets.h:61
void HandleChatMessage(ChatMsg type, uint32 lang, std::string msg, std::string target="")
Definition: ChatHandler.cpp:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleClearRaidMarker ( WorldPackets::Party::ClearRaidMarker packet)
642 {
643  Group* group = GetPlayer()->GetGroup();
644  if (!group)
645  return;
646 
647  if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
648  return;
649 
650  group->DeleteRaidMarker(packet.MarkerId);
651 }
void DeleteRaidMarker(uint8 markerId)
Definition: Group.cpp:2467
uint8 MarkerId
Definition: PartyPackets.h:594
bool isRaidGroup() const
Definition: Group.cpp:2509
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleClearTradeItemOpcode ( WorldPackets::Trade::ClearTradeItem clearTradeItem)
751 {
752  TradeData* my_trade = _player->m_trade;
753  if (!my_trade)
754  return;
755 
756  my_trade->UpdateClientStateIndex();
757 
758  // invalid slot number
759  if (clearTradeItem.TradeSlot >= TRADE_SLOT_COUNT)
760  return;
761 
762  my_trade->SetItem(TradeSlots(clearTradeItem.TradeSlot), NULL);
763 }
uint8 TradeSlot
Definition: TradePackets.h:68
arena_t NULL
Definition: jemalloc_internal.h:624
void SetItem(TradeSlots slot, Item *item, bool update=false)
Definition: TradeData.cpp:55
Definition: TradeData.h:34
TradeSlots
Definition: TradeData.h:23
Player * _player
Definition: WorldSession.h:1797
Definition: TradeData.h:25
void UpdateClientStateIndex()
Definition: TradeData.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleComplaint ( WorldPackets::Ticket::Complaint packet)
100 { // NOTE: all chat messages from this spammer are automatically ignored by the spam reporter until logout in case of chat spam.
101  // if it's mail spam - ALL mails from this spammer are automatically removed by client
102 
104  result.ComplaintType = packet.ComplaintType;
105  result.Result = 0;
106  SendPacket(result.Write());
107 }
uint8 ComplaintType
Definition: TicketPackets.h:217
uint32 ComplaintType
Definition: TicketPackets.h:233
WorldPacket const * Write() override
Definition: TicketPackets.cpp:270
uint8 Result
Definition: TicketPackets.h:234
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: TicketPackets.h:226

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCompleteCinematic ( WorldPackets::Misc::CompleteCinematic packet)
690 {
691 }

+ Here is the caller graph for this function:

void WorldSession::HandleConfirmRespecWipeOpcode ( WorldPackets::Talent::ConfirmRespecWipe confirmRespecWipe)
41 {
42  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(confirmRespecWipe.RespecMaster, UNIT_NPC_FLAG_TRAINER);
43  if (!unit)
44  {
45  TC_LOG_DEBUG("network", "WORLD: HandleConfirmRespecWipeOpcode - %s not found or you can't interact with him.", confirmRespecWipe.RespecMaster.ToString().c_str());
46  return;
47  }
48 
49  if (confirmRespecWipe.RespecType != SPEC_RESET_TALENTS)
50  {
51  TC_LOG_DEBUG("network", "WORLD: HandleConfirmRespecWipeOpcode - reset type %d is not implemented.", confirmRespecWipe.RespecType);
52  return;
53  }
54 
56  return;
57 
58  // remove fake death
59  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
60  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
61 
62  if (!_player->ResetTalents())
63  {
64  GetPlayer()->SendRespecWipeConfirm(ObjectGuid::Empty, 0);
65  return;
66  }
67 
68  _player->SendTalentsInfoData();
69  unit->CastSpell(_player, 14867, true); //spell: "Untalent Visual Effect"
70 }
ObjectGuid RespecMaster
Definition: TalentPackets.h:92
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
bool isCanTrainingAndResetTalentsOf(Player *player) const
Definition: Creature.cpp:970
Definition: Unit.h:739
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 RespecType
Definition: TalentPackets.h:93
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
Definition: Player.h:160
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleContactListOpcode ( WorldPackets::Social::SendContactList packet)
26 {
27  TC_LOG_DEBUG("network", "WorldSession::HandleContactListOpcode: Flags: %u", packet.Flags);
28  _player->GetSocial()->SendSocialList(_player, packet.Flags);
29 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 Flags
Definition: SocialPackets.h:39
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleContinuePlayerLogin ( )
856 {
857  if (!PlayerLoading() || GetPlayer())
858  {
859  KickPlayer();
860  return;
861  }
862 
864  if (!holder->Initialize())
865  {
866  delete holder; // delete all unprocessed queries
868  return;
869  }
870 
872 
874 }
bool Initialize()
Definition: CharacterHandler.cpp:71
Definition: AuthenticationPackets.h:195
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
QueryResultHolderFuture _charLoginCallback
Definition: WorldSession.h:1744
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
QueryResultHolderFuture DelayQueryHolder(SQLQueryHolder *holder)
Definition: DatabaseWorkerPool.cpp:169
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Opcodes.h:32
void Clear()
Definition: ObjectGuid.h:215
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterHandler.cpp:58
bool PlayerLoading() const
Definition: WorldSession.h:889

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleConvertRaidOpcode ( WorldPackets::Party::ConvertRaid packet)
450 {
451  Group* group = GetPlayer()->GetGroup();
452  if (!group)
453  return;
454 
455  if (_player->InBattleground())
456  return;
457 
458  // error handling
459  if (!group->IsLeader(GetPlayer()->GetGUID()) || group->GetMembersCount() < 2)
460  return;
461 
462  // everything's fine, do it (is it 0 (PARTY_OP_INVITE) correct code)
464 
465  // New 4.x: it is now possible to convert a raid to a group if member count is 5 or less
466  if (packet.Raid)
467  group->ConvertToRaid();
468  else
469  group->ConvertToGroup();
470 }
void ConvertToGroup()
Definition: Group.cpp:268
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4843
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
Definition: WorldSession.h:783
void SendPartyResult(PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
Definition: GroupHandler.cpp:48
Player * _player
Definition: WorldSession.h:1797
uint32 GetMembersCount() const
Definition: Group.h:297
bool Raid
Definition: PartyPackets.h:340
void ConvertToRaid()
Definition: Group.cpp:244
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleCreatureQuery ( WorldPackets::Query::QueryCreature packet)

Only static data is sent in this packet !!!

67 {
69 
70  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(packet.CreatureID);
71 
72  response.CreatureID = packet.CreatureID;
73 
74  if (creatureInfo)
75  {
76  response.Allow = true;
77 
78  WorldPackets::Query::CreatureStats& stats = response.Stats;
79 
80  stats.Leader = creatureInfo->RacialLeader;
81 
82  stats.Name[0] = creatureInfo->Name;
83  stats.NameAlt[0] = creatureInfo->FemaleName;
84 
85  stats.Flags[0] = creatureInfo->type_flags;
86  stats.Flags[1] = creatureInfo->type_flags2;
87 
88  stats.CreatureType = creatureInfo->type;
89  stats.CreatureFamily = creatureInfo->family;
90  stats.Classification = creatureInfo->rank;
91 
92  for (uint32 i = 0; i < MAX_KILL_CREDIT; ++i)
93  stats.ProxyCreatureID[i] = creatureInfo->KillCredit[i];
94 
95  stats.CreatureDisplayID[0] = creatureInfo->Modelid1;
96  stats.CreatureDisplayID[1] = creatureInfo->Modelid2;
97  stats.CreatureDisplayID[2] = creatureInfo->Modelid3;
98  stats.CreatureDisplayID[3] = creatureInfo->Modelid4;
99 
100  stats.HpMulti = creatureInfo->ModHealth;
101  stats.EnergyMulti = creatureInfo->ModMana;
102 
103  stats.CreatureMovementInfoID = creatureInfo->movementId;
104  stats.RequiredExpansion = creatureInfo->expansionUnknown;
105 
106  stats.Title = creatureInfo->SubName;
107  //stats.TitleAlt = ;
108  stats.CursorName = creatureInfo->IconName;
109 
110  if (CreatureQuestItemList const* items = sObjectMgr->GetCreatureQuestItemList(packet.CreatureID))
111  for (uint32 item : *items)
112  stats.QuestItems.push_back(item);
113 
114  LocaleConstant localeConstant = GetSessionDbLocaleIndex();
115  if (localeConstant >= LOCALE_enUS)
116  if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(packet.CreatureID))
117  {
118  ObjectMgr::GetLocaleString(creatureLocale->Name, localeConstant, stats.Name[0]);
119  ObjectMgr::GetLocaleString(creatureLocale->NameAlt, localeConstant, stats.NameAlt[0]);
120  ObjectMgr::GetLocaleString(creatureLocale->Title, localeConstant, stats.Title);
121  ObjectMgr::GetLocaleString(creatureLocale->TitleAlt, localeConstant, stats.TitleAlt);
122  }
123  }
124 
125  SendPacket(response.Write());
126 }
float HpMulti
Definition: QueryPackets.h:51
Definition: Creature.h:258
Definition: QueryPackets.h:64
uint32 expansionUnknown
Definition: Creature.h:96
std::string Name
Definition: Creature.h:88
uint32 RequiredExpansion
Definition: QueryPackets.h:56
std::string CursorName
Definition: QueryPackets.h:47
std::string TitleAlt
Definition: QueryPackets.h:46
uint32 rank
Definition: Creature.h:102
uint32 type_flags2
Definition: Creature.h:118
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1060
float ModHealth
Definition: Creature.h:131
std::vector< uint32 > CreatureQuestItemList
Definition: Creature.h:209
bool Allow
Definition: QueryPackets.h:71
uint32 KillCredit[MAX_KILL_CREDIT]
Definition: Creature.h:83
std::vector< int32 > QuestItems
Definition: QueryPackets.h:54
std::string Name[MAX_CREATURE_NAMES]
Definition: QueryPackets.h:60
#define sObjectMgr
Definition: ObjectMgr.h:1567
CreatureStats Stats
Definition: QueryPackets.h:72
uint32 CreatureMovementInfoID
Definition: QueryPackets.h:55
uint32 CreatureID
Definition: QueryPackets.h:40
uint32 CreatureID
Definition: QueryPackets.h:73
#define MAX_KILL_CREDIT
Definition: Creature.h:72
int32 CreatureFamily
Definition: QueryPackets.h:49
uint32 Flags[2]
Definition: QueryPackets.h:57
WorldPacket const * Write() override
Definition: QueryPackets.cpp:29
LocaleConstant
Definition: Common.h:115
std::string IconName
Definition: Creature.h:91
std::string FemaleName
Definition: Creature.h:89
uint32_t uint32
Definition: Define.h:150
float EnergyMulti
Definition: QueryPackets.h:52
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
float ModMana
Definition: Creature.h:133
uint32 Modelid1
Definition: Creature.h:84
int32 Classification
Definition: QueryPackets.h:50
uint32 Modelid3
Definition: Creature.h:86
uint32 Modelid2
Definition: Creature.h:85
Definition: Common.h:117
std::string Title
Definition: QueryPackets.h:45
bool Leader
Definition: QueryPackets.h:53
std::string NameAlt[MAX_CREATURE_NAMES]
Definition: QueryPackets.h:61
uint32 family
Definition: Creature.h:112
static void GetLocaleString(StringVector const &data, LocaleConstant localeConstant, std::string &value)
Definition: ObjectMgr.h:1345
bool RacialLeader
Definition: Creature.h:138
int32 CreatureType
Definition: QueryPackets.h:48
uint32 Modelid4
Definition: Creature.h:87
uint32 ProxyCreatureID[MAX_KILL_CREDIT]
Definition: QueryPackets.h:58
uint32 movementId
Definition: Creature.h:139
std::string SubName
Definition: Creature.h:90
Definition: Creature.h:79
uint32 type
Definition: Creature.h:116
Definition: QueryPackets.h:43
uint32 CreatureDisplayID[MAX_CREATURE_MODELS]
Definition: QueryPackets.h:59
uint32 type_flags
Definition: Creature.h:117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDBQueryBulk ( WorldPackets::Query::DBQueryBulk packet)
404 {
405  DB2StorageBase const* store = sDB2Manager.GetStorage(packet.TableHash);
406  if (!store)
407  {
408  TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: %s requested unsupported unknown hotfix type: %u", GetPlayerInfo().c_str(), packet.TableHash);
409  return;
410  }
411 
413  {
415  response.TableHash = packet.TableHash;
416  response.RecordID = rec.RecordID;
417 
418  if (store->HasRecord(rec.RecordID))
419  {
420  response.Allow = true;
421  response.Timestamp = sDB2Manager.GetHotfixDate(rec.RecordID, packet.TableHash);
422  store->WriteRecord(rec.RecordID, GetSessionDbcLocale(), response.Data);
423  }
424  else
425  {
426  TC_LOG_TRACE("network", "CMSG_DB_QUERY_BULK: %s requested non-existing entry %u in datastore: %u", GetPlayerInfo().c_str(), rec.RecordID, packet.TableHash);
427  response.Timestamp = time(NULL);
428  }
429 
430  SendPacket(response.Write());
431  }
432 }
#define sDB2Manager
Definition: DB2Stores.h:224
ByteBuffer Data
Definition: QueryPackets.h:203
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: QueryPackets.h:192
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
bool Allow
Definition: QueryPackets.h:202
uint32 RecordID
Definition: QueryPackets.h:201
virtual bool HasRecord(uint32 id) const =0
WorldPacket const * Write() override
Definition: QueryPackets.cpp:259
Interface class for common access.
Definition: DB2Store.h:27
uint32 Timestamp
Definition: QueryPackets.h:200
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 TableHash
Definition: QueryPackets.h:188
virtual void WriteRecord(uint32 id, uint32 locale, ByteBuffer &buffer) const =0
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint32 TableHash
Definition: QueryPackets.h:199
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::vector< DBQueryRecord > Queries
Definition: QueryPackets.h:189
uint32 RecordID
Definition: QueryPackets.h:181

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDeclineGuildInvites ( WorldPackets::Guild::DeclineGuildInvites packet)
375 {
377 }
bool Allow
Definition: GuildPackets.h:193
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Player.h:544
Definition: UpdateFields.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDeclinePetition ( WorldPackets::Petition::DeclinePetition packet)
358 {
359  TC_LOG_DEBUG("network", "Petition %s declined by %s", packet.PetitionGUID.ToString().c_str(), _player->GetGUID().ToString().c_str());
360 
362  stmt->setUInt64(0, packet.PetitionGUID.GetCounter());
364 
365  if (!result)
366  return;
367 
368  Field* fields = result->Fetch();
369  ObjectGuid ownerguid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
370 
371  Player* owner = ObjectAccessor::FindConnectedPlayer(ownerguid);
372  if (owner) // petition owner online
373  {
374  // Disabled because packet isn't handled by the client in any way
375  /*
376  WorldPackets::Petition::PetitionDeclined packet;
377  packet.Decliner = _player->GetGUID();
378  owner->GetSession()->SendPacket(packet.Write());
379  */
380  }
381 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Class used to access individual fields of database query result.
Definition: Field.h:56
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:270
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid PetitionGUID
Definition: PetitionPackets.h:176
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDeleteEquipmentSet ( WorldPackets::EquipmentSet::DeleteEquipmentSet deleteEquipmentSet)
1658 {
1659  _player->DeleteEquipmentSet(deleteEquipmentSet.ID);
1660 }
Player * _player
Definition: WorldSession.h:1797
uint64 ID
Definition: EquipmentSetPackets.h:66

+ Here is the caller graph for this function:

void WorldSession::HandleDelFriendOpcode ( WorldPackets::Social::DelFriend packet)
Todo:
: handle VirtualRealmAddress
93 {
95  TC_LOG_DEBUG("network", "WorldSession::HandleDelFriendOpcode: %s", packet.Player.Guid.ToString().c_str());
96 
97  GetPlayer()->GetSocial()->RemoveFromSocialList(packet.Player.Guid, SOCIAL_FLAG_FRIEND);
98 
99  sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_REMOVED, packet.Player.Guid);
100 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SocialMgr.h:74
#define sSocialMgr
Definition: SocialMgr.h:160
ObjectGuid Guid
Definition: SocialPackets.h:91
Definition: SocialMgr.h:40
std::string ToString() const
Definition: ObjectGuid.cpp:99
QualifiedGUID Player
Definition: SocialPackets.h:113

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDelIgnoreOpcode ( WorldPackets::Social::DelIgnore packet)
Todo:
: handle VirtualRealmAddress
151 {
153  TC_LOG_DEBUG("network", "WorldSession::HandleDelIgnoreOpcode: %s", packet.Player.Guid.ToString().c_str());
154 
155  GetPlayer()->GetSocial()->RemoveFromSocialList(packet.Player.Guid, SOCIAL_FLAG_IGNORED);
156 
157  sSocialMgr->SendFriendStatus(GetPlayer(), FRIEND_IGNORE_REMOVED, packet.Player.Guid);
158 }
Definition: SocialMgr.h:41
QualifiedGUID Player
Definition: SocialPackets.h:144
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sSocialMgr
Definition: SocialMgr.h:160
ObjectGuid Guid
Definition: SocialPackets.h:91
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: SocialMgr.h:85

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDestroyItemOpcode ( WorldPackets::Item::DestroyItem destroyItem)
272 {
273  TC_LOG_DEBUG("network", "HandleDestroyItemOpcode: receive ContainerId: %u, SlotNum: %u, Count: %u",
274  destroyItem.ContainerId, destroyItem.SlotNum, destroyItem.Count);
275 
276  uint16 pos = (destroyItem.ContainerId << 8) | destroyItem.SlotNum;
277 
278  // prevent drop unequipable items (in combat, for example) and non-empty bags
279  if (_player->IsEquipmentPos(pos) || _player->IsBagPos(pos))
280  {
281  InventoryResult msg = _player->CanUnequipItem(pos, false);
282  if (msg != EQUIP_ERR_OK)
283  {
284  _player->SendEquipError(msg, _player->GetItemByPos(pos));
285  return;
286  }
287  }
288 
289  Item* item = _player->GetItemByPos(destroyItem.ContainerId, destroyItem.SlotNum);
290  if (!item)
291  {
292  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
293  return;
294  }
295 
297  {
298  _player->SendEquipError(EQUIP_ERR_DROP_BOUND_ITEM, NULL, NULL);
299  return;
300  }
301 
302  if (destroyItem.Count)
303  {
304  uint32 i_count = destroyItem.Count;
305  _player->DestroyItemCount(item, i_count, true);
306  }
307  else
308  _player->DestroyItem(destroyItem.ContainerId, destroyItem.SlotNum, true);
309 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:48
Definition: Item.h:71
uint8 SlotNum
Definition: ItemPackets.h:342
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: Item.h:72
Player * _player
Definition: WorldSession.h:1797
uint32 GetFlags() const
Definition: ItemTemplate.h:656
uint32 Count
Definition: ItemPackets.h:341
Definition: ItemTemplate.h:178
InventoryResult
Definition: Item.h:46
uint8 ContainerId
Definition: ItemPackets.h:343
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDFGetJoinStatus ( WorldPacket recvData)
406 {
407  TC_LOG_DEBUG("lfg", "CMSG_DF_GET_JOIN_STATUS %s", GetPlayerInfo().c_str());
408 
409  if (!GetPlayer()->isUsingLfg())
410  return;
411 
412  ObjectGuid guid = GetPlayer()->GetGUID();
413  lfg::LfgUpdateData updateData = sLFGMgr->GetLfgStatus(guid);
414 
415  if (GetPlayer()->GetGroup())
416  {
417  SendLfgUpdateStatus(updateData, true);
418  updateData.dungeons.clear();
419  SendLfgUpdateStatus(updateData, false);
420  }
421  else
422  {
423  SendLfgUpdateStatus(updateData, false);
424  updateData.dungeons.clear();
425  SendLfgUpdateStatus(updateData, true);
426  }
427 }
Definition: LFGMgr.h:161
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendLfgUpdateStatus(lfg::LfgUpdateData const &updateData, bool party)
Definition: LFGHandler.cpp:429
LfgDungeonSet dungeons
Definition: LFGMgr.h:171
#define sLFGMgr
Definition: LFGMgr.h:481
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDFGetSystemInfo ( WorldPacket recvData)
273 {
274  bool forPlayer = recvData.ReadBit();
275  TC_LOG_DEBUG("lfg", "CMSG_DF_GET_SYSTEM_INFO %s for %s", GetPlayerInfo().c_str(), (forPlayer ? "player" : "party"));
276 
277  if (forPlayer)
279  else
281 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendLfgPlayerLockInfo()
Definition: LFGHandler.cpp:283
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
bool ReadBit()
Definition: ByteBuffer.h:186
void SendLfgPartyLockInfo()
Definition: LFGHandler.cpp:355

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDismissCritter ( WorldPackets::Pet::DismissCritter dismissCritter)
42 {
43  Unit* pet = ObjectAccessor::GetCreatureOrPetOrVehicle(*_player, packet.CritterGUID);
44 
45  if (!pet)
46  {
47  TC_LOG_DEBUG("network", "Vanitypet (%s) does not exist - player '%s' (%s / account: %u) attempted to dismiss it (possibly lagged out)",
48  packet.CritterGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetAccountId());
49  return;
50  }
51 
52  if (_player->GetCritterGUID() == pet->GetGUID())
53  {
54  if (pet->GetTypeId() == TYPEID_UNIT && pet->IsSummon())
55  pet->ToTempSummon()->UnSummon();
56  }
57 }
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
TempSummon * ToTempSummon()
Definition: Unit.h:2206
virtual void UnSummon(uint32 msTime=0)
Definition: TemporarySummon.cpp:237
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
bool IsSummon() const
Definition: Unit.h:1401
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDoReadyCheckOpcode ( WorldPackets::Party::DoReadyCheck packet)

error handling

554 {
555  Group* group = GetPlayer()->GetGroup();
556  if (!group)
557  return;
558 
560  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
561  return;
562  /********************/
563 
564  // everything's fine, do it
565  group->StartReadyCheck(GetPlayer()->GetGUID(), packet.PartyIndex);
566 }
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
int8 PartyIndex
Definition: PartyPackets.h:384
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
void StartReadyCheck(ObjectGuid starterGuid, int8 partyIndex, uint32 duration=READYCHECK_DURATION)
Definition: Group.cpp:2365
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDuelAccepted ( )
59 {
60  if (!GetPlayer()->duel) // ignore accept from duel-sender
61  return;
62 
63  Player* player = GetPlayer();
64  Player* plTarget = player->duel->opponent;
65 
66  if (player == player->duel->initiator || !plTarget || player == plTarget || player->duel->startTime != 0 || plTarget->duel->startTime != 0)
67  return;
68 
69  TC_LOG_DEBUG("network", "Player 1 is: %s (%s)", player->GetGUID().ToString().c_str(), player->GetName().c_str());
70  TC_LOG_DEBUG("network", "Player 2 is: %s (%s)", plTarget->GetGUID().ToString().c_str(), plTarget->GetName().c_str());
71 
72  time_t now = time(NULL);
73  player->duel->startTimer = now;
74  plTarget->duel->startTimer = now;
75 
76  WorldPackets::Duel::DuelCountdown packet(3000); // milliseconds
77  WorldPacket const* worldPacket = packet.Write();
78  player->GetSession()->SendPacket(worldPacket);
79  plTarget->GetSession()->SendPacket(worldPacket);
80 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: DuelPackets.h:59
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDuelCancelled ( )
83 {
84  // no duel requested
85  if (!GetPlayer()->duel)
86  return;
87 
88  // player surrendered in a duel using /forfeit
89  if (GetPlayer()->duel->startTime != 0)
90  {
91  GetPlayer()->CombatStopWithPets(true);
92  if (GetPlayer()->duel->opponent)
93  GetPlayer()->duel->opponent->CombatStopWithPets(true);
94 
95  GetPlayer()->CastSpell(GetPlayer(), 7267, true); // beg
96  GetPlayer()->DuelComplete(DUEL_WON);
97  return;
98  }
99 
100  GetPlayer()->DuelComplete(DUEL_INTERRUPTED);
101 }
Definition: SharedDefines.h:4726
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4727

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleDuelResponseOpcode ( WorldPackets::Duel::DuelResponse duelResponse)
51 {
52  if (duelResponse.Accepted)
54  else
56 }
void HandleDuelCancelled()
Definition: DuelHandler.cpp:82
bool Accepted
Definition: DuelPackets.h:105
void HandleDuelAccepted()
Definition: DuelHandler.cpp:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleEjectPassenger ( WorldPackets::Vehicle::EjectPassenger ejectPassenger)
139 {
140  Vehicle* vehicle = _player->GetVehicleKit();
141  if (!vehicle)
142  {
143  TC_LOG_ERROR("network", "HandleEjectPassenger: %s is not in a vehicle!", GetPlayer()->GetGUID().ToString().c_str());
144  return;
145  }
146 
147  if (ejectPassenger.Passenger.IsUnit())
148  {
149  Unit* unit = ObjectAccessor::GetUnit(*_player, ejectPassenger.Passenger);
150  if (!unit) // creatures can be ejected too from player mounts
151  {
152  TC_LOG_ERROR("network", "%s tried to eject %s from vehicle, but the latter was not found in world!", GetPlayer()->GetGUID().ToString().c_str(), ejectPassenger.Passenger.ToString().c_str());
153  return;
154  }
155 
156  if (!unit->IsOnVehicle(vehicle->GetBase()))
157  {
158  TC_LOG_ERROR("network", "%s tried to eject %s, but they are not in the same vehicle", GetPlayer()->GetGUID().ToString().c_str(), ejectPassenger.Passenger.ToString().c_str());
159  return;
160  }
161 
162  VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(unit);
163  ASSERT(seat);
164  if (seat->IsEjectable())
165  unit->ExitVehicle();
166  else
167  TC_LOG_ERROR("network", "%s attempted to eject %s from non-ejectable seat.", GetPlayer()->GetGUID().ToString().c_str(), ejectPassenger.Passenger.ToString().c_str());
168  }
169  else
170  TC_LOG_ERROR("network", "HandleEjectPassenger: %s tried to eject invalid %s ", GetPlayer()->GetGUID().ToString().c_str(), ejectPassenger.Passenger.ToString().c_str());
171 }
Definition: DBCStructure.h:1305
bool IsUnit() const
Definition: ObjectGuid.h:250
Definition: Vehicle.h:32
bool IsOnVehicle(const Unit *vehicle) const
Definition: Unit.cpp:14336
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Player * GetPlayer() const
Definition: WorldSession.h:927
void ExitVehicle(Position const *exitPosition=NULL)
Definition: Unit.cpp:15321
VehicleSeatEntry const * GetSeatForPassenger(Unit const *passenger) const
Returns information on the seat of specified passenger, represented by the format in VehicleSeat...
Definition: Vehicle.cpp:598
string ToString(int i)
Definition: strutil.h:491
ObjectGuid Passenger
Definition: VehiclePackets.h:136
Player * _player
Definition: WorldSession.h:1797
bool IsEjectable() const
Definition: DBCStructure.h:1380
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
Unit * GetBase() const
May be called from scripts.
Definition: Vehicle.h:49

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleEmoteOpcode ( WorldPackets::Chat::EmoteClient packet)
571 {
572  if (!GetPlayer()->IsAlive() || GetPlayer()->HasUnitState(UNIT_STATE_DIED))
573  return;
574 
575  sScriptMgr->OnPlayerClearEmote(GetPlayer());
576 
577  if (_player->GetUInt32Value(UNIT_NPC_EMOTESTATE))
578  _player->SetUInt32Value(UNIT_NPC_EMOTESTATE, 0);
579 }
Definition: UpdateFields.h:136
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleEnableTaxiNodeOpcode ( WorldPackets::Taxi::EnableTaxiNode enableTaxiNode)
32 {
33  Creature* unit = GetPlayer()->GetMap()->GetCreature(enableTaxiNode.Unit);
35 }
bool SendLearnNewTaxiNode(Creature *unit)
Definition: TaxiHandler.cpp:131
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Unit
Definition: TaxiPackets.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleEquipmentSetSave ( WorldPackets::EquipmentSet::SaveEquipmentSet saveEquipmentSet)

cheating check 1 (item equipped but sent empty guid)

cheating check 2 (sent guid does not match equipped item)

clear invalid bits (i > EQUIPMENT_SLOT_END)

1628 {
1629  if (saveEquipmentSet.Set.SetID >= MAX_EQUIPMENT_SET_INDEX) // client set slots amount
1630  return;
1631 
1632  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
1633  {
1634  if (!(saveEquipmentSet.Set.IgnoreMask & (1 << i)))
1635  {
1636  ObjectGuid const& itemGuid = saveEquipmentSet.Set.Pieces[i];
1637 
1638  Item* item = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
1639 
1641  if (!item && !itemGuid.IsEmpty())
1642  return;
1643 
1645  if (item && item->GetGUID() != itemGuid)
1646  return;
1647  }
1648  else
1649  saveEquipmentSet.Set.Pieces[i].Clear();
1650  }
1651 
1652  saveEquipmentSet.Set.IgnoreMask &= 0x7FFFF;
1653 
1654  _player->SetEquipmentSet(std::move(saveEquipmentSet.Set));
1655 }
#define INVENTORY_SLOT_BAG_0
Definition: Item.h:259
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
uint8_t uint8
Definition: Define.h:152
EquipmentSetInfo::EquipmentSetData Set
Definition: EquipmentSetPackets.h:56
Definition: ObjectGuid.h:189
#define MAX_EQUIPMENT_SET_INDEX
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleFarSightOpcode ( WorldPackets::Misc::FarSight packet)
789 {
790  if (packet.Enable)
791  {
792  TC_LOG_DEBUG("network", "Added FarSight %s to %s", _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str(), _player->GetGUID().ToString().c_str());
793  if (WorldObject* target = _player->GetViewpoint())
794  _player->SetSeer(target);
795  else
796  TC_LOG_ERROR("network", "Player %s (%s) requests non-existing seer %s", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), _player->GetGuidValue(PLAYER_FARSIGHT).ToString().c_str());
797  }
798  else
799  {
800  TC_LOG_DEBUG("network", "%s set vision to self", _player->GetGUID().ToString().c_str());
801  _player->SetSeer(_player);
802  }
803 
804  GetPlayer()->UpdateVisibilityForPlayer();
805 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:423
Player * GetPlayer() const
Definition: WorldSession.h:927
bool Enable
Definition: MiscPackets.h:636
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: UpdateFields.h:212

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleForceSpeedChangeAck ( WorldPackets::Movement::MovementSpeedAck packet)
413 {
414 
415  GetPlayer()->ValidateMovementInfo(&packet.Ack.movementInfo);
416 
417  // now can skip not our packet
418  if (_player->GetGUID() != packet.Ack.movementInfo.guid)
419  return;
420 
421  /*----------------*/
422 
423  // client ACK send one packet for mounted/run case and need skip all except last from its
424  // in other cases anti-cheat check can be fail in false case
425  UnitMoveType move_type;
426 
427  static char const* const move_type_name[MAX_MOVE_TYPE] =
428  {
429  "Walk",
430  "Run",
431  "RunBack",
432  "Swim",
433  "SwimBack",
434  "TurnRate",
435  "Flight",
436  "FlightBack",
437  "PitchRate"
438  };
439 
440  OpcodeClient opcode = packet.GetOpcode();
441  switch (opcode)
442  {
443 
444  case CMSG_MOVE_FORCE_WALK_SPEED_CHANGE_ACK: move_type = MOVE_WALK; break;
445  case CMSG_MOVE_FORCE_RUN_SPEED_CHANGE_ACK: move_type = MOVE_RUN; break;
447  case CMSG_MOVE_FORCE_SWIM_SPEED_CHANGE_ACK: move_type = MOVE_SWIM; break;
449  case CMSG_MOVE_FORCE_TURN_RATE_CHANGE_ACK: move_type = MOVE_TURN_RATE; break;
450  case CMSG_MOVE_FORCE_FLIGHT_SPEED_CHANGE_ACK: move_type = MOVE_FLIGHT; break;
453 
454  default:
455  TC_LOG_ERROR("network", "WorldSession::HandleForceSpeedChangeAck: Unknown move type opcode: %u", opcode);
456  return;
457  }
458 
459  // skip all forced speed changes except last and unexpected
460  // in run/mounted case used one ACK and it must be skipped. m_forced_speed_changes[MOVE_RUN] store both.
461  if (_player->m_forced_speed_changes[move_type] > 0)
462  {
463  --_player->m_forced_speed_changes[move_type];
464  if (_player->m_forced_speed_changes[move_type] > 0)
465  return;
466  }
467 
468  if (!_player->GetTransport() && std::fabs(_player->GetSpeed(move_type) - packet.Speed) > 0.01f)
469  {
470  if (_player->GetSpeed(move_type) > packet.Speed) // must be greater - just correct
471  {
472  TC_LOG_ERROR("network", "%sSpeedChange player %s is NOT correct (must be %f instead %f), force set to correct value",
473  move_type_name[move_type], _player->GetName().c_str(), _player->GetSpeed(move_type), packet.Speed);
474  _player->SetSpeed(move_type, _player->GetSpeedRate(move_type), true);
475  }
476  else // must be lesser - cheating
477  {
478  TC_LOG_DEBUG("misc", "Player %s from account id %u kicked for incorrect speed (must be %f instead %f)",
479  _player->GetName().c_str(), _player->GetSession()->GetAccountId(), _player->GetSpeed(move_type), packet.Speed);
480  _player->GetSession()->KickPlayer();
481  }
482  }
483 }
UnitMoveType
Definition: Unit.h:597
Definition: Unit.h:605
#define MAX_MOVE_TYPE
Definition: Unit.h:610
float Speed
Definition: MovementPackets.h:314
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Unit.h:599
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Unit.h:601
Definition: Opcodes.h:422
Definition: Unit.h:602
MovementInfo movementInfo
Definition: MovementPackets.h:292
Definition: Opcodes.h:430
OpcodeClient GetOpcode() const
Definition: Packet.h:72
Definition: Unit.h:607
ObjectGuid guid
Definition: Object.h:270
Definition: Unit.h:600
Definition: Opcodes.h:427
Player * _player
Definition: WorldSession.h:1797
MovementAck Ack
Definition: MovementPackets.h:313
Definition: Unit.h:604
Definition: Unit.h:606
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
OpcodeClient
Definition: Opcodes.h:46
Definition: Unit.h:603
Definition: Opcodes.h:428
Definition: Opcodes.h:425

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGameObjectQueryOpcode ( WorldPackets::Query::QueryGameObject packet)

Only static data is sent in this packet !!!

130 {
132 
133  response.GameObjectID = packet.GameObjectID;
134 
135  if (GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.GameObjectID))
136  {
137  response.Allow = true;
139 
140  stats.Type = gameObjectInfo->type;
141  stats.DisplayID = gameObjectInfo->displayId;
142 
143  stats.Name[0] = gameObjectInfo->name;
144  stats.IconName = gameObjectInfo->IconName;
145  stats.CastBarCaption = gameObjectInfo->castBarCaption;
146  stats.UnkString = gameObjectInfo->unk1;
147 
148  LocaleConstant localeConstant = GetSessionDbLocaleIndex();
149  if (localeConstant >= LOCALE_enUS)
150  if (GameObjectLocale const* gameObjectLocale = sObjectMgr->GetGameObjectLocale(packet.GameObjectID))
151  {
152  ObjectMgr::GetLocaleString(gameObjectLocale->Name, localeConstant, stats.Name[0]);
153  ObjectMgr::GetLocaleString(gameObjectLocale->CastBarCaption, localeConstant, stats.CastBarCaption);
154  ObjectMgr::GetLocaleString(gameObjectLocale->Unk1, localeConstant, stats.UnkString);
155  }
156 
157  stats.Size = gameObjectInfo->size;
158 
159  if (GameObjectQuestItemList const* items = sObjectMgr->GetGameObjectQuestItemList(packet.GameObjectID))
160  for (uint32 item : *items)
161  stats.QuestItems.push_back(item);
162 
163  for (uint32 i = 0; i < MAX_GAMEOBJECT_DATA; i++)
164  stats.Data[i] = gameObjectInfo->raw.data[i];
165  }
166 
167  SendPacket(response.Write());
168 }
uint32 Data[MAX_GAMEOBJECT_DATA]
Definition: QueryPackets.h:235
std::vector< uint32 > GameObjectQuestItemList
Definition: GameObject.h:859
bool Allow
Definition: QueryPackets.h:255
uint32 Type
Definition: QueryPackets.h:233
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1060
Definition: GameObject.h:34
std::string Name[4]
Definition: QueryPackets.h:229
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::string UnkString
Definition: QueryPackets.h:232
Definition: QueryPackets.h:227
GameObjectStats Stats
Definition: QueryPackets.h:256
LocaleConstant
Definition: Common.h:115
WorldPacket const * Write() override
Definition: QueryPackets.cpp:290
Definition: GameObject.h:803
uint32_t uint32
Definition: Define.h:150
uint32 GameObjectID
Definition: QueryPackets.h:254
uint32 GameObjectID
Definition: QueryPackets.h:224
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: QueryPackets.h:247
Definition: Common.h:117
std::vector< int32 > QuestItems
Definition: QueryPackets.h:237
static void GetLocaleString(StringVector const &data, LocaleConstant localeConstant, std::string &value)
Definition: ObjectMgr.h:1345
float Size
Definition: QueryPackets.h:236
std::string IconName
Definition: QueryPackets.h:230
uint32 DisplayID
Definition: QueryPackets.h:234
std::string CastBarCaption
Definition: QueryPackets.h:231
#define MAX_GAMEOBJECT_DATA
Definition: SharedDefines.h:2117

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGameobjectReportUse ( WorldPackets::GameObject::GameObjReportUse packet)
231 {
232  // ignore for remote control state
233  if (_player->m_mover != _player)
234  return;
235 
236  if (GameObject* go = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Guid))
237  {
238  if (go->AI()->GossipHello(_player))
239  return;
240 
241  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_USE_GAMEOBJECT, go->GetEntry());
242  }
243 }
ObjectGuid Guid
Definition: GameObjectPackets.h:47
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: GameObject.h:880
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGameObjectUseOpcode ( WorldPackets::GameObject::GameObjUse packet)
218 {
219  if (GameObject* obj = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Guid))
220  {
221  // ignore for remote control state
222  if (GetPlayer()->m_mover != GetPlayer())
223  if (!(GetPlayer()->IsOnVehicle(GetPlayer()->m_mover) || GetPlayer()->IsMounted()) && !obj->GetGOInfo()->IsUsableMounted())
224  return;
225 
226  obj->Use(GetPlayer());
227  }
228 }
ObjectGuid Guid
Definition: GameObjectPackets.h:37
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: GameObject.h:880

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGarrisonCancelConstruction ( WorldPackets::Garrison::GarrisonCancelConstruction garrisonCancelConstruction)
38 {
39  if (!_player->GetNPCIfCanInteractWith(garrisonCancelConstruction.NpcGUID, UNIT_NPC_FLAG_GARRISON_ARCHITECT))
40  return;
41 
42  if (Garrison* garrison = _player->GetGarrison())
43  garrison->CancelBuildingConstruction(garrisonCancelConstruction.PlotInstanceID);
44 }
Definition: Garrison.h:83
ObjectGuid NpcGUID
Definition: GarrisonPackets.h:188
uint32 PlotInstanceID
Definition: GarrisonPackets.h:189
Player * _player
Definition: WorldSession.h:1797
Definition: Unit.h:767

+ Here is the caller graph for this function:

void WorldSession::HandleGarrisonGetBuildingLandmarks ( WorldPackets::Garrison::GarrisonGetBuildingLandmarks garrisonGetBuildingLandmarks)
53 {
54  if (Garrison* garrison = _player->GetGarrison())
55  garrison->SendBuildingLandmarks(_player);
56 }
Definition: Garrison.h:83
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleGarrisonPurchaseBuilding ( WorldPackets::Garrison::GarrisonPurchaseBuilding garrisonPurchaseBuilding)
29 {
30  if (!_player->GetNPCIfCanInteractWith(garrisonPurchaseBuilding.NpcGUID, UNIT_NPC_FLAG_GARRISON_ARCHITECT))
31  return;
32 
33  if (Garrison* garrison = _player->GetGarrison())
34  garrison->PlaceBuilding(garrisonPurchaseBuilding.PlotInstanceID, garrisonPurchaseBuilding.BuildingID);
35 }
uint32 BuildingID
Definition: GarrisonPackets.h:165
Definition: Garrison.h:83
Player * _player
Definition: WorldSession.h:1797
ObjectGuid NpcGUID
Definition: GarrisonPackets.h:164
uint32 PlotInstanceID
Definition: GarrisonPackets.h:166
Definition: Unit.h:767

+ Here is the caller graph for this function:

void WorldSession::HandleGarrisonRequestBlueprintAndSpecializationData ( WorldPackets::Garrison::GarrisonRequestBlueprintAndSpecializationData garrisonRequestBlueprintAndSpecializationData)
47 {
48  if (Garrison* garrison = _player->GetGarrison())
49  garrison->SendBlueprintAndSpecializationData();
50 }
Definition: Garrison.h:83
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleGetGarrisonInfo ( WorldPackets::Garrison::GetGarrisonInfo getGarrisonInfo)
23 {
24  if (Garrison* garrison = _player->GetGarrison())
25  garrison->SendInfo();
26 }
Definition: Garrison.h:83
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleGetItemPurchaseData ( WorldPackets::Item::GetItemPurchaseData packet)
1073 {
1074  Item* item = _player->GetItemByGuid(packet.ItemGUID);
1075  if (!item)
1076  {
1077  TC_LOG_DEBUG("network", "HandleGetItemPurchaseData: Item %s not found!", packet.ItemGUID.ToString().c_str());
1078  return;
1079  }
1080 
1081  TC_LOG_DEBUG("network", "HandleGetItemPurchaseData: Item %s", packet.ItemGUID.ToString().c_str());
1082 
1083  GetPlayer()->SendRefundInfo(item);
1084 }
ObjectGuid ItemGUID
Definition: ItemPackets.h:115
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Item.h:259
Player * _player
Definition: WorldSession.h:1797
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGetMailList ( WorldPackets::Mail::MailGetList packet)
567 {
568  if (!CanOpenMailBox(packet.Mailbox))
569  return;
570 
571  Player* player = _player;
572 
573  //load players mails, and mailed items
574  if (!player->m_mailsLoaded)
575  player->_LoadMail();
576 
578  time_t curTime = time(nullptr);
579 
580  for (Mail* m : player->GetMails())
581  {
582  // skip deleted or not delivered (deliver delay not expired) mails
583  if (m->state == MAIL_STATE_DELETED || curTime < m->deliver_time)
584  continue;
585 
586  // max. 50 mails can be sent
587  if (response.Mails.size() < 50)
588  response.Mails.emplace_back(m, player);
589 
590  ++response.TotalNumRecords;
591  }
592 
593  SendPacket(response.Write());
594 
595  // recalculate m_nextMailDelivereTime and unReadMails
596  _player->UpdateNextMailTimeAndUnreads();
597 }
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Mail.h:166
int32 TotalNumRecords
Definition: MailPackets.h:91
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Mail.h:71
std::vector< MailListEntry > Mails
Definition: MailPackets.h:92
ObjectGuid Mailbox
Definition: MailPackets.h:80
Player * _player
Definition: WorldSession.h:1797
Definition: MailPackets.h:84
WorldPacket const * Write() override
Definition: MailPackets.cpp:144

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGetPVPOptionsEnabled ( WorldPackets::Battleground::GetPVPOptionsEnabled getPvPOptionsEnabled)
626 {
627  // This packet is completely irrelevant, it triggers PVP_TYPES_ENABLED lua event but that is not handled in interface code as of 6.1.2
629  pvpOptionsEnabled.WargameArenas = false;
630  pvpOptionsEnabled.RatedArenas = false;
631  pvpOptionsEnabled.WargameBattlegrounds = false;
632  pvpOptionsEnabled.ArenaSkirmish = false;
633  pvpOptionsEnabled.PugBattlegrounds = true;
634  pvpOptionsEnabled.RatedBattlegrounds = false;
635  SendPacket(pvpOptionsEnabled.Write());
636 }
bool RatedArenas
Definition: BattlegroundPackets.h:299
bool WargameBattlegrounds
Definition: BattlegroundPackets.h:300
bool RatedBattlegrounds
Definition: BattlegroundPackets.h:303
bool ArenaSkirmish
Definition: BattlegroundPackets.h:301
bool PugBattlegrounds
Definition: BattlegroundPackets.h:302
Definition: BattlegroundPackets.h:291
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool WargameArenas
Definition: BattlegroundPackets.h:298
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:227

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGetUndeleteCooldownStatus ( WorldPackets::Character::GetUndeleteCharacterCooldownStatus )

empty result to force wait

2308 {
2311  result.set_value(PreparedQueryResult(nullptr));
2312  _undeleteCooldownStatusCallback.SetFutureResult(result.get_future());
2313 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
QueryCallback< PreparedQueryResult, bool, true > _undeleteCooldownStatusCallback
Definition: WorldSession.h:1742
std::promise< PreparedQueryResult > PreparedQueryResultPromise
Definition: Callback.h:27
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGMTicketGetCaseStatusOpcode ( WorldPackets::Ticket::GMTicketGetCaseStatus packet)
30 {
31  // TODO: Implement GmCase and handle this packet properly
33  SendPacket(status.Write());
34 }
Definition: TicketPackets.h:62
WorldPacket const * Write() override
Definition: TicketPackets.cpp:41
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGMTicketSystemStatusOpcode ( WorldPackets::Ticket::GMTicketGetSystemStatus packet)
37 {
38  // Note: This only disables the ticket UI at client side and is not fully reliable
39  // Note: This disables the whole customer support UI after trying to send a ticket in disabled state (MessageBox: "GM Help Tickets are currently unavaiable."). UI remains disabled until the character relogs.
41  response.Status = sSupportMgr->GetSupportSystemStatus() ? GMTICKET_QUEUE_STATUS_ENABLED : GMTICKET_QUEUE_STATUS_DISABLED;
42  SendPacket(response.Write());
43 }
Definition: SupportMgr.h:31
Definition: TicketPackets.h:44
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: SupportMgr.h:30
#define sSupportMgr
Definition: SupportMgr.h:296
WorldPacket const * Write() override
Definition: TicketPackets.cpp:34
int32 Status
Definition: TicketPackets.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGossipHelloOpcode ( WorldPackets::NPC::Hello packet)
259 {
260  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_GOSSIP);
261  if (!unit)
262  {
263  TC_LOG_DEBUG("network", "WORLD: HandleGossipHelloOpcode - %s not found or you can not interact with him.", packet.Unit.ToString().c_str());
264  return;
265  }
266 
267  // set faction visible if needed
268  if (FactionTemplateEntry const* factionTemplateEntry = sFactionTemplateStore.LookupEntry(unit->getFaction()))
269  _player->GetReputationMgr().SetVisible(factionTemplateEntry);
270 
271  GetPlayer()->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_TALK);
272  // remove fake death
273  //if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
274  // GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
275 
276  if (unit->IsArmorer() || unit->IsCivilian() || unit->IsQuestGiver() || unit->IsServiceProvider() || unit->IsGuard())
277  unit->StopMoving();
278 
279  // If spiritguide, no need for gossip menu, just put player into resurrect queue
280  if (unit->IsSpiritGuide())
281  {
282  Battleground* bg = _player->GetBattleground();
283  if (bg)
284  {
285  bg->AddPlayerToResurrectQueue(unit->GetGUID(), _player->GetGUID());
286  sBattlegroundMgr->SendAreaSpiritHealerQueryOpcode(_player, bg, unit->GetGUID());
287  return;
288  }
289  }
290 
291  if (!sScriptMgr->OnGossipHello(_player, unit))
292  {
293 // _player->TalkedToCreature(unit->GetEntry(), unit->GetGUID());
294  _player->PrepareGossipMenu(unit, unit->GetCreatureTemplate()->GossipMenuId, true);
295  _player->SendPreparedGossip(unit);
296  }
297  unit->AI()->sGossipHello(_player);
298 }
Definition: Unit.h:735
bool IsArmorer() const
Definition: Unit.h:1577
uint32 getFaction() const
Definition: Unit.h:1466
Definition: Unit.h:64
uint32 GossipMenuId
Definition: Creature.h:92
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsSpiritGuide() const
Definition: Unit.h:1574
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
bool IsQuestGiver() const
Definition: Unit.h:1566
CreatureAI * AI() const
Definition: Creature.h:525
Definition: DBCStructure.h:433
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void AddPlayerToResurrectQueue(ObjectGuid npc_guid, ObjectGuid player_guid)
Definition: Battleground.cpp:1395
bool IsGuard() const
Definition: Creature.h:497
bool IsCivilian() const
Definition: Creature.h:495
Player * _player
Definition: WorldSession.h:1797
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
Definition: Battleground.h:235
bool IsServiceProvider() const
Definition: Unit.cpp:9831
#define sScriptMgr
Definition: ScriptMgr.h:837
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplatefmt)
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Unit
Definition: NPCPackets.h:45
virtual void sGossipHello(Player *)
Definition: UnitAI.h:253

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGossipSelectOptionOpcode ( WorldPackets::NPC::GossipSelectOption packet)
301 {
302  if (!_player->PlayerTalkClass->GetGossipMenu().GetItem(packet.GossipIndex))
303  return;
304 
305  // Prevent cheating on C++ scripted menus
306  if (_player->PlayerTalkClass->GetGossipMenu().GetSenderGUID() != packet.GossipUnit)
307  return;
308 
309  Creature* unit = nullptr;
310  GameObject* go = nullptr;
311  if (packet.GossipUnit.IsCreatureOrVehicle())
312  {
313  unit = GetPlayer()->GetNPCIfCanInteractWith(packet.GossipUnit, UNIT_NPC_FLAG_GOSSIP);
314  if (!unit)
315  {
316  TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with him.", packet.GossipUnit.ToString().c_str());
317  return;
318  }
319  }
320  else if (packet.GossipUnit.IsGameObject())
321  {
322  go = _player->GetGameObjectIfCanInteractWith(packet.GossipUnit);
323  if (!go)
324  {
325  TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found or you can't interact with it.", packet.GossipUnit.ToString().c_str());
326  return;
327  }
328  }
329  else
330  {
331 
332  TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - unsupported %s.", packet.GossipUnit.ToString().c_str());
333  return;
334  }
335 
336  // remove fake death
337  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
338  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
339 
340  if ((unit && unit->GetCreatureTemplate()->ScriptID != unit->LastUsedScriptID) || (go && go->GetGOInfo()->ScriptId != go->LastUsedScriptID))
341  {
342  TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - Script reloaded while in use, ignoring and set new scipt id");
343  if (unit)
345 
346  if (go)
347  go->LastUsedScriptID = go->GetGOInfo()->ScriptId;
348  _player->PlayerTalkClass->SendCloseGossip();
349  return;
350  }
351 
352  if (!packet.PromotionCode.empty())
353  {
354  if (unit)
355  {
356  unit->AI()->sGossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str());
357  if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str()))
358  _player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
359  }
360  else
361  {
362  go->AI()->GossipSelectCode(_player, packet.GossipID, packet.GossipIndex, packet.PromotionCode.c_str());
363  if (!sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex), packet.PromotionCode.c_str()))
364  _player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
365  }
366  }
367  else
368  {
369  if (unit)
370  {
371  unit->AI()->sGossipSelect(_player, packet.GossipID, packet.GossipIndex);
372  if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex)))
373  _player->OnGossipSelect(unit, packet.GossipIndex, packet.GossipID);
374  }
375  else
376  {
377  go->AI()->GossipSelect(_player, packet.GossipID, packet.GossipIndex);
378  if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(packet.GossipIndex), _player->PlayerTalkClass->GetGossipOptionAction(packet.GossipIndex)))
379  _player->OnGossipSelect(go, packet.GossipIndex, packet.GossipID);
380  }
381  }
382 }
bool IsCreatureOrVehicle() const
Definition: ObjectGuid.h:247
virtual void sGossipSelect(Player *, uint32, uint32)
Definition: UnitAI.h:254
bool IsGameObject() const
Definition: ObjectGuid.h:252
GameObjectAI * AI() const
Definition: GameObject.h:1061
Definition: Unit.h:735
int32 GossipID
Definition: NPCPackets.h:92
virtual bool GossipSelect(Player *, uint32, uint32)
Definition: GameObjectAI.h:51
std::string PromotionCode
Definition: NPCPackets.h:93
virtual bool GossipSelectCode(Player *, uint32, uint32, char const *)
Definition: GameObjectAI.h:52
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
virtual void sGossipSelectCode(Player *, uint32, uint32, char const *)
Definition: UnitAI.h:255
CreatureTemplate const * GetCreatureTemplate() const
Definition: Creature.h:558
CreatureAI * AI() const
Definition: Creature.h:525
Definition: SpellAuraDefines.h:126
GameObjectTemplate const * GetGOInfo() const
Definition: GameObject.h:894
Definition: GameObject.h:880
int32 GossipIndex
Definition: NPCPackets.h:91
uint32 ScriptId
Definition: GameObject.h:625
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 ScriptID
Definition: Creature.h:143
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid GossipUnit
Definition: NPCPackets.h:90
uint32 LastUsedScriptID
Definition: Object.h:599

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGrantLevel ( WorldPackets::RaF::GrantLevel grantLevel)
25 {
26  Player* target = ObjectAccessor::GetPlayer(*_player, grantLevel.Target);
27 
28  // check cheating
29  uint8 levels = _player->GetGrantableLevels();
30  uint8 error = 0;
31  if (!target)
32  error = ERR_REFER_A_FRIEND_NO_TARGET;
33  else if (levels == 0)
34  error = ERR_REFER_A_FRIEND_INSUFFICIENT_GRANTABLE_LEVELS;
35  else if (GetRecruiterId() != target->GetSession()->GetAccountId())
36  error = ERR_REFER_A_FRIEND_NOT_REFERRED_BY;
37  else if (target->GetTeamId() != _player->GetTeamId())
38  error = ERR_REFER_A_FRIEND_DIFFERENT_FACTION;
39  else if (target->getLevel() >= _player->getLevel())
40  error = ERR_REFER_A_FRIEND_TARGET_TOO_HIGH;
41  else if (target->getLevel() >= sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
42  error = ERR_REFER_A_FRIEND_GRANT_LEVEL_MAX_I;
43  else if (target->GetGroup() != _player->GetGroup())
44  error = ERR_REFER_A_FRIEND_NOT_IN_GROUP;
45  else if (target->getLevel() >= GetMaxLevelForExpansion(target->GetSession()->GetExpansion()))
46  error = ERR_REFER_A_FRIEND_INSUF_EXPAN_LVL;
47 
48  if (error)
49  {
51  failure.Reason = error;
52  if (error == ERR_REFER_A_FRIEND_NOT_IN_GROUP)
53  failure.Str = target->GetName();
54 
55  SendPacket(failure.Write());
56  return;
57  }
58 
59  WorldPackets::RaF::ProposeLevelGrant proposeLevelGrant;
60  proposeLevelGrant.Sender = _player->GetGUID();
61  target->SendDirectMessage(proposeLevelGrant.Write());
62 }
ObjectGuid Target
Definition: ReferAFriendPackets.h:45
int32 Reason
Definition: ReferAFriendPackets.h:66
#define sWorld
Definition: World.h:887
ObjectGuid Sender
Definition: ReferAFriendPackets.h:55
std::string Str
Definition: ReferAFriendPackets.h:65
WorldPacket const * Write() override
Definition: ReferAFriendPackets.cpp:30
TC_GAME_API Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:184
Definition: ReferAFriendPackets.h:58
uint32 GetMaxLevelForExpansion(uint32 expansion)
Definition: DBCStores.cpp:610
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: ReferAFriendPackets.h:48
uint32 GetRecruiterId() const
Definition: WorldSession.h:1085
Player * _player
Definition: WorldSession.h:1797
WorldPacket const * Write() override
Definition: ReferAFriendPackets.cpp:37
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildAcceptInvite ( WorldPackets::Guild::AcceptGuildInvite invite)
66 {
67  if (!GetPlayer()->GetGuildId())
68  if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildIdInvited()))
69  guild->HandleAcceptMember(this);
70 }
#define sGuildMgr
Definition: GuildMgr.h:61
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildAddRank ( WorldPackets::Guild::GuildAddRank packet)
153 {
154  TC_LOG_DEBUG("guild", "CMSG_GUILD_ADD_RANK [%s]: Rank: %s", GetPlayerInfo().c_str(), packet.Name.c_str());
155 
156  if (Guild* guild = GetPlayer()->GetGuild())
157  guild->HandleAddNewRank(this, packet.Name);
158 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string Name
Definition: GuildPackets.h:450
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildAssignRank ( WorldPackets::Guild::GuildAssignMemberRank packet)
103 {
104  ObjectGuid setterGuid = GetPlayer()->GetGUID();
105 
106  TC_LOG_DEBUG("guild", "CMSG_GUILD_ASSIGN_MEMBER_RANK [%s]: Target: %s Rank: %u, Issuer: %s",
107  GetPlayerInfo().c_str(), packet.Member.ToString().c_str(), packet.RankOrder, setterGuid.ToString().c_str());
108 
109  if (Guild* guild = GetPlayer()->GetGuild())
110  guild->HandleSetMemberRank(this, packet.Member, setterGuid, packet.RankOrder);
111 }
int32 RankOrder
Definition: GuildPackets.h:462
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
ObjectGuid Member
Definition: GuildPackets.h:461
Definition: ObjectGuid.h:189
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankActivate ( WorldPackets::Guild::GuildBankActivate packet)
229 {
230  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_ACTIVATE [%s]: [%s] AllSlots: %u"
231  , GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.FullUpdate);
232 
233  GameObject const* const go = GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK);
234  if (!go)
235  return;
236 
237  Guild* const guild = GetPlayer()->GetGuild();
238  if (!guild)
239  {
241  return;
242  }
243 
244  guild->SendBankList(this, 0, packet.FullUpdate);
245 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
void SendBankList(WorldSession *session, uint8 tabId, bool fullUpdate) const
Definition: Guild.cpp:3252
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
bool FullUpdate
Definition: GuildPackets.h:701
Definition: GameObject.h:880
ObjectGuid Banker
Definition: GuildPackets.h:700
Definition: Guild.h:134
Definition: Guild.h:117
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankBuyTab ( WorldPackets::Guild::GuildBankBuyTab packet)
304 {
305  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_BUY_TAB [%s]: [%s[, TabId: %u", GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.BankTab);
306 
307  if (!packet.Banker || GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
308  if (Guild* guild = GetPlayer()->GetGuild())
309  guild->HandleBuyBankTab(this, packet.BankTab);
310 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8 BankTab
Definition: GuildPackets.h:712
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Banker
Definition: GuildPackets.h:711

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankDepositMoney ( WorldPackets::Guild::GuildBankDepositMoney packet)
259 {
260  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_DEPOSIT_MONEY [%s]: [%s], money: " UI64FMTD,
261  GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.Money);
262 
263  if (GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
264  if (packet.Money && GetPlayer()->HasEnoughMoney(packet.Money))
265  if (Guild* guild = GetPlayer()->GetGuild())
266  guild->HandleMemberDepositMoney(this, packet.Money);
267 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
ObjectGuid Banker
Definition: GuildPackets.h:735
#define UI64FMTD
Definition: Define.h:137
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint64 Money
Definition: GuildPackets.h:736

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankLogQuery ( WorldPackets::Guild::GuildBankLogQuery packet)
324 {
325  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_LOG_QUERY [%s]: TabId: %u", GetPlayerInfo().c_str(), packet.Tab);
326 
327  if (Guild* guild = GetPlayer()->GetGuild())
328  guild->SendBankLog(this, packet.Tab);
329 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 Tab
Definition: GuildPackets.h:852
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankMoneyWithdrawn ( WorldPackets::Guild::GuildBankRemainingWithdrawMoneyQuery packet)
216 {
217  if (Guild* guild = GetPlayer()->GetGuild())
218  guild->SendMoneyInfo(this);
219 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankQueryTab ( WorldPackets::Guild::GuildBankQueryTab packet)
249 {
250  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TAB [%s]: %s, TabId: %u, ShowTabs: %u"
251  , GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.Tab, packet.FullUpdate);
252 
253  if (GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
254  if (Guild* guild = GetPlayer()->GetGuild())
255  guild->SendBankList(this, packet.Tab, packet.FullUpdate);
256 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
bool FullUpdate
Definition: GuildPackets.h:748
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8 Tab
Definition: GuildPackets.h:747
ObjectGuid Banker
Definition: GuildPackets.h:746
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankSetTabText ( WorldPackets::Guild::GuildBankSetTabText packet)
340 {
341  TC_LOG_DEBUG("guild", "CMSG_SET_GUILD_BANK_TEXT [%s]: TabId: %u, Text: %s", GetPlayerInfo().c_str(), packet.Tab, packet.TabText.c_str());
342 
343  if (Guild* guild = GetPlayer()->GetGuild())
344  guild->SetBankTabText(packet.Tab, packet.TabText);
345 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 Tab
Definition: GuildPackets.h:906
std::string TabText
Definition: GuildPackets.h:907
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankSwapItems ( WorldPackets::Guild::GuildBankSwapItems packet)
280 {
281  if (!GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
282  return;
283 
284  Guild* guild = GetPlayer()->GetGuild();
285  if (!guild)
286  return;
287 
288  if (packet.BankOnly)
289  {
290  guild->SwapItems(GetPlayer(), packet.BankTab1, packet.BankSlot1, packet.BankTab, packet.BankSlot, packet.StackCount);
291  }
292  else
293  {
294  // Player <-> Bank
295  // Allow to work with inventory only
296  if (!Player::IsInventoryPos(packet.ContainerSlot, packet.ContainerItemSlot) && !packet.AutoStore)
297  GetPlayer()->SendEquipError(EQUIP_ERR_INTERNAL_BAG_ERROR, NULL);
298  else
299  guild->SwapItemsWithInventory(GetPlayer(), packet.ToSlot != 0, packet.BankTab, packet.BankSlot, packet.ContainerSlot, packet.ContainerItemSlot, packet.StackCount);
300  }
301 }
uint8 BankTab1
Definition: GuildPackets.h:838
uint8 BankSlot1
Definition: GuildPackets.h:836
uint8 ContainerSlot
Definition: GuildPackets.h:839
bool AutoStore
Definition: GuildPackets.h:841
uint8 BankSlot
Definition: GuildPackets.h:835
arena_t NULL
Definition: jemalloc_internal.h:624
void SwapItems(Player *player, uint8 tabId, uint8 slotId, uint8 destTabId, uint8 destSlotId, uint32 splitedAmount)
Definition: Guild.cpp:2726
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
bool BankOnly
Definition: GuildPackets.h:842
int32 StackCount
Definition: GuildPackets.h:830
Definition: Item.h:88
void SwapItemsWithInventory(Player *player, bool toChar, uint8 tabId, uint8 slotId, uint8 playerBag, uint8 playerSlotId, uint32 splitedAmount)
Definition: Guild.cpp:2740
uint8 BankTab
Definition: GuildPackets.h:837
uint8 ContainerItemSlot
Definition: GuildPackets.h:840
uint8 ToSlot
Definition: GuildPackets.h:834
ObjectGuid Banker
Definition: GuildPackets.h:829
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankTextQuery ( WorldPackets::Guild::GuildBankTextQuery packet)
332 {
333  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_QUERY_TEXT [%s]: TabId: %u", GetPlayerInfo().c_str(), packet.Tab);
334 
335  if (Guild* guild = GetPlayer()->GetGuild())
336  guild->SendBankTabText(this, packet.Tab);
337 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 Tab
Definition: GuildPackets.h:885
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankUpdateTab ( WorldPackets::Guild::GuildBankUpdateTab packet)
313 {
314  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_UPDATE_TAB [%s]: [%s], TabId: %u, Name: %s, Icon: %s"
315  , GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.BankTab, packet.Name.c_str(), packet.Icon.c_str());
316 
317  if (!packet.Name.empty() && !packet.Icon.empty())
318  if (GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
319  if (Guild* guild = GetPlayer()->GetGuild())
320  guild->HandleSetBankTabInfo(this, packet.BankTab, packet.Name, packet.Icon);
321 }
uint8 BankTab
Definition: GuildPackets.h:723
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
ObjectGuid Banker
Definition: GuildPackets.h:722
std::string Name
Definition: GuildPackets.h:724
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
std::string Icon
Definition: GuildPackets.h:725
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildBankWithdrawMoney ( WorldPackets::Guild::GuildBankWithdrawMoney packet)
270 {
271  TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_WITHDRAW_MONEY [%s]: [%s], money: " UI64FMTD,
272  GetPlayerInfo().c_str(), packet.Banker.ToString().c_str(), packet.Money);
273 
274  if (packet.Money && GetPlayer()->GetGameObjectIfCanInteractWith(packet.Banker, GAMEOBJECT_TYPE_GUILD_BANK))
275  if (Guild* guild = GetPlayer()->GetGuild())
276  guild->HandleMemberWithdrawMoney(this, packet.Money);
277 }
ObjectGuid Banker
Definition: GuildPackets.h:777
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:2099
uint64 Money
Definition: GuildPackets.h:778
#define UI64FMTD
Definition: Define.h:137
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildChallengeUpdateRequest ( WorldPackets::Guild::GuildChallengeUpdateRequest packet)
369 {
370  if (Guild* guild = _player->GetGuild())
371  guild->HandleGuildRequestChallengeUpdate(this);
372 }
Player * _player
Definition: WorldSession.h:1797
Definition: Guild.h:320

+ Here is the caller graph for this function:

void WorldSession::HandleGuildDeclineInvitation ( WorldPackets::Guild::GuildDeclineInvitation decline)
73 {
74  GetPlayer()->SetGuildIdInvited(UI64LIT(0));
75  GetPlayer()->SetInGuild(UI64LIT(0));
76 }
#define UI64LIT(N)
Definition: Define.h:138
Player * GetPlayer() const
Definition: WorldSession.h:927

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildDelete ( WorldPackets::Guild::GuildDelete packet)
120 {
121  if (Guild* guild = GetPlayer()->GetGuild())
122  guild->HandleDelete(this);
123 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildDeleteRank ( WorldPackets::Guild::GuildDeleteRank packet)
161 {
162  TC_LOG_DEBUG("guild", "CMSG_GUILD_DELETE_RANK [%s]: Rank: %u", GetPlayerInfo().c_str(), packet.RankOrder);
163 
164  if (Guild* guild = GetPlayer()->GetGuild())
165  guild->HandleRemoveRank(this, packet.RankOrder);
166 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
int32 RankOrder
Definition: GuildPackets.h:472
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildDemoteMember ( WorldPackets::Guild::GuildDemoteMember demote)
95 {
96  TC_LOG_DEBUG("guild", "CMSG_GUILD_DEMOTE [%s]: Target: %s", GetPlayerInfo().c_str(), demote.Demotee.ToString().c_str());
97 
98  if (Guild* guild = GetPlayer()->GetGuild())
99  guild->HandleUpdateMemberRank(this, demote.Demotee, true);
100 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Demotee
Definition: GuildPackets.h:587

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildEventLogQuery ( WorldPackets::Guild::GuildEventLogQuery packet)
208 {
209  TC_LOG_DEBUG("guild", "MSG_GUILD_EVENT_LOG_QUERY [%s]", GetPlayerInfo().c_str());
210 
211  if (Guild* guild = GetPlayer()->GetGuild())
212  guild->SendEventLog(this);
213 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderAddRecruit ( WorldPackets::GuildFinder::LFGuildAddRecruit lfGuildAddRecruit)
28 {
29  if (sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUID()) >= 10)
30  return;
31 
32  if (!lfGuildAddRecruit.GuildGUID.IsGuild())
33  return;
34  if (!(lfGuildAddRecruit.ClassRoles & GUILDFINDER_ALL_ROLES) || lfGuildAddRecruit.ClassRoles > GUILDFINDER_ALL_ROLES)
35  return;
36  if (!(lfGuildAddRecruit.Availability & AVAILABILITY_ALWAYS) || lfGuildAddRecruit.Availability > AVAILABILITY_ALWAYS)
37  return;
38  if (!(lfGuildAddRecruit.PlayStyle & ALL_INTERESTS) || lfGuildAddRecruit.PlayStyle > ALL_INTERESTS)
39  return;
40 
41  MembershipRequest request = MembershipRequest(GetPlayer()->GetGUID(), lfGuildAddRecruit.GuildGUID, lfGuildAddRecruit.Availability,
42  lfGuildAddRecruit.ClassRoles, lfGuildAddRecruit.PlayStyle, lfGuildAddRecruit.Comment, time(NULL));
43  sGuildFinderMgr->AddMembershipRequest(lfGuildAddRecruit.GuildGUID, request);
44 }
int32 Availability
Definition: GuildFinderPackets.h:36
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: GuildFinderMgr.h:47
Holds all required informations about a membership request.
Definition: GuildFinderMgr.h:58
int32 ClassRoles
Definition: GuildFinderPackets.h:37
ObjectGuid GuildGUID
Definition: GuildFinderPackets.h:35
std::string Comment
Definition: GuildFinderPackets.h:39
int32 PlayStyle
Definition: GuildFinderPackets.h:38
Definition: GuildFinderMgr.h:39
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: GuildFinderMgr.h:32
bool IsGuild() const
Definition: ObjectGuid.h:259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderBrowse ( WorldPackets::GuildFinder::LFGuildBrowse lfGuildBrowse)
47 {
48  if (!(lfGuildBrowse.ClassRoles & GUILDFINDER_ALL_ROLES) || lfGuildBrowse.ClassRoles > GUILDFINDER_ALL_ROLES)
49  return;
50  if (!(lfGuildBrowse.Availability & AVAILABILITY_ALWAYS) || lfGuildBrowse.Availability > AVAILABILITY_ALWAYS)
51  return;
52  if (!(lfGuildBrowse.PlayStyle & ALL_INTERESTS) || lfGuildBrowse.PlayStyle > ALL_INTERESTS)
53  return;
54  if (lfGuildBrowse.CharacterLevel > int32(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) || lfGuildBrowse.CharacterLevel < 1)
55  return;
56 
57  Player* player = GetPlayer();
58 
59  LFGuildPlayer settings(player->GetGUID(), lfGuildBrowse.ClassRoles, lfGuildBrowse.Availability, lfGuildBrowse.PlayStyle, ANY_FINDER_LEVEL);
60  std::vector<LFGuildSettings const*> guildList = sGuildFinderMgr->GetGuildsMatchingSetting(settings, player->GetTeamId());
61 
63  lfGuildBrowseResult.Post.resize(guildList.size());
64 
65  for (std::size_t i = 0; i < guildList.size(); ++i)
66  {
67  LFGuildSettings const* guildSettings = guildList[i];
68  WorldPackets::GuildFinder::LFGuildBrowseData& guildData = lfGuildBrowseResult.Post[i];
69  Guild* guild = ASSERT_NOTNULL(sGuildMgr->GetGuildByGuid(guildSettings->GetGUID()));
70 
71  guildData.GuildName = guild->GetName();
72  guildData.GuildGUID = guild->GetGUID();
74  guildData.GuildMembers = guild->GetMembersCount();
76  guildData.PlayStyle = guildSettings->GetInterests();
77  guildData.Availability = guildSettings->GetAvailability();
78  guildData.ClassRoles = guildSettings->GetClassRoles();
79  guildData.LevelRange = guildSettings->GetLevel();
80  guildData.EmblemStyle = guild->GetEmblemInfo().GetStyle();
81  guildData.EmblemColor = guild->GetEmblemInfo().GetColor();
82  guildData.BorderStyle = guild->GetEmblemInfo().GetBorderStyle();
83  guildData.BorderColor = guild->GetEmblemInfo().GetBorderColor();
84  guildData.Background = guild->GetEmblemInfo().GetBackgroundColor();
85  guildData.Comment = guildSettings->GetComment();
86  guildData.Cached = 0;
87  guildData.MembershipRequested = sGuildFinderMgr->HasRequest(player->GetGUID(), guild->GetGUID());
88  }
89 
90  player->SendDirectMessage(lfGuildBrowseResult.Write());
91 }
WorldPacket const * Write() override
Definition: GuildFinderPackets.cpp:62
int32 EmblemColor
Definition: GuildFinderPackets.h:83
T * ASSERT_NOTNULL(T *pointer)
Definition: Errors.h:58
uint8 GetClassRoles() const
Definition: GuildFinderMgr.h:140
int32 GuildAchievementPoints
Definition: GuildFinderPackets.h:77
int32 PlayStyle
Definition: GuildFinderPackets.h:68
uint8 GetLevel() const
Definition: GuildFinderMgr.h:143
#define sGuildMgr
Definition: GuildMgr.h:61
ObjectGuid const & GetGUID() const
Definition: GuildFinderMgr.h:139
Holds settings for a guild in the finder system. Saved to database.
Definition: GuildFinderMgr.h:156
std::string const & GetName() const
Definition: Guild.h:766
EmblemInfo const & GetEmblemInfo() const
Definition: Guild.h:876
Definition: GuildFinderPackets.h:71
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
uint32 GetMembersCount() const
Definition: Guild.h:859
Definition: GuildFinderMgr.h:47
int32 EmblemStyle
Definition: GuildFinderPackets.h:82
ObjectGuid GuildGUID
Definition: GuildFinderPackets.h:74
uint32 GetBorderColor() const
Definition: Guild.h:277
uint32 GetBorderStyle() const
Definition: Guild.h:276
int32 ClassRoles
Definition: GuildFinderPackets.h:80
int8 Cached
Definition: GuildFinderPackets.h:88
int32 Availability
Definition: GuildFinderPackets.h:79
std::vector< LFGuildBrowseData > Post
Definition: GuildFinderPackets.h:99
uint32 GetColor() const
Definition: Guild.h:275
std::string const & GetComment() const
Definition: GuildFinderMgr.h:144
int32 Availability
Definition: GuildFinderPackets.h:66
int32 LevelRange
Definition: GuildFinderPackets.h:81
int32_t int32
Definition: Define.h:146
std::string Comment
Definition: GuildFinderPackets.h:87
uint32 GetStyle() const
Definition: Guild.h:274
ObjectGuid GetGUID() const
Definition: Guild.h:764
uint8 GetAvailability() const
Definition: GuildFinderMgr.h:141
int32 PlayStyle
Definition: GuildFinderPackets.h:78
int32 BorderColor
Definition: GuildFinderPackets.h:85
int32 CharacterLevel
Definition: GuildFinderPackets.h:65
AchievementMgr< Guild > & GetAchievementMgr()
Definition: Guild.h:868
int32 ClassRoles
Definition: GuildFinderPackets.h:67
std::string GuildName
Definition: GuildFinderPackets.h:73
uint32 GetAchievementPoints() const
Definition: AchievementMgr.h:339
int32 BorderStyle
Definition: GuildFinderPackets.h:84
int32 GuildMembers
Definition: GuildFinderPackets.h:76
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint8 GetInterests() const
Definition: GuildFinderMgr.h:142
Definition: GuildFinderMgr.h:39
uint32 GuildVirtualRealm
Definition: GuildFinderPackets.h:75
int8 MembershipRequested
Definition: GuildFinderPackets.h:89
Definition: GuildFinderMgr.h:52
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
uint32 GetBackgroundColor() const
Definition: Guild.h:278
Definition: GuildFinderMgr.h:32
Definition: Guild.h:320
Holds all informations about a player's finder settings. NOT stored in database.
Definition: GuildFinderMgr.h:101
Definition: World.h:235
Definition: GuildFinderPackets.h:92
int32 Background
Definition: GuildFinderPackets.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderDeclineRecruit ( WorldPackets::GuildFinder::LFGuildDeclineRecruit lfGuildDeclineRecruit)
94 {
95  if (!GetPlayer()->GetGuild())
96  return;
97 
98  if (!lfGuildDeclineRecruit.RecruitGUID.IsPlayer())
99  return;
100 
101  sGuildFinderMgr->RemoveMembershipRequest(lfGuildDeclineRecruit.RecruitGUID, GetPlayer()->GetGuild()->GetGUID());
102 }
bool IsPlayer() const
Definition: ObjectGuid.h:249
ObjectGuid RecruitGUID
Definition: GuildFinderPackets.h:109
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderGetApplications ( WorldPackets::GuildFinder::LFGuildGetApplications lfGuildGetApplications)
105 {
106  std::vector<MembershipRequest const*> applicatedGuilds = sGuildFinderMgr->GetAllMembershipRequestsForPlayer(GetPlayer()->GetGUID());
108  lfGuildApplications.Application.resize(applicatedGuilds.size());
109  lfGuildApplications.NumRemaining = 10 - sGuildFinderMgr->CountRequestsFromPlayer(GetPlayer()->GetGUID());
110 
111  for (std::size_t i = 0; i < applicatedGuilds.size(); ++i)
112  {
113  MembershipRequest const* application = applicatedGuilds[i];
114  WorldPackets::GuildFinder::LFGuildApplicationData& applicationData = lfGuildApplications.Application[i];
115 
116  Guild* guild = ASSERT_NOTNULL(sGuildMgr->GetGuildByGuid(application->GetGuildGuid()));
117  LFGuildSettings const& guildSettings = sGuildFinderMgr->GetGuildSettings(application->GetGuildGuid());
118 
119  applicationData.GuildGUID = application->GetGuildGuid();
120  applicationData.GuildVirtualRealm = GetVirtualRealmAddress();
121  applicationData.GuildName = guild->GetName();
122  applicationData.ClassRoles = guildSettings.GetClassRoles();
123  applicationData.PlayStyle = guildSettings.GetInterests();
124  applicationData.Availability = guildSettings.GetAvailability();
125  applicationData.SecondsSinceCreated = time(NULL) - application->GetSubmitTime();
126  applicationData.SecondsUntilExpiration = application->GetExpiryTime() - time(NULL);
127  applicationData.Comment = application->GetComment();
128  }
129 
130  GetPlayer()->SendDirectMessage(lfGuildApplications.Write());
131 }
int32 Availability
Definition: GuildFinderPackets.h:127
uint32 GuildVirtualRealm
Definition: GuildFinderPackets.h:123
int32 PlayStyle
Definition: GuildFinderPackets.h:126
ObjectGuid GuildGUID
Definition: GuildFinderPackets.h:122
T * ASSERT_NOTNULL(T *pointer)
Definition: Errors.h:58
uint8 GetClassRoles() const
Definition: GuildFinderMgr.h:140
#define sGuildMgr
Definition: GuildMgr.h:61
uint32 SecondsSinceCreated
Definition: GuildFinderPackets.h:128
Holds settings for a guild in the finder system. Saved to database.
Definition: GuildFinderMgr.h:156
arena_t NULL
Definition: jemalloc_internal.h:624
std::string const & GetName() const
Definition: Guild.h:766
Player * GetPlayer() const
Definition: WorldSession.h:927
time_t GetExpiryTime() const
Definition: GuildFinderMgr.h:84
std::string Comment
Definition: GuildFinderPackets.h:130
std::vector< LFGuildApplicationData > Application
Definition: GuildFinderPackets.h:140
ObjectGuid const & GetGuildGuid() const
Definition: GuildFinderMgr.h:78
Definition: GuildFinderPackets.h:133
time_t GetSubmitTime() const
Definition: GuildFinderMgr.h:83
std::string GuildName
Definition: GuildFinderPackets.h:124
int32 ClassRoles
Definition: GuildFinderPackets.h:125
Holds all required informations about a membership request.
Definition: GuildFinderMgr.h:58
std::string const & GetComment() const
Definition: GuildFinderMgr.h:85
uint8 GetAvailability() const
Definition: GuildFinderMgr.h:141
int32 NumRemaining
Definition: GuildFinderPackets.h:141
uint32 SecondsUntilExpiration
Definition: GuildFinderPackets.h:129
WorldPacket const * Write() override
Definition: GuildFinderPackets.cpp:93
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint8 GetInterests() const
Definition: GuildFinderMgr.h:142
Definition: GuildFinderPackets.h:120
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderGetGuildPost ( WorldPackets::GuildFinder::LFGuildGetGuildPost lfGuildGetGuildPost)
134 {
135  Player* player = GetPlayer();
136 
137  Guild* guild = player->GetGuild();
138  if (!guild) // Player must be in guild
139  return;
140 
142  if (guild->GetLeaderGUID() == player->GetGUID())
143  {
144  LFGuildSettings const& settings = sGuildFinderMgr->GetGuildSettings(guild->GetGUID());
145  lfGuildPost.Post = boost::in_place();
146  lfGuildPost.Post->Active = settings.IsListed();
147  lfGuildPost.Post->PlayStyle = settings.GetInterests();
148  lfGuildPost.Post->Availability = settings.GetAvailability();
149  lfGuildPost.Post->ClassRoles = settings.GetClassRoles();
150  lfGuildPost.Post->LevelRange = settings.GetLevel();
151  lfGuildPost.Post->Comment = settings.GetComment();
152  }
153 
154  player->SendDirectMessage(lfGuildPost.Write());
155 }
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:765
uint8 GetClassRoles() const
Definition: GuildFinderMgr.h:140
uint8 GetLevel() const
Definition: GuildFinderMgr.h:143
bool IsListed() const
Definition: GuildFinderMgr.h:172
Holds settings for a guild in the finder system. Saved to database.
Definition: GuildFinderMgr.h:156
Player * GetPlayer() const
Definition: WorldSession.h:927
Optional< GuildPostData > Post
Definition: GuildFinderPackets.h:170
std::string const & GetComment() const
Definition: GuildFinderMgr.h:144
ObjectGuid GetGUID() const
Definition: Guild.h:764
uint8 GetAvailability() const
Definition: GuildFinderMgr.h:141
WorldPacket const * Write() override
Definition: GuildFinderPackets.cpp:116
uint8 GetInterests() const
Definition: GuildFinderMgr.h:142
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: Guild.h:320
Definition: GuildFinderPackets.h:163

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderGetRecruits ( WorldPackets::GuildFinder::LFGuildGetRecruits lfGuildGetRecruits)
159 {
160  Player* player = GetPlayer();
161  Guild* guild = player->GetGuild();
162  if (!guild)
163  return;
164 
165  time_t now = time(nullptr);
167  lfGuildRecruits.UpdateTime = now;
168  if (std::unordered_map<ObjectGuid, MembershipRequest> const* recruitsList = sGuildFinderMgr->GetAllMembershipRequestsForGuild(guild->GetGUID()))
169  {
170  lfGuildRecruits.Recruits.resize(recruitsList->size());
171  std::size_t i = 0;
172  for (auto const& recruitRequestPair : *recruitsList)
173  {
174  WorldPackets::GuildFinder::LFGuildRecruitData& recruitData = lfGuildRecruits.Recruits[i++];
175  recruitData.RecruitGUID = recruitRequestPair.first;
177  recruitData.Comment = recruitRequestPair.second.GetComment();
178  recruitData.ClassRoles = recruitRequestPair.second.GetClassRoles();
179  recruitData.PlayStyle = recruitRequestPair.second.GetInterests();
180  recruitData.Availability = recruitRequestPair.second.GetAvailability();
181  recruitData.SecondsSinceCreated = now - recruitRequestPair.second.GetSubmitTime();
182  recruitData.SecondsUntilExpiration = recruitRequestPair.second.GetExpiryTime() - now;
183  if (CharacterInfo const* charInfo = sWorld->GetCharacterInfo(recruitRequestPair.first))
184  {
185  recruitData.Name = charInfo->Name;
186  recruitData.CharacterClass = charInfo->Class;
187  recruitData.CharacterGender = charInfo->Sex;
188  recruitData.CharacterLevel = charInfo->Level;
189  }
190  }
191  }
192 
193  player->SendDirectMessage(lfGuildRecruits.Write());
194 }
int32 PlayStyle
Definition: GuildFinderPackets.h:193
uint32 SecondsUntilExpiration
Definition: GuildFinderPackets.h:196
uint32 RecruitVirtualRealm
Definition: GuildFinderPackets.h:187
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
uint32 SecondsSinceCreated
Definition: GuildFinderPackets.h:195
int32 ClassRoles
Definition: GuildFinderPackets.h:192
Definition: World.h:532
Definition: GuildFinderPackets.h:199
ObjectGuid GetGUID() const
Definition: Guild.h:764
int32 CharacterClass
Definition: GuildFinderPackets.h:189
std::vector< LFGuildRecruitData > Recruits
Definition: GuildFinderPackets.h:206
Definition: GuildFinderPackets.h:183
WorldPacket const * Write() override
Definition: GuildFinderPackets.cpp:151
std::string Comment
Definition: GuildFinderPackets.h:188
int32 Availability
Definition: GuildFinderPackets.h:194
ObjectGuid RecruitGUID
Definition: GuildFinderPackets.h:185
int32 CharacterGender
Definition: GuildFinderPackets.h:190
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
int32 CharacterLevel
Definition: GuildFinderPackets.h:191
time_t UpdateTime
Definition: GuildFinderPackets.h:207
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: Guild.h:320
std::string Name
Definition: GuildFinderPackets.h:186

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderRemoveRecruit ( WorldPackets::GuildFinder::LFGuildRemoveRecruit lfGuildRemoveRecruit)
197 {
198  if (!lfGuildRemoveRecruit.GuildGUID.IsGuild())
199  return;
200 
201  sGuildFinderMgr->RemoveMembershipRequest(GetPlayer()->GetGUID(), lfGuildRemoveRecruit.GuildGUID);
202 }
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid GuildGUID
Definition: GuildFinderPackets.h:217
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
bool IsGuild() const
Definition: ObjectGuid.h:259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildFinderSetGuildPost ( WorldPackets::GuildFinder::LFGuildSetGuildPost lfGuildSetGuildPost)
206 {
207  // Level sent is zero if untouched, force to any (from interface). Idk why
208  if (!lfGuildSetGuildPost.LevelRange)
209  lfGuildSetGuildPost.LevelRange = ANY_FINDER_LEVEL;
210 
211  if (!(lfGuildSetGuildPost.ClassRoles & GUILDFINDER_ALL_ROLES) || lfGuildSetGuildPost.ClassRoles > GUILDFINDER_ALL_ROLES)
212  return;
213  if (!(lfGuildSetGuildPost.Availability & AVAILABILITY_ALWAYS) || lfGuildSetGuildPost.Availability > AVAILABILITY_ALWAYS)
214  return;
215  if (!(lfGuildSetGuildPost.PlayStyle & ALL_INTERESTS) || lfGuildSetGuildPost.PlayStyle > ALL_INTERESTS)
216  return;
217  if (!(lfGuildSetGuildPost.LevelRange & ALL_GUILDFINDER_LEVELS) || lfGuildSetGuildPost.LevelRange > ALL_GUILDFINDER_LEVELS)
218  return;
219 
220  Player* player = GetPlayer();
221 
222  if (!player->GetGuildId()) // Player must be in guild
223  return;
224 
225  Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId());
226  // Player must be guild master
227  if (guild->GetLeaderGUID() != player->GetGUID())
228  return;
229 
230  LFGuildSettings settings(lfGuildSetGuildPost.Active, player->GetTeamId(), guild->GetGUID(), lfGuildSetGuildPost.ClassRoles,
231  lfGuildSetGuildPost.Availability, lfGuildSetGuildPost.PlayStyle, lfGuildSetGuildPost.LevelRange, lfGuildSetGuildPost.Comment);
232  sGuildFinderMgr->SetGuildSettings(guild->GetGUID(), settings);
233 }
ObjectGuid GetLeaderGUID() const
Definition: Guild.h:765
#define sGuildMgr
Definition: GuildMgr.h:61
std::string Comment
Definition: GuildFinderPackets.h:232
Holds settings for a guild in the finder system. Saved to database.
Definition: GuildFinderMgr.h:156
int32 Availability
Definition: GuildFinderPackets.h:227
int32 PlayStyle
Definition: GuildFinderPackets.h:228
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 LevelRange
Definition: GuildFinderPackets.h:230
Definition: GuildFinderMgr.h:47
Definition: GuildFinderMgr.h:54
ObjectGuid GetGUID() const
Definition: Guild.h:764
int32 ClassRoles
Definition: GuildFinderPackets.h:229
Definition: GuildFinderMgr.h:39
Definition: GuildFinderMgr.h:52
#define sGuildFinderMgr
Definition: GuildFinderMgr.h:271
Definition: GuildFinderMgr.h:32
Definition: Guild.h:320
bool Active
Definition: GuildFinderPackets.h:231

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildGetRanks ( WorldPackets::Guild::GuildGetRanks packet)
143 {
144  TC_LOG_DEBUG("guild", "CMSG_GUILD_GET_RANKS [%s]: Guild: %s",
145  GetPlayerInfo().c_str(), packet.GuildGUID.ToString().c_str());
146 
147  if (Guild* guild = sGuildMgr->GetGuildByGuid(packet.GuildGUID))
148  if (guild->IsMember(_player->GetGUID()))
149  guild->SendGuildRankInfo(this);
150 }
#define sGuildMgr
Definition: GuildMgr.h:61
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * _player
Definition: WorldSession.h:1797
ObjectGuid GuildGUID
Definition: GuildPackets.h:482
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildGetRoster ( WorldPackets::Guild::GuildGetRoster packet)
79 {
80  if (Guild* guild = GetPlayer()->GetGuild())
81  guild->HandleRoster(this);
82  else
84 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
Definition: Guild.h:107
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:134
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildInviteByName ( WorldPackets::Guild::GuildInviteByName packet)
50 {
51  TC_LOG_DEBUG("guild", "CMSG_GUILD_INVITE [%s]: Invited: %s", GetPlayerInfo().c_str(), packet.Name.c_str());
52  if (normalizePlayerName(packet.Name))
53  if (Guild* guild = GetPlayer()->GetGuild())
54  guild->HandleInviteMember(this, packet.Name);
55 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string Name
Definition: GuildPackets.h:203

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildLeave ( WorldPackets::Guild::GuildLeave leave)
114 {
115  if (Guild* guild = GetPlayer()->GetGuild())
116  guild->HandleLeaveMember(this);
117 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildNewsUpdateSticky ( WorldPackets::Guild::GuildNewsUpdateSticky packet)
413 {
414  if (Guild* guild = GetPlayer()->GetGuild())
415  guild->HandleNewsSetSticky(this, packet.NewsID, packet.Sticky);
416 }
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 NewsID
Definition: GuildPackets.h:949
Definition: Guild.h:320
bool Sticky
Definition: GuildPackets.h:951

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildOfficerRemoveMember ( WorldPackets::Guild::GuildOfficerRemoveMember packet)
58 {
59  TC_LOG_DEBUG("guild", "CMSG_GUILD_REMOVE [%s]: Target: %s", GetPlayerInfo().c_str(), packet.Removee.ToString().c_str());
60 
61  if (Guild* guild = GetPlayer()->GetGuild())
62  guild->HandleRemoveMember(this, packet.Removee);
63 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Removee
Definition: GuildPackets.h:607
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildPermissionsQuery ( WorldPackets::Guild::GuildPermissionsQuery packet)
222 {
223  if (Guild* guild = GetPlayer()->GetGuild())
224  guild->SendPermissions(this);
225 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildPromoteMember ( WorldPackets::Guild::GuildPromoteMember promote)
87 {
88  TC_LOG_DEBUG("guild", "CMSG_GUILD_PROMOTE [%s]: Target: %s", GetPlayerInfo().c_str(), promote.Promotee.ToString().c_str());
89 
90  if (Guild* guild = GetPlayer()->GetGuild())
91  guild->HandleUpdateMemberRank(this, promote.Promotee, false);
92 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
ObjectGuid Promotee
Definition: GuildPackets.h:597
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildQueryNews ( WorldPackets::Guild::GuildQueryNews newsQuery)
406 {
407  if (Guild* guild = GetPlayer()->GetGuild())
408  if (guild->GetGUID() == newsQuery.GuildGUID)
409  guild->SendNewsUpdate(this);
410 }
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid GuildGUID
Definition: GuildPackets.h:917
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildQueryOpcode ( WorldPackets::Guild::QueryGuildInfo query)
31 {
32  TC_LOG_DEBUG("guild", "CMSG_GUILD_QUERY [%s]: Guild: %s Target: %s",
33  GetPlayerInfo().c_str(), query.GuildGuid.ToString().c_str(), query.PlayerGuid.ToString().c_str());
34 
35  if (Guild* guild = sGuildMgr->GetGuildByGuid(query.GuildGuid))
36  if (guild->IsMember(query.PlayerGuid))
37  {
38  guild->SendQueryResponse(this);
39  return;
40  }
41 
43  response.GuildGuid = query.GuildGuid;
44  SendPacket(response.Write());
45 
46  TC_LOG_DEBUG("guild", "SMSG_GUILD_QUERY_RESPONSE [%s]", GetPlayerInfo().c_str());
47 }
#define sGuildMgr
Definition: GuildMgr.h:61
ObjectGuid GuildGuid
Definition: GuildPackets.h:80
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
ObjectGuid PlayerGuid
Definition: GuildPackets.h:37
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ObjectGuid GuildGuid
Definition: GuildPackets.h:38
Definition: GuildPackets.h:41
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
WorldPacket const * Write() override
Definition: GuildPackets.cpp:29
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildRequestPartyState ( WorldPackets::Guild::RequestGuildPartyState packet)
363 {
364  if (Guild* guild = sGuildMgr->GetGuildByGuid(packet.GuildGUID))
365  guild->HandleGuildPartyRequest(this);
366 }
#define sGuildMgr
Definition: GuildMgr.h:61
ObjectGuid GuildGUID
Definition: GuildPackets.h:645
Definition: Guild.h:320

+ Here is the caller graph for this function:

void WorldSession::HandleGuildSetAchievementTracking ( WorldPackets::Guild::GuildSetAchievementTracking packet)
425 {
426  if (Guild* guild = GetPlayer()->GetGuild())
427  guild->HandleSetAchievementTracking(this, packet.AchievementIDs);
428 }
std::set< uint32 > AchievementIDs
Definition: GuildPackets.h:1017
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildSetFocusedAchievement ( WorldPackets::Achievement::GuildSetFocusedAchievement setFocusedAchievement)
1018 {
1019  if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId()))
1020  guild->GetAchievementMgr().SendAchievementInfo(_player, setFocusedAchievement.AchievementID);
1021 }
#define sGuildMgr
Definition: GuildMgr.h:61
Player * _player
Definition: WorldSession.h:1797
Definition: Guild.h:320
uint32 AchievementID
Definition: AchievementPackets.h:180

+ Here is the caller graph for this function:

void WorldSession::HandleGuildSetGuildMaster ( WorldPackets::Guild::GuildSetGuildMaster packet)
419 {
420  if (Guild* guild = GetPlayer()->GetGuild())
421  guild->HandleSetNewGuildMaster(this, packet.NewMasterName);
422 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:320
std::string NewMasterName
Definition: GuildPackets.h:961

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildSetMemberNote ( WorldPackets::Guild::GuildSetMemberNote packet)
134 {
135  TC_LOG_DEBUG("guild", "CMSG_GUILD_SET_NOTE [%s]: Target: %s, Note: %s, Public: %u",
136  GetPlayerInfo().c_str(), packet.NoteeGUID.ToString().c_str(), packet.Note.c_str(), packet.IsPublic);
137 
138  if (Guild* guild = GetPlayer()->GetGuild())
139  guild->HandleSetMemberNote(this, packet.Note, packet.NoteeGUID, packet.IsPublic);
140 }
bool IsPublic
0 == Officer, 1 == Public
Definition: GuildPackets.h:548
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid NoteeGUID
Definition: GuildPackets.h:547
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
std::string Note
Definition: GuildPackets.h:549
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildSetRankPermissions ( WorldPackets::Guild::GuildSetRankPermissions packet)
348 {
349  Guild* guild = GetPlayer()->GetGuild();
350  if (!guild)
351  return;
352 
354  for (uint8 tabId = 0; tabId < GUILD_BANK_MAX_TABS; ++tabId)
355  rightsAndSlots[tabId] = GuildBankRightsAndSlots(tabId, uint8(packet.TabFlags[tabId]), uint32(packet.TabWithdrawItemLimit[tabId]));
356 
357  TC_LOG_DEBUG("guild", "CMSG_GUILD_SET_RANK_PERMISSIONS [%s]: Rank: %s (%u)", GetPlayerInfo().c_str(), packet.RankName.c_str(), packet.RankOrder);
358 
359  guild->HandleSetRankInfo(this, packet.RankOrder, packet.RankName, packet.Flags, packet.WithdrawGoldLimit, rightsAndSlots);
360 }
int32 RankOrder
Definition: GuildPackets.h:434
int32 TabFlags[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:438
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:44
uint32_t uint32
Definition: Define.h:150
void HandleSetRankInfo(WorldSession *session, uint8 rankId, std::string const &name, uint32 rights, uint32 moneyPerDay, GuildBankRightsAndSlotsVec const &rightsAndSlots)
Definition: Guild.cpp:1535
uint32 Flags
Definition: GuildPackets.h:436
Definition: Guild.h:289
uint8_t uint8
Definition: g3dmath.h:164
int32 TabWithdrawItemLimit[GUILD_BANK_MAX_TABS]
Definition: GuildPackets.h:439
std::vector< GuildBankRightsAndSlots > GuildBankRightsAndSlotsVec
Definition: Guild.h:316
int32 WithdrawGoldLimit
Definition: GuildPackets.h:435
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:320
std::string RankName
Definition: GuildPackets.h:440

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildUpdateInfoText ( WorldPackets::Guild::GuildUpdateInfoText packet)
169 {
170  TC_LOG_DEBUG("guild", "CMSG_GUILD_UPDATE_INFO_TEXT [%s]: %s", GetPlayerInfo().c_str(), packet.InfoText.c_str());
171 
172  if (Guild* guild = GetPlayer()->GetGuild())
173  guild->HandleSetInfo(this, packet.InfoText);
174 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string InfoText
Definition: GuildPackets.h:537
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleGuildUpdateMotdText ( WorldPackets::Guild::GuildUpdateMotdText packet)
126 {
127  TC_LOG_DEBUG("guild", "CMSG_GUILD_UPDATE_MOTD_TEXT [%s]: MOTD: %s", GetPlayerInfo().c_str(), packet.MotdText.c_str());
128 
129  if (Guild* guild = GetPlayer()->GetGuild())
130  guild->HandleSetMOTD(this, packet.MotdText);
131 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Guild.h:320
std::string MotdText
Definition: GuildPackets.h:155

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleHearthAndResurrect ( WorldPackets::Battleground::HearthAndResurrect hearthAndResurrect)
676 {
677  if (_player->IsInFlight())
678  return;
679 
680  if (/*Battlefield* bf = */sBattlefieldMgr->GetBattlefieldToZoneId(_player->GetZoneId()))
681  {
682  // bf->PlayerAskToLeave(_player); FIXME
683  return;
684  }
685 
686  AreaTableEntry const* atEntry = sAreaTableStore.LookupEntry(_player->GetAreaId());
687  if (!atEntry || !(atEntry->Flags[0] & AREA_FLAG_CAN_HEARTH_AND_RESURRECT))
688  return;
689 
690  _player->BuildPlayerRepop();
691  _player->ResurrectPlayer(1.0f);
692  _player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
693 }
Definition: DBCStructure.h:37
uint32 Flags[2]
Definition: DBCStructure.h:43
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67
Player * _player
Definition: WorldSession.h:1797
Definition: DBCEnums.h:397

+ Here is the caller graph for this function:

void WorldSession::HandleIgnoreTradeOpcode ( WorldPackets::Trade::IgnoreTrade ignoreTrade)
43 {
44 }

+ Here is the caller graph for this function:

void WorldSession::HandleInitiateRolePoll ( WorldPackets::Party::InitiateRolePoll packet)
614 {
615  Group* group = GetPlayer()->GetGroup();
616  if (!group)
617  return;
618 
619  ObjectGuid guid = GetPlayer()->GetGUID();
620  if (!group->IsLeader(guid) && !group->IsAssistant(guid))
621  return;
622 
624  rolePollInform.From = GetPlayer()->GetGUID();
625  rolePollInform.PartyIndex = packet.PartyIndex;
626  group->BroadcastPacket(rolePollInform.Write(), true);
627 }
int8 PartyIndex
Definition: PartyPackets.h:459
Player * GetPlayer() const
Definition: WorldSession.h:927
int8 PartyIndex
Definition: PartyPackets.h:469
ObjectGuid From
Definition: PartyPackets.h:470
WorldPacket const * Write() override
Definition: PartyPackets.cpp:321
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignoredPlayer=ObjectGuid::Empty)
Definition: Group.cpp:1698
Definition: PartyPackets.h:462
Definition: ObjectGuid.h:189
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleInitiateTradeOpcode ( WorldPackets::Trade::InitiateTrade initiateTrade)
570 {
571  if (GetPlayer()->m_trade)
572  return;
573 
575  if (!GetPlayer()->IsAlive())
576  {
577  info.Status = TRADE_STATUS_DEAD;
578  SendTradeStatus(info);
579  return;
580  }
581 
582  if (GetPlayer()->HasUnitState(UNIT_STATE_STUNNED))
583  {
585  SendTradeStatus(info);
586  return;
587  }
588 
589  if (isLogingOut())
590  {
592  SendTradeStatus(info);
593  return;
594  }
595 
596  if (GetPlayer()->IsInFlight())
597  {
599  SendTradeStatus(info);
600  return;
601  }
602 
603  if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ))
604  {
606  return;
607  }
608 
609  Player* pOther = ObjectAccessor::FindPlayer(initiateTrade.Guid);
610  if (!pOther)
611  {
613  SendTradeStatus(info);
614  return;
615  }
616 
617  if (pOther == GetPlayer() || pOther->m_trade)
618  {
620  SendTradeStatus(info);
621  return;
622  }
623 
624  if (!pOther->IsAlive())
625  {
627  SendTradeStatus(info);
628  return;
629  }
630 
631  if (pOther->IsInFlight())
632  {
634  SendTradeStatus(info);
635  return;
636  }
637 
638  if (pOther->HasUnitState(UNIT_STATE_STUNNED))
639  {
641  SendTradeStatus(info);
642  return;
643  }
644 
645  if (pOther->GetSession()->isLogingOut())
646  {
648  SendTradeStatus(info);
649  return;
650  }
651 
652  if (pOther->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
653  {
655  SendTradeStatus(info);
656  return;
657  }
658 
659  if ((pOther->GetTeam() != _player->GetTeam() ||
662  (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) &&
664  {
666  SendTradeStatus(info);
667  return;
668  }
669 
670  if (!pOther->IsWithinDistInMap(_player, TRADE_DISTANCE, false))
671  {
673  SendTradeStatus(info);
674  return;
675  }
676 
677  if (pOther->getLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ))
678  {
680  return;
681  }
682 
683  // OK start trade
684  _player->m_trade = new TradeData(_player, pOther);
685  pOther->m_trade = new TradeData(pOther, _player);
686 
688  info.Partner = _player->GetGUID();
689  pOther->GetSession()->SendTradeStatus(info);
690 }
Definition: SharedDefines.h:4662
Definition: World.h:111
Definition: SharedDefines.h:4663
Definition: UpdateFields.h:192
Definition: Language.h:1141
Definition: SharedDefines.h:4654
void SendTradeStatus(WorldPackets::Trade::TradeStatus &status)
Definition: TradeHandler.cpp:34
ObjectGuid Partner
Definition: TradePackets.h:140
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Definition: Unit.h:553
Definition: TradeData.h:34
Definition: SharedDefines.h:4665
Definition: Language.h:1142
#define TRADE_DISTANCE
Definition: Object.h:37
Definition: SharedDefines.h:4648
Definition: SharedDefines.h:4658
Definition: TradePackets.h:130
Definition: SharedDefines.h:4667
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4664
::TradeStatus Status
Definition: TradePackets.h:137
ObjectGuid Guid
Definition: TradePackets.h:86
bool isLogingOut() const
Is the user engaged in a log out process?
Definition: WorldSession.h:943
Definition: SharedDefines.h:4659
Definition: World.h:292
Definition: SharedDefines.h:4666
Definition: Player.h:554
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: SharedDefines.h:4649
Definition: SharedDefines.h:4668

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleInspectOpcode ( WorldPackets::Inspect::Inspect inspect)
25 {
26  Player* player = ObjectAccessor::FindPlayer(inspect.Target);
27  if (!player)
28  {
29  TC_LOG_DEBUG("network", "WorldSession::HandleInspectOpcode: Target %s not found.", inspect.Target.ToString().c_str());
30  return;
31  }
32 
33  TC_LOG_DEBUG("network", "WorldSession::HandleInspectOpcode: Target %s.", inspect.Target.ToString().c_str());
34 
35  if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
36  return;
37 
38  if (GetPlayer()->IsValidAttackTarget(player))
39  return;
40 
42  inspectResult.InspecteeGUID = inspect.Target;
43 
44  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
45  {
46  if (Item* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
47  inspectResult.Items.emplace_back(item, i);
48  }
49 
50  inspectResult.ClassID = player->getClass();
51  inspectResult.GenderID = player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER);
52 
53  if (sWorld->getBoolConfig(CONFIG_TALENTS_INSPECTING) || GetPlayer()->IsGameMaster())
54  {
55  PlayerTalentMap const* talents = player->GetTalentMap(player->GetActiveTalentGroup());
56  for (PlayerTalentMap::value_type const& v : *talents)
57  {
58  if (v.second != PLAYERSPELL_REMOVED)
59  inspectResult.Talents.push_back(v.first);
60  }
61 
62  for (uint8 i = 0; i < MAX_GLYPH_SLOT_INDEX; ++i)
63  inspectResult.Glyphs.push_back(player->GetGlyph(player->GetActiveTalentGroup(), i));
64  }
65 
66  if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
67  {
68  inspectResult.GuildData = boost::in_place();
69  inspectResult.GuildData->GuildGUID = guild->GetGUID();
70  inspectResult.GuildData->NumGuildMembers = guild->GetMembersCount();
71  inspectResult.GuildData->AchievementPoints = guild->GetAchievementMgr().GetAchievementPoints();
72  }
73 
74  inspectResult.InspecteeGUID = inspect.Target;
75  inspectResult.SpecializationID = player->GetSpecId(player->GetActiveTalentGroup());
76 
77  SendPacket(inspectResult.Write());
78 }
Optional< InspectGuildData > GuildData
Definition: InspectPackets.h:78
Definition: Player.h:587
#define INVENTORY_SLOT_BAG_0
ObjectGuid Target
Definition: InspectPackets.h:37
Definition: Player.h:106
std::vector< uint16 > Glyphs
Definition: InspectPackets.h:77
#define sGuildMgr
Definition: GuildMgr.h:61
int32 ClassID
Definition: InspectPackets.h:74
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
Definition: UpdateFields.h:198
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
#define INSPECT_DISTANCE
Definition: Object.h:36
#define MAX_GLYPH_SLOT_INDEX
Definition: SharedDefines.h:854
int32 GenderID
Definition: InspectPackets.h:75
WorldPacket const * Write() override
Definition: InspectPackets.cpp:74
Definition: Item.h:259
std::unordered_map< uint32, PlayerSpellState > PlayerTalentMap
Definition: Player.h:196
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: World.h:126
std::vector< uint16 > Talents
Definition: InspectPackets.h:76
Definition: InspectPackets.h:66
std::vector< InspectItemData > Items
Definition: InspectPackets.h:73
int32 SpecializationID
Definition: InspectPackets.h:80
ObjectGuid InspecteeGUID
Definition: InspectPackets.h:79
uint8_t uint8
Definition: Define.h:152
Definition: Guild.h:320
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleInspectPVP ( WorldPackets::Inspect::InspectPVPRequest request)
Todo:
: deal with request.InspectRealmAddress
Todo:
: fill brackets
108 {
110 
112  if (!player)
113  {
114  TC_LOG_DEBUG("network", "WorldSession::HandleInspectPVP: Target %s not found.", request.InspectTarget.ToString().c_str());
115  return;
116  }
117 
118  TC_LOG_DEBUG("network", "WorldSession::HandleInspectPVP: Target %s, InspectRealmAddress %u.", request.InspectTarget.ToString().c_str(), request.InspectRealmAddress);
119 
120  if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
121  return;
122 
123  if (GetPlayer()->IsValidAttackTarget(player))
124  return;
125 
127  response.ClientGUID = request.InspectTarget;
129 
130  SendPacket(response.Write());
131 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
#define INSPECT_DISTANCE
Definition: Object.h:36
WorldPacket const * Write() override
Definition: InspectPackets.cpp:140
ObjectGuid InspectTarget
Definition: InspectPackets.h:114
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 InspectRealmAddress
Definition: InspectPackets.h:115
Definition: InspectPackets.h:130
ObjectGuid ClientGUID
Definition: InspectPackets.h:138
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleInstanceLockResponse ( WorldPackets::Instance::InstanceLockResponse packet)
1042 {
1043  if (!_player->HasPendingBind())
1044  {
1045  TC_LOG_INFO("network", "InstanceLockResponse: Player %s (%s) tried to bind himself/teleport to graveyard without a pending bind!",
1046  _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
1047  return;
1048  }
1049 
1050  if (packet.AcceptLock)
1051  _player->BindToInstance();
1052  else
1053  _player->RepopAtGraveyard();
1054 
1055  _player->SetPendingBind(0, 0);
1056 }
bool AcceptLock
Definition: InstancePackets.h:126
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the caller graph for this function:

void WorldSession::HandleItemRefund ( WorldPackets::Item::ItemPurchaseRefund packet)
1087 {
1088  Item* item = _player->GetItemByGuid(packet.ItemGUID);
1089  if (!item)
1090  {
1091  TC_LOG_DEBUG("network", "WorldSession::HandleItemRefund: Item (%s) not found!", packet.ItemGUID.ToString().c_str());
1092  return;
1093  }
1094 
1095  // Don't try to refund item currently being disenchanted
1096  if (_player->GetLootGUID() == packet.ItemGUID)
1097  return;
1098 
1099  GetPlayer()->RefundItem(item);
1100 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Item.h:259
Player * _player
Definition: WorldSession.h:1797
ObjectGuid ItemGUID
Definition: ItemPackets.h:157
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleItemTextQuery ( WorldPackets::Query::ItemTextQuery itemTextQuery)

Handles the packet sent by the client when requesting information about item text.

This function is called when player clicks on item which has some flag set

440 {
441  WorldPackets::Query::QueryItemTextResponse queryItemTextResponse;
442  queryItemTextResponse.Id = itemTextQuery.Id;
443 
444  if (Item* item = _player->GetItemByGuid(itemTextQuery.Id))
445  {
446  queryItemTextResponse.Valid = true;
447  queryItemTextResponse.Item.Text = item->GetText();
448  }
449 
450  SendPacket(queryItemTextResponse.Write());
451 }
ObjectGuid Id
Definition: QueryPackets.h:430
std::string Text
Definition: QueryPackets.h:435
Definition: Item.h:259
ObjectGuid Id
Definition: QueryPackets.h:445
ItemTextCache Item
Definition: QueryPackets.h:447
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: QueryPackets.h:438
Player * _player
Definition: WorldSession.h:1797
WorldPacket const * Write() override
Definition: QueryPackets.cpp:483
bool Valid
Definition: QueryPackets.h:446

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleJoinChannel ( WorldPackets::Channel::JoinChannel packet)
28 {
29  TC_LOG_DEBUG("chat.system", "CMSG_JOIN_CHANNEL %s ChatChannelId: %u, CreateVoiceSession: %u, Internal: %u, ChannelName: %s, Password: %s",
30  GetPlayerInfo().c_str(), packet.ChatChannelId, packet.CreateVoiceSession, packet.Internal, packet.ChannelName.c_str(), packet.Password.c_str());
31 
32  if (packet.ChatChannelId)
33  {
34  ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(packet.ChatChannelId);
35  if (!channel)
36  return;
37 
38  AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
39  if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone))
40  return;
41  }
42 
43  if (packet.ChannelName.empty())
44  return;
45 
46  if (isdigit(packet.ChannelName[0]))
47  return;
48 
49  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(GetPlayer()->GetTeam()))
50  {
51  cMgr->SetTeam(GetPlayer()->GetTeam());
52  if (Channel* channel = cMgr->GetJoinChannel(packet.ChannelName, packet.ChatChannelId))
53  channel->JoinChannel(GetPlayer(), packet.Password);
54  }
55 }
Definition: DBCStructure.h:37
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
int32 ChatChannelId
Definition: ChannelPackets.h:190
std::string Password
Definition: ChannelPackets.h:187
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Channel.h:126
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
bool Internal
Definition: ChannelPackets.h:191
Definition: ChannelMgr.h:27
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
std::string ChannelName
Definition: ChannelPackets.h:188
Definition: DBCStructure.h:172
DBCStorage< ChatChannelsEntry > sChatChannelsStore(ChatChannelsfmt)
bool CreateVoiceSession
Definition: ChannelPackets.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLearnTalentsOpcode ( WorldPackets::Talent::LearnTalents packet)
30 {
31  bool anythingLearned = false;
32  for (uint32 talentId : packet.Talents)
33  if (_player->LearnTalent(talentId))
34  anythingLearned = true;
35 
36  if (anythingLearned)
37  _player->SendTalentsInfoData();
38 }
std::vector< uint16 > Talents
Definition: TalentPackets.h:70
uint32_t uint32
Definition: Define.h:150
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleLeaveChannel ( WorldPackets::Channel::LeaveChannel packet)
58 {
59  TC_LOG_DEBUG("chat.system", "CMSG_LEAVE_CHANNEL %s ChannelName: %s, ZoneChannelID: %u",
60  GetPlayerInfo().c_str(), packet.ChannelName.c_str(), packet.ZoneChannelID);
61 
62  if (packet.ChannelName.empty())
63  return;
64 
65  if (ChannelMgr* cMgr = ChannelMgr::ForTeam(GetPlayer()->GetTeam()))
66  {
67  if (Channel* channel = cMgr->GetChannel(packet.ChannelName, GetPlayer()))
68  channel->LeaveChannel(GetPlayer(), true);
69  cMgr->LeftChannel(packet.ChannelName);
70  }
71 }
static ChannelMgr * ForTeam(uint32 team)
Definition: ChannelMgr.cpp:30
int32 ZoneChannelID
Definition: ChannelPackets.h:201
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Channel.h:126
std::string ChannelName
Definition: ChannelPackets.h:202
Definition: ChannelMgr.h:27
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLeaveGroupOpcode ( WorldPackets::Party::LeaveGroup packet)

error handling

321 {
322  Group* grp = GetPlayer()->GetGroup();
323  if (!grp)
324  return;
325 
326  if (_player->InBattleground())
327  {
329  return;
330  }
331 
333  /********************/
334 
335  // everything's fine, do it
337 
338  GetPlayer()->RemoveFromGroup(GROUP_REMOVEMETHOD_LEAVE);
339 }
Definition: SharedDefines.h:4854
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4843
Definition: SharedDefines.h:4689
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: WorldSession.h:783
void SendPartyResult(PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
Definition: GroupHandler.cpp:48
Definition: WorldSession.h:785
Player * _player
Definition: WorldSession.h:1797
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgJoinOpcode ( WorldPacket recvData)
86 {
88  (GetPlayer()->GetGroup() && GetPlayer()->GetGroup()->GetLeaderGUID() != GetPlayer()->GetGUID() &&
89  (GetPlayer()->GetGroup()->GetMembersCount() == MAX_GROUP_SIZE || !GetPlayer()->GetGroup()->isLFGGroup())))
90  {
91  recvData.rfinish();
92  return;
93  }
94 
95  uint32 roles;
96 
97  recvData >> roles;
98  for (int32 i = 0; i < 3; ++i)
99  recvData.read_skip<uint32>();
100 
101  uint32 commentLen = recvData.ReadBits(9);
102  uint32 numDungeons = recvData.ReadBits(24);
103 
104  if (!numDungeons)
105  {
106  TC_LOG_DEBUG("lfg", "CMSG_DF_JOIN %s no dungeons selected", GetPlayerInfo().c_str());
107  recvData.rfinish();
108  return;
109  }
110 
111  std::string comment = recvData.ReadString(commentLen);
112 
113  lfg::LfgDungeonSet newDungeons;
114  for (uint32 i = 0; i < numDungeons; ++i)
115  {
116  uint32 dungeon;
117  recvData >> dungeon;
118  dungeon &= 0x00FFFFFF; // remove the type from the dungeon entry
119  if (dungeon)
120  newDungeons.insert(dungeon);
121  }
122 
123  TC_LOG_DEBUG("lfg", "CMSG_DF_JOIN %s roles: %u, Dungeons: %u, Comment: %s",
124  GetPlayerInfo().c_str(), roles, uint8(newDungeons.size()), comment.c_str());
125 
126  sLFGMgr->JoinLfg(GetPlayer(), uint8(roles), newDungeons, comment);
127 }
void read_skip()
Definition: ByteBuffer.h:473
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:204
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string ReadString(uint32 length)
Definition: ByteBuffer.h:524
#define MAX_GROUP_SIZE
Definition: Group.h:42
#define sLFGMgr
Definition: LFGMgr.h:481
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
void rfinish()
Definition: ByteBuffer.h:449
uint8_t uint8
Definition: g3dmath.h:164
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgLeaveOpcode ( WorldPacket recvData)
130 {
131  ObjectGuid leaveGuid;
132  Group* group = GetPlayer()->GetGroup();
133  ObjectGuid guid = GetPlayer()->GetGUID();
134  ObjectGuid gguid = group ? group->GetGUID() : guid;
135 
136  recvData.read_skip<uint32>(); // Always 8
137  recvData.read_skip<uint32>(); // Join date
138  recvData.read_skip<uint32>(); // Always 3
139  recvData.read_skip<uint32>(); // Queue Id
140 
141  leaveGuid[4] = recvData.ReadBit();
142  leaveGuid[5] = recvData.ReadBit();
143  leaveGuid[0] = recvData.ReadBit();
144  leaveGuid[6] = recvData.ReadBit();
145  leaveGuid[2] = recvData.ReadBit();
146  leaveGuid[7] = recvData.ReadBit();
147  leaveGuid[1] = recvData.ReadBit();
148  leaveGuid[3] = recvData.ReadBit();
149 
150  recvData.ReadByteSeq(leaveGuid[7]);
151  recvData.ReadByteSeq(leaveGuid[4]);
152  recvData.ReadByteSeq(leaveGuid[3]);
153  recvData.ReadByteSeq(leaveGuid[2]);
154  recvData.ReadByteSeq(leaveGuid[6]);
155  recvData.ReadByteSeq(leaveGuid[0]);
156  recvData.ReadByteSeq(leaveGuid[1]);
157  recvData.ReadByteSeq(leaveGuid[5]);
158 
159  TC_LOG_DEBUG("lfg", "CMSG_DF_LEAVE %s in group: %u sent guid %s.",
160  GetPlayerInfo().c_str(), group ? 1 : 0, leaveGuid.ToString().c_str());
161 
162  // Check cheating - only leader can leave the queue
163  if (!group || group->GetLeaderGUID() == guid)
164  sLFGMgr->LeaveLfg(gguid);
165 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
void read_skip()
Definition: ByteBuffer.h:473
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
void ReadByteSeq(uint8 &b)
Definition: ByteBuffer.h:215
Definition: ObjectGuid.h:189
bool ReadBit()
Definition: ByteBuffer.h:186
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgProposalResultOpcode ( WorldPacket recvData)
168 {
169  uint32 proposalID; // Proposal ID
170  bool accept;
171 
172  ObjectGuid guid1;
173  ObjectGuid guid2;
174 
175  recvData >> proposalID;
176  recvData.read_skip<uint32>();
177  recvData.read_skip<uint32>();
178  recvData.read_skip<uint32>();
179 
180  guid2[4] = recvData.ReadBit();
181  guid2[5] = recvData.ReadBit();
182  guid2[0] = recvData.ReadBit();
183  guid2[6] = recvData.ReadBit();
184  guid2[2] = recvData.ReadBit();
185  guid2[7] = recvData.ReadBit();
186  guid2[1] = recvData.ReadBit();
187  guid2[3] = recvData.ReadBit();
188 
189  recvData.ReadByteSeq(guid2[7]);
190  recvData.ReadByteSeq(guid2[4]);
191  recvData.ReadByteSeq(guid2[3]);
192  recvData.ReadByteSeq(guid2[2]);
193  recvData.ReadByteSeq(guid2[6]);
194  recvData.ReadByteSeq(guid2[0]);
195  recvData.ReadByteSeq(guid2[1]);
196  recvData.ReadByteSeq(guid2[5]);
197 
198  guid1[7] = recvData.ReadBit();
199  accept = recvData.ReadBit();
200  guid1[1] = recvData.ReadBit();
201  guid1[3] = recvData.ReadBit();
202  guid1[0] = recvData.ReadBit();
203  guid1[5] = recvData.ReadBit();
204  guid1[4] = recvData.ReadBit();
205  guid1[6] = recvData.ReadBit();
206  guid1[2] = recvData.ReadBit();
207 
208  recvData.ReadByteSeq(guid1[7]);
209  recvData.ReadByteSeq(guid1[1]);
210  recvData.ReadByteSeq(guid1[5]);
211  recvData.ReadByteSeq(guid1[6]);
212  recvData.ReadByteSeq(guid1[3]);
213  recvData.ReadByteSeq(guid1[4]);
214  recvData.ReadByteSeq(guid1[0]);
215  recvData.ReadByteSeq(guid1[2]);
216 
217  TC_LOG_DEBUG("lfg", "CMSG_LFG_PROPOSAL_RESULT %s proposal: %u accept: %u",
218  GetPlayerInfo().c_str(), proposalID, accept ? 1 : 0);
219  sLFGMgr->UpdateProposal(proposalID, GetPlayer()->GetGUID(), accept);
220 }
void read_skip()
Definition: ByteBuffer.h:473
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
void ReadByteSeq(uint8 &b)
Definition: ByteBuffer.h:215
Definition: ObjectGuid.h:189
bool ReadBit()
Definition: ByteBuffer.h:186

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgSetBootVoteOpcode ( WorldPacket recvData)
252 {
253  bool agree; // Agree to kick player
254  recvData >> agree;
255 
256  ObjectGuid guid = GetPlayer()->GetGUID();
257  TC_LOG_DEBUG("lfg", "CMSG_LFG_SET_BOOT_VOTE %s agree: %u",
258  GetPlayerInfo().c_str(), agree ? 1 : 0);
259  sLFGMgr->UpdateBoot(guid, agree);
260 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgSetCommentOpcode ( WorldPacket recvData)
241 {
242  uint32 length = recvData.ReadBits(9);
243  std::string comment = recvData.ReadString(length);
244 
245  TC_LOG_DEBUG("lfg", "CMSG_LFG_SET_COMMENT %s comment: %s",
246  GetPlayerInfo().c_str(), comment.c_str());
247 
248  sLFGMgr->SetComment(GetPlayer()->GetGUID(), comment);
249 }
uint32 ReadBits(int32 bits)
Definition: ByteBuffer.h:204
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string ReadString(uint32 length)
Definition: ByteBuffer.h:524
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
float length(float v)
Definition: vectorMath.h:208
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgSetRolesOpcode ( WorldPacket recvData)
223 {
224  uint8 roles;
225  recvData >> roles; // Player Group Roles
226  ObjectGuid guid = GetPlayer()->GetGUID();
227  Group* group = GetPlayer()->GetGroup();
228  if (!group)
229  {
230  TC_LOG_DEBUG("lfg", "CMSG_DF_SET_ROLES %s Not in group",
231  GetPlayerInfo().c_str());
232  return;
233  }
234  ObjectGuid gguid = group->GetGUID();
235  TC_LOG_DEBUG("lfg", "CMSG_DF_SET_ROLES: Group %s, Player %s, Roles: %u",
236  gguid.ToString().c_str(), GetPlayerInfo().c_str(), roles);
237  sLFGMgr->UpdateRoleCheck(gguid, guid, roles);
238 }
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfgTeleportOpcode ( WorldPacket recvData)
263 {
264  bool out;
265  recvData >> out;
266 
267  TC_LOG_DEBUG("lfg", "CMSG_DF_TELEPORT %s out: %u",
268  GetPlayerInfo().c_str(), out ? 1 : 0);
269  sLFGMgr->TeleportPlayer(GetPlayer(), out, true);
270 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLfrJoinOpcode ( WorldPacket recvData)
388 {
389  uint32 entry; // Raid id to search
390  recvData >> entry;
391  TC_LOG_DEBUG("lfg", "CMSG_LFG_LFR_JOIN %s dungeon entry: %u",
392  GetPlayerInfo().c_str(), entry);
393  //SendLfrUpdateListOpcode(entry);
394 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32_t uint32
Definition: Define.h:150
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

void WorldSession::HandleLfrLeaveOpcode ( WorldPacket recvData)
397 {
398  uint32 dungeonId; // Raid id queue to leave
399  recvData >> dungeonId;
400  TC_LOG_DEBUG("lfg", "CMSG_LFG_LFR_LEAVE %s dungeonId: %u",
401  GetPlayerInfo().c_str(), dungeonId);
402  //sLFGMgr->LeaveLfr(GetPlayer(), dungeonId);
403 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32_t uint32
Definition: Define.h:150
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195

+ Here is the call graph for this function:

void WorldSession::HandleListInventoryOpcode ( WorldPackets::NPC::Hello packet)
533 {
534  if (!GetPlayer()->IsAlive())
535  return;
536 
537  SendListInventory(packet.Unit);
538 }
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Unit
Definition: NPCPackets.h:45
void SendListInventory(ObjectGuid guid)
Definition: ItemHandler.cpp:540

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLoadScreenOpcode ( WorldPackets::Character::LoadingScreenNotify loadingScreenNotify)
889 {
890  // TODO: Do something with this packet
891 }

+ Here is the caller graph for this function:

void WorldSession::HandleLogoutCancelOpcode ( WorldPackets::Character::LogoutCancel logoutCancel)

we can move again

Stand Up

DISABLE_ROTATE

298 {
299  // Player have already logged out serverside, too late to cancel
300  if (!GetPlayer())
301  return;
302 
304 
306 
307  // not remove flags if can't free move - its not set in Logout request code.
308  if (GetPlayer()->CanFreeMove())
309  {
311  GetPlayer()->SetRooted(false);
312 
314  GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND);
315 
318  }
319 
320  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_LOGOUT_CANCEL_ACK Message");
321 }
Definition: Unit.h:207
void SetLogoutStartTime(time_t requestTime)
Engage the logout process for the user.
Definition: WorldSession.h:946
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: CharacterPackets.h:498
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: UpdateFields.h:109
Definition: Unit.h:691

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLogoutRequestOpcode ( WorldPackets::Character::LogoutRequest logoutRequest)

TODO: Possibly add RBAC permission to log out in combat

248 {
249  ObjectGuid lguid = GetPlayer()->GetLootGUID();
250  if (!lguid.IsEmpty())
251  DoLootRelease(lguid);
252 
253  bool instantLogout = (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) && !GetPlayer()->IsInCombat()) ||
255 
257  bool canLogoutInCombat = GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
258 
259  uint32 reason = 0;
260  if (GetPlayer()->IsInCombat() && !canLogoutInCombat)
261  reason = 1;
262  else if (GetPlayer()->IsFalling())
263  reason = 3; // is jumping or falling
264  else if (GetPlayer()->duel || GetPlayer()->HasAura(9454)) // is dueling or frozen by GM via freeze command
265  reason = 2; // FIXME - Need the correct value
266 
268  logoutResponse.LogoutResult = reason;
269  logoutResponse.Instant = instantLogout;
270  SendPacket(logoutResponse.Write());
271 
272  if (reason)
273  {
275  return;
276  }
277 
278  // instant logout in taverns/cities or on taxi or for admins, gm's, mod's if its enabled in worldserver.conf
279  if (instantLogout)
280  {
281  LogoutPlayer(true);
282  return;
283  }
284 
285  // not set flags if player can't free move to prevent lost state at logout cancel
286  if (GetPlayer()->CanFreeMove())
287  {
288  if (GetPlayer()->GetStandState() == UNIT_STAND_STATE_STAND)
289  GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT);
290  GetPlayer()->SetRooted(true);
292  }
293 
294  SetLogoutStartTime(time(NULL));
295 }
Definition: Unit.h:208
Definition: Unit.h:207
bool Instant
Definition: CharacterPackets.h:477
Definition: CharacterPackets.h:469
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:386
Definition: RBAC.h:53
void SetLogoutStartTime(time_t requestTime)
Engage the logout process for the user.
Definition: WorldSession.h:946
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
void LogoutPlayer(bool save)
Log the player out
Definition: WorldSession.cpp:498
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 LogoutResult
Definition: CharacterPackets.h:476
Definition: UpdateFields.h:109
void DoLootRelease(ObjectGuid lguid)
Definition: LootHandler.cpp:250
Definition: Unit.h:691
Definition: UpdateFields.h:191
Definition: ObjectGuid.h:189
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Player.h:522

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLookingForGroup ( WorldPacket recvPacket)
void WorldSession::HandleLootMasterGiveOpcode ( WorldPacket recvPacket)
389 {
390  uint8 slotid;
391  ObjectGuid lootguid, target_playerguid;
392 
393  recvData >> lootguid >> slotid >> target_playerguid;
394 
395  if (!_player->GetGroup() || _player->GetGroup()->GetMasterLooterGuid() != _player->GetGUID() || _player->GetGroup()->GetLootMethod() != MASTER_LOOT)
396  {
397  _player->SendLootError(lootguid, LOOT_ERROR_DIDNT_KILL);
398  return;
399  }
400 
401  Player* target = ObjectAccessor::FindPlayer(target_playerguid);
402  if (!target)
403  {
404  _player->SendLootError(lootguid, LOOT_ERROR_PLAYER_NOT_FOUND);
405  return;
406  }
407 
408  TC_LOG_DEBUG("network", "WorldSession::HandleLootMasterGiveOpcode (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [%s].", target->GetName().c_str());
409 
410  if (_player->GetLootGUID() != lootguid)
411  {
412  _player->SendLootError(lootguid, LOOT_ERROR_DIDNT_KILL);
413  return;
414  }
415 
416  if (!_player->IsInRaidWith(target) || !_player->IsInMap(target))
417  {
418  _player->SendLootError(lootguid, LOOT_ERROR_MASTER_OTHER);
419  TC_LOG_INFO("loot", "MasterLootItem: Player %s tried to give an item to ineligible player %s !", GetPlayer()->GetName().c_str(), target->GetName().c_str());
420  return;
421  }
422 
423  Loot* loot = NULL;
424 
425  if (GetPlayer()->GetLootGUID().IsCreatureOrVehicle())
426  {
427  Creature* creature = GetPlayer()->GetMap()->GetCreature(lootguid);
428  if (!creature)
429  return;
430 
431  loot = &creature->loot;
432  }
433  else if (GetPlayer()->GetLootGUID().IsGameObject())
434  {
435  GameObject* pGO = GetPlayer()->GetMap()->GetGameObject(lootguid);
436  if (!pGO)
437  return;
438 
439  loot = &pGO->loot;
440  }
441 
442  if (!loot)
443  return;
444 
445  if (slotid >= loot->items.size() + loot->quest_items.size())
446  {
447  TC_LOG_DEBUG("loot", "MasterLootItem: Player %s might be using a hack! (slot %d, size %lu)",
448  GetPlayer()->GetName().c_str(), slotid, (unsigned long)loot->items.size());
449  return;
450  }
451 
452  LootItem& item = slotid >= loot->items.size() ? loot->quest_items[slotid - loot->items.size()] : loot->items[slotid];
453 
454  ItemPosCountVec dest;
455  InventoryResult msg = target->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item.itemid, item.count);
456  if (item.follow_loot_rules && !item.AllowedForPlayer(target))
458  if (msg != EQUIP_ERR_OK)
459  {
460  if (msg == EQUIP_ERR_ITEM_MAX_COUNT)
461  _player->SendLootError(lootguid, LOOT_ERROR_MASTER_UNIQUE_ITEM);
462  else if (msg == EQUIP_ERR_INV_FULL)
463  _player->SendLootError(lootguid, LOOT_ERROR_MASTER_INV_FULL);
464  else
465  _player->SendLootError(lootguid, LOOT_ERROR_MASTER_OTHER);
466 
467  target->SendEquipError(msg, NULL, NULL, item.itemid);
468  return;
469  }
470 
471  // now move item from loot to target inventory
472  Item* newitem = target->StoreNewItem(dest, item.itemid, true, item.randomPropertyId, item.GetAllowedLooters(), item.BonusListIDs);
473  target->SendNewItem(newitem, uint32(item.count), false, false, true);
474  target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_ITEM, item.itemid, item.count);
475  target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_TYPE, item.itemid, item.count, loot->loot_type);
476  target->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_EPIC_ITEM, item.itemid, item.count);
477 
478  // mark as looted
479  item.count = 0;
480  item.is_looted = true;
481 
482  loot->NotifyItemRemoved(slotid);
483  --loot->unlootedCount;
484 }
Definition: LootMgr.h:112
bool follow_loot_rules
Definition: LootMgr.h:172
Definition: Item.h:98
Definition: LootMgr.h:114
Definition: DBCEnums.h:234
Definition: Unit.h:379
Definition: Item.h:58
Definition: LootMgr.h:115
Loot loot
Definition: Creature.h:578
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
bool is_looted
Definition: LootMgr.h:166
void NotifyItemRemoved(uint8 lootIndex)
Definition: LootMgr.cpp:629
int32 randomPropertyId
Definition: LootMgr.h:161
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: Item.h:48
Definition: Unit.h:378
uint8 unlootedCount
Definition: LootMgr.h:323
GuidSet const & GetAllowedLooters() const
Definition: LootMgr.h:187
Definition: LootMgr.h:314
Definition: Item.h:259
bool AllowedForPlayer(Player const *player) const
Definition: LootMgr.cpp:378
Loot loot
Definition: GameObject.h:1007
Definition: GameObject.h:880
Definition: Item.h:65
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: LootMgr.h:157
Definition: LootMgr.h:116
std::vector< LootItem > items
Definition: LootMgr.h:320
Player * _player
Definition: WorldSession.h:1797
LootType loot_type
Definition: LootMgr.h:325
uint8_t uint8
Definition: Define.h:152
Definition: LootMgr.h:106
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
uint8 count
Definition: LootMgr.h:165
Definition: ObjectGuid.h:189
Definition: DBCEnums.h:289
uint32_t uint32
Definition: g3dmath.h:168
std::vector< int32 > BonusListIDs
Definition: LootMgr.h:162
InventoryResult
Definition: Item.h:46
uint32 itemid
Definition: LootMgr.h:159
std::vector< LootItem > quest_items
Definition: LootMgr.h:321
Definition: LootMgr.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLootMoneyOpcode ( WorldPackets::Loot::LootMoney packet)
104 {
105  Player* player = GetPlayer();
106  ObjectGuid guid = player->GetLootGUID();
107  if (!guid)
108  return;
109 
110  Loot* loot = NULL;
111  bool shareMoney = true;
112 
113  switch (guid.GetHigh())
114  {
116  {
117  GameObject* go = GetPlayer()->GetMap()->GetGameObject(guid);
118 
119  // do not check distance for GO if player is the owner of it (ex. fishing bobber)
120  if (go && ((go->GetOwnerGUID() == player->GetGUID() || go->IsWithinDistInMap(player, INTERACTION_DISTANCE))))
121  loot = &go->loot;
122 
123  break;
124  }
125  case HighGuid::Corpse: // remove insignia ONLY in BG
126  {
127  Corpse* bones = ObjectAccessor::GetCorpse(*player, guid);
128 
129  if (bones && bones->IsWithinDistInMap(player, INTERACTION_DISTANCE))
130  {
131  loot = &bones->loot;
132  shareMoney = false;
133  }
134 
135  break;
136  }
137  case HighGuid::Item:
138  {
139  if (Item* item = player->GetItemByGuid(guid))
140  {
141  loot = &item->loot;
142  shareMoney = false;
143  }
144  break;
145  }
146  case HighGuid::Creature:
147  case HighGuid::Vehicle:
148  {
149  Creature* creature = player->GetMap()->GetCreature(guid);
150  bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
151  if (lootAllowed && creature->IsWithinDistInMap(player, INTERACTION_DISTANCE))
152  {
153  loot = &creature->loot;
154  if (creature->IsAlive())
155  shareMoney = false;
156  }
157  else
158  player->SendLootError(guid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL);
159  break;
160  }
161  default:
162  return; // unlootable type
163  }
164 
165  if (loot)
166  {
167  loot->NotifyMoneyRemoved();
168  if (shareMoney && player->GetGroup()) //item, pickpocket and players can be looted only single player
169  {
170  Group* group = player->GetGroup();
171 
172  std::vector<Player*> playersNear;
173  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
174  {
175  Player* member = itr->GetSource();
176  if (!member)
177  continue;
178 
179  if (player->IsAtGroupRewardDistance(member))
180  playersNear.push_back(member);
181  }
182 
183  uint32 goldPerPlayer = uint32((loot->gold) / (playersNear.size()));
184 
185  for (std::vector<Player*>::const_iterator i = playersNear.begin(); i != playersNear.end(); ++i)
186  {
187  (*i)->ModifyMoney(goldPerPlayer);
188  (*i)->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, goldPerPlayer);
189 
190  if (Guild* guild = sGuildMgr->GetGuildById((*i)->GetGuildId()))
191  if (uint32 guildGold = CalculatePct(goldPerPlayer, (*i)->GetTotalAuraModifier(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT)))
192  guild->HandleMemberDepositMoney(this, guildGold, true);
193 
195  packet.Money = goldPerPlayer;
196  packet.SoleLooter = playersNear.size() <= 1 ? true : false;
197  (*i)->SendDirectMessage(packet.Write());
198  }
199  }
200  else
201  {
202  player->ModifyMoney(loot->gold);
203  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LOOT_MONEY, loot->gold);
204 
205  if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
206  if (uint32 guildGold = CalculatePct(loot->gold, player->GetTotalAuraModifier(SPELL_AURA_DEPOSIT_BONUS_MONEY_IN_GUILD_BANK_ON_LOOT)))
207  guild->HandleMemberDepositMoney(this, guildGold, true);
208 
210  packet.Money = loot->gold;
211  packet.SoleLooter = true; // "You loot..."
212  SendPacket(packet.Write());
213  }
214 
215  loot->gold = 0;
216 
217  // Delete the money loot record from the DB
218  if (!loot->containerID.IsEmpty())
220 
221  // Delete container if empty
222  if (loot->isLooted() && guid.IsItem())
223  player->GetSession()->DoLootRelease(guid);
224  }
225 }
#define INTERACTION_DISTANCE
Definition: Object.h:34
Definition: SharedDefines.h:170
Definition: Corpse.h:49
Map * GetMap() const
Definition: Object.h:543
#define sGuildMgr
Definition: GuildMgr.h:61
Loot loot
Definition: Creature.h:578
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: LootPackets.h:126
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 Money
Definition: LootPackets.h:133
WorldPacket const * Write() override
Definition: LootPackets.cpp:94
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
bool IsItem() const
Definition: ObjectGuid.h:251
Definition: LootMgr.h:314
bool IsAlive() const
Definition: Unit.h:1692
Definition: LootMgr.h:107
void NotifyMoneyRemoved()
Definition: LootMgr.cpp:645
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
Loot loot
Definition: GameObject.h:1007
Definition: GameObject.h:880
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
GroupReference * GetFirstMember()
Definition: Group.h:295
T CalculatePct(T base, U pct)
Definition: Util.h:92
ObjectGuid GetOwnerGUID() const
Definition: GameObject.h:925
uint32 gold
Definition: LootMgr.h:322
bool isLooted() const
Definition: LootMgr.h:375
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
LootType loot_type
Definition: LootMgr.h:325
Definition: DBCEnums.h:257
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
Definition: LootMgr.h:91
Loot loot
Definition: Corpse.h:76
Definition: LootMgr.h:106
ObjectGuid containerID
Definition: LootMgr.h:330
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
void DeleteLootMoneyFromContainerItemDB()
Definition: LootMgr.cpp:726
Definition: Guild.h:320
bool SoleLooter
Definition: LootPackets.h:134
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLootOpcode ( WorldPackets::Loot::LootUnit packet)
228 {
229  // Check possible cheat
230  if (!GetPlayer()->IsAlive() || !packet.Unit.IsCreatureOrVehicle())
231  return;
232 
233  GetPlayer()->SendLoot(packet.Unit, LOOT_CORPSE);
234 
235  // interrupt cast
236  if (GetPlayer()->IsNonMeleeSpellCast(false))
237  GetPlayer()->InterruptNonMeleeSpells(false);
238 }
bool IsCreatureOrVehicle() const
Definition: ObjectGuid.h:247
ObjectGuid Unit
Definition: LootPackets.h:36
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: LootMgr.h:90

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLootReleaseOpcode ( WorldPackets::Loot::LootRelease packet)
241 {
242  // cheaters can modify lguid to prevent correct apply loot release code and re-loot
243  // use internal stored guid
244  ObjectGuid lguid = GetPlayer()->GetLootGUID();
245  if (!lguid.IsEmpty())
246  if (lguid == packet.Unit)
247  DoLootRelease(lguid);
248 }
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Unit
Definition: LootPackets.h:115
void DoLootRelease(ObjectGuid lguid)
Definition: LootHandler.cpp:250
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleLootRoll ( WorldPackets::Loot::LootRoll packet)
369 {
370  Group* group = GetPlayer()->GetGroup();
371  if (!group)
372  return;
373 
374  group->CountRollVote(GetPlayer()->GetGUID(), packet.LootObj, packet.RollType);
375 
376  switch (packet.RollType)
377  {
378  case ROLL_NEED:
379  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_NEED, 1);
380  break;
381  case ROLL_GREED:
382  GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ROLL_GREED, 1);
383  break;
384  }
385 }
void CountRollVote(ObjectGuid playerGUID, ObjectGuid Guid, uint8 Choise)
Definition: Group.cpp:1325
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid LootObj
Definition: LootPackets.h:154
Definition: DBCEnums.h:279
uint8 RollType
Definition: LootPackets.h:156
Definition: DBCEnums.h:280
Definition: LootMgr.h:43
Definition: LootMgr.h:44
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMailCreateTextItem ( WorldPackets::Mail::MailCreateTextItem packet)
601 {
602  if (!CanOpenMailBox(packet.Mailbox))
603  return;
604 
605  Player* player = _player;
606 
607  Mail* m = player->GetMail(packet.MailID);
608  if (!m || (m->body.empty() && !m->mailTemplateId) || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr) || (m->checked & MAIL_CHECK_MASK_COPIED))
609  {
610  player->SendMailResult(packet.MailID, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
611  return;
612  }
613 
614  Item* bodyItem = new Item; // This is not bag and then can be used new Item.
615  if (!bodyItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), MAIL_BODY_ITEM_TEMPLATE, player))
616  {
617  delete bodyItem;
618  return;
619  }
620 
621  // in mail template case we need create new item text
622  if (m->mailTemplateId)
623  {
624  MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId);
625  if (!mailTemplateEntry)
626  {
627  player->SendMailResult(packet.MailID, MAIL_MADE_PERMANENT, MAIL_ERR_INTERNAL_ERROR);
628  return;
629  }
630 
631  bodyItem->SetText(mailTemplateEntry->Body->Str[GetSessionDbcLocale()]);
632  }
633  else
634  bodyItem->SetText(m->body);
635 
636  if (m->messageType == MAIL_NORMAL)
637  bodyItem->SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(m->sender));
638 
640 
641  ItemPosCountVec dest;
642  uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, bodyItem, false);
643  if (msg == EQUIP_ERR_OK)
644  {
647  player->m_mailsUpdated = true;
648 
649  player->StoreItem(dest, bodyItem, true);
650  player->SendMailResult(packet.MailID, MAIL_MADE_PERMANENT, MAIL_OK);
651  }
652  else
653  {
654  player->SendMailResult(packet.MailID, MAIL_MADE_PERMANENT, MAIL_ERR_EQUIP_ERROR, msg);
655  delete bodyItem;
656  }
657 }
uint32 MailID
Definition: MailPackets.h:103
Definition: UpdateFields.h:44
Definition: ItemTemplate.h:168
uint16 mailTemplateId
Definition: Mail.h:171
Definition: Unit.h:379
Definition: SharedDefines.h:4605
Definition: DB2Structure.h:897
uint8 messageType
Definition: Mail.h:169
ObjectGuid Mailbox
Definition: MailPackets.h:102
virtual bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const *owner)
Definition: Item.cpp:254
MailState state
Definition: Mail.h:183
Definition: UpdateFields.h:49
uint32 checked
Definition: Mail.h:182
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Mail.h:70
Definition: Mail.h:38
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
#define sObjectMgr
Definition: ObjectMgr.h:1567
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:50
Definition: SharedDefines.h:4606
DB2Storage< MailTemplateEntry > sMailTemplateStore("MailTemplate.db2", MailTemplateFormat, HOTFIX_SEL_MAIL_TEMPLATE)
std::string body
Definition: Mail.h:175
Definition: Mail.h:166
char const * Str[TOTAL_LOCALES]
Definition: Common.h:148
Definition: Item.h:48
Definition: Unit.h:378
Definition: Item.h:259
#define MAIL_BODY_ITEM_TEMPLATE
Definition: Mail.h:33
time_t deliver_time
Definition: Mail.h:179
Definition: Mail.h:71
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4611
uint8_t uint8
Definition: Define.h:152
LocalizedString * Body
Definition: DB2Structure.h:900
Definition: SharedDefines.h:4600
void SetText(std::string const &text)
Definition: Item.h:356
ObjectGuid::LowType sender
Definition: Mail.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMailDelete ( WorldPackets::Mail::MailDelete packet)
363 {
364  Mail* m = _player->GetMail(packet.MailID);
365  Player* player = _player;
366  player->m_mailsUpdated = true;
367  if (m)
368  {
369  // delete shouldn't show up for COD mails
370  if (m->COD)
371  {
372  player->SendMailResult(packet.MailID, MAIL_DELETED, MAIL_ERR_INTERNAL_ERROR);
373  return;
374  }
375 
377  }
378  player->SendMailResult(packet.MailID, MAIL_DELETED, MAIL_OK);
379 }
Definition: SharedDefines.h:4605
MailState state
Definition: Mail.h:183
uint64 COD
Definition: Mail.h:181
Definition: Mail.h:166
Definition: SharedDefines.h:4599
Definition: Mail.h:71
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4611
int32 MailID
Definition: MailPackets.h:179

+ Here is the caller graph for this function:

void WorldSession::HandleMailMarkAsRead ( WorldPackets::Mail::MailMarkAsRead packet)
345 {
346  if (!CanOpenMailBox(packet.Mailbox))
347  return;
348 
349  Player* player = _player;
350  Mail* m = player->GetMail(packet.MailID);
351  if (m && m->state != MAIL_STATE_DELETED)
352  {
353  if (player->unReadMails)
354  --player->unReadMails;
356  player->m_mailsUpdated = true;
358  }
359 }
MailState state
Definition: Mail.h:183
uint32 checked
Definition: Mail.h:182
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Mail.h:70
int32 MailID
Definition: MailPackets.h:168
Definition: Mail.h:166
ObjectGuid Mailbox
Definition: MailPackets.h:167
Definition: Mail.h:71
Definition: Mail.h:48
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMailReturnToSender ( WorldPackets::Mail::MailReturnToSender packet)
382 {
383  //TODO: find a proper way to replace this check. Idea: Save Guid form MailGetList until CMSG_CLOSE_INTERACTION is sent
384  /*if (!CanOpenMailBox(mailbox))
385  return;*/
386 
387  Player* player = _player;
388  Mail* m = player->GetMail(packet.MailID);
389  if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr) || m->sender != packet.SenderGUID.GetCounter())
390  {
391  player->SendMailResult(packet.MailID, MAIL_RETURNED_TO_SENDER, MAIL_ERR_INTERNAL_ERROR);
392  return;
393  }
394  //we can return mail now, so firstly delete the old one
396 
398  stmt->setUInt32(0, packet.MailID);
399  trans->Append(stmt);
400 
402  stmt->setUInt32(0, packet.MailID);
403  trans->Append(stmt);
404 
405  player->RemoveMail(packet.MailID);
406 
407  // only return mail if the player exists (and delete if not existing)
408  if (m->messageType == MAIL_NORMAL && m->sender)
409  {
410  MailDraft draft(m->subject, m->body);
411  if (m->mailTemplateId)
412  draft = MailDraft(m->mailTemplateId, false); // items already included
413 
414  if (m->HasItems())
415  {
416  for (MailItemInfoVec::iterator itr2 = m->items.begin(); itr2 != m->items.end(); ++itr2)
417  {
418  if (Item* const item = player->GetMItem(itr2->item_guid))
419  draft.AddItem(item);
420  player->RemoveMItem(itr2->item_guid);
421  }
422  }
423  draft.AddMoney(m->money).SendReturnToSender(GetAccountId(), m->receiver, m->sender, trans);
424  }
425 
427 
428  delete m; //we can deallocate old mail
429  player->SendMailResult(packet.MailID, MAIL_RETURNED_TO_SENDER, MAIL_OK);
430 }
std::vector< MailItemInfo > items
Definition: Mail.h:176
int32 MailID
Definition: MailPackets.h:156
uint16 mailTemplateId
Definition: Mail.h:171
Definition: SharedDefines.h:4605
uint8 messageType
Definition: Mail.h:169
MailState state
Definition: Mail.h:183
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
ObjectGuid SenderGUID
Definition: MailPackets.h:157
Definition: Mail.h:38
ObjectGuid::LowType receiver
Definition: Mail.h:173
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
uint64 money
Definition: Mail.h:180
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
std::string body
Definition: Mail.h:175
Definition: Mail.h:166
Definition: Mail.h:118
Definition: CharacterDatabase.h:425
bool HasItems() const
Definition: Mail.h:206
Definition: Item.h:259
Definition: CharacterDatabase.h:127
time_t deliver_time
Definition: Mail.h:179
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: Mail.h:71
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4611
std::string subject
Definition: Mail.h:174
Definition: SharedDefines.h:4598
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58
ObjectGuid::LowType sender
Definition: Mail.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMailTakeItem ( WorldPackets::Mail::MailTakeItem packet)
434 {
435  uint32 AttachID = packet.AttachID;
436 
437  if (!CanOpenMailBox(packet.Mailbox))
438  return;
439 
440  Player* player = _player;
441 
442  Mail* m = player->GetMail(packet.MailID);
443  if (!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(nullptr))
444  {
445  player->SendMailResult(packet.MailID, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
446  return;
447  }
448 
449  // verify that the mail has the item to avoid cheaters taking COD items without paying
450  if (std::find_if(m->items.begin(), m->items.end(), [AttachID](MailItemInfo info){ return info.item_guid == AttachID; }) == m->items.end())
451  {
452  player->SendMailResult(packet.MailID, MAIL_ITEM_TAKEN, MAIL_ERR_INTERNAL_ERROR);
453  return;
454  }
455 
456  // prevent cheating with skip client money check
457  if (!player->HasEnoughMoney(uint64(m->COD)))
458  {
459  player->SendMailResult(packet.MailID, MAIL_ITEM_TAKEN, MAIL_ERR_NOT_ENOUGH_MONEY);
460  return;
461  }
462 
463  Item* it = player->GetMItem(packet.AttachID);
464 
465  ItemPosCountVec dest;
466  uint8 msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, it, false);
467  if (msg == EQUIP_ERR_OK)
468  {
470  m->RemoveItem(packet.AttachID);
471  m->removedItems.push_back(packet.AttachID);
472 
473  if (m->COD > 0) //if there is COD, take COD money from player and send them to sender by mail
474  {
475  ObjectGuid sender_guid = ObjectGuid::Create<HighGuid::Player>(m->sender);
476  Player* receiver = ObjectAccessor::FindConnectedPlayer(sender_guid);
477 
478  uint32 sender_accId = 0;
479 
481  {
482  std::string sender_name;
483  if (receiver)
484  {
485  sender_accId = receiver->GetSession()->GetAccountId();
486  sender_name = receiver->GetName();
487  }
488  else
489  {
490  // can be calculated early
491  sender_accId = ObjectMgr::GetPlayerAccountIdByGUID(sender_guid);
492 
493  if (!ObjectMgr::GetPlayerNameByGUID(sender_guid, sender_name))
494  sender_name = sObjectMgr->GetTrinityStringForDBCLocale(LANG_UNKNOWN);
495  }
496  sLog->outCommand(GetAccountId(), "GM %s (Account: %u) receiver mail item: %s (Entry: %u Count: %u) and send COD money: " UI64FMTD " to player: %s (Account: %u)",
497  GetPlayerName().c_str(), GetAccountId(), it->GetTemplate()->GetDefaultLocaleName(), it->GetEntry(), it->GetCount(), m->COD, sender_name.c_str(), sender_accId);
498  }
499  else if (!receiver)
500  sender_accId = ObjectMgr::GetPlayerAccountIdByGUID(sender_guid);
501 
502  // check player existence
503  if (receiver || sender_accId)
504  {
505  MailDraft(m->subject, "")
506  .AddMoney(m->COD)
508  }
509 
510  player->ModifyMoney(-int32(m->COD));
511  }
512  m->COD = 0;
514  player->m_mailsUpdated = true;
515  player->RemoveMItem(it->GetGUID().GetCounter());
516 
517  uint32 count = it->GetCount(); // save counts before store and possible merge with deleting
518  it->SetState(ITEM_UNCHANGED); // need to set this state, otherwise item cannot be removed later, if neccessary
519  player->MoveItemToInventory(dest, it, true);
520 
521  player->SaveInventoryAndGoldToDB(trans);
522  player->_SaveMail(trans);
524 
525  player->SendMailResult(packet.MailID, MAIL_ITEM_TAKEN, MAIL_OK, 0, packet.AttachID, count);
526  }
527  else
528  player->SendMailResult(packet.MailID, MAIL_ITEM_TAKEN, MAIL_ERR_EQUIP_ERROR, msg);
529 }
std::vector< MailItemInfo > items
Definition: Mail.h:176
uint32 GetCount() const
Definition: Item.h:322
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
Definition: Unit.h:379
This mail was copied. Do not allow making a copy of items in mail.
Definition: Mail.h:51
Definition: SharedDefines.h:4605
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
MailState state
Definition: Mail.h:183
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Mail.h:70
uint64 COD
Definition: Mail.h:181
#define sLog
Definition: Log.h:154
Definition: Mail.h:38
ObjectGuid::LowType receiver
Definition: Mail.h:173
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:4606
Definition: Mail.h:159
void SendMailTo(SQLTransaction &trans, MailReceiver const &receiver, MailSender const &sender, MailCheckMask checked=MAIL_CHECK_MASK_NONE, uint32 deliver_delay=0)
Definition: Mail.cpp:173
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Mail.h:166
Definition: Mail.h:118
Definition: Item.h:48
Definition: Unit.h:378
int32 AttachID
Definition: MailPackets.h:192
Definition: Item.h:259
#define UI64FMTD
Definition: Define.h:137
uint32_t uint32
Definition: Define.h:150
time_t deliver_time
Definition: Mail.h:179
uint64_t uint64
Definition: Define.h:149
Definition: Mail.h:71
ObjectGuid Mailbox
Definition: MailPackets.h:190
Definition: Item.h:216
int32 MailID
Definition: MailPackets.h:191
ObjectGuid const & GetGUID() const
Definition: Object.h:105
static bool GetPlayerNameByGUID(ObjectGuid const &guid, std::string &name)
Definition: ObjectMgr.cpp:2258
Definition: SharedDefines.h:4597
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4608
Definition: SharedDefines.h:4611
std::string subject
Definition: Mail.h:174
int32_t int32
Definition: g3dmath.h:167
Definition: RBAC.h:63
MailDraft & AddMoney(uint64 money)
Definition: Mail.h:137
uint8_t uint8
Definition: Define.h:152
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetEntry() const
Definition: Object.h:107
Definition: ObjectGuid.h:189
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: Language.h:78
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: Mail.h:104
bool RemoveItem(ObjectGuid::LowType item_guid)
Definition: Mail.h:193
std::vector< ObjectGuid::LowType > removedItems
Definition: Mail.h:177
Definition: Mail.h:83
LowType GetCounter() const
Definition: ObjectGuid.h:221
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58
ObjectGuid::LowType sender
Definition: Mail.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMailTakeMoney ( WorldPackets::Mail::MailTakeMoney packet)
532 {
533  if (!CanOpenMailBox(packet.Mailbox))
534  return;
535 
536  Player* player = _player;
537 
538  Mail* m = player->GetMail(packet.MailID);
539  if ((!m || m->state == MAIL_STATE_DELETED || m->deliver_time > time(NULL)) ||
540  (packet.Money > 0 && m->money != uint64(packet.Money)))
541  {
542  player->SendMailResult(packet.MailID, MAIL_MONEY_TAKEN, MAIL_ERR_INTERNAL_ERROR);
543  return;
544  }
545 
546  if (!player->ModifyMoney(m->money, false))
547  {
548  player->SendMailResult(packet.MailID, MAIL_MONEY_TAKEN, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_TOO_MUCH_GOLD);
549  return;
550  }
551 
552  m->money = 0;
554  player->m_mailsUpdated = true;
555 
556  player->SendMailResult(packet.MailID, MAIL_MONEY_TAKEN, MAIL_OK);
557 
558  // save money and mail to prevent cheating
560  player->SaveGoldToDB(trans);
561  player->_SaveMail(trans);
563 }
int64 Money
Definition: MailPackets.h:204
Definition: SharedDefines.h:4605
MailState state
Definition: Mail.h:183
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Mail.h:70
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: SharedDefines.h:4606
int32 MailID
Definition: MailPackets.h:203
uint64 money
Definition: Mail.h:180
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Mail.h:166
Definition: Item.h:125
time_t deliver_time
Definition: Mail.h:179
uint64_t uint64
Definition: Define.h:149
Definition: Mail.h:71
ObjectGuid Mailbox
Definition: MailPackets.h:202
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4611
Definition: SharedDefines.h:4596
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMeetingStoneInfo ( WorldPacket recPacket)
void WorldSession::HandleMinimapPingOpcode ( WorldPackets::Party::MinimapPingClient packet)
388 {
389  if (!GetPlayer()->GetGroup())
390  return;
391 
393  minimapPing.Sender = GetPlayer()->GetGUID();
394  minimapPing.PositionX = packet.PositionX;
395  minimapPing.PositionY = packet.PositionY;
396  GetPlayer()->GetGroup()->BroadcastPacket(minimapPing.Write(), true, -1, GetPlayer()->GetGUID());
397 }
float PositionY
Definition: PartyPackets.h:282
WorldPacket const * Write() override
Definition: PartyPackets.cpp:211
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PartyPackets.h:285
ObjectGuid Sender
Definition: PartyPackets.h:292
float PositionX
Definition: PartyPackets.h:293
float PositionY
Definition: PartyPackets.h:294
float PositionX
Definition: PartyPackets.h:281

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMirrorImageDataRequest ( WorldPackets::Spells::GetMirrorImageData getMirrorImageData)
481 {
482  ObjectGuid guid = getMirrorImageData.UnitGUID;
483 
484  // Get unit for which data is needed by client
485  Unit* unit = ObjectAccessor::GetUnit(*_player, guid);
486  if (!unit)
487  return;
488 
490  return;
491 
492  // Get creator of the unit (SPELL_AURA_CLONE_CASTER does not stack)
493  Unit* creator = unit->GetAuraEffectsByType(SPELL_AURA_CLONE_CASTER).front()->GetCaster();
494  if (!creator)
495  return;
496 
497  if (Player* player = creator->ToPlayer())
498  {
499  WorldPackets::Spells::MirrorImageComponentedData mirrorImageComponentedData;
500  mirrorImageComponentedData.UnitGUID = guid;
501  mirrorImageComponentedData.DisplayID = creator->GetDisplayId();
502  mirrorImageComponentedData.RaceID = creator->getRace();
503  mirrorImageComponentedData.Gender = creator->getGender();
504  mirrorImageComponentedData.ClassID = creator->getClass();
505 
506  Guild* guild = player->GetGuild();
507 
508  mirrorImageComponentedData.SkinColor = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_SKIN_ID);
509  mirrorImageComponentedData.FaceVariation = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_FACE_ID);
510  mirrorImageComponentedData.HairVariation = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_STYLE_ID);
511  mirrorImageComponentedData.HairColor = player->GetByteValue(PLAYER_BYTES, PLAYER_BYTES_OFFSET_HAIR_COLOR_ID);
512  mirrorImageComponentedData.BeardVariation = player->GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_FACIAL_STYLE);
513  mirrorImageComponentedData.GuildGUID = (guild ? guild->GetGUID() : ObjectGuid::Empty);
514 
515  mirrorImageComponentedData.ItemDisplayID.reserve(11);
516 
517  static EquipmentSlots const itemSlots[] =
518  {
519  EQUIPMENT_SLOT_HEAD,
520  EQUIPMENT_SLOT_SHOULDERS,
521  EQUIPMENT_SLOT_BODY,
522  EQUIPMENT_SLOT_CHEST,
523  EQUIPMENT_SLOT_WAIST,
524  EQUIPMENT_SLOT_LEGS,
525  EQUIPMENT_SLOT_FEET,
526  EQUIPMENT_SLOT_WRISTS,
527  EQUIPMENT_SLOT_HANDS,
528  EQUIPMENT_SLOT_TABARD,
529  EQUIPMENT_SLOT_BACK,
530  EQUIPMENT_SLOT_END
531  };
532 
533  // Display items in visible slots
534  for (auto const& slot : itemSlots)
535  {
536  uint32 itemDisplayId;
537  if ((slot == EQUIPMENT_SLOT_HEAD && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_HELM)) ||
538  (slot == EQUIPMENT_SLOT_BACK && player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_HIDE_CLOAK)))
539  itemDisplayId = 0;
540  else if (Item const* item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
541  itemDisplayId = item->GetDisplayId();
542  else
543  itemDisplayId = 0;
544 
545  mirrorImageComponentedData.ItemDisplayID.push_back(itemDisplayId);
546  }
547  SendPacket(mirrorImageComponentedData.Write());
548  }
549  else
550  {
551  WorldPackets::Spells::MirrorImageCreatureData mirrorImageCreatureData;
552  mirrorImageCreatureData.UnitGUID = guid;
553  mirrorImageCreatureData.DisplayID = creator->GetDisplayId();
554  SendPacket(mirrorImageCreatureData.Write());
555  }
556 }
#define INVENTORY_SLOT_BAG_0
uint8 HairColor
Definition: SpellPackets.h:773
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
ObjectGuid GuildGUID
Definition: SpellPackets.h:775
uint32 GetDisplayId() const
Definition: Unit.h:2012
Definition: Player.h:572
Definition: SpellAuraDefines.h:307
std::vector< uint32 > ItemDisplayID
Definition: SpellPackets.h:777
uint32 DisplayID
Definition: SpellPackets.h:788
uint8 HairVariation
Definition: SpellPackets.h:772
uint32 DisplayID
Definition: SpellPackets.h:766
uint8 RaceID
Definition: SpellPackets.h:767
Player * ToPlayer()
Definition: Object.h:191
Definition: Player.h:573
WorldPacket const * Write() override
Definition: SpellPackets.cpp:769
Definition: SpellPackets.h:780
Definition: UpdateFields.h:197
uint8 SkinColor
Definition: SpellPackets.h:770
Definition: Player.h:527
ObjectGuid UnitGUID
Definition: SpellPackets.h:754
Definition: Item.h:259
Definition: Player.h:528
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1832
uint32_t uint32
Definition: Define.h:150
ObjectGuid GetGUID() const
Definition: Guild.h:764
uint8 BeardVariation
Definition: SpellPackets.h:774
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: SpellPackets.cpp:747
Definition: Player.h:571
uint8 ClassID
Definition: SpellPackets.h:769
ObjectGuid UnitGUID
Definition: SpellPackets.h:787
uint8 getRace() const
Definition: Unit.h:1411
Player * _player
Definition: WorldSession.h:1797
uint8 getGender() const
Definition: Unit.h:1415
uint8 getClass() const
Definition: Unit.h:1413
bool HasAuraType(AuraType auraType) const
Definition: Unit.cpp:4247
Definition: UpdateFields.h:191
Definition: Player.h:579
Definition: ObjectGuid.h:189
Definition: UpdateFields.h:196
Definition: Guild.h:320
Definition: Unit.h:1305
uint8 FaceVariation
Definition: SpellPackets.h:771
uint8 Gender
Definition: SpellPackets.h:768
Definition: Player.h:574
ObjectGuid UnitGUID
Definition: SpellPackets.h:765

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMissileTrajectoryCollision ( WorldPackets::Spells::MissileTrajectoryCollision packet)
559 {
560  Unit* caster = ObjectAccessor::GetUnit(*_player, packet.Target);
561  if (!caster)
562  return;
563 
564  Spell* spell = caster->FindCurrentSpellBySpellId(packet.SpellID);
565  if (!spell || !spell->m_targets.HasDst())
566  return;
567 
568  Position pos = *spell->m_targets.GetDstPos();
569  pos.Relocate(packet.CollisionPos);
570  spell->m_targets.ModDst(pos);
571 
573  notify.Caster = packet.Target;
574  notify.CastID = packet.CastID;
575  notify.CollisionPos = packet.CollisionPos;
576  caster->SendMessageToSet(notify.Write(), true);
577 }
G3D::Vector3 CollisionPos
Definition: SpellPackets.h:851
ObjectGuid Caster
Definition: SpellPackets.h:849
WorldPacket const * Write() override
Definition: SpellPackets.cpp:811
Spell * FindCurrentSpellBySpellId(uint32 spell_id) const
Definition: Unit.cpp:2931
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
SpellCastTargets m_targets
Definition: Spell.h:584
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
int32 SpellID
Definition: SpellPackets.h:837
uint8 CastID
Definition: SpellPackets.h:850
void ModDst(Position const &pos)
Definition: Spell.cpp:407
void Relocate(float x, float y)
Definition: Position.h:67
bool HasDst() const
Definition: Spell.h:229
G3D::Vector3 CollisionPos
Definition: SpellPackets.h:839
Player * _player
Definition: WorldSession.h:1797
Definition: Position.h:27
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Definition: Unit.h:1305
ObjectGuid Target
Definition: SpellPackets.h:836
uint8 CastID
Definition: SpellPackets.h:838
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMountSpecialAnimOpcode ( WorldPackets::Misc::MountSpecial mountSpecial)
1120 {
1121  WorldPackets::Misc::SpecialMountAnim specialMountAnim;
1122  specialMountAnim.UnitGUID = _player->GetGUID();
1123  GetPlayer()->SendMessageToSet(specialMountAnim.Write(), false);
1124 }
WorldPacket const * Write() override
Definition: MiscPackets.cpp:601
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: MiscPackets.h:783
ObjectGuid UnitGUID
Definition: MiscPackets.h:790
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveChangeVehicleSeats ( WorldPackets::Vehicle::MoveChangeVehicleSeats moveChangeVehicleSeats)
73 {
74  Unit* vehicle_base = GetPlayer()->GetVehicleBase();
75  if (!vehicle_base)
76  return;
77 
78  VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer());
79  if (!seat->CanSwitchFromSeat())
80  {
81  TC_LOG_ERROR("network", "HandleMoveChangeVehicleSeats: %s tried to switch seats but current seatflags %u don't permit that.",
82  GetPlayer()->GetGUID().ToString().c_str(), seat->Flags);
83  return;
84  }
85 
86  GetPlayer()->ValidateMovementInfo(&moveChangeVehicleSeats.Status);
87 
88  if (vehicle_base->GetGUID() != moveChangeVehicleSeats.Status.guid)
89  return;
90 
91  vehicle_base->m_movementInfo = moveChangeVehicleSeats.Status;
92 
93  if (moveChangeVehicleSeats.DstVehicle.IsEmpty())
94  GetPlayer()->ChangeSeat(-1, moveChangeVehicleSeats.DstSeatIndex != 255);
95  else if (Unit* vehUnit = ObjectAccessor::GetUnit(*GetPlayer(), moveChangeVehicleSeats.DstVehicle))
96  if (Vehicle* vehicle = vehUnit->GetVehicleKit())
97  if (vehicle->HasEmptySeat(moveChangeVehicleSeats.DstSeatIndex))
98  vehUnit->HandleSpellClick(GetPlayer(), int8(moveChangeVehicleSeats.DstSeatIndex));
99 }
Definition: DBCStructure.h:1305
Definition: Vehicle.h:32
ObjectGuid DstVehicle
Definition: VehiclePackets.h:103
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
MovementInfo m_movementInfo
Definition: Object.h:612
int8_t int8
Definition: g3dmath.h:163
Player * GetPlayer() const
Definition: WorldSession.h:927
bool CanSwitchFromSeat() const
Definition: DBCStructure.h:1376
string ToString(int i)
Definition: strutil.h:491
ObjectGuid guid
Definition: Object.h:270
MovementInfo Status
Definition: VehiclePackets.h:104
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint8 DstSeatIndex
Definition: VehiclePackets.h:105
uint32 Flags
Definition: DBCStructure.h:1308
Definition: Unit.h:1305
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveDismissVehicle ( WorldPackets::Vehicle::MoveDismissVehicle moveDismissVehicle)
27 {
28  ObjectGuid vehicleGUID = _player->GetCharmGUID();
29  if (vehicleGUID.IsEmpty())
30  return;
31 
32  _player->ValidateMovementInfo(&moveDismissVehicle.Status);
33  _player->m_movementInfo = moveDismissVehicle.Status;
34 
35  _player->ExitVehicle();
36 }
Player * _player
Definition: WorldSession.h:1797
MovementInfo Status
Definition: VehiclePackets.h:77
Definition: ObjectGuid.h:189
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveKnockBackAck ( WorldPackets::Movement::MovementAckMessage movementAck)
493 {
494  GetPlayer()->ValidateMovementInfo(&movementAck.Ack.movementInfo);
495 
496  if (_player->m_mover->GetGUID() != movementAck.Ack.movementInfo.guid)
497  return;
498 
499  _player->m_movementInfo = movementAck.Ack.movementInfo;
500 
502  updateKnockBack.movementInfo = &_player->m_movementInfo;
503  _player->SendMessageToSet(updateKnockBack.Write(), false);
504 }
MovementInfo * movementInfo
Definition: MovementPackets.h:358
Player * GetPlayer() const
Definition: WorldSession.h:927
MovementInfo movementInfo
Definition: MovementPackets.h:292
MovementAck Ack
Definition: MovementPackets.h:303
ObjectGuid guid
Definition: Object.h:270
WorldPacket const * Write() override
Definition: MovementPackets.cpp:644
Player * _player
Definition: WorldSession.h:1797
Definition: MovementPackets.h:351

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMovementAckMessage ( WorldPackets::Movement::MovementAckMessage movementAck)
507 {
508  GetPlayer()->ValidateMovementInfo(&movementAck.Ack.movementInfo);
509 }
Player * GetPlayer() const
Definition: WorldSession.h:927
MovementInfo movementInfo
Definition: MovementPackets.h:292
MovementAck Ack
Definition: MovementPackets.h:303

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMovementOpcodes ( WorldPackets::Movement::ClientPlayerMovement packet)
Todo:
discard movement packets after the player is rooted
261 {
262  OpcodeClient opcode = packet.GetOpcode();
263 
264  Unit* mover = _player->m_mover;
265 
266  ASSERT(mover != nullptr); // there must always be a mover
267 
268  Player* plrMover = mover->ToPlayer();
269 
270  // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
271  if (plrMover && plrMover->IsBeingTeleported())
272  return;
273 
274  GetPlayer()->ValidateMovementInfo(&packet.movementInfo);
275 
276  MovementInfo& movementInfo = packet.movementInfo;
277 
278  // prevent tampered movement data
279  if (movementInfo.guid != mover->GetGUID())
280  {
281  TC_LOG_ERROR("network", "HandleMovementOpcodes: guid error");
282  return;
283  }
284 
285  if (!movementInfo.pos.IsPositionValid())
286  {
287  TC_LOG_ERROR("network", "HandleMovementOpcodes: Invalid Position");
288  return;
289  }
290 
291  // stop some emotes at player move
292  if (plrMover && (plrMover->GetUInt32Value(UNIT_NPC_EMOTESTATE) != 0))
293  plrMover->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_ONESHOT_NONE);
294 
295  /* handle special cases */
296  if (!movementInfo.transport.guid.IsEmpty())
297  {
298  // transports size limited
299  // (also received at zeppelin leave by some reason with t_* as absolute in continent coordinates, can be safely skipped)
300  if (movementInfo.transport.pos.GetPositionX() > 50 || movementInfo.transport.pos.GetPositionY() > 50 || movementInfo.transport.pos.GetPositionZ() > 50)
301  {
302  return;
303  }
304 
305  if (!Trinity::IsValidMapCoord(movementInfo.pos.GetPositionX() + movementInfo.transport.pos.GetPositionX(), movementInfo.pos.GetPositionY() + movementInfo.transport.pos.GetPositionY(),
306  movementInfo.pos.GetPositionZ() + movementInfo.transport.pos.GetPositionZ(), movementInfo.pos.GetOrientation() + movementInfo.transport.pos.GetOrientation()))
307  {
308  return;
309  }
310 
311  // if we boarded a transport, add us to it
312  if (plrMover)
313  {
314  if (!plrMover->GetTransport())
315  {
316  if (Transport* transport = plrMover->GetMap()->GetTransport(movementInfo.transport.guid))
317  transport->AddPassenger(plrMover);
318  }
319  else if (plrMover->GetTransport()->GetGUID() != movementInfo.transport.guid)
320  {
321  plrMover->GetTransport()->RemovePassenger(plrMover);
322  if (Transport* transport = plrMover->GetMap()->GetTransport(movementInfo.transport.guid))
323  transport->AddPassenger(plrMover);
324  else
325  movementInfo.ResetTransport();
326  }
327  }
328 
329  if (!mover->GetTransport() && !mover->GetVehicle())
330  {
331  GameObject* go = mover->GetMap()->GetGameObject(movementInfo.transport.guid);
332  if (!go || go->GetGoType() != GAMEOBJECT_TYPE_TRANSPORT)
333  movementInfo.transport.guid.Clear();
334  }
335  }
336  else if (plrMover && plrMover->GetTransport()) // if we were on a transport, leave
337  plrMover->m_transport->RemovePassenger(plrMover);
338 
339  // fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
340  if (opcode == CMSG_MOVE_FALL_LAND && plrMover && !plrMover->IsInFlight())
341  plrMover->HandleFall(movementInfo);
342 
343  if (plrMover && ((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != plrMover->IsInWater())
344  {
345  // now client not include swimming flag in case jumping under water
346  plrMover->SetInWater(!plrMover->IsInWater() || plrMover->GetBaseMap()->IsUnderWater(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY(), movementInfo.pos.GetPositionZ()));
347  }
348 
349  uint32 mstime = getMSTime();
350  /*----------------------*/
351  if (m_clientTimeDelay == 0)
352  m_clientTimeDelay = mstime - movementInfo.time;
353 
354  /* process position-change */
355  movementInfo.time = movementInfo.time + m_clientTimeDelay + MOVEMENT_PACKET_TIME_DELAY;
356 
357  movementInfo.guid = mover->GetGUID();
358  mover->m_movementInfo = movementInfo;
359 
360  // Some vehicles allow the passenger to turn by himself
361  if (Vehicle* vehicle = mover->GetVehicle())
362  {
363  if (VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(mover))
364  {
365  if (seat->Flags & VEHICLE_SEAT_FLAG_ALLOW_TURNING)
366  {
367  if (movementInfo.pos.GetOrientation() != mover->GetOrientation())
368  {
369  mover->SetOrientation(movementInfo.pos.GetOrientation());
371  }
372  }
373  }
374  return;
375  }
376 
377  mover->UpdatePosition(movementInfo.pos);
378 
380  moveUpdate.movementInfo = &mover->m_movementInfo;
381  mover->SendMessageToSet(moveUpdate.Write(), _player);
382 
383  if (plrMover) // nothing is charmed, or player charmed
384  {
385  if (plrMover->IsSitState() && (movementInfo.flags & (MOVEMENTFLAG_MASK_MOVING | MOVEMENTFLAG_MASK_TURNING)))
386  plrMover->SetStandState(UNIT_STAND_STATE_STAND);
387 
388  plrMover->UpdateFallInformationIfNeed(movementInfo, opcode);
389 
390  if (movementInfo.pos.GetPositionZ() < plrMover->GetMap()->GetMinHeight(movementInfo.pos.GetPositionX(), movementInfo.pos.GetPositionY()))
391  {
392  if (!(plrMover->GetBattleground() && plrMover->GetBattleground()->HandlePlayerUnderMap(_player)))
393  {
394  // NOTE: this is actually called many times while falling
395  // even after the player has been teleported away
397  if (plrMover->IsAlive())
398  {
399  plrMover->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS);
400  plrMover->EnvironmentalDamage(DAMAGE_FALL_TO_VOID, GetPlayer()->GetMaxHealth());
401  // player can be alive if GM/etc
402  // change the death state to CORPSE to prevent the death timer from
403  // starting in the next player update
404  if (!plrMover->IsAlive())
405  plrMover->KillPlayer();
406  }
407  }
408  }
409  }
410 }
Definition: DBCStructure.h:1305
Definition: Unit.h:207
MovementInfo * movementInfo
Definition: MovementPackets.h:52
Definition: Vehicle.h:32
Definition: UpdateFields.h:136
Map * GetMap() const
Definition: Object.h:543
#define MOVEMENT_PACKET_TIME_DELAY
Definition: MovementHandler.cpp:36
void SetOrientation(float orientation)
Definition: Position.h:99
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:808
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except=0)
Definition: Unit.cpp:3816
uint32 getMSTime()
Definition: Timer.h:24
Definition: Opcodes.h:417
Definition: Transport.h:28
Position pos
Definition: Object.h:273
Player * GetPlayer() const
Definition: WorldSession.h:927
struct MovementInfo::TransportInfo transport
Player * ToPlayer()
Definition: Object.h:191
uint32 time
Definition: Object.h:274
Definition: Object.h:267
float GetOrientation() const
Definition: Position.h:107
bool IsValidMapCoord(float c)
Definition: GridDefines.h:218
float GetPositionY() const
Definition: Position.h:105
Definition: Unit.h:796
Definition: Unit.h:58
uint32 flags
Definition: Object.h:271
float GetPositionZ() const
Definition: Position.h:106
OpcodeClient GetOpcode() const
Definition: Packet.h:72
uint32_t uint32
Definition: Define.h:150
WorldPacket const * Write() override
Definition: MovementPackets.cpp:470
Definition: DBCEnums.h:717
Definition: GameObject.h:880
Definition: MovementPackets.h:45
MovementInfo movementInfo
Definition: MovementPackets.h:42
void ResetTransport()
Definition: Object.h:341
void Clear()
Definition: ObjectGuid.h:215
ObjectGuid guid
Definition: Object.h:270
Position pos
Definition: Object.h:290
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Transport * GetTransport() const
Definition: Object.h:602
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Vehicle * GetVehicle() const
Definition: Unit.h:2166
Player * _player
Definition: WorldSession.h:1797
#define ASSERT
Definition: Errors.h:55
virtual bool UpdatePosition(float x, float y, float z, float ang, bool teleport=false)
Definition: Unit.cpp:15454
ObjectGuid guid
Definition: Object.h:289
Definition: UpdateFields.h:191
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
OpcodeClient
Definition: Opcodes.h:46
bool IsPositionValid() const
Definition: Position.cpp:40
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
Transport * GetTransport(ObjectGuid const &guid)
Definition: Map.cpp:3555
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
float GetPositionX() const
Definition: Position.h:104
std::atomic< uint32 > m_clientTimeDelay
Definition: WorldSession.h:1828
Definition: Unit.h:1305
Definition: SharedDefines.h:2076
Definition: SharedDefines.h:2412
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Unit.h:813
Definition: Player.h:531

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveSetVehicleRecAck ( WorldPackets::Vehicle::MoveSetVehicleRecIdAck setVehicleRecIdAck)
189 {
190  GetPlayer()->ValidateMovementInfo(&setVehicleRecIdAck.Data.movementInfo);
191 }
Player * GetPlayer() const
Definition: WorldSession.h:927
WorldPackets::Movement::MovementAck Data
Definition: VehiclePackets.h:47
MovementInfo movementInfo
Definition: MovementPackets.h:292

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveSplineDoneOpcode ( WorldPackets::Movement::MoveSplineDone moveSplineDone)
529 {
530  MovementInfo movementInfo = moveSplineDone.movementInfo;
531  _player->ValidateMovementInfo(&movementInfo);
532 
533  // in taxi flight packet received in 2 case:
534  // 1) end taxi path in far (multi-node) flight
535  // 2) switch from one map to other in case multim-map taxi path
536  // we need process only (1)
537 
538  uint32 curDest = GetPlayer()->m_taxi.GetTaxiDestination();
539  if (curDest)
540  {
541  TaxiNodesEntry const* curDestNode = sTaxiNodesStore.LookupEntry(curDest);
542 
543  // far teleport case
544  if (curDestNode && curDestNode->MapID != GetPlayer()->GetMapId())
545  {
546  if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
547  {
548  // short preparations to continue flight
549  FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
550 
551  flight->SetCurrentNodeAfterTeleport();
552  TaxiPathNodeEntry const* node = flight->GetPath()[flight->GetCurrentNode()];
553  flight->SkipCurrentNode();
554 
555  GetPlayer()->TeleportTo(curDestNode->MapID, node->Loc.X, node->Loc.Y, node->Loc.Z, GetPlayer()->GetOrientation());
556  }
557  }
558 
559  return;
560  }
561 
562  // at this point only 1 node is expected (final destination)
563  if (GetPlayer()->m_taxi.GetPath().size() != 1)
564  return;
565 
566  GetPlayer()->CleanupAfterTaxiFlight();
567  GetPlayer()->SetFallInformation(0, GetPlayer()->GetPositionZ());
568  if (GetPlayer()->pvpInfo.IsHostile)
569  GetPlayer()->CastSpell(GetPlayer(), 2479, true);
570 }
void SetCurrentNodeAfterTeleport()
Definition: WaypointMovementGenerator.cpp:392
float Z
Definition: DBCEnums.h:36
float Y
Definition: DBCEnums.h:35
uint32 GetCurrentNode() const
Definition: WaypointMovementGenerator.h:43
Definition: WaypointMovementGenerator.h:105
Definition: MotionMaster.h:45
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Object.h:267
void SkipCurrentNode()
Definition: WaypointMovementGenerator.h:128
uint32_t uint32
Definition: Define.h:150
MovementInfo movementInfo
Definition: MovementPackets.h:448
uint32 MapID
Definition: DB2Structure.h:1327
float X
Definition: DBCEnums.h:34
Definition: DB2Structure.h:1345
DBCPosition3D Loc
Definition: DB2Structure.h:1351
Player * _player
Definition: WorldSession.h:1797
Definition: DB2Structure.h:1324
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", TaxiNodesFormat, HOTFIX_SEL_TAXI_NODES)
TaxiPathNodeList const & GetPath()
Definition: WaypointMovementGenerator.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveTeleportAck ( WorldPackets::Movement::MoveTeleportAck packet)
218 {
219  TC_LOG_DEBUG("network", "CMSG_MOVE_TELEPORT_ACK: Guid: %s, Sequence: %u, Time: %u", packet.MoverGUID.ToString().c_str(), packet.AckIndex, packet.MoveTime);
220 
221  Player* plMover = _player->m_mover->ToPlayer();
222 
223  if (!plMover || !plMover->IsBeingTeleportedNear())
224  return;
225 
226  if (packet.MoverGUID != plMover->GetGUID())
227  return;
228 
229  plMover->SetSemaphoreTeleportNear(false);
230 
231  uint32 old_zone = plMover->GetZoneId();
232 
233  WorldLocation const& dest = plMover->GetTeleportDest();
234 
235  plMover->UpdatePosition(dest, true);
236 
237  uint32 newzone, newarea;
238  plMover->GetZoneAndAreaId(newzone, newarea);
239  plMover->UpdateZone(newzone, newarea);
240 
241  // new zone
242  if (old_zone != newzone)
243  {
244  // honorless target
245  if (plMover->pvpInfo.IsHostile)
246  plMover->CastSpell(plMover, 2479, true);
247 
248  // in friendly area
249  else if (plMover->IsPvP() && !plMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
250  plMover->UpdatePvP(false, false);
251  }
252 
253  // resummon pet
254  GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
255 
256  //lets process all delayed operations on successful teleport
257  GetPlayer()->ProcessDelayedOperations();
258 }
Definition: Position.h:228
Definition: Player.h:526
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid MoverGUID
Definition: MovementPackets.h:285
uint32_t uint32
Definition: Define.h:150
Player * _player
Definition: WorldSession.h:1797
int32 MoveTime
Definition: MovementPackets.h:287
int32 AckIndex
Definition: MovementPackets.h:286
Definition: UpdateFields.h:191
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleMoveTimeSkippedOpcode ( WorldPackets::Movement::MoveTimeSkipped moveTimeSkipped)
525 {
526 }

+ Here is the caller graph for this function:

void WorldSession::HandleMoveWorldportAckOpcode ( WorldPackets::Movement::WorldPortResponse packet)
39 {
41 }
void HandleMoveWorldportAckOpcode()
Definition: MovementHandler.cpp:43

+ Here is the call graph for this function:

void WorldSession::HandleMoveWorldportAckOpcode ( )
44 {
45  // ignore unexpected far teleports
46  if (!GetPlayer()->IsBeingTeleportedFar())
47  return;
48 
49  bool seamlessTeleport = GetPlayer()->IsBeingTeleportedSeamlessly();
50  GetPlayer()->SetSemaphoreTeleportFar(false);
51 
52  // get the teleport destination
53  WorldLocation const& loc = GetPlayer()->GetTeleportDest();
54 
55  // possible errors in the coordinate validity check
57  {
58  LogoutPlayer(false);
59  return;
60  }
61 
62  // get the destination map entry, not the current one, this will fix homebind and reset greeting
63  MapEntry const* mEntry = sMapStore.LookupEntry(loc.GetMapId());
64  InstanceTemplate const* mInstance = sObjectMgr->GetInstanceTemplate(loc.GetMapId());
65 
66  // reset instance validity, except if going to an instance inside an instance
67  if (GetPlayer()->m_InstanceValid == false && !mInstance)
68  GetPlayer()->m_InstanceValid = true;
69 
70  Map* oldMap = GetPlayer()->GetMap();
71  Map* newMap = sMapMgr->CreateMap(loc.GetMapId(), GetPlayer());
72 
73  if (GetPlayer()->IsInWorld())
74  {
75  TC_LOG_ERROR("network", "%s %s is still in world when teleported from map %s (%u) to new map %s (%u)", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str(), oldMap->GetMapName(), oldMap->GetId(), newMap ? newMap->GetMapName() : "Unknown", loc.GetMapId());
76  oldMap->RemovePlayerFromMap(GetPlayer(), false);
77  }
78 
79  // relocate the player to the teleport destination
80  // the CannotEnter checks are done in TeleporTo but conditions may change
81  // while the player is in transit, for example the map may get full
82  if (!newMap || newMap->CannotEnter(GetPlayer()))
83  {
84  TC_LOG_ERROR("network", "Map %d (%s) could not be created for %s (%s), porting player to homebind", loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown", GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str());
85  GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
86  return;
87  }
88 
89  float z = loc.GetPositionZ();
90  if (GetPlayer()->HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
91  z += GetPlayer()->GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
92 
93  GetPlayer()->Relocate(loc.GetPositionX(), loc.GetPositionY(), z, loc.GetOrientation());
94 
95  GetPlayer()->ResetMap();
96  GetPlayer()->SetMap(newMap);
97 
98  if (!seamlessTeleport)
99  GetPlayer()->SendInitialPacketsBeforeAddToMap();
100 
101  if (!GetPlayer()->GetMap()->AddPlayerToMap(GetPlayer(), !seamlessTeleport))
102  {
103  TC_LOG_ERROR("network", "WORLD: failed to teleport player %s (%s) to map %d (%s) because of unknown reason!",
104  GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str(), loc.GetMapId(), newMap ? newMap->GetMapName() : "Unknown");
105  GetPlayer()->ResetMap();
106  GetPlayer()->SetMap(oldMap);
107  GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation());
108  return;
109  }
110 
111  // battleground state prepare (in case join to BG), at relogin/tele player not invited
112  // only add to bg group and object, if the player was invited (else he entered through command)
113  if (_player->InBattleground())
114  {
115  // cleanup setting if outdated
116  if (!mEntry->IsBattlegroundOrArena())
117  {
118  // We're not in BG
119  _player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE);
120  // reset destination bg team
121  _player->SetBGTeam(0);
122  }
123  // join to bg case
124  else if (Battleground* bg = _player->GetBattleground())
125  {
126  if (_player->IsInvitedForBattlegroundInstance(_player->GetBattlegroundId()))
127  bg->AddPlayer(_player);
128  }
129  }
130 
131  if (!seamlessTeleport)
132  GetPlayer()->SendInitialPacketsAfterAddToMap();
133  else
134  {
135  GetPlayer()->UpdateVisibilityForPlayer();
136  if (Garrison* garrison = GetPlayer()->GetGarrison())
137  garrison->SendRemoteInfo();
138  }
139 
140  // flight fast teleport case
141  if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
142  {
143  if (!_player->InBattleground())
144  {
145  if (!seamlessTeleport)
146  {
147  // short preparations to continue flight
148  FlightPathMovementGenerator* flight = (FlightPathMovementGenerator*)(GetPlayer()->GetMotionMaster()->top());
149  flight->Initialize(GetPlayer());
150  }
151  return;
152  }
153 
154  // battleground state prepare, stop flight
155  GetPlayer()->GetMotionMaster()->MovementExpired();
156  GetPlayer()->CleanupAfterTaxiFlight();
157  }
158 
159  // resurrect character at enter into instance where his corpse exist after add to map
160 
161  if (mEntry->IsDungeon() && !GetPlayer()->IsAlive())
162  if (GetPlayer()->GetCorpseLocation().GetMapId() == mEntry->ID)
163  {
164  GetPlayer()->ResurrectPlayer(0.5f, false);
165  GetPlayer()->SpawnCorpseBones();
166  }
167 
168  bool allowMount = !mEntry->IsDungeon() || mEntry->IsBattlegroundOrArena();
169  if (mInstance)
170  {
171  // check if this instance has a reset time and send it to player if so
172  Difficulty diff = GetPlayer()->GetDifficultyID(mEntry);
173  if (MapDifficultyEntry const* mapDiff = GetMapDifficultyData(mEntry->ID, diff))
174  {
175  if (mapDiff->RaidDuration)
176  {
177  if (time_t timeReset = sInstanceSaveMgr->GetResetTimeFor(mEntry->ID, diff))
178  {
179  uint32 timeleft = uint32(timeReset - time(NULL));
180  GetPlayer()->SendInstanceResetWarning(mEntry->ID, diff, timeleft, true);
181  }
182  }
183  }
184 
185  // check if instance is valid
186  if (!GetPlayer()->CheckInstanceValidity(false))
187  GetPlayer()->m_InstanceValid = false;
188 
189  // instance mounting is handled in InstanceTemplate
190  allowMount = mInstance->AllowMount;
191  }
192 
193  // mount allow check
194  if (!allowMount)
195  _player->RemoveAurasByType(SPELL_AURA_MOUNTED);
196 
197  // update zone immediately, otherwise leave channel will cause crash in mtmap
198  uint32 newzone, newarea;
199  GetPlayer()->GetZoneAndAreaId(newzone, newarea);
200  GetPlayer()->UpdateZone(newzone, newarea);
201 
202  // honorless target
203  if (GetPlayer()->pvpInfo.IsHostile)
204  GetPlayer()->CastSpell(GetPlayer(), 2479, true);
205 
206  // in friendly area
207  else if (GetPlayer()->IsPvP() && !GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
208  GetPlayer()->UpdatePvP(false, false);
209 
210  // resummon pet
211  GetPlayer()->ResummonPetTemporaryUnSummonedIfAny();
212 
213  //lets process all delayed operations on successful teleport
214  GetPlayer()->ProcessDelayedOperations();
215 }
Difficulty
Definition: DBCEnums.h:402
Definition: Position.h:228
MapDifficultyEntry const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:724
virtual void RemovePlayerFromMap(Player *, bool)
Definition: Map.cpp:872
Definition: Map.h:222
Definition: Player.h:526
Definition: WaypointMovementGenerator.h:105
void Initialize(Unit *u) override
Definition: MovementGenerator.h:54
Definition: MotionMaster.h:45
Definition: DBCStructure.h:830
Definition: Garrison.h:83
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: UpdateFields.h:160
uint32 GetId(void) const
Definition: Map.h:325
float GetOrientation() const
Definition: Position.h:107
void LogoutPlayer(bool save)
Log the player out
Definition: WorldSession.cpp:498
string ToString(int i)
Definition: strutil.h:491
Definition: Unit.h:804
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
bool IsDungeon() const
Definition: DBCStructure.h:857
uint32 GetMapId() const
Definition: Position.h:254
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
uint32 ID
Definition: DBCStructure.h:832
Definition: Map.h:259
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:243
bool AllowMount
Definition: Map.h:226
Player * _player
Definition: WorldSession.h:1797
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:863
Definition: DBCStructure.h:885
DBCStorage< MapEntry > sMapStore(Mapfmt)
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
#define sMapMgr
Definition: MapManager.h:194
Definition: SharedDefines.h:4560
Definition: Battleground.h:235
Definition: UpdateFields.h:191
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
virtual EnterState CannotEnter(Player *)
Definition: Map.h:386
float GetPositionX() const
Definition: Position.h:104
const char * GetMapName() const
Definition: Map.cpp:2644
Definition: SpellAuraDefines.h:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleNameQueryOpcode ( WorldPackets::Query::QueryPlayerName packet)
48 {
50 }
ObjectGuid Player
Definition: QueryPackets.h:89
void SendNameQueryOpcode(ObjectGuid guid)
Definition: QueryHandler.cpp:32

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleNextCinematicCamera ( WorldPackets::Misc::NextCinematicCamera packet)
694 {
695 }

+ Here is the caller graph for this function:

void WorldSession::HandleNpcTextQueryOpcode ( WorldPackets::Query::QueryNPCText packet)
217 {
218  TC_LOG_DEBUG("network", "WORLD: CMSG_NPC_TEXT_QUERY TextId: %u", packet.TextID);
219 
220  NpcText const* npcText = sObjectMgr->GetNpcText(packet.TextID);
221 
223  response.TextID = packet.TextID;
224 
225  if (npcText)
226  {
227  for (uint8 i = 0; i < MAX_NPC_TEXT_OPTIONS; ++i)
228  {
229  response.Probabilities[i] = npcText->Data[i].Probability;
230  response.BroadcastTextID[i] = npcText->Data[i].BroadcastTextID;
231  if (!response.Allow && npcText->Data[i].BroadcastTextID)
232  response.Allow = true;
233  }
234  }
235 
236  if (!response.Allow)
237  TC_LOG_ERROR("sql.sql", "HandleNpcTextQueryOpcode: no BroadcastTextID found for text %u in `npc_text table`", packet.TextID);
238 
239  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_NPC_TEXT_UPDATE");
240 
241  SendPacket(response.Write());
242 }
uint32 TextID
Definition: QueryPackets.h:159
Definition: NPCHandler.h:30
bool Allow
Definition: QueryPackets.h:170
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
WorldPacket const * Write() override
Definition: QueryPackets.cpp:225
#define sObjectMgr
Definition: ObjectMgr.h:1567
#define MAX_NPC_TEXT_OPTIONS
Definition: NPCHandler.h:28
Definition: QueryPackets.h:162
float Probability
Definition: NPCHandler.h:24
NpcTextData Data[MAX_NPC_TEXT_OPTIONS]
Definition: NPCHandler.h:32
uint32 BroadcastTextID[MAX_NPC_TEXT_OPTIONS]
Definition: QueryPackets.h:172
float Probabilities[MAX_NPC_TEXT_OPTIONS]
Definition: QueryPackets.h:171
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 BroadcastTextID
Definition: NPCHandler.h:25
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 TextID
Definition: QueryPackets.h:169

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleObjectUpdateFailedOpcode ( WorldPackets::Misc::ObjectUpdateFailed objectUpdateFailed)
1064 {
1065  TC_LOG_ERROR("network", "Object update failed for %s for player %s (%s)", objectUpdateFailed.ObjectGUID.ToString().c_str(), GetPlayerName().c_str(), _player->GetGUID().ToString().c_str());
1066 
1067  // If create object failed for current player then client will be stuck on loading screen
1068  if (_player->GetGUID() == objectUpdateFailed.ObjectGUID)
1069  {
1070  LogoutPlayer(true);
1071  return;
1072  }
1073 
1074  // Pretend we've never seen this object
1075  _player->m_clientGUIDs.erase(objectUpdateFailed.ObjectGUID);
1076 }
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
ObjectGuid ObjectGUID
Definition: MiscPackets.h:588
void LogoutPlayer(bool save)
Log the player out
Definition: WorldSession.cpp:498
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleObjectUpdateRescuedOpcode ( WorldPackets::Misc::ObjectUpdateRescued objectUpdateRescued)
1079 {
1080  TC_LOG_ERROR("network", "Object update rescued for %s for player %s (%s)", objectUpdateRescued.ObjectGUID.ToString().c_str(), GetPlayerName().c_str(), _player->GetGUID().ToString().c_str());
1081 
1082  // Client received values update after destroying object
1083  // re-register object in m_clientGUIDs to send DestroyObject on next visibility update
1084  _player->m_clientGUIDs.insert(objectUpdateRescued.ObjectGUID);
1085 }
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
ObjectGuid ObjectGUID
Definition: MiscPackets.h:598
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleOfferPetition ( WorldPackets::Petition::OfferPetition packet)
384 {
386  if (!player)
387  return;
388 
389  TC_LOG_DEBUG("network", "OFFER PETITION: %s, to %s", packet.ItemGUID.ToString().c_str(), packet.TargetPlayer.ToString().c_str());
390 
391  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != player->GetTeam())
392  {
394  return;
395  }
396 
397  if (player->GetGuildId())
398  {
400  return;
401  }
402 
403  if (player->GetGuildIdInvited())
404  {
406  return;
407  }
408 
410  stmt->setUInt64(0, packet.ItemGUID.GetCounter());
412 
413  uint8 signs = 0;
414  // result == NULL also correct charter without signs
415  if (result)
416  signs = uint8(result->GetRowCount());
417 
419  signaturesPacket.Item = packet.ItemGUID;
420  signaturesPacket.Owner = _player->GetGUID();
421  signaturesPacket.OwnerAccountID = ObjectGuid::Create<HighGuid::WowAccount>(player->GetSession()->GetAccountId());
422  signaturesPacket.PetitionID = int32(packet.ItemGUID.GetCounter()); // @todo verify that...
423 
424  signaturesPacket.Signatures.reserve(signs);
425  for (uint8 i = 0; i < signs; ++i)
426  {
427  Field* fields2 = result->Fetch();
428  ObjectGuid signerGUID = ObjectGuid::Create<HighGuid::Player>(fields2[0].GetUInt64());
429 
431  signature.Signer = signerGUID;
432  signature.Choice = 0;
433  signaturesPacket.Signatures.push_back(signature);
434 
435  // Checking the return value just to be double safe
436  if (!result->NextRow())
437  break;
438  }
439 
440  player->GetSession()->SendPacket(signaturesPacket.Write());
441 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: Guild.h:127
Definition: Guild.h:105
Definition: Guild.h:129
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
ObjectGuid ItemGUID
Definition: PetitionPackets.h:207
Definition: PreparedStatement.h:74
Definition: Guild.h:137
ObjectGuid TargetPlayer
Definition: PetitionPackets.h:206
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid Item
Definition: PetitionPackets.h:129
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
Definition: Guild.h:104
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
Definition: CharacterDatabase.h:265
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleOpeningCinematic ( WorldPackets::Misc::OpeningCinematic packet)
2293 {
2294  // Only players that has not yet gained any experience can use this
2295  if (_player->GetUInt32Value(PLAYER_XP))
2296  return;
2297 
2298  if (ChrClassesEntry const* classEntry = sChrClassesStore.LookupEntry(_player->getClass()))
2299  {
2300  if (classEntry->CinematicSequenceID)
2301  _player->SendCinematicStart(classEntry->CinematicSequenceID);
2302  else if (ChrRacesEntry const* raceEntry = sChrRacesStore.LookupEntry(_player->getRace()))
2303  _player->SendCinematicStart(raceEntry->CinematicSequenceID);
2304  }
2305 }
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesfmt)
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesfmt)
Definition: DBCStructure.h:204
Definition: UpdateFields.h:215
Definition: DBCStructure.h:181
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleOpenItemOpcode ( WorldPackets::Spells::OpenItem packet)
129 {
130  Player* player = _player;
131 
132  // ignore for remote control state
133  if (player->m_mover != player)
134  return;
135  TC_LOG_INFO("network", "bagIndex: %u, slot: %u", packet.Slot, packet.PackSlot);
136 
137  Item* item = player->GetItemByPos(packet.Slot, packet.PackSlot);
138  if (!item)
139  {
140  player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
141  return;
142  }
143 
144  ItemTemplate const* proto = item->GetTemplate();
145  if (!proto)
146  {
147  player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
148  return;
149  }
150 
151  // Verify that the bag is an actual bag or wrapped item that can be used "normally"
153  {
154  player->SendEquipError(EQUIP_ERR_CLIENT_LOCKED_OUT, item, NULL);
155  TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [%s] tried to open item [%s, entry: %u] which is not openable!",
156  player->GetName().c_str(), player->GetGUID().ToString().c_str(), item->GetGUID().ToString().c_str(), proto->GetId());
157  return;
158  }
159 
160  // locked item
161  uint32 lockId = proto->GetLockID();
162  if (lockId)
163  {
164  LockEntry const* lockInfo = sLockStore.LookupEntry(lockId);
165 
166  if (!lockInfo)
167  {
168  player->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
169  TC_LOG_ERROR("network", "WORLD::OpenItem: item [%s] has an unknown lockId: %u!", item->GetGUID().ToString().c_str(), lockId);
170  return;
171  }
172 
173  // was not unlocked yet
174  if (item->IsLocked())
175  {
176  player->SendEquipError(EQUIP_ERR_ITEM_LOCKED, item, NULL);
177  return;
178  }
179  }
180 
181  if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))// wrapped?
182  {
184 
185  stmt->setUInt64(0, item->GetGUID().GetCounter());
186 
188 
189  if (result)
190  {
191  Field* fields = result->Fetch();
192  uint32 entry = fields[0].GetUInt32();
193  uint32 flags = fields[1].GetUInt32();
194 
196  item->SetEntry(entry);
197  item->SetUInt32Value(ITEM_FIELD_FLAGS, flags);
198  item->SetState(ITEM_CHANGED, player);
199  }
200  else
201  {
202  TC_LOG_ERROR("network", "Wrapped item %s don't have record in character_gifts table and will deleted", item->GetGUID().ToString().c_str());
203  player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
204  return;
205  }
206 
208 
209  stmt->setUInt64(0, item->GetGUID().GetCounter());
210 
212  }
213  else
214  player->SendLoot(item->GetGUID(), LOOT_CORPSE);
215 }
uint32 GetLockID() const
Definition: ItemTemplate.h:687
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: ItemTemplate.h:138
uint8 PackSlot
Definition: SpellPackets.h:673
DBCStorage< LockEntry > sLockStore(Lockfmt)
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: UpdateFields.h:49
bool IsLocked() const
Definition: Item.h:306
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: DBCStructure.h:815
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
void SetEntry(uint32 entry)
Definition: Object.h:108
Definition: PreparedStatement.h:74
uint8 Slot
Definition: SpellPackets.h:672
Definition: Item.h:71
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: LootMgr.h:90
uint8 GetSlot() const
Definition: Item.h:329
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Definition: ItemTemplate.h:647
Definition: CharacterDatabase.h:148
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Item.h:87
Player * _player
Definition: WorldSession.h:1797
uint32 GetUInt32() const
Definition: Field.h:146
Definition: Item.h:84
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint32 GetFlags() const
Definition: ItemTemplate.h:656
uint32 GetId() const
Definition: ItemTemplate.h:652
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: UpdateFields.h:45
uint8 flags
Definition: DisableMgr.cpp:44
Definition: CharacterDatabase.h:149
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
uint8 GetBagSlot() const
Definition: Item.cpp:759
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221
Definition: ItemTemplate.h:175
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleOptOutOfLootOpcode ( WorldPackets::Party::OptOutOfLoot packet)
601 {
602  // ignore if player not loaded
603  if (!GetPlayer()) // needed because STATUS_AUTHED
604  {
605  if (packet.PassOnLoot)
606  TC_LOG_ERROR("network", "CMSG_OPT_OUT_OF_LOOT value<>0 for not-loaded character!");
607  return;
608  }
609 
610  GetPlayer()->SetPassOnGroupLoot(packet.PassOnLoot);
611 }
Player * GetPlayer() const
Definition: WorldSession.h:927
bool PassOnLoot
Definition: PartyPackets.h:449
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePartyInviteOpcode ( WorldPackets::Party::PartyInviteClient packet)
62 {
64 
65  // no player
66  if (!player)
67  {
69  return;
70  }
71 
72  // restrict invite to GMs
73  if (!sWorld->getBoolConfig(CONFIG_ALLOW_GM_GROUP) && !GetPlayer()->IsGameMaster() && player->IsGameMaster())
74  {
76  return;
77  }
78 
79  // can't group with
80  if (!GetPlayer()->IsGameMaster() && !sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && GetPlayer()->GetTeam() != player->GetTeam())
81  {
83  return;
84  }
85  if (GetPlayer()->GetInstanceId() != 0 && player->GetInstanceId() != 0 && GetPlayer()->GetInstanceId() != player->GetInstanceId() && GetPlayer()->GetMapId() == player->GetMapId())
86  {
88  return;
89  }
90  // just ignore us
91  if (player->GetInstanceId() != 0 && player->GetDungeonDifficultyID() != GetPlayer()->GetDungeonDifficultyID())
92  {
94  return;
95  }
96 
97  if (player->GetSocial()->HasIgnore(GetPlayer()->GetGUID()))
98  {
100  return;
101  }
102 
103  Group* group = GetPlayer()->GetGroup();
104  if (group && group->isBGGroup())
105  group = GetPlayer()->GetOriginalGroup();
106 
107  Group* group2 = player->GetGroup();
108  if (group2 && group2->isBGGroup())
109  group2 = player->GetOriginalGroup();
110 
111  // player already in another group or invited
112  if (group2 || player->GetGroupInvite())
113  {
115 
116  if (group2)
117  {
118  // tell the player that they were invited but it failed as they were already in a group
120  partyInvite.Initialize(GetPlayer(), packet.ProposedRoles, false);
121  player->GetSession()->SendPacket(partyInvite.Write());
122  }
123 
124  return;
125  }
126 
127  if (group)
128  {
129  // not have permissions for invite
130  if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
131  {
133  return;
134  }
135  // not have place
136  if (group->IsFull())
137  {
139  return;
140  }
141  }
142 
143  // ok, but group not exist, start a new group
144  // but don't create and save the group to the DB until
145  // at least one person joins
146  if (!group)
147  {
148  group = new Group;
149  // new group: if can't add then delete
150  if (!group->AddLeaderInvite(GetPlayer()))
151  {
152  delete group;
153  return;
154  }
155  if (!group->AddInvite(player))
156  {
157  delete group;
158  return;
159  }
160  }
161  else
162  {
163  // already existed group: if can't add then just leave
164  if (!group->AddInvite(player))
165  {
166  return;
167  }
168  }
169 
171  partyInvite.Initialize(GetPlayer(), packet.ProposedRoles, true);
172  player->GetSession()->SendPacket(partyInvite.Write());
173 
175 }
Definition: SharedDefines.h:4850
Definition: World.h:117
Definition: PartyPackets.h:58
Definition: SharedDefines.h:4852
Definition: SharedDefines.h:4846
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
void Initialize(Player *const inviter, int32 proposedRoles, bool canAccept)
Definition: PartyPackets.cpp:96
bool IsFull() const
Definition: Group.cpp:2499
Definition: SharedDefines.h:4851
Definition: SharedDefines.h:4843
WorldPacket const * Write() override
Definition: PartyPackets.cpp:59
std::string TargetName
Definition: PartyPackets.h:53
bool isBGGroup() const
Definition: Group.cpp:2514
static Summons Group[]
Definition: boss_urom.cpp:77
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
TC_GAME_API Player * FindPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:220
Definition: WorldSession.h:783
Definition: SharedDefines.h:4844
Definition: SharedDefines.h:4847
void SendPartyResult(PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
Definition: GroupHandler.cpp:48
bool AddInvite(Player *player)
Definition: Group.cpp:299
Definition: SharedDefines.h:4848
bool AddLeaderInvite(Player *player)
Definition: Group.cpp:320
int32 ProposedRoles
Definition: PartyPackets.h:51
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePartyInviteResponseOpcode ( WorldPackets::Party::PartyInviteResponse packet)
178 {
179  Group* group = GetPlayer()->GetGroupInvite();
180 
181  if (!group)
182  return;
183 
184  if (packet.Accept)
185  {
186  // Remove player from invitees in any case
187  group->RemoveInvite(GetPlayer());
188 
189  if (group->GetLeaderGUID() == GetPlayer()->GetGUID())
190  {
191  TC_LOG_ERROR("network", "HandleGroupAcceptOpcode: player %s (%s) tried to accept an invite to his own group", GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
192  return;
193  }
194 
195  // Group is full
196  if (group->IsFull())
197  {
199  return;
200  }
201 
202  Player* leader = ObjectAccessor::FindPlayer(group->GetLeaderGUID());
203 
204  // Forming a new group, create it
205  if (!group->IsCreated())
206  {
207  // This can happen if the leader is zoning. To be removed once delayed actions for zoning are implemented
208  if (!leader)
209  {
210  group->RemoveAllInvites();
211  return;
212  }
213 
214  // If we're about to create a group there really should be a leader present
215  ASSERT(leader);
216  group->RemoveInvite(leader);
217  group->Create(leader);
218  sGroupMgr->AddGroup(group);
219  }
220 
221  // Everything is fine, do it, PLAYER'S GROUP IS SET IN ADDMEMBER!!!
222  if (!group->AddMember(GetPlayer()))
223  return;
224 
225  group->BroadcastGroupUpdate();
226  }
227  else
228  {
229  // Remember leader if online (group pointer will be invalid if group gets disbanded)
231 
232  // uninvite, group can be deleted
233  GetPlayer()->UninviteFromGroup();
234 
235  if (!leader || !leader->GetSession())
236  return;
237 
238  // report
240  leader->GetSession()->SendPacket(decline.Write());
241  }
242 }
ObjectGuid GetLeaderGUID() const
Definition: Group.cpp:2529
void RemoveAllInvites()
Definition: Group.cpp:339
void BroadcastGroupUpdate(void)
Definition: Group.cpp:2283
Definition: PartyPackets.h:116
Player * GetPlayer() const
Definition: WorldSession.h:927
void RemoveInvite(Player *player)
Definition: Group.cpp:330
bool Create(Player *leader)
Definition: Group.cpp:98
bool AddMember(Player *player)
Definition: Group.cpp:368
bool IsFull() const
Definition: Group.cpp:2499
bool Accept
Definition: PartyPackets.h:100
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
bool IsCreated() const
Definition: Group.cpp:2524
string ToString(int i)
Definition: strutil.h:491
#define sGroupMgr
Definition: GroupMgr.h:59
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: WorldSession.h:783
Definition: SharedDefines.h:4847
void SendPartyResult(PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
Definition: GroupHandler.cpp:48
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePartyUninviteOpcode ( WorldPackets::Party::PartyUninvite packet)
245 {
246  // can't uninvite yourself
247  if (packet.TargetGUID == GetPlayer()->GetGUID())
248  {
249  TC_LOG_ERROR("network", "WorldSession::HandleGroupUninviteGuidOpcode: leader %s (%s) tried to uninvite himself from the group.",
250  GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
251  return;
252  }
253 
254  PartyResult res = GetPlayer()->CanUninviteFromGroup(packet.TargetGUID);
255  if (res != ERR_PARTY_RESULT_OK)
256  {
258  return;
259  }
260 
261  Group* grp = GetPlayer()->GetGroup();
262  // grp is checked already above in CanUninviteFromGroup()
263  ASSERT(grp);
264 
265  if (grp->IsMember(packet.TargetGUID))
266  {
267  Player::RemoveFromGroup(grp, packet.TargetGUID, GROUP_REMOVEMETHOD_KICK, GetPlayer()->GetGUID(), packet.Reason.c_str());
268  return;
269  }
270 
271  if (Player* player = grp->GetInvited(packet.TargetGUID))
272  {
273  player->UninviteFromGroup();
274  return;
275  }
276 
278 }
std::string Reason
Definition: PartyPackets.h:113
Definition: SharedDefines.h:4845
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SharedDefines.h:4688
Definition: SharedDefines.h:4843
string ToString(int i)
Definition: strutil.h:491
PartyResult
Definition: SharedDefines.h:4841
Definition: WorldSession.h:784
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2566
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Player * GetInvited(ObjectGuid guid) const
Definition: Group.cpp:348
void SendPartyResult(PartyOperation operation, std::string const &member, PartyResult res, uint32 val=0)
Definition: GroupHandler.cpp:48
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
ObjectGuid TargetGUID
Definition: PartyPackets.h:112
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetAbandon ( WorldPackets::Pet::PetAbandon packet)
591 {
592  if (!_player->IsInWorld())
593  return;
594 
596  if (pet)
597  {
598  if (pet->IsPet())
599  _player->RemovePet(pet->ToPet(), PET_SAVE_AS_DELETED);
600  else if (pet->GetGUID() == _player->GetCharmGUID())
601  _player->StopCastingCharm();
602  }
603 }
Pet * ToPet()
Definition: Unit.h:2200
ObjectGuid Pet
Definition: PetPackets.h:56
Definition: Creature.h:467
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
Definition: PetDefines.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetAction ( WorldPackets::Pet::PetAction packet)
Todo:
allow control charmed player?
64 {
65  ObjectGuid guid1 = packet.PetGUID; //pet guid
66  ObjectGuid guid2 = packet.TargetGUID; //tag guid
67 
68  uint32 spellid = UNIT_ACTION_BUTTON_ACTION(packet.Action);
69  uint8 flag = UNIT_ACTION_BUTTON_TYPE(packet.Action); //delete = 0x07 CastSpell = C1
70 
71  // used also for charmed creature
72  Unit* pet = ObjectAccessor::GetUnit(*_player, guid1);
73  TC_LOG_DEBUG("network", "HandlePetAction: %s - flag: %u, spellid: %u, target: %s.", guid1.ToString().c_str(), uint32(flag), spellid, guid2.ToString().c_str());
74 
75  if (!pet)
76  {
77  TC_LOG_DEBUG("network", "HandlePetAction: %s doesn't exist for %s %s", guid1.ToString().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str());
78  return;
79  }
80 
81  if (pet != GetPlayer()->GetFirstControlled())
82  {
83  TC_LOG_DEBUG("network", "HandlePetAction: %s does not belong to %s %s", guid1.ToString().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str());
84  return;
85  }
86 
87  if (!pet->IsAlive())
88  {
89  SpellInfo const* spell = (flag == ACT_ENABLED || flag == ACT_PASSIVE) ? sSpellMgr->GetSpellInfo(spellid) : NULL;
90  if (!spell)
91  return;
93  return;
94  }
95 
97  if (pet->GetTypeId() == TYPEID_PLAYER && !(flag == ACT_COMMAND && spellid == COMMAND_ATTACK))
98  return;
99 
100  if (GetPlayer()->m_Controlled.size() == 1)
101  HandlePetActionHelper(pet, guid1, spellid, flag, guid2, packet.ActionPosition.x, packet.ActionPosition.y, packet.ActionPosition.z);
102  else
103  {
104  //If a pet is dismissed, m_Controlled will change
105  std::vector<Unit*> controlled;
106  for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
107  if ((*itr)->GetEntry() == pet->GetEntry() && (*itr)->IsAlive())
108  controlled.push_back(*itr);
109  for (std::vector<Unit*>::iterator itr = controlled.begin(); itr != controlled.end(); ++itr)
110  HandlePetActionHelper(*itr, guid1, spellid, flag, guid2, packet.ActionPosition.x, packet.ActionPosition.y, packet.ActionPosition.z);
111  }
112 }
float x
Definition: Vector3.h:62
uint32 Action
Definition: PetPackets.h:200
Definition: Unit.h:1139
void HandlePetActionHelper(Unit *pet, ObjectGuid guid1, uint32 spellid, uint16 flag, ObjectGuid guid2, float x, float y, float z)
Definition: PetHandler.cpp:137
#define UNIT_ACTION_BUTTON_TYPE(X)
Definition: Unit.h:1145
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Definition: SpellInfo.h:326
arena_t NULL
Definition: jemalloc_internal.h:624
#define UNIT_ACTION_BUTTON_ACTION(X)
Definition: Unit.h:1144
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
float y
Definition: Vector3.h:62
TypeID GetTypeId() const
Definition: Object.h:113
bool IsAlive() const
Definition: Unit.h:1692
bool HasAttribute(SpellAttr0 attribute) const
Definition: SpellInfo.h:462
ObjectGuid TargetGUID
Definition: PetPackets.h:201
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
G3D::Vector3 ActionPosition
Definition: PetPackets.h:202
Definition: SharedDefines.h:379
Definition: Unit.h:1122
Definition: Unit.h:1121
float z
Definition: Vector3.h:62
ObjectGuid PetGUID
Definition: PetPackets.h:199
Definition: ObjectGuid.h:33
Player * _player
Definition: WorldSession.h:1797
uint8_t uint8
Definition: Define.h:152
Definition: Unit.h:1119
uint32 GetEntry() const
Definition: Object.h:107
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetActionHelper ( Unit pet,
ObjectGuid  guid1,
uint32  spellid,
uint16  flag,
ObjectGuid  guid2,
float  x,
float  y,
float  z 
)
Todo:
Send proper error message to client
Todo:
: confirm this check
138 {
139  CharmInfo* charmInfo = pet->GetCharmInfo();
140  if (!charmInfo)
141  {
142  TC_LOG_DEBUG("network", "WorldSession::HandlePetAction(petGuid: %s, tagGuid: %s, spellId: %u, flag: %u): object (%s Entry: %u TypeId: %u) is considered pet-like but doesn't have a charminfo!",
143  guid1.ToString().c_str(), guid2.ToString().c_str(), spellid, flag, pet->GetGUID().ToString().c_str(), pet->GetEntry(), pet->GetTypeId());
144  return;
145  }
146 
147  switch (flag)
148  {
149  case ACT_COMMAND: //0x07
150  switch (spellid)
151  {
152  case COMMAND_STAY: //flat=1792 //STAY
153  pet->StopMoving();
154  pet->GetMotionMaster()->Clear(false);
155  pet->GetMotionMaster()->MoveIdle();
156  charmInfo->SetCommandState(COMMAND_STAY);
157 
158  charmInfo->SetIsCommandAttack(false);
159  charmInfo->SetIsAtStay(true);
160  charmInfo->SetIsCommandFollow(false);
161  charmInfo->SetIsFollowing(false);
162  charmInfo->SetIsReturning(false);
163  charmInfo->SaveStayPosition();
164  break;
165  case COMMAND_FOLLOW: //spellid=1792 //FOLLOW
166  pet->AttackStop();
167  pet->InterruptNonMeleeSpells(false);
169  charmInfo->SetCommandState(COMMAND_FOLLOW);
170 
171  charmInfo->SetIsCommandAttack(false);
172  charmInfo->SetIsAtStay(false);
173  charmInfo->SetIsReturning(true);
174  charmInfo->SetIsCommandFollow(true);
175  charmInfo->SetIsFollowing(false);
176  break;
177  case COMMAND_ATTACK: //spellid=1792 //ATTACK
178  {
179  // Can't attack if owner is pacified
180  if (_player->HasAuraType(SPELL_AURA_MOD_PACIFY))
181  {
182  //pet->SendPetCastFail(spellid, SPELL_FAILED_PACIFIED);
184  return;
185  }
186 
187  // only place where pet can be player
188  Unit* TargetUnit = ObjectAccessor::GetUnit(*_player, guid2);
189  if (!TargetUnit)
190  return;
191 
192  if (Unit* owner = pet->GetOwner())
193  if (!owner->IsValidAttackTarget(TargetUnit))
194  return;
195 
197  // This is true if pet has no target or has target but targets differs.
198  if (pet->GetVictim() != TargetUnit || (pet->GetVictim() == TargetUnit && !pet->GetCharmInfo()->IsCommandAttack()))
199  {
200  if (pet->GetVictim())
201  pet->AttackStop();
202 
203  if (pet->GetTypeId() != TYPEID_PLAYER && pet->ToCreature()->IsAIEnabled)
204  {
205  charmInfo->SetIsCommandAttack(true);
206  charmInfo->SetIsAtStay(false);
207  charmInfo->SetIsFollowing(false);
208  charmInfo->SetIsCommandFollow(false);
209  charmInfo->SetIsReturning(false);
210 
211  pet->ToCreature()->AI()->AttackStart(TargetUnit);
212 
213  //10% chance to play special pet attack talk, else growl
214  if (pet->IsPet() && ((Pet*)pet)->getPetType() == SUMMON_PET && pet != TargetUnit && urand(0, 100) < 10)
216  else
217  {
218  // 90% chance for pet and 100% chance for charmed creature
219  pet->SendPetAIReaction(guid1);
220  }
221  }
222  else // charmed player
223  {
224  if (pet->GetVictim() && pet->GetVictim() != TargetUnit)
225  pet->AttackStop();
226 
227  charmInfo->SetIsCommandAttack(true);
228  charmInfo->SetIsAtStay(false);
229  charmInfo->SetIsFollowing(false);
230  charmInfo->SetIsCommandFollow(false);
231  charmInfo->SetIsReturning(false);
232 
233  pet->Attack(TargetUnit, true);
234  pet->SendPetAIReaction(guid1);
235  }
236  }
237  break;
238  }
239  case COMMAND_ABANDON: // abandon (hunter pet) or dismiss (summoned pet)
240  if (pet->GetCharmerGUID() == GetPlayer()->GetGUID())
241  _player->StopCastingCharm();
242  else if (pet->GetOwnerGUID() == GetPlayer()->GetGUID())
243  {
244  ASSERT(pet->GetTypeId() == TYPEID_UNIT);
245  if (pet->IsPet())
246  {
247  if (((Pet*)pet)->getPetType() == HUNTER_PET)
248  GetPlayer()->RemovePet((Pet*)pet, PET_SAVE_AS_DELETED);
249  else
250  //dismissing a summoned pet is like killing them (this prevents returning a soulshard...)
251  pet->setDeathState(CORPSE);
252  }
253  else if (pet->HasUnitTypeMask(UNIT_MASK_MINION))
254  {
255  ((Minion*)pet)->UnSummon();
256  }
257  }
258  break;
259  case COMMAND_MOVE_TO:
260  pet->StopMoving();
261  pet->GetMotionMaster()->Clear(false);
262  pet->GetMotionMaster()->MovePoint(0, x, y, z);
263  charmInfo->SetCommandState(COMMAND_MOVE_TO);
264 
265  charmInfo->SetIsCommandAttack(false);
266  charmInfo->SetIsAtStay(true);
267  charmInfo->SetIsFollowing(false);
268  charmInfo->SetIsReturning(false);
269  charmInfo->SaveStayPosition();
270  break;
271  default:
272  TC_LOG_ERROR("network", "WORLD: unknown PET flag Action %i and spellid %i.", uint32(flag), spellid);
273  }
274  break;
275  case ACT_REACTION: // 0x6
276  switch (spellid)
277  {
278  case REACT_PASSIVE: //passive
279  pet->AttackStop();
280  // no break;
281  case REACT_DEFENSIVE: //recovery
282  case REACT_AGGRESSIVE: //activete
283  if (pet->GetTypeId() == TYPEID_UNIT)
284  pet->ToCreature()->SetReactState(ReactStates(spellid));
285  break;
286  }
287  break;
288  case ACT_DISABLED: // 0x81 spell (disabled), ignore
289  case ACT_PASSIVE: // 0x01
290  case ACT_ENABLED: // 0xC1 spell
291  {
292  Unit* unit_target = NULL;
293 
294  if (!guid2.IsEmpty())
295  unit_target = ObjectAccessor::GetUnit(*_player, guid2);
296 
297  // do not cast unknown spells
298  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
299  if (!spellInfo)
300  {
301  TC_LOG_ERROR("network", "WORLD: unknown PET spell id %i", spellid);
302  return;
303  }
304 
305  for (SpellEffectInfo const* effect: spellInfo->GetEffectsForDifficulty(DIFFICULTY_NONE))
306  {
307  if (effect && (effect->TargetA.GetTarget() == TARGET_UNIT_SRC_AREA_ENEMY || effect->TargetA.GetTarget() == TARGET_UNIT_DEST_AREA_ENEMY || effect->TargetA.GetTarget() == TARGET_DEST_DYNOBJ_ENEMY))
308  return;
309  }
310 
311  // do not cast not learned spells
312  if (!pet->HasSpell(spellid) || spellInfo->IsPassive())
313  return;
314 
315  // Clear the flags as if owner clicked 'attack'. AI will reset them
316  // after AttackStart, even if spell failed
317  if (pet->GetCharmInfo())
318  {
319  pet->GetCharmInfo()->SetIsAtStay(false);
320  pet->GetCharmInfo()->SetIsCommandAttack(true);
321  pet->GetCharmInfo()->SetIsReturning(false);
322  pet->GetCharmInfo()->SetIsFollowing(false);
323  }
324 
325  Spell* spell = new Spell(pet, spellInfo, TRIGGERED_NONE);
326 
327  SpellCastResult result = spell->CheckPetCast(unit_target);
328 
329  //auto turn to target unless possessed
330  if (result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->isPossessed() && !pet->IsVehicle())
331  {
332  if (unit_target)
333  {
334  pet->SetInFront(unit_target);
335  if (Player* player = unit_target->ToPlayer())
336  pet->SendUpdateToPlayer(player);
337  }
338  else if (Unit* unit_target2 = spell->m_targets.GetUnitTarget())
339  {
340  pet->SetInFront(unit_target2);
341  if (Player* player = unit_target2->ToPlayer())
342  pet->SendUpdateToPlayer(player);
343  }
344 
345  if (Unit* powner = pet->GetCharmerOrOwner())
346  if (Player* player = powner->ToPlayer())
347  pet->SendUpdateToPlayer(player);
348 
349  result = SPELL_CAST_OK;
350  }
351 
352  if (result == SPELL_CAST_OK)
353  {
354  unit_target = spell->m_targets.GetUnitTarget();
355 
356  //10% chance to play special pet attack talk, else growl
357  //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
358  if (pet->IsPet() && (((Pet*)pet)->getPetType() == SUMMON_PET) && (pet != unit_target) && (urand(0, 100) < 10))
360  else
361  {
362  pet->SendPetAIReaction(guid1);
363  }
364 
365  if (unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->isPossessed() && !pet->IsVehicle())
366  {
367  // This is true if pet has no target or has target but targets differs.
368  if (pet->GetVictim() != unit_target)
369  {
370  if (pet->GetVictim())
371  pet->AttackStop();
372  pet->GetMotionMaster()->Clear();
373  if (pet->ToCreature()->IsAIEnabled)
374  pet->ToCreature()->AI()->AttackStart(unit_target);
375  }
376  }
377 
378  spell->prepare(&(spell->m_targets));
379  }
380  else
381  {
382  if (pet->isPossessed() || pet->IsVehicle())
383  Spell::SendCastResult(GetPlayer(), spellInfo, 0, result);
384  else
385  spell->SendPetCastResult(result);
386 
387  if (!pet->GetSpellHistory()->HasCooldown(spellid))
388  pet->GetSpellHistory()->ResetCooldown(spellid, true);
389 
390  spell->finish(false);
391  delete spell;
392 
393  // reset specific flags in case of spell fail. AI will reset other flags
394  if (pet->GetCharmInfo())
395  pet->GetCharmInfo()->SetIsCommandAttack(false);
396  }
397  break;
398  }
399  default:
400  TC_LOG_ERROR("network", "WORLD: unknown PET flag Action %i and spellid %i.", uint32(flag), spellid);
401  }
402 }
bool AttackStop()
Definition: Unit.cpp:7337
Definition: SharedDefines.h:1421
Definition: DBCEnums.h:404
Definition: PetDefines.h:24
Unit * GetUnitTarget() const
Definition: Spell.cpp:222
Definition: Unit.h:1139
bool Attack(Unit *victim, bool meleeAttack)
Definition: Unit.cpp:7222
bool IsPassive() const
Definition: SpellInfo.cpp:1403
void MoveIdle()
Definition: MotionMaster.cpp:185
Definition: Unit.h:1131
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
bool IsVehicle() const
Definition: Unit.h:1406
void Clear(bool reset=true)
Definition: MotionMaster.h:138
Definition: SpellInfo.h:326
void SetIsFollowing(bool val)
Definition: Unit.cpp:15751
void SaveStayPosition()
Definition: Unit.cpp:15720
Definition: Unit.h:1129
SpellCastTargets m_targets
Definition: Spell.h:584
Definition: PetDefines.h:74
static void SendCastResult(Player *caster, SpellInfo const *spellInfo, uint8 cast_count, SpellCastResult result, SpellCustomErrors customError=SPELL_CUSTOM_ERROR_NONE, OpcodeServer opcode=SMSG_CAST_FAILED, uint32 *misc=nullptr)
Definition: Spell.cpp:3732
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
Definition: Unit.h:1130
virtual bool HasSpell(uint32) const
Definition: Unit.h:1593
Definition: ObjectGuid.h:32
arena_t NULL
Definition: jemalloc_internal.h:624
ObjectGuid GetCharmerGUID() const
Definition: Unit.h:1704
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: SharedDefines.h:1897
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Unit.h:543
bool IsAIEnabled
Definition: Unit.h:2161
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Definition: Unit.h:859
Definition: SharedDefines.h:1885
Definition: PetDefines.h:25
Player * ToPlayer()
Definition: Object.h:191
void SetCommandState(CommandStates st)
Definition: Unit.h:1210
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
void MovePoint(uint32 id, Position const &pos, bool generatePath=true)
Definition: MotionMaster.h:172
Definition: TemporarySummon.h:66
Definition: SpellAuraDefines.h:85
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
bool IsCommandAttack()
Definition: Unit.cpp:15705
void finish(bool ok=true)
Definition: Spell.cpp:3620
Definition: Unit.h:1140
Unit * GetCharmerOrOwner() const
Definition: Unit.cpp:7627
void SendPetCastResult(SpellCastResult result)
Definition: Spell.cpp:3720
void SetIsReturning(bool val)
Definition: Unit.cpp:15761
Definition: Unit.h:559
Unit * GetVictim() const
Definition: Unit.h:1379
void SendPetAIReaction(ObjectGuid guid)
Definition: Unit.cpp:12729
G3D::int16 z
Definition: Vector3int16.h:46
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
CreatureAI * AI() const
Definition: Creature.h:525
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
Definition: SharedDefines.h:1886
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Unit.h:1123
bool isPossessed() const
Definition: Unit.h:1743
void SendPetTalk(uint32 pettalk)
Definition: Unit.cpp:12717
ReactStates
Definition: Unit.h:1127
void SetIsAtStay(bool val)
Definition: Unit.cpp:15741
bool IsPet() const
Definition: Unit.h:1403
void SetIsCommandAttack(bool val)
Definition: Unit.cpp:15700
Definition: Unit.h:1122
Definition: Unit.h:1201
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:5611
Definition: Unit.h:1121
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:549
Definition: ObjectGuid.h:33
Definition: Unit.h:1138
virtual void setDeathState(DeathState s)
Definition: Unit.cpp:10593
Player * _player
Definition: WorldSession.h:1797
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:591
Unit * GetOwner() const
Definition: Unit.cpp:7542
Creature * ToCreature()
Definition: Object.h:194
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition: Unit.cpp:2916
SpellEffectInfoVector GetEffectsForDifficulty(uint32 difficulty) const
Definition: SpellInfo.cpp:3311
uint32 HasUnitTypeMask(uint32 mask) const
Definition: Unit.h:1399
Definition: Unit.h:1119
#define ASSERT
Definition: Errors.h:55
Definition: Unit.h:1141
SpellCastResult
Definition: SharedDefines.h:1265
#define PET_FOLLOW_DIST
Definition: PetDefines.h:77
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: PetDefines.h:34
uint32_t uint32
Definition: g3dmath.h:168
Definition: PetDefines.h:73
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: Unit.h:1137
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:15771
Definition: Unit.h:1305
void SetIsCommandFollow(bool val)
Definition: Unit.cpp:15710
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
void SetReactState(ReactStates st)
Definition: Creature.h:502
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29
Definition: SharedDefines.h:1538
void SendUpdateToPlayer(Player *player)
Definition: Object.cpp:251
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: Pet.h:46
Definition: Unit.h:1120
Definition: Unit.h:460
virtual float GetFollowAngle() const
Definition: Unit.h:2194
void MoveFollow(Unit *target, float dist, float angle, MovementSlot slot=MOTION_SLOT_ACTIVE)
Definition: MotionMaster.cpp:265
Definition: Spell.h:294

+ Here is the caller graph for this function:

void WorldSession::HandlePetCancelAuraOpcode ( WorldPackets::Spells::PetCancelAura packet)
364 {
365  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.SpellID);
366  if (!spellInfo)
367  {
368  TC_LOG_ERROR("network", "WORLD: unknown PET spell id %u", packet.SpellID);
369  return;
370  }
371 
373 
374  if (!pet)
375  {
376  TC_LOG_ERROR("network", "HandlePetCancelAura: Attempt to cancel an aura for non-existant %s by player '%s'", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str());
377  return;
378  }
379 
380  if (pet != GetPlayer()->GetGuardianPet() && pet != GetPlayer()->GetCharm())
381  {
382  TC_LOG_ERROR("network", "HandlePetCancelAura: %s is not a pet of player '%s'", packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str());
383  return;
384  }
385 
386  if (!pet->IsAlive())
387  {
389  return;
390  }
391 
393 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: SpellInfo.h:326
ObjectGuid PetGUID
Definition: SpellPackets.h:83
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Unit.h:452
uint32 SpellID
Definition: SpellPackets.h:84
bool IsAlive() const
Definition: Unit.h:1692
#define sSpellMgr
Definition: SpellMgr.h:756
void SendPetActionFeedback(uint8 msg)
-------—Pet responses methods--------------—
Definition: Unit.cpp:12706
void RemoveOwnedAura(AuraMap::iterator &i, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3365
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: PetDefines.h:66

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetCastSpellOpcode ( WorldPackets::Spells::PetCastSpell petCastSpell)
648 {
649  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(petCastSpell.Cast.SpellID);
650  if (!spellInfo)
651  {
652  TC_LOG_ERROR("network", "WorldSession::HandlePetCastSpellOpcode: unknown spell id %i tried to cast by %s",
653  petCastSpell.Cast.SpellID, petCastSpell.PetGUID.ToString().c_str());
654  return;
655  }
656 
657  Unit* caster = ObjectAccessor::GetUnit(*_player, petCastSpell.PetGUID);
658  if (!caster)
659  {
660  TC_LOG_ERROR("network", "WorldSession::HandlePetCastSpellOpcode: Caster %s not found.", petCastSpell.PetGUID.ToString().c_str());
661  return;
662  }
663 
664  // This opcode is also sent from charmed and possessed units (players and creatures)
665  if (caster != _player->GetGuardianPet() && caster != _player->GetCharm())
666  {
667  TC_LOG_ERROR("network", "WorldSession::HandlePetCastSpellOpcode: %s isn't pet of player %s (%s).", petCastSpell.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
668  return;
669  }
670 
671  // do not cast not learned spells
672  if (!caster->HasSpell(spellInfo->Id) || spellInfo->IsPassive())
673  return;
674 
675  SpellCastTargets targets(caster, petCastSpell.Cast);
676 
678 
679  Spell* spell = new Spell(caster, spellInfo, TRIGGERED_NONE);
680  spell->m_cast_count = petCastSpell.Cast.CastID;
681  spell->m_misc.Raw.Data[0] = petCastSpell.Cast.Misc[0];
682  spell->m_misc.Raw.Data[1] = petCastSpell.Cast.Misc[1];
683  spell->m_targets = targets;
684 
685  SpellCastResult result = spell->CheckPetCast(NULL);
686  if (result == SPELL_CAST_OK)
687  {
688  if (Creature* creature = caster->ToCreature())
689  {
690  if (Pet* pet = creature->ToPet())
691  {
692  // 10% chance to play special pet attack talk, else growl
693  // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell
694  if (pet->getPetType() == SUMMON_PET && (urand(0, 100) < 10))
695  pet->SendPetTalk(PET_TALK_SPECIAL_SPELL);
696  else
697  pet->SendPetAIReaction(petCastSpell.PetGUID);
698  }
699  }
700 
701  spell->prepare(&targets);
702  }
703  else
704  {
705  spell->SendPetCastResult(result);
706 
707  if (!caster->GetSpellHistory()->HasCooldown(spellInfo->Id))
708  caster->GetSpellHistory()->ResetCooldown(spellInfo->Id, true);
709 
710  spell->finish(false);
711  delete spell;
712  }
713 }
union Spell::@326 m_misc
uint32 Id
Definition: SpellInfo.h:329
Definition: PetDefines.h:24
bool IsPassive() const
Definition: SpellInfo.cpp:1403
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Definition: SpellInfo.h:326
int32 SpellID
Definition: SpellPackets.h:250
SpellCastTargets m_targets
Definition: Spell.h:584
Pet * ToPet()
Definition: Unit.h:2200
struct Spell::@326::@328 Raw
virtual bool HasSpell(uint32) const
Definition: Unit.h:1593
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 Misc[2]
Definition: SpellPackets.h:258
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
SpellHistory * GetSpellHistory()
Definition: Unit.h:1926
void finish(bool ok=true)
Definition: Spell.cpp:3620
void SendPetCastResult(SpellCastResult result)
Definition: Spell.cpp:3720
Definition: Unit.h:559
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: Spell.h:170
SpellCastResult CheckPetCast(Unit *target)
Definition: Spell.cpp:5611
void ResetCooldown(uint32 spellId, bool update=false)
Definition: SpellHistory.cpp:549
Player * _player
Definition: WorldSession.h:1797
bool HasCooldown(SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
Definition: SpellHistory.cpp:591
Creature * ToCreature()
Definition: Object.h:194
ObjectGuid PetGUID
Definition: SpellPackets.h:278
SpellCastResult
Definition: SharedDefines.h:1265
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
SpellCastRequest Cast
Definition: SpellPackets.h:279
Definition: PetDefines.h:73
uint8 m_cast_count
Definition: Spell.h:552
Definition: Unit.h:1305
Definition: SharedDefines.h:1538
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Pet.h:46
Definition: Unit.h:460
uint8 CastID
Definition: SpellPackets.h:249
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetitionBuy ( WorldPackets::Petition::PetitionBuy packet)
34 {
35  TC_LOG_DEBUG("network", "Petitioner %s tried sell petition: title %s", packet.Unit.ToString().c_str(), packet.Title.c_str());
36 
37  // prevent cheating
38  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_PETITIONER);
39  if (!creature)
40  {
41  TC_LOG_DEBUG("network", "WORLD: HandlePetitionBuyOpcode - %s not found or you can't interact with him.", packet.Unit.ToString().c_str());
42  return;
43  }
44 
45  // remove fake death
46  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
47  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
48 
49  uint32 charterItemID = GUILD_CHARTER_ITEM_ID;
50  uint32 cost = sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD);
51 
52  // do not let if already in guild.
53  if (_player->GetGuildId())
54  return;
55 
56  if (sGuildMgr->GetGuildByName(packet.Title))
57  {
59  return;
60  }
61 
62  if (sObjectMgr->IsReservedName(packet.Title) || !ObjectMgr::IsValidCharterName(packet.Title))
63  {
65  return;
66  }
67 
68  ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(charterItemID);
69  if (!pProto)
70  {
71  _player->SendBuyError(BUY_ERR_CANT_FIND_ITEM, NULL, charterItemID, 0);
72  return;
73  }
74 
75  if (!_player->HasEnoughMoney(uint64(cost)))
76  {
77  _player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, charterItemID, 0);
78  return;
79  }
80 
81  ItemPosCountVec dest;
82  InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, charterItemID, pProto->GetBuyCount());
83  if (msg != EQUIP_ERR_OK)
84  {
85  _player->SendEquipError(msg, NULL, NULL, charterItemID);
86  return;
87  }
88 
89  _player->ModifyMoney(-int32(cost));
90  Item* charter = _player->StoreNewItem(dest, charterItemID, true);
91  if (!charter)
92  return;
93 
95  // ITEM_FIELD_ENCHANTMENT_1_1 is guild/arenateam id
96  // ITEM_FIELD_ENCHANTMENT_1_1+1 is current signatures count (showed on item)
97  charter->SetState(ITEM_CHANGED, _player);
98  _player->SendNewItem(charter, 1, true, false);
99 
100  // a petition is invalid, if both the owner and the type matches
101  // we checked above, if this player is in an arenateam, so this must be
102  // datacorruption
104  stmt->setUInt64(0, _player->GetGUID().GetCounter());
106 
107  std::ostringstream ssInvalidPetitionGUIDs;
108 
109  if (result)
110  {
111  do
112  {
113  Field* fields = result->Fetch();
114  ssInvalidPetitionGUIDs << '\'' << fields[0].GetUInt64() << "', ";
115  } while (result->NextRow());
116  }
117 
118  // delete petitions with the same guid as this one
119  ssInvalidPetitionGUIDs << '\'' << charter->GetGUID().GetCounter() << '\'';
120 
121  TC_LOG_DEBUG("network", "Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
124  trans->PAppend("DELETE FROM petition WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
125  trans->PAppend("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
126 
128  stmt->setUInt64(0, _player->GetGUID().GetCounter());
129  stmt->setUInt64(1, charter->GetGUID().GetCounter());
130  stmt->setString(2, packet.Title);
131  trans->Append(stmt);
132 
134 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: Guild.h:131
Definition: Unit.h:379
#define sGuildMgr
Definition: GuildMgr.h:61
Definition: CharacterDatabase.h:267
Class used to access individual fields of database query result.
Definition: Field.h:56
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: World.h:371
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 GetBuyCount() const
Definition: ItemTemplate.h:661
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Definition: Item.h:48
Definition: Unit.h:378
Definition: Item.h:150
Definition: Item.h:259
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
void EscapeString(std::string &str)
Apply escape string'ing for current collation. (utf8)
Definition: DatabaseWorkerPool.cpp:231
uint64_t uint64
Definition: Define.h:149
Definition: Guild.h:130
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid Unit
Definition: PetitionPackets.h:102
Definition: Item.h:152
Definition: Unit.h:753
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Definition: ItemTemplate.h:647
Definition: Unit.h:550
std::string Title
Definition: PetitionPackets.h:103
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: CharacterDatabase.h:426
Player * _player
Definition: WorldSession.h:1797
#define GUILD_CHARTER_ITEM_ID
Definition: PetitionsHandler.cpp:31
Definition: Guild.h:104
static bool IsValidCharterName(std::string const &name)
Definition: ObjectMgr.cpp:7605
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
InventoryResult
Definition: Item.h:46
Definition: UpdateFields.h:50
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetitionRenameGuild ( WorldPackets::Petition::PetitionRenameGuild packet)
233 {
234  Item* item = _player->GetItemByGuid(packet.PetitionGuid);
235  if (!item)
236  return;
237 
238  if (sGuildMgr->GetGuildByName(packet.NewGuildName))
239  {
241  return;
242  }
243 
244  if (sObjectMgr->IsReservedName(packet.NewGuildName) || !ObjectMgr::IsValidCharterName(packet.NewGuildName))
245  {
247  return;
248  }
249 
251 
252  stmt->setString(0, packet.NewGuildName);
253  stmt->setUInt64(1, packet.PetitionGuid.GetCounter());
254 
256 
258  renameResponse.PetitionGuid = packet.PetitionGuid;
259  renameResponse.NewGuildName = packet.NewGuildName;
260  SendPacket(renameResponse.Write());
261 
262  TC_LOG_DEBUG("network", "Petition %s renamed to '%s'", packet.PetitionGuid.ToString().c_str(), packet.NewGuildName.c_str());
263 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
Definition: Guild.h:131
#define sGuildMgr
Definition: GuildMgr.h:61
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
std::string NewGuildName
Definition: PetitionPackets.h:239
Definition: CharacterDatabase.h:326
std::string NewGuildName
Definition: PetitionPackets.h:228
Definition: Item.h:259
Definition: Guild.h:130
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Player * _player
Definition: WorldSession.h:1797
ObjectGuid PetitionGuid
Definition: PetitionPackets.h:238
Definition: Guild.h:104
static bool IsValidCharterName(std::string const &name)
Definition: ObjectMgr.cpp:7605
WorldPacket const * Write() override
Definition: PetitionPackets.cpp:182
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
ObjectGuid PetitionGuid
Definition: PetitionPackets.h:227
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetitionShowList ( WorldPackets::Petition::PetitionShowList packet)
566 {
568 }
ObjectGuid PetitionUnit
Definition: PetitionPackets.h:81
void SendPetitionShowList(ObjectGuid guid)
Definition: PetitionsHandler.cpp:570

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetitionShowSignatures ( WorldPackets::Petition::PetitionShowSignatures packet)
137 {
138  uint8 signs = 0;
139 
140  // if has guild => error, return;
141  if (_player->GetGuildId())
142  return;
143 
145 
146  stmt->setUInt64(0, packet.Item.GetCounter());
147 
149 
150  // result == NULL also correct in case no sign yet
151  if (result)
152  signs = uint8(result->GetRowCount());
153 
154  TC_LOG_DEBUG("network", "CMSG_PETITION_SHOW_SIGNATURES %s", packet.Item.ToString().c_str());
155 
157  signaturesPacket.Item = packet.Item;
158  signaturesPacket.Owner = _player->GetGUID();
159  signaturesPacket.OwnerAccountID = ObjectGuid::Create<HighGuid::WowAccount>(ObjectMgr::GetPlayerAccountIdByGUID(_player->GetGUID()));
160  signaturesPacket.PetitionID = int32(packet.Item.GetCounter()); // @todo verify that...
161 
162  signaturesPacket.Signatures.reserve(signs);
163  for (uint8 i = 1; i <= signs; ++i)
164  {
165  Field* fields2 = result->Fetch();
166  ObjectGuid signerGUID = ObjectGuid::Create<HighGuid::Player>(fields2[0].GetUInt64());
167 
169  signature.Signer = signerGUID;
170  signature.Choice = 0;
171  signaturesPacket.Signatures.push_back(signature);
172 
173  // Checking the return value just to be double safe
174  if (!result->NextRow())
175  break;
176  }
177 
178  SendPacket(signaturesPacket.Write());
179 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Class used to access individual fields of database query result.
Definition: Field.h:56
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
uint8_t uint8
Definition: g3dmath.h:164
ObjectGuid Item
Definition: PetitionPackets.h:129
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
Definition: CharacterDatabase.h:265
ObjectGuid Item
Definition: PetitionPackets.h:113
std::string ToString() const
Definition: ObjectGuid.cpp:99
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetRename ( WorldPackets::Pet::PetRename packet)
516 {
517  ObjectGuid petguid = packet.RenameData.PetGUID;
518  bool isdeclined = packet.RenameData.HasDeclinedNames;
519 
520  std::string name = packet.RenameData.NewName;
521  DeclinedName declinedname = packet.RenameData.DeclinedNames;
522 
523  Pet* pet = ObjectAccessor::GetPet(*_player, petguid);
524  // check it!
525  if (!pet || !pet->IsPet() || ((Pet*)pet)->getPetType()!= HUNTER_PET ||
527  pet->GetOwnerGUID() != _player->GetGUID() || !pet->GetCharmInfo())
528  return;
529 
531  if (res != PET_NAME_SUCCESS)
532  {
533  SendPetNameInvalid(res, name, NULL);
534  return;
535  }
536 
537  if (sObjectMgr->IsReservedName(name))
538  {
540  return;
541  }
542 
543  pet->SetName(name);
544 
546 
548 
549  if (isdeclined)
550  {
551  std::wstring wname;
552  if (!Utf8toWStr(name, wname))
553  return;
554 
555  if (!ObjectMgr::CheckDeclinedNames(wname, declinedname))
556  {
558  return;
559  }
560  }
561 
563  if (isdeclined)
564  {
566  stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
567  trans->Append(stmt);
568 
570  stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
571  stmt->setUInt64(1, _player->GetGUID().GetCounter());
572 
573  for (uint8 i = 0; i < 5; i++)
574  stmt->setString(i + 2, declinedname.name[i]);
575 
576  trans->Append(stmt);
577  }
578 
580  stmt->setString(0, name);
581  stmt->setUInt64(1, _player->GetGUID().GetCounter());
582  stmt->setUInt32(2, pet->GetCharmInfo()->GetPetNumber());
583  trans->Append(stmt);
584 
586 
587  pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, uint32(time(NULL))); // cast can't be helped
588 }
TC_GAME_API Pet * GetPet(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:179
Definition: Group.h:134
Definition: UpdateFields.h:146
static PetNameInvalidReason CheckPetName(std::string const &name)
Definition: ObjectMgr.cpp:7623
Definition: CharacterDatabase.h:556
PetNameInvalidReason
Definition: SharedDefines.h:4785
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
bool HasByteFlag(uint16 index, uint8 offset, uint8 flag) const
Definition: Object.cpp:1298
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
Definition: SharedDefines.h:4802
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void SetName(std::string const &newname)
Definition: Object.h:480
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Definition: PetDefines.h:25
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
PetRenameData RenameData
Definition: PetPackets.h:189
void SendPetNameInvalid(uint32 error, std::string const &name, DeclinedName *declinedName)
Definition: PetHandler.cpp:715
ObjectGuid PetGUID
Definition: PetPackets.h:163
Definition: UpdateFields.h:126
uint32 GetPetNumber() const
Definition: Unit.h:1207
void RemoveByteFlag(uint16 index, uint8 offset, uint8 newFlag)
Definition: Object.cpp:1271
static bool CheckDeclinedNames(const std::wstring &w_ownname, DeclinedName const &names)
Definition: ObjectMgr.cpp:7814
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: SharedDefines.h:4788
bool IsPet() const
Definition: Unit.h:1403
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
void SetGroupUpdateFlag(uint32 flag)
Definition: Pet.cpp:1928
uint8_t uint8
Definition: Define.h:152
Definition: Unit.h:321
Definition: CharacterDatabase.h:554
Definition: SharedDefines.h:4796
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
bool HasDeclinedNames
Definition: PetPackets.h:166
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
std::string NewName
Definition: PetPackets.h:165
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:1698
Definition: Unit.h:1101
Definition: CharacterDatabase.h:555
std::string name[MAX_DECLINED_NAME_CASES]
Definition: Unit.h:1103
DeclinedName DeclinedNames
Definition: PetPackets.h:167
Definition: Pet.h:46
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetSetAction ( WorldPackets::Pet::PetSetAction packet)
458 {
459  ObjectGuid petguid = packet.PetGUID;
460  Unit* pet = ObjectAccessor::GetUnit(*_player, petguid);
461 
462  if (!pet || pet != _player->GetFirstControlled())
463  {
464  TC_LOG_ERROR("network", "HandlePetSetAction: Unknown %s or owner (%s)", petguid.ToString().c_str(), _player->GetGUID().ToString().c_str());
465  return;
466  }
467 
468  CharmInfo* charmInfo = pet->GetCharmInfo();
469  if (!charmInfo)
470  {
471  TC_LOG_ERROR("network", "WorldSession::HandlePetSetAction: object (%s) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().ToString().c_str());
472  return;
473  }
474 
475  uint32 position = packet.Index;
476  uint32 actionData = packet.Action;
477 
478  uint32 spell_id = UNIT_ACTION_BUTTON_ACTION(actionData);
479  uint8 act_state = UNIT_ACTION_BUTTON_TYPE(actionData);
480 
481  TC_LOG_DEBUG("network", "Player %s has changed pet spell action. Position: %u, Spell: %u, State: 0x%X",
482  _player->GetName().c_str(), position, spell_id, uint32(act_state));
483 
484  //if it's act for spell (en/disable/cast) and there is a spell given (0 = remove spell) which pet doesn't know, don't add
485  if (!((act_state == ACT_ENABLED || act_state == ACT_DISABLED || act_state == ACT_PASSIVE) && spell_id && !pet->HasSpell(spell_id)))
486  {
487  if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spell_id))
488  {
489  //sign for autocast
490  if (act_state == ACT_ENABLED)
491  {
492  if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
493  ((Pet*)pet)->ToggleAutocast(spellInfo, true);
494  else
495  for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
496  if ((*itr)->GetEntry() == pet->GetEntry())
497  (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, true);
498  }
499  //sign for no/turn off autocast
500  else if (act_state == ACT_DISABLED)
501  {
502  if (pet->GetTypeId() == TYPEID_UNIT && pet->IsPet())
503  ((Pet*)pet)->ToggleAutocast(spellInfo, false);
504  else
505  for (Unit::ControlList::iterator itr = GetPlayer()->m_Controlled.begin(); itr != GetPlayer()->m_Controlled.end(); ++itr)
506  if ((*itr)->GetEntry() == pet->GetEntry())
507  (*itr)->GetCharmInfo()->ToggleCreatureAutocast(spellInfo, false);
508  }
509  }
510 
511  charmInfo->SetActionBar(position, spell_id, ActiveStates(act_state));
512  }
513 }
#define UNIT_ACTION_BUTTON_TYPE(X)
Definition: Unit.h:1145
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
Definition: SpellInfo.h:326
virtual bool HasSpell(uint32) const
Definition: Unit.h:1593
Definition: ObjectGuid.h:32
#define UNIT_ACTION_BUTTON_ACTION(X)
Definition: Unit.h:1144
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
uint32 Index
Definition: PetPackets.h:214
TypeID GetTypeId() const
Definition: Object.h:113
uint32 Action
Definition: PetPackets.h:215
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
bool IsPet() const
Definition: Unit.h:1403
Definition: Unit.h:1201
Definition: Unit.h:1121
ActiveStates
Definition: Unit.h:1117
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
void SetActionBar(uint8 index, uint32 spellOrAction, ActiveStates type)
Definition: Unit.h:1225
uint8_t uint8
Definition: Define.h:152
Definition: Unit.h:1119
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Pet.h:46
Definition: Unit.h:1120
ObjectGuid PetGUID
Definition: PetPackets.h:212

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetSpellAutocastOpcode ( WorldPackets::Pet::PetSpellAutocast packet)
606 {
608  if (!pet)
609  {
610  TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcode: Pet %s not found.", packet.PetGUID.ToString().c_str());
611  return;
612  }
613 
614  if (pet != _player->GetGuardianPet() && pet != _player->GetCharm())
615  {
616  TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcode: %s isn't pet of player %s (%s).",
617  packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
618  return;
619  }
620 
621  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.SpellID);
622  if (!spellInfo)
623  {
624  TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcode: Unknown spell id %u used by %s.", packet.SpellID, packet.PetGUID.ToString().c_str());
625  return;
626  }
627 
628  // do not add not learned spells/ passive spells
629  if (!pet->HasSpell(packet.SpellID) || !spellInfo->IsAutocastable())
630  return;
631 
632  CharmInfo* charmInfo = pet->GetCharmInfo();
633  if (!charmInfo)
634  {
635  TC_LOG_ERROR("network", "WorldSession::HandlePetSpellAutocastOpcode: object (%s) is considered pet-like but doesn't have a charminfo!", pet->GetGUID().ToString().c_str());
636  return;
637  }
638 
639  if (pet->IsPet())
640  pet->ToPet()->ToggleAutocast(spellInfo, packet.AutocastEnabled);
641  else
642  charmInfo->ToggleCreatureAutocast(spellInfo, packet.AutocastEnabled);
643 
644  charmInfo->SetSpellAutocast(spellInfo, packet.AutocastEnabled);
645 }
bool AutocastEnabled
Definition: PetPackets.h:78
bool IsAutocastable() const
Definition: SpellInfo.cpp:1408
Definition: SpellInfo.h:326
Pet * ToPet()
Definition: Unit.h:2200
void SetSpellAutocast(SpellInfo const *spellInfo, bool state)
Definition: Unit.cpp:12095
bool HasSpell(uint32 spellID) const override
Definition: Creature.cpp:2337
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 SpellID
Definition: PetPackets.h:77
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
#define sSpellMgr
Definition: SpellMgr.h:756
ObjectGuid PetGUID
Definition: PetPackets.h:76
void ToggleAutocast(SpellInfo const *spellInfo, bool apply)
Definition: Pet.cpp:1728
bool IsPet() const
Definition: Unit.h:1403
Definition: Unit.h:1201
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void ToggleCreatureAutocast(SpellInfo const *spellInfo, bool apply)
Definition: Unit.cpp:12038
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePetStopAttack ( WorldPackets::Pet::PetStopAttack packet)
115 {
117 
118  if (!pet)
119  {
120  TC_LOG_ERROR("network", "HandlePetStopAttack: %s does not exist", packet.PetGUID.ToString().c_str());
121  return;
122  }
123 
124  if (pet != GetPlayer()->GetPet() && pet != GetPlayer()->GetCharm())
125  {
126  TC_LOG_ERROR("network", "HandlePetStopAttack: %s isn't a pet or charmed creature of player %s",
127  packet.PetGUID.ToString().c_str(), GetPlayer()->GetName().c_str());
128  return;
129  }
130 
131  if (!pet->IsAlive())
132  return;
133 
134  pet->AttackStop();
135 }
bool AttackStop()
Definition: Unit.cpp:7337
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsAlive() const
Definition: Unit.h:1692
ObjectGuid PetGUID
Definition: PetPackets.h:66
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePingOpcode ( WorldPacket recvPacket)
void WorldSession::HandlePlayedTime ( WorldPackets::Character::RequestPlayedTime packet)
710 {
712  playedTime.TotalTime = _player->GetTotalPlayedTime();
713  playedTime.LevelTime = _player->GetLevelPlayedTime();
714  playedTime.TriggerEvent = packet.TriggerScriptEvent; // 0-1 - will not show in chat frame
715  SendPacket(playedTime.Write());
716 }
int32 TotalTime
Definition: CharacterPackets.h:557
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:426
int32 LevelTime
Definition: CharacterPackets.h:558
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
bool TriggerScriptEvent
Definition: CharacterPackets.h:547
bool TriggerEvent
Definition: CharacterPackets.h:559
Definition: CharacterPackets.h:550

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePlayerLogin ( LoginQueryHolder holder)
894 {
895  ObjectGuid playerGuid = holder->GetGuid();
896 
897  Player* pCurrChar = new Player(this);
898  // for send server info and strings (config)
899  ChatHandler chH = ChatHandler(pCurrChar->GetSession());
900 
901  // "GetAccountId() == db stored account id" checked in LoadFromDB (prevent login not own character using cheating tools)
902  if (!pCurrChar->LoadFromDB(playerGuid, holder))
903  {
904  SetPlayer(NULL);
905  KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
906  delete pCurrChar; // delete it manually
907  delete holder; // delete all unprocessed queries
909  return;
910  }
911 
913 
914  pCurrChar->GetMotionMaster()->Initialize();
915  pCurrChar->SendDungeonDifficulty();
916 
918  loginVerifyWorld.MapID = pCurrChar->GetMapId();
919  loginVerifyWorld.Pos = pCurrChar->GetPosition();
920  SendPacket(loginVerifyWorld.Write());
921 
922  // load player specific part before send times
923  LoadAccountData(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_ACCOUNT_DATA), PER_CHARACTER_CACHE_MASK);
924 
926  accountDataTimes.PlayerGuid = playerGuid;
927  accountDataTimes.ServerTime = uint32(sWorld->GetGameTime());
928  for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
929  accountDataTimes.AccountTimes[i] = uint32(GetAccountData(AccountDataType(i))->Time);
930 
931  SendPacket(accountDataTimes.Write());
932 
934 
935  // Send MOTD
936  {
938  motd.Text = &sWorld->GetMotd();
939  SendPacket(motd.Write());
940  TC_LOG_DEBUG("network", "WORLD: Sent motd (SMSG_MOTD)");
941  }
942 
944 
945  // Send PVPSeason
946  {
948  season.PreviousSeason = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID) - sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS);
949 
950  if (sWorld->getBoolConfig(CONFIG_ARENA_SEASON_IN_PROGRESS))
951  season.CurrentSeason = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID);
952 
953  SendPacket(season.Write());
954  TC_LOG_DEBUG("network", "WORLD: Sent PVPSeason");
955  }
956 
957  // send server info
958  {
959  if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1)
961 
962  TC_LOG_DEBUG("network", "WORLD: Sent server info");
963  }
964 
965  //QueryResult* result = CharacterDatabase.PQuery("SELECT guildid, rank FROM guild_member WHERE guid = '%u'", pCurrChar->GetGUIDLow());
966  if (PreparedQueryResult resultGuild = holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_GUILD))
967  {
968  Field* fields = resultGuild->Fetch();
969  pCurrChar->SetInGuild(fields[0].GetUInt64());
970  pCurrChar->SetRank(fields[1].GetUInt8());
971  if (Guild* guild = sGuildMgr->GetGuildById(pCurrChar->GetGuildId()))
972  pCurrChar->SetGuildLevel(guild->GetLevel());
973  }
974  else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about non existed membership
975  {
976  pCurrChar->SetInGuild(UI64LIT(0));
977  pCurrChar->SetRank(0);
978  pCurrChar->SetGuildLevel(0);
979  }
980 
981  //WorldPacket data(SMSG_LEARNED_DANCE_MOVES, 4+4);
982  //data << uint64(0);
983  //SendPacket(&data);
984 
986  hotfixInfo.Hotfixes = sDB2Manager.GetHotfixData();
987  SendPacket(hotfixInfo.Write());
988 
989  // TODO: Move this to BattlePetMgr::SendJournalLock() just to have all packets in one file
991  SendPacket(lock.Write());
992 
993  pCurrChar->SendInitialPacketsBeforeAddToMap();
994 
995  //Show cinematic at the first time that player login
996  if (!pCurrChar->getCinematic())
997  {
998  pCurrChar->setCinematic(1);
999 
1000  if (ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(pCurrChar->getClass()))
1001  {
1002  if (cEntry->CinematicSequenceID)
1003  pCurrChar->SendCinematicStart(cEntry->CinematicSequenceID);
1004  else if (ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(pCurrChar->getRace()))
1005  pCurrChar->SendCinematicStart(rEntry->CinematicSequenceID);
1006 
1007  // send new char string if not empty
1008  if (!sWorld->GetNewCharString().empty())
1009  chH.PSendSysMessage("%s", sWorld->GetNewCharString().c_str());
1010  }
1011  }
1012 
1013  if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar))
1014  {
1015  AreaTriggerStruct const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
1016  if (at)
1017  pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
1018  else
1019  pCurrChar->TeleportTo(pCurrChar->m_homebindMapId, pCurrChar->m_homebindX, pCurrChar->m_homebindY, pCurrChar->m_homebindZ, pCurrChar->GetOrientation());
1020  }
1021 
1022  ObjectAccessor::AddObject(pCurrChar);
1023  //TC_LOG_DEBUG("Player %s added to Map.", pCurrChar->GetName().c_str());
1024 
1025  if (pCurrChar->GetGuildId())
1026  {
1027  if (Guild* guild = sGuildMgr->GetGuildById(pCurrChar->GetGuildId()))
1028  guild->SendLoginInfo(this);
1029  else
1030  {
1031  // remove wrong guild data
1032  TC_LOG_ERROR("misc", "Player %s (%s) marked as member of not existing guild (id: " UI64FMTD "), removing guild membership for player.", pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), pCurrChar->GetGuildId());
1033  pCurrChar->SetInGuild(UI64LIT(0));
1034  }
1035  }
1036 
1037  pCurrChar->SendInitialPacketsAfterAddToMap();
1038 
1040  stmt->setUInt64(0, pCurrChar->GetGUID().GetCounter());
1041  CharacterDatabase.Execute(stmt);
1042 
1044  stmt->setUInt32(0, GetAccountId());
1045  LoginDatabase.Execute(stmt);
1046 
1047  pCurrChar->SetInGameTime(getMSTime());
1048 
1049  // announce group about member online (must be after add to player list to receive announce to self)
1050  if (Group* group = pCurrChar->GetGroup())
1051  {
1052  //pCurrChar->groupInfo.group->SendInit(this); // useless
1053  group->SendUpdate();
1054  group->ResetMaxEnchantingLevel();
1055  }
1056 
1057  // friend status
1058  sSocialMgr->SendFriendStatus(pCurrChar, FRIEND_ONLINE, pCurrChar->GetGUID(), true);
1059 
1060  // Place character in world (and load zone) before some object loading
1061  pCurrChar->LoadCorpse(holder->GetPreparedResult(PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION));
1062 
1063  // setting Ghost+speed if dead
1064  if (pCurrChar->m_deathState != ALIVE)
1065  {
1066  // not blizz like, we must correctly save and load player instead...
1067  if (pCurrChar->getRace() == RACE_NIGHTELF && !pCurrChar->HasAura(20584))
1068  pCurrChar->CastSpell(pCurrChar, 20584, true, 0);// auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form)
1069 
1070  if (!pCurrChar->HasAura(8326))
1071  pCurrChar->CastSpell(pCurrChar, 8326, true, 0); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?)
1072 
1073  pCurrChar->SetWaterWalking(true);
1074  }
1075 
1076  pCurrChar->ContinueTaxiFlight();
1077 
1078  // reset for all pets before pet loading
1079  if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_PET_TALENTS))
1080  Pet::resetTalentsForAllPetsOf(pCurrChar);
1081 
1082  // Load pet if any (if player not alive and in taxi flight or another then pet will remember as temporary unsummoned)
1083  pCurrChar->LoadPet();
1084 
1085  // Set FFA PvP for non GM in non-rest mode
1086  if (sWorld->IsFFAPvPRealm() && !pCurrChar->IsGameMaster() && !pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING))
1087  pCurrChar->SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
1088 
1089  if (pCurrChar->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_CONTESTED_PVP))
1090  pCurrChar->SetContestedPvP();
1091 
1092  // Apply at_login requests
1093  if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
1094  {
1095  pCurrChar->ResetSpells();
1097  }
1098 
1099  if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
1100  {
1101  pCurrChar->ResetTalents(true);
1102  pCurrChar->ResetTalentSpecialization();
1103  pCurrChar->SendTalentsInfoData(); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
1105  }
1106 
1107  bool firstLogin = pCurrChar->HasAtLoginFlag(AT_LOGIN_FIRST);
1108  if (firstLogin)
1109  {
1110  pCurrChar->RemoveAtLoginFlag(AT_LOGIN_FIRST);
1111 
1112  PlayerInfo const* info = sObjectMgr->GetPlayerInfo(pCurrChar->getRace(), pCurrChar->getClass());
1113  for (uint32 spellId : info->castSpells)
1114  pCurrChar->CastSpell(pCurrChar, spellId, true);
1115  }
1116 
1117  // show time before shutdown if shutdown planned.
1118  if (sWorld->IsShuttingDown())
1119  sWorld->ShutdownMsg(true, pCurrChar);
1120 
1121  if (sWorld->getBoolConfig(CONFIG_ALL_TAXI_PATHS))
1122  pCurrChar->SetTaxiCheater(true);
1123 
1124  if (pCurrChar->IsGameMaster())
1126 
1127  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Login Character: [%s] (%s) Level: %d",
1128  GetAccountId(), GetRemoteAddress().c_str(), pCurrChar->GetName().c_str(), pCurrChar->GetGUID().ToString().c_str(), pCurrChar->getLevel());
1129 
1130  if (!pCurrChar->IsStandState() && !pCurrChar->HasUnitState(UNIT_STATE_STUNNED))
1131  pCurrChar->SetStandState(UNIT_STAND_STATE_STAND);
1132 
1134 
1135  // Handle Login-Achievements (should be handled after loading)
1136  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_ON_LOGIN, 1);
1137 
1138  sScriptMgr->OnPlayerLogin(pCurrChar, firstLogin);
1139 
1140  delete holder;
1141 }
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:20
WorldPacket const * Write() override
Definition: SystemPackets.cpp:105
Definition: Player.h:525
Definition: ObjectMgr.h:400
Definition: Unit.h:207
#define sDB2Manager
Definition: DB2Stores.h:224
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
DBCStorage< ChrRacesEntry > sChrRacesStore(ChrRacesfmt)
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
Definition: UpdateFields.h:146
Definition: ClientConfigPackets.h:42
Definition: Language.h:360
Position Pos
Definition: CharacterPackets.h:431
DBCStorage< ChrClassesEntry > sChrClassesStore(ChrClassesfmt)
Definition: SharedDefines.h:105
Definition: DBCStructure.h:204
ObjectGuid PlayerGuid
Definition: ClientConfigPackets.h:49
std::vector< std::string > const * Text
Definition: SystemPackets.h:116
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: Language.h:241
Definition: DBCEnums.h:263
Definition: World.h:140
uint32 getMSTime()
Definition: Timer.h:24
Definition: Unit.h:541
PreparedQueryResult GetPreparedResult(size_t index)
Definition: QueryHolder.cpp:78
#define UI64LIT(N)
Definition: Define.h:138
Definition: Player.h:396
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: CharacterPackets.h:423
TC_COMMON_API char const * GetFullVersion()
Definition: GitRevision.cpp:51
Definition: Unit.h:310
Definition: LoginDatabase.h:74
void SetPlayer(Player *player)
Definition: WorldSession.cpp:935
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: SocialMgr.h:71
AccountData const * GetAccountData(AccountDataType type) const
Definition: WorldSession.h:998
#define sWorld
Definition: World.h:887
Definition: CharacterDatabase.h:356
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
Definition: World.h:112
Definition: Language.h:242
void LoadAccountData(PreparedQueryResult result, uint32 mask)
Definition: WorldSession.cpp:724
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: QueryPackets.h:206
float target_Y
Definition: ObjectMgr.h:404
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Definition: DBCStructure.h:181
Definition: Unit.h:553
Definition: World.h:309
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
void GetPosition(float &x, float &y) const
Definition: Position.h:109
Definition: BattlegroundPackets.h:31
#define UI64FMTD
Definition: Define.h:137
void AddObject(T *object)
Definition: ObjectAccessor.h:98
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
ObjectGuid GetGuid() const
Definition: CharacterHandler.cpp:66
uint32 CurrentSeason
Definition: BattlegroundPackets.h:39
AccountDataType
Definition: WorldSession.h:723
#define PER_CHARACTER_CACHE_MASK
Definition: WorldSession.h:738
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
#define sSocialMgr
Definition: SocialMgr.h:160
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void Clear()
Definition: ObjectGuid.h:215
Definition: Chat.h:56
time_t Time
Definition: WorldSession.h:777
void SendFeatureSystemStatus()
Definition: CharacterHandler.cpp:1143
WorldPacket const * Write() override
Definition: QueryPackets.cpp:271
Player * _player
Definition: WorldSession.h:1797
float target_Z
Definition: ObjectMgr.h:405
HotfixData const * Hotfixes
Definition: QueryPackets.h:213
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
void SendTutorialsData()
Definition: WorldSession.cpp:797
Definition: World.h:320
static void resetTalentsForAllPetsOf(Player *owner, Pet *online_pet=nullptr)
Definition: Pet.cpp:1626
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
Definition: UpdateFields.h:191
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32 PreviousSeason
Definition: BattlegroundPackets.h:38
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: SystemPackets.h:109
PlayerCreateInfoSpells castSpells
Definition: Player.h:411
Definition: Guild.h:320
#define NUM_ACCOUNT_DATA_TYPES
Definition: WorldSession.h:735
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:372
int32 MapID
Definition: CharacterPackets.h:430
void SendSetTimeZoneInformation()
Definition: AuthHandler.cpp:80
Definition: Group.h:191
float target_X
Definition: ObjectMgr.h:403
uint32 target_mapId
Definition: ObjectMgr.h:402
Definition: Player.h:522

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePlayerLoginOpcode ( WorldPackets::Character::PlayerLogin playerLogin)
831 {
832  if (PlayerLoading() || GetPlayer() != NULL)
833  {
834  TC_LOG_ERROR("network", "Player tries to login again, AccountId = %d", GetAccountId());
835  KickPlayer();
836  return;
837  }
838 
839  TC_LOG_DEBUG("network", "WORLD: Recvd Player Logon Message");
840 
841  m_playerLoading = playerLogin.Guid;
842 
843  TC_LOG_DEBUG("network", "Character %s logging in", playerLogin.Guid.ToString().c_str());
844 
845  if (!IsLegitCharacterForAccount(playerLogin.Guid))
846  {
847  TC_LOG_ERROR("network", "Account (%u) can't login with that character (%s).", GetAccountId(), playerLogin.Guid.ToString().c_str());
848  KickPlayer();
849  return;
850  }
851 
853 }
ObjectGuid Guid
Guid of the player that is logging in.
Definition: CharacterPackets.h:419
bool IsLegitCharacterForAccount(ObjectGuid lowGUID)
Definition: WorldSession.h:1787
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
void KickPlayer()
Kick a player out of the World.
Definition: WorldSession.cpp:646
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
void SendConnectToInstance(WorldPackets::Auth::ConnectToSerial serial)
Definition: WorldSession.cpp:705
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool PlayerLoading() const
Definition: WorldSession.h:889
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePortGraveyard ( WorldPackets::Misc::PortGraveyard packet)
360 {
361  if (GetPlayer()->IsAlive() || !GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
362  return;
363  GetPlayer()->RepopAtGraveyard();
364 }
Definition: Player.h:521
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: UpdateFields.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePushQuestToParty ( WorldPackets::Quest::PushQuestToParty packet)
564 {
565  if (!_player->CanShareQuest(packet.QuestID))
566  return;
567 
568  Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
569  if (!quest)
570  return;
571 
572  Player * const sender = GetPlayer();
573 
574  Group* group = sender->GetGroup();
575  if (!group)
576  return;
577 
578  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
579  {
580  Player* receiver = itr->GetSource();
581 
582  if (!receiver || receiver == sender)
583  continue;
584 
585  if (!receiver->SatisfyQuestStatus(quest, false))
586  {
587  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ONQUEST);
588  continue;
589  }
590 
591  if (receiver->GetQuestStatus(packet.QuestID) == QUEST_STATUS_COMPLETE)
592  {
593  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_ALREADY_DONE);
594  continue;
595  }
596 
597  if (!receiver->CanTakeQuest(quest, false))
598  {
599  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_INVALID);
600  continue;
601  }
602 
603  if (!receiver->SatisfyQuestLog(false))
604  {
605  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_LOG_FULL);
606  continue;
607  }
608 
609  if (!receiver->GetDivider().IsEmpty())
610  {
611  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_BUSY);
612  continue;
613  }
614 
615  sender->SendPushToPartyResponse(receiver, QUEST_PUSH_SUCCESS);
616 
617  if (quest->IsAutoAccept() && receiver->CanAddQuest(quest, true) && receiver->CanTakeQuest(quest, true))
618  receiver->AddQuestAndCheckCompletion(quest, sender);
619 
620  if (quest->IsAutoComplete() && quest->IsRepeatable() && !quest->IsDailyOrWeekly())
621  receiver->PlayerTalkClass->SendQuestGiverRequestItems(quest, sender->GetGUID(), receiver->CanCompleteRepeatableQuest(quest), true);
622  else
623  {
624  receiver->SetDivider(sender->GetGUID());
625  receiver->PlayerTalkClass->SendQuestGiverQuestDetails(quest, receiver->GetGUID(), true);
626  }
627  }
628 }
Definition: QuestDef.h:111
bool IsAutoComplete() const
Definition: QuestDef.cpp:315
Definition: QuestDef.h:81
Definition: QuestDef.h:279
Definition: QuestDef.h:74
Definition: QuestDef.h:77
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
bool IsRepeatable() const
Definition: QuestDef.h:363
bool IsAutoAccept() const
Definition: QuestDef.cpp:310
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: QuestDef.h:73
Player * _player
Definition: WorldSession.h:1797
Definition: QuestDef.h:79
uint32 QuestID
Definition: QuestPackets.h:568
Definition: QuestDef.h:80
bool IsDailyOrWeekly() const
Definition: QuestDef.h:379
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandlePVPLogDataOpcode ( WorldPackets::Battleground::PVPLogDataRequest pvpLogDataRequest)
228 {
229  Battleground* bg = _player->GetBattleground();
230  if (!bg)
231  return;
232 
233  // Prevent players from sending BuildPvpLogDataPacket in an arena except for when sent in BattleGround::EndBattleGround.
234  if (bg->isArena())
235  return;
236 
238  bg->BuildPvPLogDataPacket(pvpLogData);
239  SendPacket(pvpLogData.Write());
240 }
Definition: BattlegroundPackets.h:89
bool isArena() const
Definition: Battleground.h:326
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:102
void BuildPvPLogDataPacket(WorldPackets::Battleground::PVPLogData &pvpLogData)
Definition: Battleground.cpp:1322
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
Definition: Battleground.h:235

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryCorpseLocation ( WorldPackets::Query::QueryCorpseLocationFromClient packet)
171 {
172  if (!_player->HasCorpse())
173  {
175  packet.Valid = false; // corpse not found
176  SendPacket(packet.Write());
177  return;
178  }
179 
180  WorldLocation corpseLocation = _player->GetCorpseLocation();
181  uint32 corpseMapID = corpseLocation.GetMapId();
182  uint32 mapID = corpseLocation.GetMapId();
183  float x = corpseLocation.GetPositionX();
184  float y = corpseLocation.GetPositionY();
185  float z = corpseLocation.GetPositionZ();
186 
187  // if corpse at different map
188  if (mapID != _player->GetMapId())
189  {
190  // search entrance map for proper show entrance
191  if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapID))
192  {
193  if (corpseMapEntry->IsDungeon() && corpseMapEntry->CorpseMapID >= 0)
194  {
195  // if corpse map have entrance
196  if (Map const* entranceMap = sMapMgr->CreateBaseMap(corpseMapEntry->CorpseMapID))
197  {
198  mapID = corpseMapEntry->CorpseMapID;
199  x = corpseMapEntry->CorpsePos.X;
200  y = corpseMapEntry->CorpsePos.Y;
201  z = entranceMap->GetHeight(GetPlayer()->GetPhaseMask(), x, y, MAX_HEIGHT);
202  }
203  }
204  }
205  }
206 
208  packet.Valid = true;
209  packet.MapID = corpseMapID;
210  packet.ActualMapID = mapID;
211  packet.Position = G3D::Vector3(x, y, z);
212  packet.Transport = ObjectGuid::Empty;
213  SendPacket(packet.Write());
214 }
Definition: Position.h:228
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
G3D::Vector3 Position
Definition: QueryPackets.h:275
bool Valid
Definition: QueryPackets.h:278
Definition: DBCStructure.h:830
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Transport
Definition: QueryPackets.h:274
Definition: Vector3.h:58
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
float GetPositionZ() const
Definition: Position.h:106
WorldPacket const * Write() override
Definition: QueryPackets.cpp:328
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint32 GetMapId() const
Definition: Position.h:254
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Map.h:259
int32 MapID
Definition: QueryPackets.h:277
Player * _player
Definition: WorldSession.h:1797
DBCStorage< MapEntry > sMapStore(Mapfmt)
#define sMapMgr
Definition: MapManager.h:194
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
#define MAX_HEIGHT
Definition: Map.h:247
Definition: QueryPackets.h:267
int32 ActualMapID
Definition: QueryPackets.h:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryCorpseTransport ( WorldPackets::Query::QueryCorpseTransport packet)
283 {
284  Corpse* corpse = _player->GetCorpse();
285 
287  if (!corpse || corpse->GetTransGUID().IsEmpty() || corpse->GetTransGUID() != queryCorpseTransport.Transport)
288  {
289  response.Position = G3D::Vector3(0.0f, 0.0f, 0.0f);
290  response.Facing = 0.0f;
291  }
292  else
293  {
294  response.Position = G3D::Vector3(corpse->GetTransOffsetX(), corpse->GetTransOffsetY(), corpse->GetTransOffsetZ());
295  response.Facing = corpse->GetTransOffsetO();
296  }
297 
298  SendPacket(response.Write());
299 }
Definition: Corpse.h:49
float GetTransOffsetZ() const
Definition: Object.h:605
float Facing
Definition: QueryPackets.h:299
float GetTransOffsetY() const
Definition: Object.h:604
WorldPacket const * Write() override
Definition: QueryPackets.cpp:348
Definition: Vector3.h:58
float GetTransOffsetX() const
Definition: Object.h:603
G3D::Vector3 Position
Definition: QueryPackets.h:298
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
Definition: QueryPackets.h:291
float GetTransOffsetO() const
Definition: Object.h:606
virtual ObjectGuid GetTransGUID() const
Definition: Object.cpp:3102
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryInspectAchievements ( WorldPackets::Inspect::QueryInspectAchievements inspect)
134 {
135  Player* player = ObjectAccessor::FindPlayer(inspect.Guid);
136  if (!player)
137  {
138  TC_LOG_DEBUG("network", "WorldSession::HandleQueryInspectAchievements: [%s] inspected unknown Player [%s]", GetPlayer()->GetGUID().ToString().c_str(), inspect.Guid.ToString().c_str());
139  return;
140  }
141 
142  TC_LOG_DEBUG("network", "WorldSession::HandleQueryInspectAchievements: [%s] inspected Player [%s]", GetPlayer()->GetGUID().ToString().c_str(), inspect.Guid.ToString().c_str());
143 
144  if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
145  return;
146 
147  if (GetPlayer()->IsValidAttackTarget(player))
148  return;
149 
150  player->SendRespondInspectAchievements(GetPlayer());
151 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
#define INSPECT_DISTANCE
Definition: Object.h:36
string ToString(int i)
Definition: strutil.h:491
ObjectGuid Guid
Definition: InspectPackets.h:148
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryNextMailTime ( WorldPackets::Mail::MailQueryNextMailTime packet)
Todo:
Fix me! ... this void has probably bad condition, but good data are sent
661 {
663 
664  if (!_player->m_mailsLoaded)
665  _player->_LoadMail();
666 
667  if (_player->unReadMails > 0)
668  {
669  result.NextMailTime = 0.0f;
670 
671  time_t now = time(nullptr);
672  std::set<ObjectGuid::LowType> sentSenders;
673 
674  for (Mail* mail : _player->GetMails())
675  {
676  if (mail->checked & MAIL_CHECK_MASK_READ)
677  continue;
678 
679  // already delivered
680  if (now < mail->deliver_time)
681  continue;
682 
683  // only send each mail sender once
684  if (sentSenders.count(mail->sender))
685  continue;
686 
687  result.Next.emplace_back(mail);
688 
689  sentSenders.insert(mail->sender);
690 
691  // do not send more than 2 mails
692  if (sentSenders.size() > 2)
693  break;
694  }
695  }
696  else
697  result.NextMailTime = -DAY;
698 
699  SendPacket(result.Write());
700 }
std::vector< MailNextTimeEntry > Next
Definition: MailPackets.h:234
Definition: Mail.h:166
Definition: Common.h:99
float NextMailTime
Definition: MailPackets.h:233
WorldPacket const * Write() override
Definition: MailPackets.cpp:250
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Mail.h:48
Player * _player
Definition: WorldSession.h:1797
Definition: MailPackets.h:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryPageText ( WorldPackets::Query::QueryPageText packet)

Only static data is sent in this packet !!!

246 {
247  uint32 pageID = packet.PageTextID;
248 
249  while (pageID)
250  {
251  PageText const* pageText = sObjectMgr->GetPageText(pageID);
252 
254  response.PageTextID = pageID;
255 
256  if (!pageText)
257  {
258  response.Allow = false;
259  pageID = 0;
260  }
261  else
262  {
263  response.Allow = true;
264  response.Info.ID = pageID;
265  response.Info.NextPageID = pageText->NextPageID;
266  response.Info.Text = pageText->Text;
267 
268  LocaleConstant localeConstant = GetSessionDbLocaleIndex();
269  if (localeConstant >= LOCALE_enUS)
270  if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID))
271  ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, response.Info.Text);
272 
273  pageID = pageText->NextPageID;
274  }
275 
276  SendPacket(response.Write());
277 
278  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_QUERY_PAGE_TEXT_RESPONSE");
279  }
280 }
uint32 NextPageID
Definition: QueryPackets.h:142
std::string Text
Definition: QueryPackets.h:143
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:1060
uint32 PageTextID
Definition: QueryPackets.h:148
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string Text
Definition: ObjectMgr.h:57
uint32 PageTextID
Definition: QueryPackets.h:129
#define sObjectMgr
Definition: ObjectMgr.h:1567
WorldPacket const * Write() override
Definition: QueryPackets.cpp:199
bool Allow
Definition: QueryPackets.h:146
LocaleConstant
Definition: Common.h:115
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Common.h:117
PageTextInfo Info
Definition: QueryPackets.h:147
Definition: NPCHandler.h:35
static void GetLocaleString(StringVector const &data, LocaleConstant localeConstant, std::string &value)
Definition: ObjectMgr.h:1345
uint32 NextPageID
Definition: ObjectMgr.h:58
Definition: ObjectMgr.h:55
Definition: QueryPackets.h:132

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryPetition ( WorldPackets::Petition::QueryPetition packet)
182 {
183  TC_LOG_DEBUG("network", "Received CMSG_QUERY_PETITION Petition %s PetitionID %u", packet.ItemGUID.ToString().c_str(), packet.PetitionID);
184 
186 }
uint32 PetitionID
Definition: PetitionPackets.h:37
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendPetitionQueryOpcode(ObjectGuid petitionguid)
Definition: PetitionsHandler.cpp:188
ObjectGuid ItemGUID
Definition: PetitionPackets.h:36
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryPetName ( WorldPackets::Query::QueryPetName packet)
405 {
407 }
void SendQueryPetNameResponse(ObjectGuid guid)
Definition: PetHandler.cpp:409
ObjectGuid UnitGUID
Definition: QueryPackets.h:404

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryQuestCompletionNPCs ( WorldPackets::Query::QueryQuestCompletionNPCs queryQuestCompletionNPCs)
302 {
304 
305  for (int32& questID : queryQuestCompletionNPCs.QuestCompletionNPCs)
306  {
307  WorldPackets::Query::QuestCompletionNPC questCompletionNPC;
308 
309  if (!sObjectMgr->GetQuestTemplate(questID))
310  {
311  TC_LOG_DEBUG("network", "WORLD: Unknown quest %u in CMSG_QUERY_QUEST_COMPLETION_NPCS by %s", questID, _player->GetGUID().ToString().c_str());
312  continue;
313  }
314 
315  questCompletionNPC.QuestID = questID;
316 
317  auto creatures = sObjectMgr->GetCreatureQuestInvolvedRelationReverseBounds(questID);
318  for (auto it = creatures.first; it != creatures.second; ++it)
319  questCompletionNPC.NPCs.push_back(it->second);
320 
321  auto gos = sObjectMgr->GetGOQuestInvolvedRelationReverseBounds(questID);
322  for (auto it = gos.first; it != gos.second; ++it)
323  questCompletionNPC.NPCs.push_back(it->second | 0x80000000); // GO mask
324 
325  response.QuestCompletionNPCs.push_back(questCompletionNPC);
326  }
327 
328  SendPacket(response.Write());
329 }
WorldPacket const * Write() override
Definition: QueryPackets.cpp:423
Definition: QueryPackets.h:381
std::vector< int32 > NPCs
Definition: QueryPackets.h:384
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::vector< int32 > QuestCompletionNPCs
Definition: QueryPackets.h:378
int32 QuestID
Definition: QueryPackets.h:383
int32_t int32
Definition: Define.h:146
std::vector< QuestCompletionNPC > QuestCompletionNPCs
Definition: QueryPackets.h:394
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQueryTimeOpcode ( WorldPackets::Query::QueryTime queryTime)
53 {
55 }
void SendQueryTimeResponse()
Definition: QueryHandler.cpp:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestConfirmAccept ( WorldPackets::Quest::QuestConfirmAccept packet)
462 {
463  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUEST_CONFIRM_ACCEPT questId = %u", packet.QuestID);
464 
465  if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID))
466  {
467  if (!quest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT))
468  return;
469 
470  Player* originalPlayer = ObjectAccessor::FindPlayer(_player->GetDivider());
471  if (!originalPlayer)
472  return;
473 
474  if (!_player->IsInSameRaidWith(originalPlayer))
475  return;
476 
477  if (!originalPlayer->IsActiveQuest(packet.QuestID))
478  return;
479 
480  if (!_player->CanTakeQuest(quest, true))
481  return;
482 
483  if (_player->CanAddQuest(quest, true))
484  {
485  _player->AddQuestAndCheckCompletion(quest, NULL); // NULL, this prevent DB script from duplicate running
486 
487  if (quest->GetSrcSpell() > 0)
488  _player->CastSpell(_player, quest->GetSrcSpell(), true);
489  }
490  }
491 
492  _player->SetDivider(ObjectGuid::Empty);
493 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: QuestDef.h:279
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
int32 QuestID
Definition: QuestPackets.h:494
Definition: QuestDef.h:143
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverAcceptQuestOpcode ( WorldPackets::Quest::QuestGiverAcceptQuest packet)
98 {
99  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_ACCEPT_QUEST %s, quest = %u, startcheat = %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, packet.StartCheat);
100 
101  Object* object;
102  if (!packet.QuestGiverGUID.IsPlayer())
104  else
106 
107 #define CLOSE_GOSSIP_CLEAR_DIVIDER() \
108  do { \
109  _player->PlayerTalkClass->SendCloseGossip(); \
110  _player->SetDivider(ObjectGuid::Empty); \
111  } while (0)
112 
113  // no or incorrect quest giver
114  if (!object)
115  {
117  return;
118  }
119 
120  if (Player* playerQuestObject = object->ToPlayer())
121  {
122  if ((_player->GetDivider().IsEmpty() && _player->GetDivider() != packet.QuestGiverGUID) || !playerQuestObject->CanShareQuest(packet.QuestID))
123  {
125  return;
126  }
127  if (!_player->IsInSameRaidWith(playerQuestObject))
128  {
130  return;
131  }
132  }
133  else
134  {
135  if (!object->hasQuest(packet.QuestID))
136  {
138  return;
139  }
140  }
141 
142  // some kind of WPE protection
143  if (!_player->CanInteractWithQuestGiver(object))
144  {
146  return;
147  }
148 
149  if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID))
150  {
151  // prevent cheating
152  if (!GetPlayer()->CanTakeQuest(quest, true))
153  {
155  return;
156  }
157 
158  if (!_player->GetDivider().IsEmpty())
159  {
160  Player* player = ObjectAccessor::FindPlayer(_player->GetDivider());
161  if (player)
162  {
163  player->SendPushToPartyResponse(_player, QUEST_PUSH_ACCEPTED);
164  _player->SetDivider(ObjectGuid::Empty);
165  }
166  }
167 
168  if (_player->CanAddQuest(quest, true))
169  {
170  _player->AddQuestAndCheckCompletion(quest, object);
171 
172  if (quest->HasFlag(QUEST_FLAGS_PARTY_ACCEPT))
173  {
174  if (Group* group = _player->GetGroup())
175  {
176  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
177  {
178  Player* player = itr->GetSource();
179 
180  if (!player || player == _player) // not self
181  continue;
182 
183  if (player->CanTakeQuest(quest, true))
184  {
185  player->SetDivider(_player->GetGUID());
186 
187  // need confirmation that any gossip window will close
188  player->PlayerTalkClass->SendCloseGossip();
189 
190  _player->SendQuestConfirmAccept(quest, player);
191  }
192  }
193  }
194  }
195 
196  _player->PlayerTalkClass->SendCloseGossip();
197 
198  if (quest->GetSrcSpell() > 0)
199  _player->CastSpell(_player, quest->GetSrcSpell(), true);
200 
201  return;
202  }
203  }
204 
206 
207 #undef CLOSE_GOSSIP_CLEAR_DIVIDER
208 }
Definition: Object.h:95
bool IsPlayer() const
Definition: ObjectGuid.h:249
Definition: QuestDef.h:75
Definition: ObjectGuid.h:47
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: QuestDef.h:279
bool StartCheat
Definition: QuestPackets.h:425
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define CLOSE_GOSSIP_CLEAR_DIVIDER()
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: ObjectGuid.h:49
int32 QuestID
Definition: QuestPackets.h:424
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: ObjectGuid.h:51
Definition: QuestDef.h:143
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:423
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverCancel ( WorldPacket recvData)
410 {
411  _player->PlayerTalkClass->SendCloseGossip();
412 }
Player * _player
Definition: WorldSession.h:1797
void WorldSession::HandleQuestgiverChooseRewardOpcode ( WorldPackets::Quest::QuestGiverChooseReward packet)
249 {
250  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_CHOOSE_REWARD npc = %s, quest = %u, reward = %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, packet.ItemChoiceID);
251 
252  Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
253  if (!quest)
254  return;
255 
256  // This is Real Item Entry, not slot id as pre 5.x
257  if (packet.ItemChoiceID)
258  {
259  ItemTemplate const* rewardProto = sObjectMgr->GetItemTemplate(packet.ItemChoiceID);
260  if (!rewardProto)
261  {
262  TC_LOG_ERROR("network", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get invalid reward item (Item Entry: %u) for quest %u (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.ItemChoiceID, packet.QuestID);
263  return;
264  }
265 
266  bool itemValid = false;
267  for (uint32 i = 0; i < quest->GetRewChoiceItemsCount(); ++i)
268  {
269  if (quest->RewardChoiceItemId[i] && quest->RewardChoiceItemId[i] == uint32(packet.ItemChoiceID))
270  {
271  itemValid = true;
272  break;
273  }
274  }
275 
276  if (!itemValid && quest->GetQuestPackageID())
277  {
278  if (std::vector<QuestPackageItemEntry const*> const* questPackageItems = sDB2Manager.GetQuestPackageItems(quest->GetQuestPackageID()))
279  {
280  for (QuestPackageItemEntry const* questPackageItem : *questPackageItems)
281  {
282  if (questPackageItem->ItemID != uint32(packet.ItemChoiceID))
283  continue;
284 
285  rewardProto = sObjectMgr->GetItemTemplate(questPackageItem->ItemID);
286  if (rewardProto)
287  {
288  if (rewardProto->CanWinForPlayer(_player))
289  {
290  itemValid = true;
291  break;
292  }
293  }
294  }
295  }
296  }
297 
298  if (!itemValid)
299  {
300  TC_LOG_ERROR("network", "Error in CMSG_QUESTGIVER_CHOOSE_REWARD: player %s (%s) tried to get reward item (Item Entry: %u) wich is not a reward for quest %u (possible packet-hacking detected)", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.ItemChoiceID, packet.QuestID);
301  return;
302  }
303  }
304 
305  Object* object = _player;
306 
307  if (!quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
308  {
310  if (!object || !object->hasInvolvedQuest(packet.QuestID))
311  return;
312 
313  // some kind of WPE protection
314  if (!_player->CanInteractWithQuestGiver(object))
315  return;
316  }
317 
318  if ((!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(packet.QuestID) == QUEST_STATUS_NONE) ||
319  (_player->GetQuestStatus(packet.QuestID) != QUEST_STATUS_COMPLETE && !quest->IsAutoComplete()))
320  {
321  TC_LOG_ERROR("network", "Error in QUEST_STATUS_COMPLETE: player %s (%s) tried to complete quest %u, but is not allowed to do so (possible packet-hacking or high latency)",
322  _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.QuestID);
323  return;
324  }
325 
326  if (_player->CanRewardQuest(quest, packet.ItemChoiceID, true))
327  {
328  _player->RewardQuest(quest, packet.ItemChoiceID, object);
329 
330  switch (object->GetTypeId())
331  {
332  case TYPEID_UNIT:
333  case TYPEID_PLAYER:
334  {
335  //For AutoSubmition was added plr case there as it almost same exclute AI script cases.
336  Creature* creatureQGiver = object->ToCreature();
337  if (!creatureQGiver || !sScriptMgr->OnQuestReward(_player, creatureQGiver, quest, packet.ItemChoiceID))
338  {
339  // Send next quest
340  if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest))
341  {
342  // Only send the quest to the player if the conditions are met
343  if (_player->CanTakeQuest(nextQuest, false))
344  {
345  if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
346  _player->AddQuestAndCheckCompletion(nextQuest, object);
347 
348  _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true);
349  }
350  }
351 
352  if (creatureQGiver)
353  creatureQGiver->AI()->sQuestReward(_player, quest, packet.ItemChoiceID);
354  }
355  break;
356  }
357  case TYPEID_GAMEOBJECT:
358  {
359  GameObject* questGiver = object->ToGameObject();
360  if (!sScriptMgr->OnQuestReward(_player, questGiver, quest, packet.ItemChoiceID))
361  {
362  // Send next quest
363  if (Quest const* nextQuest = _player->GetNextQuest(packet.QuestGiverGUID, quest))
364  {
365  // Only send the quest to the player if the conditions are met
366  if (_player->CanTakeQuest(nextQuest, false))
367  {
368  if (nextQuest->IsAutoAccept() && _player->CanAddQuest(nextQuest, true))
369  _player->AddQuestAndCheckCompletion(nextQuest, object);
370 
371  _player->PlayerTalkClass->SendQuestGiverQuestDetails(nextQuest, packet.QuestGiverGUID, true);
372  }
373  }
374 
375  questGiver->AI()->QuestReward(_player, quest, packet.ItemChoiceID);
376  }
377  break;
378  }
379  default:
380  break;
381  }
382  }
383  else
384  _player->PlayerTalkClass->SendQuestGiverOfferReward(quest, packet.QuestGiverGUID, true);
385 }
Definition: Object.h:95
virtual void sQuestReward(Player *, Quest const *, uint32)
Definition: UnitAI.h:258
Definition: QuestDef.h:111
#define sDB2Manager
Definition: DB2Stores.h:224
GameObjectAI * AI() const
Definition: GameObject.h:1061
Definition: QuestDef.h:279
int32 ItemChoiceID
Definition: QuestPackets.h:284
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:282
Definition: QuestDef.h:158
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: DB2Structure.h:1079
#define sObjectMgr
Definition: ObjectMgr.h:1567
GameObject * ToGameObject()
Definition: Object.h:200
Definition: QuestDef.h:110
Definition: ObjectGuid.h:49
TypeID GetTypeId() const
Definition: Object.h:113
int32 QuestID
Definition: QuestPackets.h:283
Definition: ObjectGuid.h:51
virtual bool QuestReward(Player *, Quest const *, uint32)
Definition: GameObjectAI.h:54
CreatureAI * AI() const
Definition: Creature.h:525
Definition: ObjectGuid.h:34
uint32_t uint32
Definition: Define.h:150
Definition: GameObject.h:880
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
Player * _player
Definition: WorldSession.h:1797
Creature * ToCreature()
Definition: Object.h:194
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
virtual bool hasInvolvedQuest(uint32) const
Definition: Object.h:181
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool CanWinForPlayer(Player const *player) const
Definition: ItemTemplate.cpp:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverCompleteQuest ( WorldPackets::Quest::QuestGiverCompleteQuest packet)
496 {
497  bool autoCompleteMode = packet.FromScript; // 0 - standart complete quest mode with npc, 1 - auto-complete mode
498 
499  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_COMPLETE_QUEST npc = %s, questId = %u self-complete: %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, autoCompleteMode ? 1 : 0);
500 
501  Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID);
502  if (!quest)
503  return;
504 
505  if (autoCompleteMode && !quest->HasFlag(QUEST_FLAGS_AUTOCOMPLETE))
506  return;
507 
508  Object* object = nullptr;
509  if (autoCompleteMode)
510  object = _player;
511  else
513 
514  if (!object)
515  return;
516 
517  if (autoCompleteMode == 0)
518  {
519  if (!object->hasInvolvedQuest(packet.QuestID))
520  return;
521 
522  // some kind of WPE protection
523  if (!_player->CanInteractWithQuestGiver(object))
524  return;
525  }
526  else
527  {
528  // Do not allow completing quests on other players.
529  if (packet.QuestGiverGUID != _player->GetGUID())
530  return;
531  }
532 
533  if (!_player->CanSeeStartQuest(quest) && _player->GetQuestStatus(packet.QuestID) == QUEST_STATUS_NONE)
534  {
535  TC_LOG_ERROR("network", "Possible hacking attempt: Player %s [%s] tried to complete quest [entry: %u] without being in possession of the quest!",
536  _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.QuestID);
537  return;
538  }
539 
540  if (Battleground* bg = _player->GetBattleground())
541  bg->HandleQuestComplete(packet.QuestID, _player);
542 
543  if (_player->GetQuestStatus(packet.QuestID) != QUEST_STATUS_COMPLETE)
544  {
545  if (quest->IsRepeatable())
546  _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanCompleteRepeatableQuest(quest), false);
547  else
548  _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanRewardQuest(quest, false), false);
549  }
550  else
551  {
552  if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_DELIVER)) // some items required
553  _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, packet.QuestGiverGUID, _player->CanRewardQuest(quest, false), false);
554  else // no items required
555  _player->PlayerTalkClass->SendQuestGiverOfferReward(quest, packet.QuestGiverGUID, true);
556  }
557 }
Definition: Object.h:95
Definition: QuestDef.h:111
Definition: QuestDef.h:211
Definition: QuestDef.h:279
Definition: QuestDef.h:158
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: QuestDef.h:110
Definition: ObjectGuid.h:49
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:312
Definition: ObjectGuid.h:51
bool FromScript
Definition: QuestPackets.h:314
Player * _player
Definition: WorldSession.h:1797
Definition: Battleground.h:235
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
int32 QuestID
Definition: QuestPackets.h:313
virtual bool hasInvolvedQuest(uint32) const
Definition: Object.h:181
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverHelloOpcode ( WorldPackets::Quest::QuestGiverHello packet)
71 {
72  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_HELLO %s", packet.QuestGiverGUID.ToString().c_str());
73 
74  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.QuestGiverGUID, UNIT_NPC_FLAG_QUESTGIVER);
75  if (!creature)
76  {
77  TC_LOG_DEBUG("network", "WORLD: HandleQuestgiverHelloOpcode - %s not found or you can't interact with him.",
78  packet.QuestGiverGUID.ToString().c_str());
79  return;
80  }
81 
82  // remove fake death
83  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
84  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
85  // Stop the npc if moving
86  creature->StopMoving();
87 
88  if (sScriptMgr->OnGossipHello(_player, creature))
89  return;
90 
91  _player->PrepareGossipMenu(creature, creature->GetCreatureTemplate()->GossipMenuId, true);
92  _player->SendPreparedGossip(creature);
93 
94  creature->AI()->sGossipHello(_player);
95 }
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:86
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Unit.h:736
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
#define sScriptMgr
Definition: ScriptMgr.h:837
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverQueryQuestOpcode ( WorldPackets::Quest::QuestGiverQueryQuest packet)
211 {
212  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_QUERY_QUEST QuestGiverGUID = %s, QuestID = %u, RespondToGiver = %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID, packet.RespondToGiver);
213 
214  // Verify that the guid is valid and is a questgiver or involved in the requested quest
216  if (!object || (!object->hasQuest(packet.QuestID) && !object->hasInvolvedQuest(packet.QuestID)))
217  {
218  _player->PlayerTalkClass->SendCloseGossip();
219  return;
220  }
221 
222  if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID))
223  {
224  if (!_player->CanTakeQuest(quest, true))
225  return;
226 
227  if (quest->IsAutoAccept() && _player->CanAddQuest(quest, true))
228  _player->AddQuestAndCheckCompletion(quest, object);
229 
230  if (quest->IsAutoComplete())
231  _player->PlayerTalkClass->SendQuestGiverRequestItems(quest, object->GetGUID(), _player->CanCompleteQuest(quest->GetQuestId()), true);
232  else
233  _player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, object->GetGUID(), true);
234  }
235 }
Definition: Object.h:95
Definition: ObjectGuid.h:47
Definition: QuestDef.h:279
bool RespondToGiver
Definition: QuestPackets.h:413
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: ObjectGuid.h:49
Definition: ObjectGuid.h:51
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
int32 QuestID
Definition: QuestPackets.h:412
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:411

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverQuestAutoLaunch ( WorldPacket recvPacket)
560 {
561 }
void WorldSession::HandleQuestgiverRequestRewardOpcode ( WorldPackets::Quest::QuestGiverRequestReward packet)
388 {
389  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_REQUEST_REWARD npc = %s, quest = %u", packet.QuestGiverGUID.ToString().c_str(), packet.QuestID);
390 
392  if (!object || !object->hasInvolvedQuest(packet.QuestID))
393  return;
394 
395  // some kind of WPE protection
396  if (!_player->CanInteractWithQuestGiver(object))
397  return;
398 
399  if (_player->CanCompleteQuest(packet.QuestID))
400  _player->CompleteQuest(packet.QuestID);
401 
402  if (_player->GetQuestStatus(packet.QuestID) != QUEST_STATUS_COMPLETE)
403  return;
404 
405  if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID))
406  _player->PlayerTalkClass->SendQuestGiverOfferReward(quest, packet.QuestGiverGUID, true);
407 }
Definition: Object.h:95
Definition: QuestDef.h:111
Definition: QuestDef.h:279
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: ObjectGuid.h:49
Definition: ObjectGuid.h:51
int32 QuestID
Definition: QuestPackets.h:401
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:400
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverStatusMultipleQuery ( WorldPackets::Quest::QuestGiverStatusMultipleQuery packet)
643 {
645 
646  for (auto itr = _player->m_clientGUIDs.begin(); itr != _player->m_clientGUIDs.end(); ++itr)
647  {
648  if (itr->IsAnyTypeCreature())
649  {
650  // need also pet quests case support
652  if (!questgiver || questgiver->IsHostileTo(_player))
653  continue;
655  continue;
656 
657  response.QuestGiver.emplace_back(questgiver->GetGUID(), _player->GetQuestDialogStatus(questgiver));
658  }
659  else if (itr->IsGameObject())
660  {
661  GameObject* questgiver = GetPlayer()->GetMap()->GetGameObject(*itr);
662  if (!questgiver || questgiver->GetGoType() != GAMEOBJECT_TYPE_QUESTGIVER)
663  continue;
664 
665  response.QuestGiver.emplace_back(questgiver->GetGUID(), _player->GetQuestDialogStatus(questgiver));
666  }
667  }
668 
669  SendPacket(response.Write());
670 }
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
std::vector< QuestGiverInfo > QuestGiver
Definition: QuestPackets.h:76
WorldPacket const * Write() override
Definition: QuestPackets.cpp:33
Definition: Unit.h:736
Definition: GameObject.h:880
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool HasFlag64(uint16 index, uint64 flag) const
Definition: Object.cpp:1327
Definition: SharedDefines.h:2067
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
Definition: UpdateFields.h:135

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestgiverStatusQueryOpcode ( WorldPackets::Quest::QuestGiverStatusQuery packet)
36 {
37  uint32 questStatus = DIALOG_STATUS_NONE;
38 
40  if (!questGiver)
41  {
42  TC_LOG_INFO("network", "Error in CMSG_QUESTGIVER_STATUS_QUERY, called for non-existing questgiver (%s)", packet.QuestGiverGUID.ToString().c_str());
43  return;
44  }
45 
46  switch (questGiver->GetTypeId())
47  {
48  case TYPEID_UNIT:
49  {
50  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for npc, %s", questGiver->GetGUID().ToString().c_str());
51  if (!questGiver->ToCreature()->IsHostileTo(_player)) // do not show quest status to enemies
52  questStatus = _player->GetQuestDialogStatus(questGiver);
53  break;
54  }
55  case TYPEID_GAMEOBJECT:
56  {
57  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTGIVER_STATUS_QUERY for GameObject %s", questGiver->GetGUID().ToString().c_str());
58  questStatus = _player->GetQuestDialogStatus(questGiver);
59  break;
60  }
61  default:
62  TC_LOG_ERROR("network", "QuestGiver called for unexpected type %u", questGiver->GetTypeId());
63  break;
64  }
65 
66  //inform client about status of quest
67  _player->PlayerTalkClass->SendQuestGiverStatus(questStatus, packet.QuestGiverGUID);
68 }
Definition: Object.h:95
ObjectGuid QuestGiverGUID
Definition: QuestPackets.h:37
Definition: ObjectGuid.h:32
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: ObjectGuid.h:49
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:51
Definition: ObjectGuid.h:34
uint32_t uint32
Definition: Define.h:150
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
Creature * ToCreature()
Definition: Object.h:194
bool IsHostileTo(Unit const *unit) const
Definition: Unit.cpp:7165
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
TC_GAME_API Object * GetObjectByTypeMask(WorldObject const &, ObjectGuid const &, uint32 typemask)
Definition: ObjectAccessor.cpp:96
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: QuestDef.h:122
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestLogRemoveQuest ( WorldPackets::Quest::QuestLogRemoveQuest packet)
415 {
416  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUESTLOG_REMOVE_QUEST slot = %u", packet.Entry);
417 
418  if (packet.Entry < MAX_QUEST_LOG_SIZE)
419  {
420  if (uint32 questId = _player->GetQuestSlotQuestId(packet.Entry))
421  {
422  if (!_player->TakeQuestSourceItem(questId, true))
423  return; // can't un-equip some items, reject quest cancel
424 
425  if (Quest const* quest = sObjectMgr->GetQuestTemplate(questId))
426  {
427  if (quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_TIMED))
428  _player->RemoveTimedQuest(questId);
429 
430  if (quest->HasFlag(QUEST_FLAGS_FLAGS_PVP))
431  {
432  _player->pvpInfo.IsHostile = _player->pvpInfo.IsInHostileArea || _player->HasPvPForcingQuest();
433  _player->UpdatePvPState();
434  }
435  }
436 
437  _player->TakeQuestSourceItem(questId, true); // remove quest src item from player
438  _player->RemoveActiveQuest(questId);
439  _player->RemoveTimedAchievement(ACHIEVEMENT_TIMED_TYPE_QUEST, questId);
440 
441  TC_LOG_INFO("network", "%s abandoned quest %u", _player->GetGUID().ToString().c_str(), questId);
442 
443  if (sWorld->getBoolConfig(CONFIG_QUEST_ENABLE_QUEST_TRACKER)) // check if Quest Tracker is enabled
444  {
445  // prepare Quest Tracker datas
447  stmt->setUInt32(0, questId);
448  stmt->setUInt64(1, _player->GetGUID().GetCounter());
449 
450  // add to Quest Tracker
452  }
453  }
454 
455  _player->SetQuestSlot(packet.Entry, 0);
456 
457  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_QUEST_ABANDONED, 1);
458  }
459 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: QuestDef.h:279
Definition: QuestDef.h:214
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:43
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: QuestDef.h:155
Definition: PreparedStatement.h:74
Definition: World.h:165
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:579
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8 Entry
Definition: QuestPackets.h:435
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: DBCEnums.h:184
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestPOIQuery ( WorldPackets::Query::QuestPOIQuery questPoiQuery)
332 {
333  if (questPoiQuery.MissingQuestCount > MAX_QUEST_LOG_SIZE)
334  return;
335 
336  // Read quest ids and add the in a unordered_set so we don't send POIs for the same quest multiple times
337  std::unordered_set<int32> questIds;
338  for (int32 i = 0; i < questPoiQuery.MissingQuestCount; ++i)
339  questIds.insert(questPoiQuery.MissingQuestPOIs[i]); // QuestID
340 
342 
343  for (auto itr = questIds.begin(); itr != questIds.end(); ++itr)
344  {
345  int32 QuestID = *itr;
346 
347  bool questOk = false;
348 
349  uint16 questSlot = _player->FindQuestSlot(uint32(QuestID));
350 
351  if (questSlot != MAX_QUEST_LOG_SIZE)
352  questOk = _player->GetQuestSlotQuestId(questSlot) == uint32(QuestID);
353 
354  if (questOk)
355  {
356  QuestPOIVector const* poiData = sObjectMgr->GetQuestPOIVector(QuestID);
357  if (poiData)
358  {
360 
361  questPOIData.QuestID = QuestID;
362 
363  for (auto data = poiData->begin(); data != poiData->end(); ++data)
364  {
365  WorldPackets::Query::QuestPOIBlobData questPOIBlobData;
366 
367  questPOIBlobData.BlobIndex = data->BlobIndex;
368  questPOIBlobData.ObjectiveIndex = data->ObjectiveIndex;
369  questPOIBlobData.QuestObjectiveID = data->QuestObjectiveID;
370  questPOIBlobData.QuestObjectID = data->QuestObjectID;
371  questPOIBlobData.MapID = data->MapID;
372  questPOIBlobData.WorldMapAreaID = data->WorldMapAreaID;
373  questPOIBlobData.Floor = data->Floor;
374  questPOIBlobData.Priority = data->Priority;
375  questPOIBlobData.Flags = data->Flags;
376  questPOIBlobData.WorldEffectID = data->WorldEffectID;
377  questPOIBlobData.PlayerConditionID = data->PlayerConditionID;
378  questPOIBlobData.UnkWoD1 = data->UnkWoD1;
379 
380  for (auto points = data->points.begin(); points != data->points.end(); ++points)
381  {
382  WorldPackets::Query::QuestPOIBlobPoint questPOIBlobPoint;
383 
384  questPOIBlobPoint.X = points->X;
385  questPOIBlobPoint.Y = points->Y;
386 
387  TC_LOG_ERROR("misc", "Quest: %i BlobIndex: %i X/Y: %i/%i", QuestID, data->BlobIndex, points->X, points->Y);
388 
389  questPOIBlobData.QuestPOIBlobPointStats.push_back(questPOIBlobPoint);
390  }
391 
392  questPOIData.QuestPOIBlobDataStats.push_back(questPOIBlobData);
393  }
394 
395  response.QuestPOIDataStats.push_back(questPOIData);
396  }
397  }
398  }
399 
400  SendPacket(response.Write());
401 }
std::vector< QuestPOIBlobData > QuestPOIBlobDataStats
Definition: QueryPackets.h:358
std::vector< QuestPOIData > QuestPOIDataStats
Definition: QueryPackets.h:368
int32 Flags
Definition: QueryPackets.h:348
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:43
int32 MapID
Definition: QueryPackets.h:344
int32 ObjectiveIndex
Definition: QueryPackets.h:341
int32 BlobIndex
Definition: QueryPackets.h:340
int32 UnkWoD1
Definition: QueryPackets.h:351
Definition: QueryPackets.h:361
int32 WorldEffectID
Definition: QueryPackets.h:349
int32 WorldMapAreaID
Definition: QueryPackets.h:345
#define sObjectMgr
Definition: ObjectMgr.h:1567
int32 Priority
Definition: QueryPackets.h:347
WorldPacket const * Write() override
Definition: QueryPackets.cpp:374
Definition: QueryPackets.h:355
int32_t int32
Definition: Define.h:146
uint16_t uint16
Definition: Define.h:151
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 QuestObjectiveID
Definition: QueryPackets.h:342
int32 X
Definition: QueryPackets.h:334
Definition: QueryPackets.h:338
int32 QuestID
Definition: QueryPackets.h:357
std::vector< QuestPOIBlobPoint > QuestPOIBlobPointStats
Definition: QueryPackets.h:352
Player * _player
Definition: WorldSession.h:1797
int32 QuestObjectID
Definition: QueryPackets.h:343
std::vector< QuestPOI > QuestPOIVector
Definition: ObjectMgr.h:573
Definition: QueryPackets.h:332
int32 MissingQuestCount
Definition: QueryPackets.h:328
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
int32 Y
Definition: QueryPackets.h:335
uint32_t uint32
Definition: g3dmath.h:168
int32 Floor
Definition: QueryPackets.h:346
int32 PlayerConditionID
Definition: QueryPackets.h:350
int32 MissingQuestPOIs[50]
Definition: QueryPackets.h:329

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestPushResult ( WorldPackets::Quest::QuestPushResult packet)
631 {
632  if (!_player->GetDivider().IsEmpty())
633  {
634  if (_player->GetDivider() == packet.SenderGUID)
635  if (Player* player = ObjectAccessor::FindPlayer(_player->GetDivider()))
636  player->SendPushToPartyResponse(_player, static_cast<QuestPushReason>(packet.Result));
637 
638  _player->SetDivider(ObjectGuid::Empty);
639  }
640 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
ObjectGuid SenderGUID
Definition: QuestPackets.h:523
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Player * _player
Definition: WorldSession.h:1797
uint8 Result
Definition: QuestPackets.h:525

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleQuestQueryOpcode ( WorldPackets::Quest::QueryQuestInfo packet)
238 {
239  if (!_player)
240  return;
241 
242  TC_LOG_DEBUG("network", "WORLD: Received CMSG_QUEST_QUERY quest = %u", packet.QuestID);
243 
244  if (Quest const* quest = sObjectMgr->GetQuestTemplate(packet.QuestID))
245  _player->PlayerTalkClass->SendQuestQueryResponse(quest);
246 }
Definition: QuestDef.h:279
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
Player * _player
Definition: WorldSession.h:1797
int32 QuestID
Definition: QuestPackets.h:97

+ Here is the caller graph for this function:

void WorldSession::HandleRandomizeCharNameOpcode ( WorldPackets::Character::GenerateRandomCharacterName packet)
2256 {
2257  if (!Player::IsValidRace(packet.Race))
2258  {
2259  TC_LOG_ERROR("misc", "Invalid race (%u) sent by accountId: %u", packet.Race, GetAccountId());
2260  return;
2261  }
2262 
2263  if (!Player::IsValidGender(packet.Sex))
2264  {
2265  TC_LOG_ERROR("misc", "Invalid gender (%u) sent by accountId: %u", packet.Sex, GetAccountId());
2266  return;
2267  }
2268 
2270  result.Success = true;
2271  result.Name = sDB2Manager.GetNameGenEntry(packet.Race, packet.Sex, GetSessionDbcLocale());
2272 
2273  SendPacket(result.Write());
2274 }
#define sDB2Manager
Definition: DB2Stores.h:224
uint32 GetAccountId() const
Definition: WorldSession.h:922
uint8 Race
Definition: CharacterPackets.h:333
LocaleConstant GetSessionDbcLocale() const
Definition: WorldSession.h:1059
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8 Sex
Definition: CharacterPackets.h:332
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:315
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string Name
Definition: CharacterPackets.h:343
bool Success
Definition: CharacterPackets.h:344

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRandomRollOpcode ( WorldPackets::Misc::RandomRollClient packet)

error handling

400 {
401  uint32 minimum, maximum, roll;
402  minimum = packet.Min;
403  maximum = packet.Max;
404 
406  if (minimum > maximum || maximum > 10000) // < 32768 for urand call
407  return;
408  /********************/
409 
410  // everything's fine, do it
411  roll = urand(minimum, maximum);
412 
414  randomRoll.Min = minimum;
415  randomRoll.Max = maximum;
416  randomRoll.Result = roll;
417  randomRoll.Roller = GetPlayer()->GetGUID();
418  randomRoll.RollerWowAccount = GetAccountGUID();
419  if (GetPlayer()->GetGroup())
420  GetPlayer()->GetGroup()->BroadcastPacket(randomRoll.Write(), false);
421  else
422  SendPacket(randomRoll.Write());
423 }
ObjectGuid RollerWowAccount
Definition: MiscPackets.h:532
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 Result
Definition: MiscPackets.h:535
ObjectGuid Roller
Definition: MiscPackets.h:531
int32 Min
Definition: MiscPackets.h:533
WorldPacket const * Write() override
Definition: MiscPackets.cpp:376
int32 Max
Definition: MiscPackets.h:520
int32 Max
Definition: MiscPackets.h:534
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: MiscPackets.h:524
int32 Min
Definition: MiscPackets.h:519
ObjectGuid GetAccountGUID() const
Definition: WorldSession.h:923

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleReadItem ( WorldPackets::Item::ReadItem readItem)
Todo:
: 6.x research new values
312 {
313  Item* item = _player->GetItemByPos(readItem.PackSlot, readItem.Slot);
314  if (item && item->GetTemplate()->GetPageText())
315  {
316  InventoryResult msg = _player->CanUseItem(item);
317  if (msg == EQUIP_ERR_OK)
318  {
320  packet.Item = item->GetGUID();
321  SendPacket(packet.Write());
322 
323  TC_LOG_INFO("network", "STORAGE: Item page sent");
324  }
325  else
326  {
328  /*WorldPackets::Item::ReadItemResultFailed packet;
329  packet.Item = item->GetGUID();
330  packet.Subcode = ??;
331  packet.Delay = ??;
332  SendPacket(packet.Write());*/
333 
334  TC_LOG_INFO("network", "STORAGE: Unable to read item");
335  _player->SendEquipError(msg, item, NULL);
336  }
337  }
338  else
339  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
340 }
uint8 PackSlot
Definition: ItemPackets.h:400
Definition: ItemPackets.h:416
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 GetPageText() const
Definition: ItemTemplate.h:685
WorldPacket const * Write() override
Definition: ItemPackets.cpp:463
Definition: Item.h:48
Definition: Item.h:71
ObjectGuid Item
Definition: ItemPackets.h:423
Definition: Item.h:259
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
uint8 Slot
Definition: ItemPackets.h:401
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
InventoryResult
Definition: Item.h:46
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleReadyCheckResponseOpcode ( WorldPackets::Party::ReadyCheckResponseClient packet)
569 {
570  Group* group = GetPlayer()->GetGroup();
571  if (!group)
572  return;
573 
574  // everything's fine, do it
575  group->SetMemberReadyCheck(GetPlayer()->GetGUID(), packet.IsReady);
576 }
void SetMemberReadyCheck(ObjectGuid guid, bool ready)
Definition: Group.cpp:2413
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsReady
Definition: PartyPackets.h:408
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleReclaimCorpse ( WorldPackets::Misc::ReclaimCorpse packet)
408 {
409  if (_player->IsAlive())
410  return;
411 
412  // do not allow corpse reclaim in arena
413  if (_player->InArena())
414  return;
415 
416  // body not released yet
417  if (!_player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
418  return;
419 
420  Corpse* corpse = _player->GetCorpse();
421  if (!corpse)
422  return;
423 
424  // prevent resurrect before 30-sec delay after body release not finished
425  if (time_t(corpse->GetGhostTime() + _player->GetCorpseReclaimDelay(corpse->GetType() == CORPSE_RESURRECTABLE_PVP)) > time_t(time(NULL)))
426  return;
427 
428  if (!corpse->IsWithinDistInMap(_player, CORPSE_RECLAIM_RADIUS, true))
429  return;
430 
431  // resurrect
432  _player->ResurrectPlayer(_player->InBattleground() ? 1.0f : 0.5f);
433 
434  // spawn bones
435  _player->SpawnCorpseBones();
436 }
Definition: Corpse.h:31
Definition: Corpse.h:49
Definition: Player.h:521
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
CorpseType GetType() const
Definition: Corpse.h:71
time_t const & GetGhostTime() const
Definition: Corpse.h:69
Player * _player
Definition: WorldSession.h:1797
Definition: UpdateFields.h:191
#define CORPSE_RECLAIM_RADIUS
Definition: Corpse.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRemoveGlyph ( WorldPacket recvData)
1479 {
1480  uint32 slot;
1481  recvData >> slot;
1482 
1483  if (slot >= MAX_GLYPH_SLOT_INDEX)
1484  {
1485  TC_LOG_DEBUG("network", "Client sent wrong glyph slot number in opcode CMSG_REMOVE_GLYPH %u", slot);
1486  return;
1487  }
1488 
1489  if (uint32 glyph = _player->GetGlyph(_player->GetActiveTalentGroup(), slot))
1490  {
1491  if (GlyphPropertiesEntry const* gp = sGlyphPropertiesStore.LookupEntry(glyph))
1492  {
1493  _player->RemoveAurasDueToSpell(gp->SpellID);
1494  _player->SetGlyph(slot, 0);
1495  _player->SendTalentsInfoData();
1496  }
1497  }
1498 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define MAX_GLYPH_SLOT_INDEX
Definition: SharedDefines.h:854
uint32_t uint32
Definition: Define.h:150
DBCStorage< GlyphPropertiesEntry > sGlyphPropertiesStore(GlyphPropertiesfmt)
Definition: DBCStructure.h:509
Player * _player
Definition: WorldSession.h:1797
void WorldSession::HandleReorderCharacters ( WorldPackets::Character::ReorderCharacters reorderChars)
2277 {
2279 
2280  for (WorldPackets::Character::ReorderCharacters::ReorderInfo const& reorderInfo : reorderChars.Entries)
2281  {
2283  stmt->setUInt8(0, reorderInfo.NewPosition);
2284  stmt->setUInt64(1, reorderInfo.PlayerGUID.GetCounter());
2285  stmt->setUInt32(2, GetAccountId());
2286  trans->Append(stmt);
2287  }
2288 
2290 }
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Array< ReorderInfo > Entries
Definition: CharacterPackets.h:360
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint8 NewPosition
Definition: CharacterPackets.h:353
Definition: CharacterDatabase.h:501
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
ObjectGuid PlayerGUID
Definition: CharacterPackets.h:352
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRepairItemOpcode ( WorldPackets::Item::RepairItem packet)
838 {
839  TC_LOG_DEBUG("network", "WORLD: CMSG_REPAIR_ITEM: Npc %s, Item %s, UseGuildBank: %u",
840  packet.NpcGUID.ToString().c_str(), packet.ItemGUID.ToString().c_str(), packet.UseGuildBank);
841 
842  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.NpcGUID, UNIT_NPC_FLAG_REPAIR);
843  if (!unit)
844  {
845  TC_LOG_DEBUG("network", "WORLD: HandleRepairItemOpcode - %s not found or you can not interact with him.", packet.NpcGUID.ToString().c_str());
846  return;
847  }
848 
849  // remove fake death
850  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
851  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
852 
853  // reputation discount
854  float discountMod = _player->GetReputationPriceDiscount(unit);
855 
856  if (!packet.ItemGUID.IsEmpty())
857  {
858  TC_LOG_DEBUG("network", "ITEM: Repair %s, at %s", packet.ItemGUID.ToString().c_str(), packet.NpcGUID.ToString().c_str());
859 
860  Item* item = _player->GetItemByGuid(packet.ItemGUID);
861  if (item)
862  _player->DurabilityRepair(item->GetPos(), true, discountMod, packet.UseGuildBank);
863  }
864  else
865  {
866  TC_LOG_DEBUG("network", "ITEM: Repair all items at %s", packet.NpcGUID.ToString().c_str());
867  _player->DurabilityRepairAll(true, discountMod, packet.UseGuildBank);
868  }
869 }
ObjectGuid NpcGUID
Definition: ItemPackets.h:189
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid ItemGUID
Definition: ItemPackets.h:190
Definition: Item.h:259
Definition: SpellAuraDefines.h:126
bool UseGuildBank
Definition: ItemPackets.h:191
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
Definition: Unit.h:747
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleReplicateItems ( WorldPackets::AuctionHouse::AuctionReplicateItems packet)
647 {
648  //@todo implement this properly
650  response.ChangeNumberCursor = packet.ChangeNumberCursor;
651  response.ChangeNumberGlobal = packet.ChangeNumberGlobal;
653  response.DesiredDelay = 300;
654  response.Result = 0;
655  SendPacket(response.Write());
656 }
int32 ChangeNumberTombstone
Definition: AuctionHousePackets.h:193
Definition: AuctionHousePackets.h:337
uint32 ChangeNumberTombstone
Definition: AuctionHousePackets.h:347
uint32 ChangeNumberCursor
Definition: AuctionHousePackets.h:344
int32 ChangeNumberCursor
Definition: AuctionHousePackets.h:192
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:313
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 Result
Definition: AuctionHousePackets.h:348
int32 ChangeNumberGlobal
Definition: AuctionHousePackets.h:191
uint32 ChangeNumberGlobal
Definition: AuctionHousePackets.h:345
uint32 DesiredDelay
Definition: AuctionHousePackets.h:346

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRepopRequest ( WorldPackets::Misc::RepopRequest packet)
52 {
53  if (GetPlayer()->IsAlive() || GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
54  return;
55 
56  if (GetPlayer()->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
57  return; // silently return, client should display the error by itself
58 
59  // the world update order is sessions, players, creatures
60  // the netcode runs in parallel with all of these
61  // creatures can kill players
62  // so if the server is lagging enough the player can
63  // release spirit after he's killed but before he is updated
64  if (GetPlayer()->getDeathState() == JUST_DIED)
65  {
66  TC_LOG_DEBUG("network", "HandleRepopRequestOpcode: got request after player %s(%s) was killed and before he was updated",
67  GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
68  GetPlayer()->KillPlayer();
69  }
70 
71  //this is spirit release confirm?
72  GetPlayer()->RemovePet(NULL, PET_SAVE_NOT_IN_SLOT, true);
73  GetPlayer()->BuildPlayerRepop();
74  GetPlayer()->RepopAtGraveyard();
75 }
Definition: Player.h:521
Definition: Unit.h:542
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
string ToString(int i)
Definition: strutil.h:491
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
Definition: PetDefines.h:38
Definition: UpdateFields.h:191
Definition: SpellAuraDefines.h:374

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleReportPvPAFK ( WorldPackets::Battleground::ReportPvPPlayerAFK reportPvPPlayerAFK)
585 {
586  Player* reportedPlayer = ObjectAccessor::FindPlayer(reportPvPPlayerAFK.Offender);
587  if (!reportedPlayer)
588  {
589  TC_LOG_DEBUG("bg.battleground", "WorldSession::HandleReportPvPAFK: player not found");
590  return;
591  }
592 
593  TC_LOG_DEBUG("bg.battleground", "WorldSession::HandleReportPvPAFK: %s reported %s", _player->GetName().c_str(), reportedPlayer->GetName().c_str());
594 
595  reportedPlayer->ReportedAfkBy(_player);
596 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
ObjectGuid Offender
Definition: BattlegroundPackets.h:321
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestAccountData ( WorldPackets::ClientConfig::RequestAccountData request)
647 {
648  TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA: type %u", request.DataType);
649 
650  if (request.DataType >= NUM_ACCOUNT_DATA_TYPES)
651  return;
652 
653  AccountData const* adata = GetAccountData(AccountDataType(request.DataType));
654 
656  data.Player = _player ? _player->GetGUID() : ObjectGuid::Empty;
657  data.Time = adata->Time;
658  data.Size = adata->Data.size();
659  data.DataType = request.DataType;
660 
661  uLongf destSize = compressBound(data.Size);
662 
663  data.CompressedData.resize(destSize);
664 
665  if (data.Size && compress(data.CompressedData.contents(), &destSize, (uint8 const*)adata->Data.c_str(), data.Size) != Z_OK)
666  {
667  TC_LOG_ERROR("network", "RAD: Failed to compress account data");
668  return;
669  }
670 
671  data.CompressedData.resize(destSize);
672 
673  SendPacket(data.Write());
674 }
uint32 Time
UnixTime.
Definition: ClientConfigPackets.h:83
uint8 * contents()
Definition: ByteBuffer.h:573
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
WorldPacket const * Write() override
Definition: ClientConfigPackets.cpp:104
void resize(size_t newsize)
Definition: ByteBuffer.h:590
Definition: WorldSession.h:775
uint8 DataType
Definition: ClientConfigPackets.h:85
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
AccountData const * GetAccountData(AccountDataType type) const
Definition: WorldSession.h:998
uint32 Size
decompressed size
Definition: ClientConfigPackets.h:84
std::string Data
Definition: WorldSession.h:778
ObjectGuid Player
Definition: ClientConfigPackets.h:82
AccountDataType
Definition: WorldSession.h:723
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uLong FAR uLongf
Definition: zconf.h:382
time_t Time
Definition: WorldSession.h:777
Player * _player
Definition: WorldSession.h:1797
#define Z_OK
Definition: zlib.h:173
ByteBuffer CompressedData
Definition: ClientConfigPackets.h:86
uint8_t uint8
Definition: Define.h:152
Definition: ClientConfigPackets.h:75
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
#define NUM_ACCOUNT_DATA_TYPES
Definition: WorldSession.h:735
uint8 DataType
Definition: ClientConfigPackets.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestBattlefieldStatusOpcode ( WorldPackets::Battleground::RequestBattlefieldStatus requestBattlefieldStatus)
430 {
431  // we must update all queues here
432  Battleground* bg = NULL;
433  for (uint8 i = 0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
434  {
435  BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i);
436  if (!bgQueueTypeId)
437  continue;
438  BattlegroundTypeId bgTypeId = BattlegroundMgr::BGTemplateId(bgQueueTypeId);
439  uint8 arenaType = BattlegroundMgr::BGArenaType(bgQueueTypeId);
440  if (bgTypeId == _player->GetBattlegroundTypeId())
441  {
442  bg = _player->GetBattleground();
443  //i cannot check any variable from player class because player class doesn't know if player is in 2v2 / 3v3 or 5v5 arena
444  //so i must use bg pointer to get that information
445  if (bg && bg->GetArenaType() == arenaType)
446  {
448  sBattlegroundMgr->BuildBattlegroundStatusActive(&battlefieldStatus, bg, _player, i, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), arenaType);
449  SendPacket(battlefieldStatus.Write());
450  continue;
451  }
452  }
453 
454  //we are sending update to player about queue - he can be invited there!
455  //get GroupQueueInfo for queue status
456  BattlegroundQueue& bgQueue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
457  GroupQueueInfo ginfo;
458  if (!bgQueue.GetPlayerGroupInfoData(_player->GetGUID(), &ginfo))
459  continue;
460  if (ginfo.IsInvitedToBGInstanceGUID)
461  {
462  bg = sBattlegroundMgr->GetBattleground(ginfo.IsInvitedToBGInstanceGUID, bgTypeId);
463  if (!bg)
464  continue;
465 
466 
468  sBattlegroundMgr->BuildBattlegroundStatusNeedConfirmation(&battlefieldStatus, bg, _player, i, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), getMSTimeDiff(getMSTime(), ginfo.RemoveInviteTime), arenaType);
469  SendPacket(battlefieldStatus.Write());
470  }
471  else
472  {
473  bg = sBattlegroundMgr->GetBattlegroundTemplate(bgTypeId);
474  if (!bg)
475  continue;
476 
477  // expected bracket entry
478  PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), _player->getLevel());
479  if (!bracketEntry)
480  continue;
481 
482  uint32 avgTime = bgQueue.GetAverageQueueWaitTime(&ginfo, bracketEntry->GetBracketId());
484  sBattlegroundMgr->BuildBattlegroundStatusQueued(&battlefieldStatus, bg, _player, i, _player->GetBattlegroundQueueJoinTime(bgQueueTypeId), avgTime, arenaType, ginfo.Players.size() > 1);
485  SendPacket(battlefieldStatus.Write());
486  }
487  }
488 }
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:165
BattlegroundTypeId
Definition: SharedDefines.h:4558
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:177
uint32 getMSTimeDiff(uint32 oldMSTime, uint32 newMSTime)
Definition: Timer.h:33
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:209
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:156
uint32 getMSTime()
Definition: Timer.h:24
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: BattlegroundPackets.h:185
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
Definition: BattlegroundQueue.cpp:414
uint8 GetArenaType() const
Definition: Battleground.h:281
uint32 GetAverageQueueWaitTime(GroupQueueInfo *ginfo, BattlegroundBracketId bracket_id) const
Definition: BattlegroundQueue.cpp:261
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:760
static BattlegroundTypeId BGTemplateId(BattlegroundQueueTypeId bgQueueTypeId)
Definition: BattlegroundMgr.cpp:667
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: BattlegroundQueue.h:41
Definition: BattlegroundQueue.h:75
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Player * _player
Definition: WorldSession.h:1797
Definition: DBCStructure.h:926
BattlegroundBracketId GetBracketId() const
Definition: DBCStructure.h:935
Definition: BattlegroundPackets.h:170
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
uint8_t uint8
Definition: Define.h:152
uint32 GetMapId() const
Definition: Battleground.h:352
Definition: Battleground.h:235
static uint8 BGArenaType(BattlegroundQueueTypeId bgQueueTypeId)
Definition: BattlegroundMgr.cpp:698
uint32 RemoveInviteTime
Definition: BattlegroundQueue.h:50
std::map< ObjectGuid, PlayerQueueInfo * > Players
Definition: BattlegroundQueue.h:43
uint32 IsInvitedToBGInstanceGUID
Definition: BattlegroundQueue.h:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestCategoryCooldowns ( WorldPackets::Spells::RequestCategoryCooldowns requestCategoryCooldowns)
608 {
609  _player->SendSpellCategoryCooldowns();
610 }
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleRequestCemeteryList ( WorldPackets::Misc::RequestCemeteryList packet)
367 {
368  uint32 zoneId = _player->GetZoneId();
369  uint32 team = _player->GetTeam();
370 
371  std::vector<uint32> graveyardIds;
372  auto range = sObjectMgr->GraveYardStore.equal_range(zoneId);
373 
374  for (auto it = range.first; it != range.second && graveyardIds.size() < 16; ++it) // client max
375  {
376  if (it->second.team == 0 || it->second.team == team)
377  graveyardIds.push_back(it->first);
378  }
379 
380  if (graveyardIds.empty())
381  {
382  TC_LOG_DEBUG("network", "No graveyards found for zone %u for %s (team %u) in CMSG_REQUEST_CEMETERY_LIST",
383  zoneId, _player->GetGUID().ToString().c_str(), team);
384  return;
385  }
386 
388  packet.IsGossipTriggered = false;
389  packet.CemeteryID.reserve(graveyardIds.size());
390 
391  for (uint32 id : graveyardIds)
392  packet.CemeteryID.push_back(id);
393 
394  SendPacket(packet.Write());
395 }
WorldPacket const * Write() override
Definition: MiscPackets.cpp:245
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
bool IsGossipTriggered
Definition: MiscPackets.h:377
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
std::vector< uint32 > CemeteryID
Definition: MiscPackets.h:378

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestForcedReactionsOpcode ( WorldPackets::Reputation::RequestForcedReactions requestForcedReactions)
1240 {
1241  _player->GetReputationMgr().SendForceReactions();
1242 }
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleRequestGuildRewardsList ( WorldPackets::Guild::RequestGuildRewardsList packet)
380 {
381  if (sGuildMgr->GetGuildById(_player->GetGuildId()))
382  {
383  std::vector<GuildReward> const& rewards = sGuildMgr->GetGuildRewards();
384 
386  rewardList.Version = uint32(time(NULL));
387  rewardList.RewardItems.reserve(rewards.size());
388 
389  for (uint32 i = 0; i < rewards.size(); i++)
390  {
392  rewardItem.ItemID = rewards[i].ItemID;
393  rewardItem.RaceMask = rewards[i].RaceMask;
394  rewardItem.MinGuildLevel = 0;
395  rewardItem.MinGuildRep = rewards[i].MinGuildRep;
396  rewardItem.AchievementsRequired = rewards[i].AchievementsRequired;
397  rewardItem.Cost = rewards[i].Cost;
398  rewardList.RewardItems.push_back(rewardItem);
399  }
400 
401  SendPacket(rewardList.Write());
402  }
403 }
uint32 ItemID
Definition: GuildPackets.h:673
std::vector< uint32 > AchievementsRequired
Definition: GuildPackets.h:675
#define sGuildMgr
Definition: GuildMgr.h:61
arena_t NULL
Definition: jemalloc_internal.h:624
std::vector< GuildRewardItem > RewardItems
Definition: GuildPackets.h:689
int32 MinGuildRep
Definition: GuildPackets.h:678
uint32 Version
Definition: GuildPackets.h:690
Definition: GuildPackets.h:671
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: GuildPackets.h:682
int32 MinGuildLevel
Definition: GuildPackets.h:677
Player * _player
Definition: WorldSession.h:1797
uint64 Cost
Definition: GuildPackets.h:679
uint32 RaceMask
Definition: GuildPackets.h:676
WorldPacket const * Write() override
Definition: GuildPackets.cpp:533
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestHonorStatsOpcode ( WorldPackets::Inspect::RequestHonorStats request)
Todo:
81 {
82  Player* player = ObjectAccessor::FindPlayer(request.TargetGUID);
83  if (!player)
84  {
85  TC_LOG_DEBUG("network", "WorldSession::HandleRequestHonorStatsOpcode: Target %s not found.", request.TargetGUID.ToString().c_str());
86  return;
87  }
88 
89  TC_LOG_DEBUG("network", "WorldSession::HandleRequestHonorStatsOpcode: Target %s.", request.TargetGUID.ToString().c_str());
90 
91  if (!GetPlayer()->IsWithinDistInMap(player, INSPECT_DISTANCE, false))
92  return;
93 
94  if (GetPlayer()->IsValidAttackTarget(player))
95  return;
96 
98  honorStats.PlayerGUID = request.TargetGUID;
99  honorStats.LifetimeHK = player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS);
100  honorStats.YesterdayHK = player->GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_YESTERDAY_KILLS);
101  honorStats.TodayHK = player->GetUInt16Value(PLAYER_FIELD_KILLS, PLAYER_FIELD_KILLS_OFFSET_TODAY_KILLS);
102  honorStats.LifetimeMaxRank = 0;
103 
104  SendPacket(honorStats.Write());
105 }
Definition: UpdateFields.h:272
WorldPacket const * Write() override
Definition: InspectPackets.cpp:109
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 LifetimeMaxRank
Definition: InspectPackets.h:104
uint16 TodayHK
Definition: InspectPackets.h:103
ObjectGuid PlayerGUID
Definition: InspectPackets.h:100
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
#define INSPECT_DISTANCE
Definition: Object.h:36
Definition: InspectPackets.h:93
uint16 YesterdayHK
Definition: InspectPackets.h:102
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: UpdateFields.h:273
ObjectGuid TargetGUID
Definition: InspectPackets.h:90
uint32 LifetimeHK
Definition: InspectPackets.h:101
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestPartyJoinUpdates ( WorldPackets::Party::RequestPartyJoinUpdates packet)
473 {
474  Group* group = GetPlayer()->GetGroup();
475  if (!group)
476  return;
477 
478  group->SendTargetIconList(this, packet.PartyIndex);
479  group->SendRaidMarkersChanged(this, packet.PartyIndex);
480 }
int8 PartyIndex
Definition: PartyPackets.h:350
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendRaidMarkersChanged(WorldSession *session=nullptr, int8 partyIndex=0)
Definition: Group.cpp:2482
void SendTargetIconList(WorldSession *session, int8 partyIndex=0)
Definition: Group.cpp:1554
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestPartyMemberStatsOpcode ( WorldPackets::Party::RequestPartyMemberStats packet)
579 {
580  WorldPackets::Party::PartyMemberStats partyMemberStats;
581 
583  if (!player)
584  {
585  partyMemberStats.MemberStats.GUID = packet.TargetGUID;
586  partyMemberStats.MemberStats.Status = MEMBER_STATUS_OFFLINE;
587  }
588  else
589  partyMemberStats.Initialize(player);
590 
591  SendPacket(partyMemberStats.Write());
592 }
WorldPacket const * Write() override
Definition: PartyPackets.cpp:149
void Initialize(Player const *player)
Definition: PartyPackets.cpp:412
Definition: Group.h:63
GroupMemberStats MemberStats
Definition: PartyPackets.h:209
ObjectGuid GUID
Definition: PartyPackets.h:172
int16 Status
Definition: PartyPackets.h:174
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: PartyPackets.h:201
ObjectGuid TargetGUID
Definition: PartyPackets.h:134
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestPetInfo ( WorldPackets::Pet::RequestPetInfo packet)
60 {
61 }

+ Here is the caller graph for this function:

void WorldSession::HandleRequestPvpReward ( WorldPackets::Battleground::RequestPVPRewards packet)
639 {
640  _player->SendPvpRewards();
641 }
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleRequestRaidInfoOpcode ( WorldPackets::Party::RequestRaidInfo packet)
595 {
596  // every time the player checks the character screen
597  _player->SendRaidInfo();
598 }
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleRequestRatedBattlefieldInfo ( WorldPackets::Battleground::RequestRatedBattlefieldInfo packet)

: perfome research in this case The unk fields are related to arenas

599 {
603  data << uint32(0); // BgWeeklyWins20vs20
604  data << uint32(0); // BgWeeklyPlayed20vs20
605  data << uint32(0); // BgWeeklyPlayed15vs15
606  data << uint32(0);
607  data << uint32(0); // BgWeeklyWins10vs10
608  data << uint32(0);
609  data << uint32(0);
610  data << uint32(0);
611  data << uint32(0); // BgWeeklyWins15vs15
612  data << uint32(0);
613  data << uint32(0);
614  data << uint32(0);
615  data << uint32(0);
616  data << uint32(0);
617  data << uint32(0);
618  data << uint32(0); // BgWeeklyPlayed10vs10
619  data << uint32(0);
620  data << uint32(0);
621 
622  SendPacket(&data);
623 }
Definition: Opcodes.h:1431
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestStabledPets ( WorldPackets::NPC::RequestStabledPets packet)
468 {
469  if (!CheckStableMaster(packet.StableMaster))
470  return;
471 
472  // remove fake death
473  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
474  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
475 
476  // remove mounts this fix bug where getting pet from stable while mounted deletes pet.
477  if (GetPlayer()->IsMounted())
478  GetPlayer()->RemoveAurasByType(SPELL_AURA_MOUNTED);
479 
480  SendStablePet(packet.StableMaster);
481 }
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid StableMaster
Definition: NPCPackets.h:251
void SendStablePet(ObjectGuid guid)
Definition: NPCHandler.cpp:483
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550
bool CheckStableMaster(ObjectGuid guid)
Definition: PetHandler.cpp:434
Definition: SpellAuraDefines.h:138

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestVehicleExit ( WorldPackets::Vehicle::RequestVehicleExit requestVehicleExit)
174 {
175  if (Vehicle* vehicle = GetPlayer()->GetVehicle())
176  {
177  if (VehicleSeatEntry const* seat = vehicle->GetSeatForPassenger(GetPlayer()))
178  {
179  if (seat->CanEnterOrExit())
180  GetPlayer()->ExitVehicle();
181  else
182  TC_LOG_ERROR("network", "%s tried to exit vehicle, but seatflags %u (ID: %u) don't permit that.",
183  GetPlayer()->GetGUID().ToString().c_str(), seat->ID, seat->Flags);
184  }
185  }
186 }
Definition: DBCStructure.h:1305
Definition: Vehicle.h:32
Player * GetPlayer() const
Definition: WorldSession.h:927
string ToString(int i)
Definition: strutil.h:491
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestVehicleNextSeat ( WorldPackets::Vehicle::RequestVehicleNextSeat requestVehicleNextSeat)
56 {
57  Unit* vehicle_base = GetPlayer()->GetVehicleBase();
58  if (!vehicle_base)
59  return;
60 
61  VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer());
62  if (!seat->CanSwitchFromSeat())
63  {
64  TC_LOG_ERROR("network", "HandleRequestVehicleNextSeat: %s tried to switch seats but current seatflags %u don't permit that.",
65  GetPlayer()->GetGUID().ToString().c_str(), seat->Flags);
66  return;
67  }
68 
69  GetPlayer()->ChangeSeat(-1, true);
70 }
Definition: DBCStructure.h:1305
Player * GetPlayer() const
Definition: WorldSession.h:927
bool CanSwitchFromSeat() const
Definition: DBCStructure.h:1376
string ToString(int i)
Definition: strutil.h:491
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 Flags
Definition: DBCStructure.h:1308
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestVehiclePrevSeat ( WorldPackets::Vehicle::RequestVehiclePrevSeat requestVehiclePrevSeat)
39 {
40  Unit* vehicle_base = GetPlayer()->GetVehicleBase();
41  if (!vehicle_base)
42  return;
43 
44  VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer());
45  if (!seat->CanSwitchFromSeat())
46  {
47  TC_LOG_ERROR("network", "HandleRequestVehiclePrevSeat: %s tried to switch seats but current seatflags %u don't permit that.",
48  GetPlayer()->GetGUID().ToString().c_str(), seat->Flags);
49  return;
50  }
51 
52  GetPlayer()->ChangeSeat(-1, false);
53 }
Definition: DBCStructure.h:1305
Player * GetPlayer() const
Definition: WorldSession.h:927
bool CanSwitchFromSeat() const
Definition: DBCStructure.h:1376
string ToString(int i)
Definition: strutil.h:491
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 Flags
Definition: DBCStructure.h:1308
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestVehicleSwitchSeat ( WorldPackets::Vehicle::RequestVehicleSwitchSeat requestVehicleSwitchSeat)
102 {
103  Unit* vehicle_base = GetPlayer()->GetVehicleBase();
104  if (!vehicle_base)
105  return;
106 
107  VehicleSeatEntry const* seat = GetPlayer()->GetVehicle()->GetSeatForPassenger(GetPlayer());
108  if (!seat->CanSwitchFromSeat())
109  {
110  TC_LOG_ERROR("network", "HandleRequestVehicleSwitchSeat: %s tried to switch seats but current seatflags %u don't permit that.",
111  GetPlayer()->GetGUID().ToString().c_str(), seat->Flags);
112  return;
113  }
114 
115  if (vehicle_base->GetGUID() == requestVehicleSwitchSeat.Vehicle)
116  GetPlayer()->ChangeSeat(int8(requestVehicleSwitchSeat.SeatIndex));
117  else if (Unit* vehUnit = ObjectAccessor::GetUnit(*GetPlayer(), requestVehicleSwitchSeat.Vehicle))
118  if (Vehicle* vehicle = vehUnit->GetVehicleKit())
119  if (vehicle->HasEmptySeat(int8(requestVehicleSwitchSeat.SeatIndex)))
120  vehUnit->HandleSpellClick(GetPlayer(), int8(requestVehicleSwitchSeat.SeatIndex));
121 }
Definition: DBCStructure.h:1305
Definition: Vehicle.h:32
int8_t int8
Definition: Define.h:148
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
uint8 SeatIndex
Definition: VehiclePackets.h:116
int8_t int8
Definition: g3dmath.h:163
Player * GetPlayer() const
Definition: WorldSession.h:927
bool CanSwitchFromSeat() const
Definition: DBCStructure.h:1376
string ToString(int i)
Definition: strutil.h:491
ObjectGuid Vehicle
Definition: VehiclePackets.h:115
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 Flags
Definition: DBCStructure.h:1308
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRequestWowTokenMarketPrice ( WorldPackets::Token::RequestWowTokenMarketPrice requestWowTokenMarketPrice)
Todo:
: 6.x fix implementation
33 {
35 
37  response.CurrentMarketPrice = 300000000;
38  response.UnkInt = requestWowTokenMarketPrice.UnkInt;
39  response.Result = TOKEN_RESULT_SUCCESS;
40  //packet.ReadUInt32("UnkInt32");
41 
42  SendPacket(response.Write());
43 }
uint32 UnkInt
Definition: TokenPackets.h:76
WorldPacket const * Write() override
Definition: TokenPackets.cpp:47
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint64 CurrentMarketPrice
Definition: TokenPackets.h:75
uint32 UnkInt
Definition: TokenPackets.h:65
Definition: SharedDefines.h:4886
uint32 Result
Definition: TokenPackets.h:77

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleResetInstancesOpcode ( WorldPackets::Instance::ResetInstances packet)
845 {
846  if (Group* group = _player->GetGroup())
847  {
848  if (group->IsLeader(_player->GetGUID()))
849  group->ResetInstances(INSTANCE_RESET_ALL, false, false, _player);
850  }
851  else
852  _player->ResetInstances(INSTANCE_RESET_ALL, false, false);
853 }
Definition: Map.h:750
Player * _player
Definition: WorldSession.h:1797
Definition: Group.h:191

+ Here is the caller graph for this function:

void WorldSession::HandleResurrectResponse ( WorldPackets::Misc::ResurrectResponse packet)
439 {
440  if (GetPlayer()->IsAlive())
441  return;
442 
443  if (packet.Response != 0) // Accept = 0 Decline = 1 Timeout = 2
444  {
445  GetPlayer()->ClearResurrectRequestData(); // reject
446  return;
447  }
448 
449  if (!GetPlayer()->IsResurrectRequestedBy(packet.Resurrecter))
450  return;
451 
452  GetPlayer()->ResurrectUsingRequestData();
453 }
uint32 Response
Definition: MiscPackets.h:389
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid Resurrecter
Definition: MiscPackets.h:388

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleRideVehicleInteract ( WorldPackets::Vehicle::RideVehicleInteract rideVehicleInteract)
124 {
125  if (Player* player = ObjectAccessor::FindPlayer(rideVehicleInteract.Vehicle))
126  {
127  if (!player->GetVehicleKit())
128  return;
129  if (!player->IsInRaidWith(_player))
130  return;
131  if (!player->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
132  return;
133 
134  _player->EnterVehicle(player);
135  }
136 }
#define INTERACTION_DISTANCE
Definition: Object.h:34
ObjectGuid Vehicle
Definition: VehiclePackets.h:126
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSaveCUFProfiles ( WorldPackets::Misc::SaveCUFProfiles packet)
1088 {
1089  if (packet.CUFProfiles.size() > MAX_CUF_PROFILES)
1090  {
1091  TC_LOG_ERROR("entities.player", "HandleSaveCUFProfiles - %s tried to save more than %i CUF profiles. Hacking attempt?", GetPlayerName().c_str(), MAX_CUF_PROFILES);
1092  return;
1093  }
1094 
1095  for (uint8 i = 0; i < packet.CUFProfiles.size(); ++i)
1096  GetPlayer()->SaveCUFProfile(i, std::move(packet.CUFProfiles[i]));
1097 
1098  for (uint8 i = packet.CUFProfiles.size(); i < MAX_CUF_PROFILES; ++i)
1099  GetPlayer()->SaveCUFProfile(i, nullptr);
1100 }
#define MAX_CUF_PROFILES
Maximum number of CompactUnitFrames profiles.
Definition: Player.h:202
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
Player * GetPlayer() const
Definition: WorldSession.h:927
std::vector< std::unique_ptr< CUFProfile > > CUFProfiles
Definition: MiscPackets.h:656
uint8_t uint8
Definition: Define.h:152
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSaveGuildEmblem ( WorldPackets::Guild::SaveGuildEmblem packet)
177 {
178  EmblemInfo emblemInfo;
179  emblemInfo.ReadPacket(packet);
180 
181  TC_LOG_DEBUG("guild", "CMSG_SAVE_GUILD_EMBLEM [%s]: Guid: [%s] Style: %d, Color: %d, BorderStyle: %d, BorderColor: %d, BackgroundColor: %d"
182  , GetPlayerInfo().c_str(), packet.Vendor.ToString().c_str(), emblemInfo.GetStyle()
183  , emblemInfo.GetColor(), emblemInfo.GetBorderStyle()
184  , emblemInfo.GetBorderColor(), emblemInfo.GetBackgroundColor());
185 
186  if (GetPlayer()->GetNPCIfCanInteractWith(packet.Vendor, UNIT_NPC_FLAG_TABARDDESIGNER))
187  {
188  // Remove fake death
189  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
190  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
191 
192  if (!emblemInfo.ValidateEmblemColors())
193  {
195  return;
196  }
197 
198  if (Guild* guild = GetPlayer()->GetGuild())
199  guild->HandleSetEmblem(this, emblemInfo);
200  else
201  Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_NOGUILD); // "You are not part of a guild!";
202  }
203  else
204  Guild::SendSaveEmblemResult(this, ERR_GUILDEMBLEM_INVALIDVENDOR); // "That's not an emblem vendor!"
205 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Guild.h:217
uint32 GetBorderColor() const
Definition: Guild.h:277
uint32 GetBorderStyle() const
Definition: Guild.h:276
ObjectGuid Vendor
Definition: GuildPackets.h:992
static void SendSaveEmblemResult(WorldSession *session, GuildEmblemError errCode)
Definition: Guild.cpp:65
uint32 GetColor() const
Definition: Guild.h:275
Definition: SpellAuraDefines.h:126
uint32 GetStyle() const
Definition: Guild.h:274
Definition: Unit.h:754
Definition: Unit.h:550
void ReadPacket(WorldPackets::Guild::SaveGuildEmblem &packet)
Definition: Guild.cpp:673
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
bool ValidateEmblemColors()
Definition: Guild.cpp:682
Definition: Guild.h:220
uint32 GetBackgroundColor() const
Definition: Guild.h:278
Definition: Guild.h:320
Definition: Guild.h:264
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleScenePlaybackCanceled ( WorldPackets::Scenes::ScenePlaybackCanceled scenePlaybackCanceled)
34 {
35  TC_LOG_DEBUG("scenes", "HandleScenePlaybackCanceled: SceneInstanceID: %u", scenePlaybackCanceled.SceneInstanceID);
36 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 SceneInstanceID
Definition: ScenePackets.h:71

+ Here is the caller graph for this function:

void WorldSession::HandleScenePlaybackComplete ( WorldPackets::Scenes::ScenePlaybackComplete scenePlaybackComplete)
28 {
29 
30  TC_LOG_DEBUG("scenes", "HandleScenePlaybackComplete: SceneInstanceID: %u", scenePlaybackComplete.SceneInstanceID);
31 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 SceneInstanceID
Definition: ScenePackets.h:61

+ Here is the caller graph for this function:

void WorldSession::HandleSceneTriggerEvent ( WorldPackets::Scenes::SceneTriggerEvent sceneTriggerEvent)
23 {
24  TC_LOG_DEBUG("scenes", "HandleSceneTriggerEvent: SceneInstanceID: %u Event: %s", sceneTriggerEvent.SceneInstanceID, sceneTriggerEvent._Event.c_str());
25 }
uint32 SceneInstanceID
Definition: ScenePackets.h:50
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string _Event
Definition: ScenePackets.h:51

+ Here is the caller graph for this function:

void WorldSession::HandleSelfResOpcode ( WorldPackets::Spells::SelfRes packet)
451 {
452  if (_player->HasAuraType(SPELL_AURA_PREVENT_RESURRECTION))
453  return; // silent return, client should display error by itself and not send this opcode
454 
455  if (_player->GetUInt32Value(PLAYER_SELF_RES_SPELL))
456  {
457  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(_player->GetUInt32Value(PLAYER_SELF_RES_SPELL));
458  if (spellInfo)
459  _player->CastSpell(_player, spellInfo, false, nullptr);
460 
461  _player->SetUInt32Value(PLAYER_SELF_RES_SPELL, 0);
462  }
463 }
Definition: SpellInfo.h:326
Definition: UpdateFields.h:268
#define sSpellMgr
Definition: SpellMgr.h:756
Player * _player
Definition: WorldSession.h:1797
Definition: SpellAuraDefines.h:374

+ Here is the caller graph for this function:

void WorldSession::HandleSellItemOpcode ( WorldPackets::Item::SellItem packet)
343 {
344  TC_LOG_DEBUG("network", "WORLD: Received CMSG_SELL_ITEM: Vendor %s, Item %s, Amount: %u",
345  packet.VendorGUID.ToString().c_str(), packet.ItemGUID.ToString().c_str(), packet.Amount);
346 
347  if (packet.ItemGUID.IsEmpty())
348  return;
349 
350  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(packet.VendorGUID, UNIT_NPC_FLAG_VENDOR);
351  if (!creature)
352  {
353  TC_LOG_DEBUG("network", "WORLD: HandleSellItemOpcode - %s not found or you can not interact with him.", packet.VendorGUID.ToString().c_str());
354  _player->SendSellError(SELL_ERR_CANT_FIND_VENDOR, nullptr, packet.ItemGUID);
355  return;
356  }
357 
358  // remove fake death
359  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
360  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
361 
362  Item* pItem = _player->GetItemByGuid(packet.ItemGUID);
363  if (pItem)
364  {
365  // prevent sell not owner item
366  if (_player->GetGUID() != pItem->GetOwnerGUID())
367  {
368  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
369  return;
370  }
371 
372  // prevent sell non empty bag by drag-and-drop at vendor's item list
373  if (pItem->IsNotEmptyBag())
374  {
375  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
376  return;
377  }
378 
379  // prevent sell currently looted item
380  if (_player->GetLootGUID() == pItem->GetGUID())
381  {
382  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
383  return;
384  }
385 
386  // prevent selling item for sellprice when the item is still refundable
387  // this probably happens when right clicking a refundable item, the client sends both
388  // CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified)
390  return; // Therefore, no feedback to client
391 
392  // special case at auto sell (sell all)
393  if (packet.Amount == 0)
394  packet.Amount = pItem->GetCount();
395  else
396  {
397  // prevent sell more items that exist in stack (possible only not from client)
398  if (packet.Amount > pItem->GetCount())
399  {
400  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
401  return;
402  }
403  }
404 
405  ItemTemplate const* pProto = pItem->GetTemplate();
406  if (pProto)
407  {
408  if (pProto->GetSellPrice() > 0)
409  {
410  if (packet.Amount < pItem->GetCount()) // need split items
411  {
412  Item* pNewItem = pItem->CloneItem(packet.Amount, _player);
413  if (!pNewItem)
414  {
415  TC_LOG_ERROR("network", "WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), packet.Amount);
416  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
417  return;
418  }
419 
420  pItem->SetCount(pItem->GetCount() - packet.Amount);
421  _player->ItemRemovedQuestCheck(pItem->GetEntry(), packet.Amount);
422  if (_player->IsInWorld())
423  pItem->SendUpdateToPlayer(_player);
424  pItem->SetState(ITEM_CHANGED, _player);
425 
426  _player->AddItemToBuyBackSlot(pNewItem);
427  if (_player->IsInWorld())
428  pNewItem->SendUpdateToPlayer(_player);
429  }
430  else
431  {
432  _player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
433  _player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
435  _player->AddItemToBuyBackSlot(pItem);
436  }
437 
438  uint32 money = pProto->GetSellPrice() * packet.Amount;
439  _player->ModifyMoney(money);
440  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_MONEY_FROM_VENDORS, money);
441  }
442  else
443  _player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, packet.ItemGUID);
444  return;
445  }
446  }
447  _player->SendSellError(SELL_ERR_CANT_FIND_ITEM, creature, packet.ItemGUID);
448  return;
449 }
uint32 GetCount() const
Definition: Item.h:322
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
uint32 Amount
Definition: ItemPackets.h:203
Definition: Item.h:165
Item * CloneItem(uint32 count, Player const *player=NULL) const
Definition: Item.cpp:1095
Definition: Unit.h:742
Definition: UpdateFields.h:49
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
void SetCount(uint32 value)
Definition: Item.cpp:794
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsNotEmptyBag() const
Definition: Item.cpp:286
ObjectGuid ItemGUID
Definition: ItemPackets.h:202
ObjectGuid VendorGUID
Definition: ItemPackets.h:201
uint32 GetSellPrice() const
Definition: ItemTemplate.h:663
Definition: Item.h:259
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
void RemoveFromUpdateQueueOf(Player *player)
Definition: Item.cpp:738
ObjectGuid GetOwnerGUID() const
Definition: Item.h:272
uint8 GetSlot() const
Definition: Item.h:329
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Definition: ItemTemplate.h:647
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
Definition: ItemTemplate.h:147
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Item.h:164
Definition: Item.h:163
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
uint8 GetBagSlot() const
Definition: Item.cpp:759
void SendUpdateToPlayer(Player *player)
Definition: Object.cpp:251
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsEmpty() const
Definition: ObjectGuid.h:242
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSendMail ( WorldPackets::Mail::SendMail packet)
62 {
63  if (packet.Info.Attachments.size() > MAX_MAIL_ITEMS) // client limit
64  {
65  GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_TOO_MANY_ATTACHMENTS);
66  return;
67  }
68 
69  if (!CanOpenMailBox(packet.Info.Mailbox))
70  return;
71 
72  if (packet.Info.Target.empty())
73  return;
74 
75  Player* player = _player;
76 
77  if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
78  {
80  return;
81  }
82 
83  ObjectGuid receiverGuid;
84  if (normalizePlayerName(packet.Info.Target))
85  receiverGuid = ObjectMgr::GetPlayerGUIDByName(packet.Info.Target);
86 
87  if (!receiverGuid)
88  {
89  TC_LOG_INFO("network", "Player %s is sending mail to %s (GUID: not existed!) with subject %s "
90  "and body %s includes " SZFMTD " items, " SI64FMTD " copper and " SI64FMTD " COD copper with StationeryID = %d",
91  GetPlayerInfo().c_str(), packet.Info.Target.c_str(), packet.Info.Subject.c_str(), packet.Info.Body.c_str(),
92  packet.Info.Attachments.size(), packet.Info.SendMoney, packet.Info.Cod, packet.Info.StationeryID);
93  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_NOT_FOUND);
94  return;
95  }
96 
97  if (packet.Info.SendMoney < 0)
98  {
99  GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_INTERNAL_ERROR);
100  TC_LOG_WARN("cheat", "Player %s attempted to send mail to %s (%s) with negative money value (SendMoney: " SI64FMTD ")",
101  GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.SendMoney);
102  return;
103  }
104 
105  if (packet.Info.Cod < 0)
106  {
107  GetPlayer()->SendMailResult(0, MAIL_SEND, MAIL_ERR_INTERNAL_ERROR);
108  TC_LOG_WARN("cheat", "Player %s attempted to send mail to %s (%s) with negative COD value (Cod: " SI64FMTD ")",
109  GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.Cod);
110  return;
111  }
112 
113  TC_LOG_INFO("network", "Player %s is sending mail to %s (%s) with subject %s and body %s "
114  "includes " SZFMTD " items, " SI64FMTD " copper and " SI64FMTD " COD copper with StationeryID = %d",
115  GetPlayerInfo().c_str(), packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), packet.Info.Subject.c_str(),
116  packet.Info.Body.c_str(), packet.Info.Attachments.size(), packet.Info.SendMoney, packet.Info.Cod, packet.Info.StationeryID);
117 
118  if (player->GetGUID() == receiverGuid)
119  {
120  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANNOT_SEND_TO_SELF);
121  return;
122  }
123 
124  uint32 cost = !packet.Info.Attachments.empty() ? 30 * packet.Info.Attachments.size() : 30; // price hardcoded in client
125 
126  int64 reqmoney = cost + packet.Info.SendMoney;
127 
128  // Check for overflow
129  if (reqmoney < packet.Info.SendMoney)
130  {
131  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
132  return;
133  }
134 
135  if (!player->HasEnoughMoney(reqmoney) && !player->IsGameMaster())
136  {
137  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_ENOUGH_MONEY);
138  return;
139  }
140 
141  Player* receiver = ObjectAccessor::FindConnectedPlayer(receiverGuid);
142 
143  uint32 receiverTeam = 0;
144  uint8 mailsCount = 0; //do not allow to send to one player more than 100 mails
145  uint8 receiverLevel = 0;
146  uint32 receiverAccountId = 0;
147  uint32 receiverBnetAccountId = 0;
148 
149  if (receiver)
150  {
151  receiverTeam = receiver->GetTeam();
152  mailsCount = receiver->GetMailSize();
153  receiverLevel = receiver->getLevel();
154  receiverAccountId = receiver->GetSession()->GetAccountId();
155  receiverBnetAccountId = receiver->GetSession()->GetBattlenetAccountId();
156  }
157  else
158  {
159  receiverTeam = ObjectMgr::GetPlayerTeamByGUID(receiverGuid);
160 
162  stmt->setUInt64(0, receiverGuid.GetCounter());
163 
165  if (result)
166  {
167  Field* fields = result->Fetch();
168  mailsCount = fields[0].GetUInt64();
169  }
170 
172  stmt->setUInt64(0, receiverGuid.GetCounter());
173 
174  result = CharacterDatabase.Query(stmt);
175  if (result)
176  {
177  Field* fields = result->Fetch();
178  receiverLevel = fields[0].GetUInt8();
179  }
180 
181  receiverAccountId = ObjectMgr::GetPlayerAccountIdByGUID(receiverGuid);
182  receiverBnetAccountId = Battlenet::AccountMgr::GetIdByGameAccount(receiverAccountId);
183  }
184 
185  // do not allow to have more than 100 mails in mailbox.. mails count is in opcode uint8!!! - so max can be 255..
186  if (mailsCount > 100)
187  {
188  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_RECIPIENT_CAP_REACHED);
189  return;
190  }
191 
192  // test the receiver's Faction... or all items are account bound
193  bool accountBound = !packet.Info.Attachments.empty();
194  for (auto const& att : packet.Info.Attachments)
195  {
196  if (Item* item = player->GetItemByGuid(att.ItemGUID))
197  {
198  ItemTemplate const* itemProto = item->GetTemplate();
199  if (!itemProto || !(itemProto->GetFlags() & ITEM_FLAG_BIND_TO_ACCOUNT))
200  {
201  accountBound = false;
202  break;
203  }
204  }
205  }
206 
207  if (!accountBound && player->GetTeam() != receiverTeam && !HasPermission(rbac::RBAC_PERM_TWO_SIDE_INTERACTION_MAIL))
208  {
209  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_NOT_YOUR_TEAM);
210  return;
211  }
212 
213  if (receiverLevel < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ))
214  {
216  return;
217  }
218 
219  std::vector<Item*> items;
220 
221  for (auto const& att : packet.Info.Attachments)
222  {
223  if (att.ItemGUID.IsEmpty())
224  {
225  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
226  return;
227  }
228 
229  Item* item = player->GetItemByGuid(att.ItemGUID);
230 
231  // prevent sending bag with items (cheat: can be placed in bag after adding equipped empty bag to mail)
232  if (!item)
233  {
234  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_MAIL_ATTACHMENT_INVALID);
235  return;
236  }
237 
238  if (!item->CanBeTraded(true))
239  {
240  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
241  return;
242  }
243 
244  if (item->IsBoundAccountWide() && item->IsSoulBound() && player->GetSession()->GetAccountId() != receiverAccountId)
245  {
246  if (!item->IsBattlenetAccountBound() || !player->GetSession()->GetBattlenetAccountId() || player->GetSession()->GetBattlenetAccountId() != receiverBnetAccountId)
247  {
248  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_NOT_SAME_ACCOUNT);
249  return;
250  }
251  }
252 
254  {
255  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_MAIL_BOUND_ITEM);
256  return;
257  }
258 
260  {
261  player->SendMailResult(0, MAIL_SEND, MAIL_ERR_CANT_SEND_WRAPPED_COD);
262  return;
263  }
264 
265  if (item->IsNotEmptyBag())
266  {
268  return;
269  }
270 
271  items.push_back(item);
272  }
273 
274  player->SendMailResult(0, MAIL_SEND, MAIL_OK);
275 
276  player->ModifyMoney(-reqmoney);
277  player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_GOLD_SPENT_FOR_MAIL, cost);
278 
279  bool needItemDelay = false;
280 
281  MailDraft draft(packet.Info.Subject, packet.Info.Body);
282 
284 
285  if (!packet.Info.Attachments.empty() || packet.Info.SendMoney > 0)
286  {
288  if (!packet.Info.Attachments.empty())
289  {
290  for (auto const& item : items)
291  {
292  if (log)
293  {
294  sLog->outCommand(GetAccountId(), "GM %s (%s) (Account: %u) mail item: %s (Entry: %u Count: %u) "
295  "to: %s (%s) (Account: %u)", GetPlayerName().c_str(), _player->GetGUID().ToString().c_str(), GetAccountId(),
296  item->GetTemplate()->GetDefaultLocaleName(), item->GetEntry(), item->GetCount(),
297  packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
298  }
299 
300  item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
301  player->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
302 
303  item->DeleteFromInventoryDB(trans); // deletes item from character's inventory
304  item->SetOwnerGUID(receiverGuid);
305  item->SaveToDB(trans); // recursive and not have transaction guard into self, item not in inventory and can be save standalone
306 
307  draft.AddItem(item);
308  }
309 
310  // if item send to character at another account, then apply item delivery delay
311  needItemDelay = player->GetSession()->GetAccountId() != receiverAccountId;
312  }
313 
314  if (log && packet.Info.SendMoney > 0)
315  {
316  sLog->outCommand(GetAccountId(), "GM %s (%s) (Account: %u) mail money: " SI64FMTD " to: %s (%s) (Account: %u)",
317  GetPlayerName().c_str(), _player->GetGUID().ToString().c_str(), GetAccountId(), packet.Info.SendMoney, packet.Info.Target.c_str(), receiverGuid.ToString().c_str(), receiverAccountId);
318  }
319  }
320 
321  // If theres is an item, there is a one hour delivery delay if sent to another account's character.
322  uint32 deliver_delay = needItemDelay ? sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY) : 0;
323 
324  // Mail sent between guild members arrives instantly if they have the guild perk "Guild Mail"
325  if (Guild* guild = sGuildMgr->GetGuildById(player->GetGuildId()))
326  if (guild->GetLevel() >= 17 && guild->IsMember(receiverGuid))
327  deliver_delay = 0;
328 
329  // don't ask for COD if there are no items
330  if (packet.Info.Attachments.empty())
331  packet.Info.Cod = 0;
332 
333  // will delete item or place to receiver mail list
334  draft
335  .AddMoney(packet.Info.SendMoney)
336  .AddCOD(packet.Info.Cod)
337  .SendMailTo(trans, MailReceiver(receiver, receiverGuid.GetCounter()), MailSender(player), packet.Info.Body.empty() ? MAIL_CHECK_MASK_COPIED : MAIL_CHECK_MASK_HAS_BODY, deliver_delay);
338 
339  player->SaveInventoryAndGoldToDB(trans);
341 }
Definition: ItemTemplate.h:174
uint32 GetCount() const
Definition: Item.h:322
Definition: UpdateFields.h:47
Definition: SharedDefines.h:4610
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: World.h:294
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: SharedDefines.h:4605
Definition: ItemTemplate.h:138
std::string const & GetPlayerName() const
Definition: WorldSession.cpp:190
int64_t int64
Definition: Define.h:145
bool IsSoulBound() const
Definition: Item.h:277
#define SZFMTD
Definition: Define.h:143
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
static void DeleteFromInventoryDB(SQLTransaction &trans, ObjectGuid::LowType itemGuid)
Definition: Item.cpp:535
Definition: UpdateFields.h:49
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log
Definition: Item.h:130
bool CanOpenMailBox(ObjectGuid guid)
Definition: MailHandler.cpp:35
Definition: Language.h:1144
int32 StationeryID
Definition: MailPackets.h:118
bool CanBeTraded(bool mail=false, bool trade=false) const
Definition: Item.cpp:769
#define sLog
Definition: Log.h:154
bool IsBattlenetAccountBound() const
Definition: Item.h:279
uint32 GetAccountId() const
Definition: WorldSession.h:922
int64 Cod
Definition: MailPackets.h:120
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
bool IsNotEmptyBag() const
Definition: Item.cpp:286
This mail was returned. Do not allow returning mail back again.
Definition: Mail.h:50
Definition: SharedDefines.h:4606
Definition: PreparedStatement.h:74
Definition: Mail.h:52
Definition: Language.h:1143
Definition: Item.h:120
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
virtual void SaveToDB(SQLTransaction &trans)
Definition: Item.cpp:311
uint8 GetUInt8() const
Definition: Field.h:70
Definition: Mail.h:118
std::string Target
Definition: MailPackets.h:121
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
bool IsBoundAccountWide() const
Definition: Item.h:278
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
std::vector< MailAttachment > Attachments
Definition: MailPackets.h:124
Definition: Item.h:79
TC_GAME_API uint32 GetIdByGameAccount(uint32 gameAccountId)
Definition: BattlenetAccountMgr.cpp:151
Definition: Item.h:259
#define SI64FMTD
Definition: Define.h:140
Definition: SharedDefines.h:4614
static ObjectGuid GetPlayerGUIDByName(std::string const &name)
Definition: ObjectMgr.cpp:2247
uint32_t uint32
Definition: Define.h:150
Definition: World.h:267
Definition: ItemTemplate.h:200
Definition: SharedDefines.h:4617
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
int64 SendMoney
Definition: MailPackets.h:119
uint8 GetSlot() const
Definition: Item.h:329
Definition: SharedDefines.h:4607
std::string Subject
Definition: MailPackets.h:122
std::string Body
Definition: MailPackets.h:123
Definition: SharedDefines.h:4595
static uint32 GetPlayerTeamByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2294
void SetNotRefundable(Player *owner, bool changestate=true, SQLTransaction *trans=NULL)
Definition: Item.cpp:1241
Definition: ItemTemplate.h:647
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: CharacterDatabase.h:100
Player * _player
Definition: WorldSession.h:1797
Definition: SharedDefines.h:4608
Definition: SharedDefines.h:4611
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: CharacterDatabase.h:57
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: RBAC.h:63
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
ObjectGuid Mailbox
Definition: MailPackets.h:117
uint8_t uint8
Definition: Define.h:152
void SetOwnerGUID(ObjectGuid guid)
Definition: Item.h:273
uint32 GetFlags() const
Definition: ItemTemplate.h:656
static uint32 GetPlayerAccountIdByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2302
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
StructSendMail Info
Definition: MailPackets.h:131
uint32 GetEntry() const
Definition: Object.h:107
Definition: ObjectGuid.h:189
#define MAX_MAIL_ITEMS
Definition: Mail.h:34
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:1239
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: Guild.h:320
Definition: SharedDefines.h:4616
uint8 GetBagSlot() const
Definition: Item.cpp:759
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: SharedDefines.h:4613
Definition: Mail.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: SharedDefines.h:4609
Definition: Mail.h:83
LowType GetCounter() const
Definition: ObjectGuid.h:221
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetActionBarToggles ( WorldPackets::Character::SetActionBarToggles packet)
698 {
699  if (!GetPlayer()) // ignore until not logged (check needed because STATUS_AUTHED)
700  {
701  if (packet.Mask != 0)
702  TC_LOG_ERROR("network", "WorldSession::HandleSetActionBarToggles in not logged state with value: %u, ignored", uint32(packet.Mask));
703  return;
704  }
705 
707 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: UpdateFields.h:267
uint8 Mask
Definition: CharacterPackets.h:537
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetActionButtonOpcode ( WorldPackets::Spells::SetActionButton packet)
677 {
678  uint32 action = ACTION_BUTTON_ACTION(packet.Action);
679  uint32 type = ACTION_BUTTON_TYPE(packet.Action);
680 
681  TC_LOG_DEBUG("network", "CMSG_SET_ACTION_BUTTON Button: %u Action: %u Type: %u", packet.Index, action, type);
682 
683  if (!packet.Action)
684  GetPlayer()->RemoveActionButton(packet.Index);
685  else
686  GetPlayer()->AddActionButton(packet.Index, action, type);
687 }
uint64 Action
two packed uint32 (action and type)
Definition: SpellPackets.h:152
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define ACTION_BUTTON_ACTION(X)
Definition: Player.h:333
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 Index
Definition: SpellPackets.h:153
uint32_t uint32
Definition: Define.h:150
#define ACTION_BUTTON_TYPE(X)
Definition: Player.h:334

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetActiveMoverOpcode ( WorldPackets::Movement::SetActiveMover packet)
486 {
487  if (GetPlayer()->IsInWorld())
488  if (_player->m_mover->GetGUID() != packet.ActiveMover)
489  TC_LOG_DEBUG("network", "HandleSetActiveMoverOpcode: incorrect mover guid: mover is %s and should be %s" , packet.ActiveMover.ToString().c_str(), _player->m_mover->GetGUID().ToString().c_str());
490 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid ActiveMover
Definition: MovementPackets.h:324
Player * _player
Definition: WorldSession.h:1797
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetActiveVoiceChannel ( WorldPackets::Voice::SetActiveVoiceChannel packet)
27 {
28 }

+ Here is the caller graph for this function:

void WorldSession::HandleSetAdvancedCombatLogging ( WorldPackets::ClientConfig::SetAdvancedCombatLogging setAdvancedCombatLogging)
1115 {
1116  _player->SetAdvancedCombatLogging(setAdvancedCombatLogging.Enable);
1117 }
Player * _player
Definition: WorldSession.h:1797
bool Enable
Definition: ClientConfigPackets.h:110

+ Here is the caller graph for this function:

void WorldSession::HandleSetAssistantLeaderOpcode ( WorldPackets::Party::SetAssistantLeader packet)
516 {
517  Group* group = GetPlayer()->GetGroup();
518  if (!group)
519  return;
520 
521  if (!group->IsLeader(GetPlayer()->GetGUID()))
522  return;
523 
524  group->SetGroupMemberFlag(packet.Target, packet.Apply, MEMBER_FLAG_ASSISTANT);
525 }
Definition: Group.h:76
ObjectGuid Target
Definition: PartyPackets.h:360
bool Apply
Definition: PartyPackets.h:362
Player * GetPlayer() const
Definition: WorldSession.h:927
void SetGroupMemberFlag(ObjectGuid guid, bool apply, GroupMemberFlags flag)
Definition: Group.cpp:2631
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetCollisionHeightAck ( WorldPackets::Movement::MoveSetCollisionHeightAck setCollisionHeightAck)
520 {
521  GetPlayer()->ValidateMovementInfo(&setCollisionHeightAck.Data.movementInfo);
522 }
Player * GetPlayer() const
Definition: WorldSession.h:927
MovementAck Data
Definition: MovementPackets.h:402
MovementInfo movementInfo
Definition: MovementPackets.h:292

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetContactNotesOpcode ( WorldPackets::Social::SetContactNotes packet)
Todo:
: handle VirtualRealmAddress
161 {
163  TC_LOG_DEBUG("network", "WorldSession::HandleSetContactNotesOpcode: Contact: %s, Notes: %s", packet.Player.Guid.ToString().c_str(), packet.Notes.c_str());
164  _player->GetSocial()->SetFriendNote(packet.Player.Guid, packet.Notes);
165 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string Notes
Definition: SocialPackets.h:124
Player * _player
Definition: WorldSession.h:1797
ObjectGuid Guid
Definition: SocialPackets.h:91
QualifiedGUID Player
Definition: SocialPackets.h:123
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetDungeonDifficultyOpcode ( WorldPackets::Misc::SetDungeonDifficulty setDungeonDifficulty)
856 {
857  DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(setDungeonDifficulty.DifficultyID);
858  if (!difficultyEntry)
859  {
860  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent an invalid instance mode %d!",
861  _player->GetGUID().ToString().c_str(), setDungeonDifficulty.DifficultyID);
862  return;
863  }
864 
865  if (difficultyEntry->InstanceType != MAP_INSTANCE)
866  {
867  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent an non-dungeon instance mode %d!",
868  _player->GetGUID().ToString().c_str(), difficultyEntry->ID);
869  return;
870  }
871 
872  if (!(difficultyEntry->Flags & DIFFICULTY_FLAG_CAN_SELECT))
873  {
874  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent unselectable instance mode %d!",
875  _player->GetGUID().ToString().c_str(), difficultyEntry->ID);
876  return;
877  }
878 
879  Difficulty difficultyID = Difficulty(difficultyEntry->ID);
880  if (difficultyID == _player->GetDungeonDifficultyID())
881  return;
882 
883  // cannot reset while in an instance
884  Map* map = _player->FindMap();
885  if (map && map->IsDungeon())
886  {
887  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: player (Name: %s, %s) tried to reset the instance while player is inside!",
888  _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
889  return;
890  }
891 
892  Group* group = _player->GetGroup();
893  if (group)
894  {
895  if (group->IsLeader(_player->GetGUID()))
896  {
897  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
898  {
899  Player* groupGuy = itr->GetSource();
900  if (!groupGuy)
901  continue;
902 
903  if (!groupGuy->IsInMap(groupGuy))
904  return;
905 
906  if (groupGuy->GetMap()->IsNonRaidDungeon())
907  {
908  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s tried to reset the instance while group member (Name: %s, %s) is inside!",
909  _player->GetGUID().ToString().c_str(), groupGuy->GetName().c_str(), groupGuy->GetGUID().ToString().c_str());
910  return;
911  }
912  }
913  // the difficulty is set even if the instances can't be reset
914  //_player->SendDungeonDifficulty(true);
916  group->SetDungeonDifficultyID(difficultyID);
917  }
918  }
919  else
920  {
921  _player->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, false, false);
922  _player->SetDungeonDifficultyID(difficultyID);
923  _player->SendDungeonDifficulty();
924  }
925 }
Difficulty
Definition: DBCEnums.h:402
void ResetInstances(uint8 method, bool isRaid, bool isLegacy, Player *SendMsgTo)
Definition: Group.cpp:2096
uint32 ID
Definition: DBCStructure.h:340
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsDungeon() const
Definition: Map.h:395
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
int32 DifficultyID
Definition: MiscPackets.h:268
Definition: DBCEnums.h:433
uint32 Flags
Definition: DBCStructure.h:346
uint32 InstanceType
Definition: DBCStructure.h:342
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: Map.h:259
Player * _player
Definition: WorldSession.h:1797
void SetDungeonDifficultyID(Difficulty difficulty)
Definition: Group.cpp:2008
DBCStorage< DifficultyEntry > sDifficultyStore(DifficultyFmt)
Definition: DBCEnums.h:479
Definition: Group.h:191
Definition: GroupReference.h:27
Definition: DBCStructure.h:338

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetEveryoneIsAssistant ( WorldPackets::Party::SetEveryoneIsAssistant packet)
630 {
631  Group* group = GetPlayer()->GetGroup();
632  if (!group)
633  return;
634 
635  if (!group->IsLeader(GetPlayer()->GetGUID()))
636  return;
637 
639 }
void SetEveryoneIsAssistant(bool apply)
Definition: Group.cpp:2760
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
bool EveryoneIsAssistant
Definition: PartyPackets.h:560
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetFactionAtWar ( WorldPackets::Character::SetFactionAtWar packet)
1182 {
1183  GetPlayer()->GetReputationMgr().SetAtWar(packet.FactionIndex, true);
1184 }
uint8 FactionIndex
Definition: CharacterPackets.h:648
Player * GetPlayer() const
Definition: WorldSession.h:927

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetFactionCheat ( WorldPacket recvData)
1193 {
1194  TC_LOG_ERROR("network", "WORLD SESSION: HandleSetFactionCheat, not expected call, please report.");
1195  GetPlayer()->GetReputationMgr().SendStates();
1196 }
Player * GetPlayer() const
Definition: WorldSession.h:927
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

void WorldSession::HandleSetFactionInactiveOpcode ( WorldPackets::Character::SetFactionInactive packet)
1235 {
1236  _player->GetReputationMgr().SetInactive(packet.Index, packet.State);
1237 }
bool State
Definition: CharacterPackets.h:669
Player * _player
Definition: WorldSession.h:1797
uint32 Index
Definition: CharacterPackets.h:668

+ Here is the caller graph for this function:

void WorldSession::HandleSetFactionNotAtWar ( WorldPackets::Character::SetFactionNotAtWar packet)
1187 {
1188  GetPlayer()->GetReputationMgr().SetAtWar(packet.FactionIndex, false);
1189 }
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 FactionIndex
Definition: CharacterPackets.h:658

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetLootMethodOpcode ( WorldPackets::Party::SetLootMethod packet)

error handling

342 {
343  Group* group = GetPlayer()->GetGroup();
344  if (!group)
345  return;
346 
348  if (!group->IsLeader(GetPlayer()->GetGUID()))
349  return;
350 
351  if (packet.LootMethod > PERSONAL_LOOT)
352  return;
353 
355  return;
356 
357  if (packet.LootMethod == MASTER_LOOT && !group->IsMember(packet.LootMasterGUID))
358  return;
359  /********************/
360 
361  // everything's fine, do it
362  group->SetLootMethod(static_cast<LootMethod>(packet.LootMethod));
363  group->SetMasterLooterGuid(packet.LootMasterGUID);
364  group->SetLootThreshold(static_cast<ItemQualities>(packet.LootThreshold));
365  group->SendUpdate();
366 }
void SetLootThreshold(ItemQualities threshold)
Definition: Group.cpp:2326
void SetLootMethod(LootMethod method)
Definition: Group.cpp:2311
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: LootMgr.h:72
uint8 LootMethod
Definition: PartyPackets.h:269
uint32 LootThreshold
Definition: PartyPackets.h:270
void SetMasterLooterGuid(ObjectGuid guid)
Definition: Group.cpp:2321
Definition: SharedDefines.h:322
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2566
Definition: SharedDefines.h:326
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
ObjectGuid LootMasterGUID
Definition: PartyPackets.h:268
void SendUpdate()
Definition: Group.cpp:1567
Definition: Group.h:191
Definition: LootMgr.h:69

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetLootSpecialization ( WorldPackets::Loot::SetLootSpecialization packet)
487 {
488  if (packet.SpecID)
489  {
490  if (ChrSpecializationEntry const* chrSpec = sChrSpecializationStore.LookupEntry(packet.SpecID))
491  {
492  if (chrSpec->ClassID == GetPlayer()->getClass())
493  GetPlayer()->SetLootSpecId(packet.SpecID);
494  }
495  }
496  else
497  GetPlayer()->SetLootSpecId(packet.SpecID);
498 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: DBCStructure.h:245
DBCStorage< ChrSpecializationEntry > sChrSpecializationStore(ChrSpecializationfmt)
uint32 SpecID
Definition: LootPackets.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetPartyAssignment ( WorldPackets::Party::SetPartyAssignment packet)
528 {
529  Group* group = GetPlayer()->GetGroup();
530  if (!group)
531  return;
532 
533  ObjectGuid senderGuid = GetPlayer()->GetGUID();
534  if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid))
535  return;
536 
537  switch (packet.Assignment)
538  {
541  group->SetGroupMemberFlag(packet.Target, packet.Set, MEMBER_FLAG_MAINASSIST);
542  break;
544  group->RemoveUniqueGroupMemberFlag(MEMBER_FLAG_MAINTANK); // Remove main assist flag from current if any.
545  group->SetGroupMemberFlag(packet.Target, packet.Set, MEMBER_FLAG_MAINTANK);
546  default:
547  break;
548  }
549 
550  group->SendUpdate();
551 }
Player * GetPlayer() const
Definition: WorldSession.h:927
void RemoveUniqueGroupMemberFlag(GroupMemberFlags flag)
Definition: Group.cpp:2745
bool Set
Definition: PartyPackets.h:374
void SetGroupMemberFlag(ObjectGuid guid, bool apply, GroupMemberFlags flag)
Definition: Group.cpp:2631
ObjectGuid Target
Definition: PartyPackets.h:373
Definition: Group.h:77
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
Definition: Group.h:83
uint8 Assignment
Definition: PartyPackets.h:371
Definition: Group.h:78
Definition: ObjectGuid.h:189
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:84
void SendUpdate()
Definition: Group.cpp:1567
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetPartyLeaderOpcode ( WorldPackets::Party::SetPartyLeader packet)
281 {
283  Group* group = GetPlayer()->GetGroup();
284 
285  if (!group || !player)
286  return;
287 
288  if (!group->IsLeader(GetPlayer()->GetGUID()) || player->GetGroup() != group)
289  return;
290 
291  // Everything's fine, accepted.
292  group->ChangeLeader(packet.TargetGUID, packet.PartyIndex);
293  group->SendUpdate();
294 }
ObjectGuid TargetGUID
Definition: PartyPackets.h:221
Player * GetPlayer() const
Definition: WorldSession.h:927
int8 PartyIndex
Definition: PartyPackets.h:220
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
void SendUpdate()
Definition: Group.cpp:1567
Definition: Group.h:191
void ChangeLeader(ObjectGuid guid, int8 partyIndex=0)
Definition: Group.cpp:651

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetPlayerDeclinedNames ( WorldPackets::Character::SetPlayerDeclinedNames packet)
1351 {
1352  // not accept declined names for unsupported languages
1353  std::string name;
1354  if (!ObjectMgr::GetPlayerNameByGUID(packet.Player, name))
1355  {
1357  return;
1358  }
1359 
1360  std::wstring wname;
1361  if (!Utf8toWStr(name, wname))
1362  {
1364  return;
1365  }
1366 
1367  if (!isCyrillicCharacter(wname[0])) // name already stored as only single alphabet using
1368  {
1370  return;
1371  }
1372 
1373  for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
1374  {
1375  if (!normalizePlayerName(packet.DeclinedNames.name[i]))
1376  {
1378  return;
1379  }
1380  }
1381 
1382  if (!ObjectMgr::CheckDeclinedNames(wname, packet.DeclinedNames))
1383  {
1385  return;
1386  }
1387 
1388  for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
1390 
1392 
1394  stmt->setUInt64(0, packet.Player.GetCounter());
1395  trans->Append(stmt);
1396 
1398  stmt->setUInt64(0, packet.Player.GetCounter());
1399 
1400  for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; i++)
1401  stmt->setString(i + 1, packet.DeclinedNames.name[i]);
1402 
1403  trans->Append(stmt);
1404 
1406 
1408 }
Definition: WorldSession.h:827
Definition: CharacterDatabase.h:429
bool isCyrillicCharacter(wchar_t wchar)
Definition: Util.h:164
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Definition: WorldSession.h:828
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:1099
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
Definition: PreparedStatement.h:74
DeclinedName DeclinedNames
Definition: CharacterPackets.h:729
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
void SendSetPlayerDeclinedNamesResult(DeclinedNameResult result, ObjectGuid guid)
Definition: CharacterHandler.cpp:2546
static bool CheckDeclinedNames(const std::wstring &w_ownname, DeclinedName const &names)
Definition: ObjectMgr.cpp:7814
void EscapeString(std::string &str)
Apply escape string'ing for current collation. (utf8)
Definition: DatabaseWorkerPool.cpp:231
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid Player
Definition: CharacterPackets.h:728
static bool GetPlayerNameByGUID(ObjectGuid const &guid, std::string &name)
Definition: ObjectMgr.cpp:2258
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::string name[MAX_DECLINED_NAME_CASES]
Definition: Unit.h:1103
Definition: CharacterDatabase.h:430
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetPvP ( WorldPackets::Misc::SetPvP packet)
343 {
344  GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP, packet.EnablePVP);
345  GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER, !packet.EnablePVP);
346 
347  if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
348  {
349  if (!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo.EndTimer)
350  GetPlayer()->UpdatePvP(true, true);
351  }
352  else
353  {
354  if (!GetPlayer()->pvpInfo.IsHostile && GetPlayer()->IsPvP())
355  GetPlayer()->pvpInfo.EndTimer = time(nullptr); // start set-off
356  }
357 }
Definition: Player.h:526
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Player.h:535
Definition: UpdateFields.h:191
bool EnablePVP
Definition: MiscPackets.h:747

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetRaidDifficultyOpcode ( WorldPackets::Misc::SetRaidDifficulty setRaidDifficulty)
928 {
929  DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(setRaidDifficulty.DifficultyID);
930  if (!difficultyEntry)
931  {
932  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent an invalid instance mode %u!",
933  _player->GetGUID().ToString().c_str(), setRaidDifficulty.DifficultyID);
934  return;
935  }
936 
937  if (difficultyEntry->InstanceType != MAP_RAID)
938  {
939  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent an non-dungeon instance mode %u!",
940  _player->GetGUID().ToString().c_str(), difficultyEntry->ID);
941  return;
942  }
943 
944  if (!(difficultyEntry->Flags & DIFFICULTY_FLAG_CAN_SELECT))
945  {
946  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent unselectable instance mode %u!",
947  _player->GetGUID().ToString().c_str(), difficultyEntry->ID);
948  return;
949  }
950 
951  if (((difficultyEntry->Flags & DIFFICULTY_FLAG_LEGACY) >> 5) != setRaidDifficulty.Legacy)
952  {
953  TC_LOG_DEBUG("network", "WorldSession::HandleSetDungeonDifficultyOpcode: %s sent not matching legacy difficulty %u!",
954  _player->GetGUID().ToString().c_str(), difficultyEntry->ID);
955  return;
956  }
957 
958  Difficulty difficultyID = Difficulty(difficultyEntry->ID);
959  if (difficultyID == (setRaidDifficulty.Legacy ? _player->GetLegacyRaidDifficultyID() : _player->GetRaidDifficultyID()))
960  return;
961 
962  // cannot reset while in an instance
963  Map* map = _player->FindMap();
964  if (map && map->IsDungeon())
965  {
966  TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: player (Name: %s, %s) tried to reset the instance while player is inside!",
967  _player->GetName().c_str(), _player->GetGUID().ToString().c_str());
968  return;
969  }
970 
971  Group* group = _player->GetGroup();
972  if (group)
973  {
974  if (group->IsLeader(_player->GetGUID()))
975  {
976  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
977  {
978  Player* groupGuy = itr->GetSource();
979  if (!groupGuy)
980  continue;
981 
982  if (!groupGuy->IsInMap(groupGuy))
983  return;
984 
985  if (groupGuy->GetMap()->IsRaid())
986  {
987  TC_LOG_DEBUG("network", "WorldSession::HandleSetRaidDifficultyOpcode: %s tried to reset the instance while group member (Name: %s, %s) is inside!",
988  _player->GetGUID().ToString().c_str(), groupGuy->GetName().c_str(), groupGuy->GetGUID().ToString().c_str());
989  return;
990  }
991  }
992  // the difficulty is set even if the instances can't be reset
993  group->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, setRaidDifficulty.Legacy != 0, _player);
994  if (setRaidDifficulty.Legacy)
995  group->SetLegacyRaidDifficultyID(difficultyID);
996  else
997  group->SetRaidDifficultyID(difficultyID);
998  }
999  }
1000  else
1001  {
1002  _player->ResetInstances(INSTANCE_RESET_CHANGE_DIFFICULTY, true, setRaidDifficulty.Legacy != 0);
1003  if (setRaidDifficulty.Legacy)
1004  _player->SetLegacyRaidDifficultyID(difficultyID);
1005  else
1006  _player->SetRaidDifficultyID(difficultyID);
1007 
1008  _player->SendRaidDifficulty(setRaidDifficulty.Legacy != 0);
1009  }
1010 }
int32 DifficultyID
Definition: MiscPackets.h:278
Difficulty
Definition: DBCEnums.h:402
void ResetInstances(uint8 method, bool isRaid, bool isLegacy, Player *SendMsgTo)
Definition: Group.cpp:2096
uint32 ID
Definition: DBCStructure.h:340
arena_t NULL
Definition: jemalloc_internal.h:624
void SetLegacyRaidDifficultyID(Difficulty difficulty)
Definition: Group.cpp:2056
bool IsDungeon() const
Definition: Map.h:395
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 Legacy
Definition: MiscPackets.h:279
Definition: DBCEnums.h:480
Definition: DBCEnums.h:433
uint32 Flags
Definition: DBCStructure.h:346
void SetRaidDifficultyID(Difficulty difficulty)
Definition: Group.cpp:2032
uint32 InstanceType
Definition: DBCStructure.h:342
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
GroupReference * GetFirstMember()
Definition: Group.h:295
Definition: Map.h:259
Player * _player
Definition: WorldSession.h:1797
Definition: DBCEnums.h:436
DBCStorage< DifficultyEntry > sDifficultyStore(DifficultyFmt)
Definition: Group.h:191
Definition: GroupReference.h:27
Definition: DBCStructure.h:338

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetRoleOpcode ( WorldPackets::Party::SetRole packet)
297 {
298  WorldPackets::Party::RoleChangedInform roleChangedInform;
299 
300  Group* group = GetPlayer()->GetGroup();
301  uint8 oldRole = group ? group->GetLfgRoles(packet.TargetGUID) : 0;
302  if (oldRole == packet.Role)
303  return;
304 
305  roleChangedInform.PartyIndex = packet.PartyIndex;
306  roleChangedInform.From = GetPlayer()->GetGUID();
307  roleChangedInform.ChangedUnit = packet.TargetGUID;
308  roleChangedInform.OldRole = oldRole;
309  roleChangedInform.NewRole = packet.Role;
310 
311  if (group)
312  {
313  group->BroadcastPacket(roleChangedInform.Write(), false);
314  group->SetLfgRoles(packet.TargetGUID, packet.Role);
315  }
316  else
317  SendPacket(roleChangedInform.Write());
318 }
Definition: PartyPackets.h:236
void SetLfgRoles(ObjectGuid guid, uint8 roles)
Definition: Group.cpp:2331
int32 Role
Definition: PartyPackets.h:233
uint8 GetLfgRoles(ObjectGuid guid)
Definition: Group.cpp:2341
int32 OldRole
Definition: PartyPackets.h:246
int8 PartyIndex
Definition: PartyPackets.h:231
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid ChangedUnit
Definition: PartyPackets.h:245
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: PartyPackets.cpp:180
ObjectGuid TargetGUID
Definition: PartyPackets.h:232
uint8_t uint8
Definition: Define.h:152
int32 NewRole
Definition: PartyPackets.h:247
void BroadcastPacket(WorldPacket const *packet, bool ignorePlayersInBGRaid, int group=-1, ObjectGuid ignoredPlayer=ObjectGuid::Empty)
Definition: Group.cpp:1698
int8 PartyIndex
Definition: PartyPackets.h:243
ObjectGuid From
Definition: PartyPackets.h:244
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetSavedInstanceExtend ( WorldPackets::Calendar::SetSavedInstanceExtend setSavedInstanceExtend)
484 {
485  TC_LOG_DEBUG("network", "CMSG_SET_SAVED_INSTANCE_EXTEND - MapId: %u, Difficulty: %u, ToggleExtend: %s", setSavedInstanceExtend.MapID, setSavedInstanceExtend.DifficultyID, setSavedInstanceExtend.Extend ? "On" : "Off");
486 
487  if (Player* player = GetPlayer())
488  {
489  InstancePlayerBind* instanceBind = player->GetBoundInstance(setSavedInstanceExtend.MapID, Difficulty(setSavedInstanceExtend.DifficultyID), setSavedInstanceExtend.Extend); // include expired instances if we are toggling extend on
490  if (!instanceBind || !instanceBind->save || !instanceBind->perm)
491  return;
492 
493  BindExtensionState newState;
494  if (!setSavedInstanceExtend.Extend || instanceBind->extendState == EXTEND_STATE_EXPIRED)
495  newState = EXTEND_STATE_NORMAL;
496  else
497  newState = EXTEND_STATE_EXTENDED;
498 
499  player->BindToInstance(instanceBind->save, true, newState, false);
500  }
501 
502  /*
503  InstancePlayerBind* instanceBind = _player->GetBoundInstance(setSavedInstanceExtend.MapID, Difficulty(setSavedInstanceExtend.DifficultyID));
504  if (!instanceBind || !instanceBind->save)
505  return;
506 
507  InstanceSave* save = instanceBind->save;
508  // http://www.wowwiki.com/Instance_Lock_Extension
509  // SendCalendarRaidLockoutUpdated(save);
510  */
511 }
bool Extend
Definition: CalendarPackets.h:445
Difficulty
Definition: DBCEnums.h:402
uint32 DifficultyID
Definition: CalendarPackets.h:446
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
int32 MapID
Definition: CalendarPackets.h:444

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetSelectionOpcode ( WorldPackets::Misc::SetSelection packet)
398 {
399  _player->SetSelection(packet.Selection);
400 }
ObjectGuid Selection
Target.
Definition: MiscPackets.h:116
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleSetSheathedOpcode ( WorldPackets::Combat::SetSheathed packet)
70 {
72  {
73  TC_LOG_ERROR("network", "Unknown sheath state %u ??", packet.CurrentSheathState);
74  return;
75  }
76 
77  GetPlayer()->SetSheath(SheathState(packet.CurrentSheathState));
78 }
int32 CurrentSheathState
Definition: CombatPackets.h:167
Player * GetPlayer() const
Definition: WorldSession.h:927
#define MAX_SHEATH_STATE
Definition: Unit.h:303
SheathState
Definition: Unit.h:296
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetSpecializationOpcode ( WorldPackets::Talent::SetSpecialization packet)
82 {
83  Player* player = GetPlayer();
84 
85  if (packet.SpecGroupIndex >= MAX_SPECIALIZATIONS)
86  {
87  TC_LOG_DEBUG("network", "WORLD: HandleSetSpecializationOpcode - specialization index %u out of range", packet.SpecGroupIndex);
88  return;
89  }
90 
91  ChrSpecializationEntry const* chrSpec = sChrSpecializationByIndexStore[player->getClass()][packet.SpecGroupIndex];
92 
93  if (!chrSpec)
94  {
95  TC_LOG_DEBUG("network", "WORLD: HandleSetSpecializationOpcode - specialization index %u not found", packet.SpecGroupIndex);
96  return;
97  }
98 
99  if (chrSpec->ClassID != player->getClass())
100  {
101  TC_LOG_DEBUG("network", "WORLD: HandleSetSpecializationOpcode - specialization %u does not belong to class %u", chrSpec->ID, player->getClass());
102  return;
103  }
104 
105  if (player->getLevel() < MIN_SPECIALIZATION_LEVEL)
106  {
107  TC_LOG_DEBUG("network", "WORLD: HandleSetSpecializationOpcode - player level too low for specializations");
108  return;
109  }
110 
111  player->LearnTalentSpecialization(chrSpec->ID);
112 }
uint32 SpecGroupIndex
Definition: TalentPackets.h:58
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define MIN_SPECIALIZATION_LEVEL
Definition: SharedDefines.h:855
#define MAX_SPECIALIZATIONS
Definition: SharedDefines.h:856
Definition: DBCStructure.h:245
uint32 ID
Definition: DBCStructure.h:247
uint32 ClassID
Definition: DBCStructure.h:249
ChrSpecializationByIndexArray sChrSpecializationByIndexStore
Definition: DBCStores.cpp:67

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetTaxiBenchmark ( WorldPackets::Misc::SetTaxiBenchmarkMode packet)
1013 {
1014  _player->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_TAXI_BENCHMARK, packet.Enable);
1015 }
bool Enable
Definition: MiscPackets.h:812
Player * _player
Definition: WorldSession.h:1797
Definition: UpdateFields.h:191
Definition: Player.h:534

+ Here is the caller graph for this function:

void WorldSession::HandleSetTitleOpcode ( WorldPackets::Character::SetTitle packet)
808 {
809  // -1 at none
810  if (packet.TitleID > 0 && packet.TitleID < MAX_TITLE_INDEX)
811  {
812  if (!GetPlayer()->HasTitle(packet.TitleID))
813  return;
814  }
815  else
816  packet.TitleID = 0;
817 
818  GetPlayer()->SetUInt32Value(PLAYER_CHOSEN_TITLE, packet.TitleID);
819 }
#define MAX_TITLE_INDEX
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: UpdateFields.h:203
int32 TitleID
Definition: CharacterPackets.h:589

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetTradeCurrencyOpcode ( WorldPackets::Trade::SetTradeCurrency setTradeCurrency)
766 {
767 }

+ Here is the caller graph for this function:

void WorldSession::HandleSetTradeGoldOpcode ( WorldPackets::Trade::SetTradeGold setTradeGold)
693 {
694  TradeData* my_trade = _player->GetTradeData();
695  if (!my_trade)
696  return;
697 
698  my_trade->UpdateClientStateIndex();
699  my_trade->SetMoney(setTradeGold.Coinage);
700 }
uint64 Coinage
Definition: TradePackets.h:107
Definition: TradeData.h:34
void SetMoney(uint64 money)
Definition: TradeData.cpp:100
Player * _player
Definition: WorldSession.h:1797
void UpdateClientStateIndex()
Definition: TradeData.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetTradeItemOpcode ( WorldPackets::Trade::SetTradeItem setTradeItem)
703 {
704  TradeData* my_trade = _player->GetTradeData();
705  if (!my_trade)
706  return;
707 
709  // invalid slot number
710  if (setTradeItem.TradeSlot >= TRADE_SLOT_COUNT)
711  {
713  SendTradeStatus(info);
714  return;
715  }
716 
717  // check cheating, can't fail with correct client operations
718  Item* item = _player->GetItemByPos(setTradeItem.PackSlot, setTradeItem.ItemSlotInPack);
719  if (!item || (setTradeItem.TradeSlot != TRADE_SLOT_NONTRADED && !item->CanBeTraded(false, true)))
720  {
722  SendTradeStatus(info);
723  return;
724  }
725 
726  ObjectGuid iGUID = item->GetGUID();
727 
728  // prevent place single item into many trade slots using cheating and client bugs
729  if (my_trade->HasItem(iGUID))
730  {
731  // cheating attempt
733  SendTradeStatus(info);
734  return;
735  }
736 
737  my_trade->UpdateClientStateIndex();
738 
739  if (setTradeItem.TradeSlot != TRADE_SLOT_NONTRADED && item->IsBindedNotWith(my_trade->GetTrader()))
740  {
742  info.TradeSlot = setTradeItem.TradeSlot;
743  SendTradeStatus(info);
744  return;
745  }
746 
747  my_trade->SetItem(TradeSlots(setTradeItem.TradeSlot), item);
748 }
bool IsBindedNotWith(Player const *player) const
Definition: Item.cpp:1111
Definition: SharedDefines.h:4671
uint8 TradeSlot
Definition: TradePackets.h:138
void SendTradeStatus(WorldPackets::Trade::TradeStatus &status)
Definition: TradeHandler.cpp:34
bool CanBeTraded(bool mail=false, bool trade=false) const
Definition: Item.cpp:769
void SetItem(TradeSlots slot, Item *item, bool update=false)
Definition: TradeData.cpp:55
uint8 PackSlot
Definition: TradePackets.h:118
uint8 TradeSlot
Definition: TradePackets.h:117
Definition: TradeData.h:34
TradeSlots
Definition: TradeData.h:23
Definition: TradeData.h:27
Definition: Item.h:259
Player * GetTrader() const
Definition: TradeData.h:41
Definition: SharedDefines.h:4651
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool HasItem(ObjectGuid itemGuid) const
Definition: TradeData.cpp:32
Definition: TradePackets.h:130
Player * _player
Definition: WorldSession.h:1797
Definition: TradeData.h:25
::TradeStatus Status
Definition: TradePackets.h:137
uint8 ItemSlotInPack
Definition: TradePackets.h:119
Definition: ObjectGuid.h:189
void UpdateClientStateIndex()
Definition: TradeData.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSetWatchedFactionOpcode ( WorldPackets::Character::SetWatchedFaction packet)
1230 {
1231  GetPlayer()->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, packet.FactionIndex);
1232 }
Definition: UpdateFields.h:274
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 FactionIndex
Definition: CharacterPackets.h:679

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleShowingCloakOpcode ( WorldPackets::Character::ShowingCloak packet)
1253 {
1254  if (packet.ShowCloak)
1256  else
1258 }
bool ShowCloak
Definition: CharacterPackets.h:569
Definition: Player.h:528
Player * _player
Definition: WorldSession.h:1797
Definition: UpdateFields.h:191

+ Here is the caller graph for this function:

void WorldSession::HandleShowingHelmOpcode ( WorldPackets::Character::ShowingHelm packet)
1245 {
1246  if (packet.ShowHelm)
1248  else
1250 }
Definition: Player.h:527
Player * _player
Definition: WorldSession.h:1797
Definition: UpdateFields.h:191
bool ShowHelm
Definition: CharacterPackets.h:579

+ Here is the caller graph for this function:

void WorldSession::HandleSignPetition ( WorldPackets::Petition::SignPetition packet)
266 {
268 
269  stmt->setUInt64(0, packet.PetitionGUID.GetCounter());
270  stmt->setUInt64(1, packet.PetitionGUID.GetCounter());
271 
273 
274  if (!result)
275  {
276  TC_LOG_ERROR("network", "Petition %s is not found for %s %s", packet.PetitionGUID.ToString().c_str(), GetPlayer()->GetGUID().ToString().c_str(), GetPlayer()->GetName().c_str());
277  return;
278  }
279 
280  Field* fields = result->Fetch();
281  ObjectGuid ownerGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
282  //uint64 signs = fields[1].GetUInt64();
283 
284  if (ownerGuid == _player->GetGUID())
285  return;
286 
287  // not let enemies sign guild charter
288  if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD) && GetPlayer()->GetTeam() != ObjectMgr::GetPlayerTeamByGUID(ownerGuid))
289  {
291  return;
292  }
293 
294  if (_player->GetGuildId())
295  {
297  return;
298  }
299 
300  if (_player->GetGuildIdInvited())
301  {
303  return;
304  }
305 
306  //if (++signs > type) // client signs maximum
307  // return;
308 
309  // Client doesn't allow to sign petition two times by one character, but not check sign by another character from same account
310  // not allow sign another player from already sign player account
312 
313  stmt->setUInt32(0, GetAccountId());
314  stmt->setUInt64(1, packet.PetitionGUID.GetCounter());
315 
316  result = CharacterDatabase.Query(stmt);
317 
319  signResult.Player = _player->GetGUID();
320  signResult.Item = packet.PetitionGUID;
321 
322  if (result)
323  {
325 
326  // close at signer side
327  SendPacket(signResult.Write());
328  return;
329  }
330 
332 
333  stmt->setUInt64(0, ownerGuid.GetCounter());
334  stmt->setUInt64(1, packet.PetitionGUID.GetCounter());
335  stmt->setUInt64(2, _player->GetGUID().GetCounter());
336  stmt->setUInt32(3, GetAccountId());
337 
339 
340  TC_LOG_DEBUG("network", "PETITION SIGN: %s by player: %s (%s Account: %u)", packet.PetitionGUID.ToString().c_str(), _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), GetAccountId());
341 
342  signResult.Error = int32(PETITION_SIGN_OK);
343 
344  // close at signer side
345  SendPacket(signResult.Write());
346 
347  // update signs count on charter, required testing...
348  //Item* item = _player->GetItemByGuid(petitionguid));
349  //if (item)
350  // item->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1+1, signs);
351 
352  // update for owner if online
353  if (Player* owner = ObjectAccessor::FindConnectedPlayer(ownerGuid))
354  owner->GetSession()->SendPacket(signResult.Write());
355 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: CharacterDatabase.h:268
Class used to access individual fields of database query result.
Definition: Field.h:56
Definition: Guild.h:127
Definition: Guild.h:105
Definition: Guild.h:129
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PetitionPackets.h:147
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
Definition: Guild.h:137
Definition: Guild.h:170
ObjectGuid Player
Definition: PetitionPackets.h:155
Definition: Guild.h:169
Definition: CharacterDatabase.h:269
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
ObjectGuid PetitionGUID
Definition: PetitionPackets.h:143
static uint32 GetPlayerTeamByGUID(ObjectGuid const &guid)
Definition: ObjectMgr.cpp:2294
int32 Error
Definition: PetitionPackets.h:156
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
Definition: Guild.h:104
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
ObjectGuid Item
Definition: PetitionPackets.h:154
Definition: CharacterDatabase.h:327
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
std::string ToString() const
Definition: ObjectGuid.cpp:99
WorldPacket const * Write() override
Definition: PetitionPackets.cpp:123
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSocketGems ( WorldPackets::Item::SocketGems socketGems)
855 {
856  if (!socketGems.ItemGuid)
857  return;
858 
859  //cheat -> tried to socket same gem multiple times
860  if ((!socketGems.GemItem[0].IsEmpty() && (socketGems.GemItem[0] == socketGems.GemItem[1] || socketGems.GemItem[0] == socketGems.GemItem[2])) ||
861  (!socketGems.GemItem[1].IsEmpty() && (socketGems.GemItem[1] == socketGems.GemItem[2])))
862  return;
863 
864  Item* itemTarget = _player->GetItemByGuid(socketGems.ItemGuid);
865  if (!itemTarget) //missing item to socket
866  return;
867 
868  ItemTemplate const* itemProto = itemTarget->GetTemplate();
869  if (!itemProto)
870  return;
871 
872  //this slot is excepted when applying / removing meta gem bonus
873  uint8 slot = itemTarget->IsEquipped() ? itemTarget->GetSlot() : uint8(NULL_SLOT);
874 
875  Item* Gems[MAX_GEM_SOCKETS];
876  for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
877  Gems[i] = !socketGems.GemItem[i].IsEmpty() ? _player->GetItemByGuid(socketGems.GemItem[i]) : NULL;
878 
879  GemPropertiesEntry const* GemProps[MAX_GEM_SOCKETS];
880  for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get geminfo from dbc storage
881  GemProps[i] = (Gems[i]) ? sGemPropertiesStore.LookupEntry(Gems[i]->GetTemplate()->GetGemProperties()) : NULL;
882 
883  // Find first prismatic socket
884  int32 firstPrismatic = 0;
885  while (firstPrismatic < MAX_GEM_SOCKETS && itemTarget->GetSocketColor(firstPrismatic))
886  ++firstPrismatic;
887 
888  for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //check for hack maybe
889  {
890  if (!GemProps[i])
891  continue;
892 
893  // tried to put gem in socket where no socket exists (take care about prismatic sockets)
894  if (!itemTarget->GetSocketColor(i))
895  {
896  // no prismatic socket
898  return;
899 
900  if (i != firstPrismatic)
901  return;
902  }
903 
904  // tried to put normal gem in meta socket
905  if (itemTarget->GetSocketColor(i) == SOCKET_COLOR_META && GemProps[i]->Type != SOCKET_COLOR_META)
906  return;
907 
908  // tried to put meta gem in normal socket
909  if (itemTarget->GetSocketColor(i) != SOCKET_COLOR_META && GemProps[i]->Type == SOCKET_COLOR_META)
910  return;
911 
912  // tried to put normal gem in cogwheel socket
913  if (itemTarget->GetSocketColor(i) == SOCKET_COLOR_COGWHEEL && GemProps[i]->Type != SOCKET_COLOR_COGWHEEL)
914  return;
915 
916  // tried to put cogwheel gem in normal socket
917  if (itemTarget->GetSocketColor(i) != SOCKET_COLOR_COGWHEEL && GemProps[i]->Type == SOCKET_COLOR_COGWHEEL)
918  return;
919  }
920 
921  uint32 GemEnchants[MAX_GEM_SOCKETS];
922  uint32 OldEnchants[MAX_GEM_SOCKETS];
923  for (int i = 0; i < MAX_GEM_SOCKETS; ++i) //get new and old enchantments
924  {
925  GemEnchants[i] = (GemProps[i]) ? GemProps[i]->EnchantID : 0;
926  OldEnchants[i] = itemTarget->GetEnchantmentId(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT+i));
927  }
928 
929  // check unique-equipped conditions
930  for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
931  {
932  if (!Gems[i])
933  continue;
934 
935  // continue check for case when attempt add 2 similar unique equipped gems in one item.
936  ItemTemplate const* iGemProto = Gems[i]->GetTemplate();
937 
938  // unique item (for new and already placed bit removed enchantments
939  if (iGemProto->GetFlags() & ITEM_FLAG_UNIQUE_EQUIPPED)
940  {
941  for (int j = 0; j < MAX_GEM_SOCKETS; ++j)
942  {
943  if (i == j) // skip self
944  continue;
945 
946  if (Gems[j])
947  {
948  if (iGemProto->GetId() == Gems[j]->GetEntry())
949  {
950  _player->SendEquipError(EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED, itemTarget, NULL);
951  return;
952  }
953  }
954  else if (OldEnchants[j])
955  {
956  if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(OldEnchants[j]))
957  {
958  if (iGemProto->GetId() == enchantEntry->SRCItemID)
959  {
960  _player->SendEquipError(EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED, itemTarget, NULL);
961  return;
962  }
963  }
964  }
965  }
966  }
967 
968  // unique limit type item
969  int32 limit_newcount = 0;
970  if (iGemProto->GetItemLimitCategory())
971  {
972  if (ItemLimitCategoryEntry const* limitEntry = sItemLimitCategoryStore.LookupEntry(iGemProto->GetItemLimitCategory()))
973  {
974  // NOTE: limitEntry->mode is not checked because if item has limit then it is applied in equip case
975  for (int j = 0; j < MAX_GEM_SOCKETS; ++j)
976  {
977  if (Gems[j])
978  {
979  // new gem
980  if (iGemProto->GetItemLimitCategory() == Gems[j]->GetTemplate()->GetItemLimitCategory())
981  ++limit_newcount;
982  }
983  else if (OldEnchants[j])
984  {
985  // existing gem
986  if (SpellItemEnchantmentEntry const* enchantEntry = sSpellItemEnchantmentStore.LookupEntry(OldEnchants[j]))
987  if (ItemTemplate const* jProto = sObjectMgr->GetItemTemplate(enchantEntry->SRCItemID))
988  if (iGemProto->GetItemLimitCategory() == jProto->GetItemLimitCategory())
989  ++limit_newcount;
990  }
991  }
992 
993  if (limit_newcount > 0 && uint32(limit_newcount) > limitEntry->Quantity)
994  {
995  _player->SendEquipError(EQUIP_ERR_ITEM_UNIQUE_EQUIPPABLE_SOCKETED, itemTarget, NULL);
996  return;
997  }
998  }
999  }
1000 
1001  // for equipped item check all equipment for duplicate equipped gems
1002  if (itemTarget->IsEquipped())
1003  {
1004  if (InventoryResult res = _player->CanEquipUniqueItem(Gems[i], slot, std::max(limit_newcount, 0)))
1005  {
1006  _player->SendEquipError(res, itemTarget, NULL);
1007  return;
1008  }
1009  }
1010  }
1011 
1012  bool SocketBonusActivated = itemTarget->GemsFitSockets(); //save state of socketbonus
1013  _player->ToggleMetaGemsActive(slot, false); //turn off all metagems (except for the target item)
1014 
1015  //if a meta gem is being equipped, all information has to be written to the item before testing if the conditions for the gem are met
1016 
1017  //remove ALL enchants
1018  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT + MAX_GEM_SOCKETS; ++enchant_slot)
1019  _player->ApplyEnchantment(itemTarget, EnchantmentSlot(enchant_slot), false);
1020 
1021  for (int i = 0; i < MAX_GEM_SOCKETS; ++i)
1022  {
1023  if (GemEnchants[i])
1024  {
1025  itemTarget->SetEnchantment(EnchantmentSlot(SOCK_ENCHANTMENT_SLOT+i), GemEnchants[i], 0, 0, _player->GetGUID());
1026  if (Item* guidItem = _player->GetItemByGuid(socketGems.GemItem[i]))
1027  {
1028  uint32 gemCount = 1;
1029  _player->DestroyItemCount(guidItem, gemCount, true);
1030  }
1031  }
1032  }
1033 
1034  for (uint32 enchant_slot = SOCK_ENCHANTMENT_SLOT; enchant_slot < SOCK_ENCHANTMENT_SLOT+MAX_GEM_SOCKETS; ++enchant_slot)
1035  _player->ApplyEnchantment(itemTarget, EnchantmentSlot(enchant_slot), true);
1036 
1037  bool SocketBonusToBeActivated = itemTarget->GemsFitSockets();//current socketbonus state
1038  if (SocketBonusActivated ^ SocketBonusToBeActivated) //if there was a change...
1039  {
1040  _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, false);
1041  itemTarget->SetEnchantment(BONUS_ENCHANTMENT_SLOT, (SocketBonusToBeActivated ? itemTarget->GetTemplate()->GetSocketBonus() : 0), 0, 0, _player->GetGUID());
1042  _player->ApplyEnchantment(itemTarget, BONUS_ENCHANTMENT_SLOT, true);
1043  //it is not displayed, client has an inbuilt system to determine if the bonus is activated
1044  }
1045 
1046  _player->ToggleMetaGemsActive(slot, true); //turn on all metagems (except for target item)
1047 
1048  _player->RemoveTradeableItem(itemTarget);
1049  itemTarget->ClearSoulboundTradeable(_player); // clear tradeable flag
1050 
1051  itemTarget->SendUpdateSockets();
1052 }
DBCStorage< GemPropertiesEntry > sGemPropertiesStore(GemPropertiesfmt)
#define MAX_GEM_SOCKETS
Definition: Item.h:195
uint32 GetSocketBonus() const
Definition: ItemTemplate.h:696
ObjectGuid ItemGuid
Definition: ItemPackets.h:512
Definition: DB2Structure.h:743
Definition: Unit.h:379
ObjectGuid GemItem[MAX_GEM_SOCKETS]
Definition: ItemPackets.h:513
EnchantmentSlot
Definition: Item.h:172
bool IsEquipped() const
Definition: Item.cpp:764
Definition: ItemTemplate.h:192
arena_t NULL
Definition: jemalloc_internal.h:624
bool GemsFitSockets() const
Definition: Item.cpp:956
uint32 Type
Definition: DBCStructure.h:505
Definition: DBCStructure.h:1214
#define sObjectMgr
Definition: ObjectMgr.h:1567
T max(const T &x, const T &y)
Definition: g3dmath.h:320
SocketColor GetSocketColor(uint32 index) const
Definition: Item.h:393
void ClearSoulboundTradeable(Player *currentOwner)
Definition: Item.cpp:1309
uint32 GetItemLimitCategory() const
Definition: ItemTemplate.h:700
Definition: DBCStructure.h:499
Definition: Item.h:259
void SendUpdateSockets()
Definition: Item.cpp:1041
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
DBCStorage< SpellItemEnchantmentEntry > sSpellItemEnchantmentStore(SpellItemEnchantmentfmt)
Definition: Item.h:176
Definition: ItemTemplate.h:320
uint8 GetSlot() const
Definition: Item.h:329
void SetEnchantment(EnchantmentSlot slot, uint32 id, uint32 duration, uint32 charges, ObjectGuid caster=ObjectGuid::Empty)
Definition: Item.cpp:905
uint8_t uint8
Definition: g3dmath.h:164
Definition: ItemTemplate.h:647
Player * _player
Definition: WorldSession.h:1797
DB2Storage< ItemLimitCategoryEntry > sItemLimitCategoryStore("ItemLimitCategory.db2", ItemLimitCategoryFormat, HOTFIX_SEL_ITEM_LIMIT_CATEGORY)
uint8_t uint8
Definition: Define.h:152
uint32 GetFlags() const
Definition: ItemTemplate.h:656
uint32 GetId() const
Definition: ItemTemplate.h:652
uint32 GetEntry() const
Definition: Object.h:107
uint32_t uint32
Definition: g3dmath.h:168
Definition: Item.h:180
InventoryResult
Definition: Item.h:46
Definition: Item.h:179
bool IsEmpty() const
Definition: ObjectGuid.h:242
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
Definition: ItemTemplate.h:325
uint32 GetEnchantmentId(EnchantmentSlot slot) const
Definition: Item.h:351

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSpellClick ( WorldPackets::Spells::SpellClick spellClick)
Todo:
Unit::SetCharmedBy: 28782 is not in world but 0 is trying to charm it! -> crash
466 {
467  // this will get something not in world. crash
469 
470  if (!unit)
471  return;
472 
474  if (!unit->IsInWorld())
475  return;
476 
477  unit->HandleSpellClick(_player);
478 }
Definition: Creature.h:467
ObjectGuid SpellClickUnitGuid
Definition: SpellPackets.h:798
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
bool IsInWorld() const
Definition: Object.h:100
bool HandleSpellClick(Unit *clicker, int8 seatId=-1)
Definition: Unit.cpp:15173

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSpiritHealerActivate ( WorldPackets::NPC::SpiritHealerActivate packet)
385 {
386  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Healer, UNIT_NPC_FLAG_SPIRITHEALER);
387  if (!unit)
388  {
389  TC_LOG_DEBUG("network", "WORLD: HandleSpiritHealerActivateOpcode - %s not found or you can not interact with him.", packet.Healer.ToString().c_str());
390  return;
391  }
392 
393  // remove fake death
394  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
395  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
396 
398 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
void SendSpiritResurrect()
Definition: NPCHandler.cpp:400
Definition: Unit.h:749
ObjectGuid Healer
Definition: NPCPackets.h:207
Definition: Unit.h:550
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSplitItemOpcode ( WorldPackets::Item::SplitItem splitItem)
33 {
34  if (!splitItem.Inv.Items.empty())
35  {
36  TC_LOG_ERROR("network", "HandleSplitItemOpcode - Invalid ItemCount (" SZFMTD ")", splitItem.Inv.Items.size());
37  return;
38  }
39 
40  TC_LOG_DEBUG("network", "HandleSplitItemOpcode: receive FromPackSlot: %u, FromSlot: %u, ToPackSlot: %u, ToSlot: %u, Quantity: %u",
41  splitItem.FromPackSlot, splitItem.FromSlot, splitItem.ToPackSlot, splitItem.ToSlot, splitItem.Quantity);
42 
43  uint16 src = ((splitItem.FromPackSlot << 8) | splitItem.FromSlot);
44  uint16 dst = ((splitItem.ToPackSlot << 8) | splitItem.ToSlot);
45 
46  if (src == dst)
47  return;
48 
49  // check count - if zero it's fake packet
50  if (!splitItem.Quantity)
51  return;
52 
53  if (!_player->IsValidPos(splitItem.FromPackSlot, splitItem.FromSlot, true))
54  {
55  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
56  return;
57  }
58 
59  if (!_player->IsValidPos(splitItem.ToPackSlot, splitItem.ToSlot, false)) // can be autostore pos
60  {
61  _player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
62  return;
63  }
64 
65  _player->SplitItem(src, dst, splitItem.Quantity);
66 }
InvUpdate Inv
Definition: ItemPackets.h:267
uint8 FromSlot
Definition: ItemPackets.h:268
#define SZFMTD
Definition: Define.h:143
int32 Quantity
Definition: ItemPackets.h:266
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 ToSlot
Definition: ItemPackets.h:263
Definition: Item.h:71
uint16_t uint16
Definition: Define.h:151
std::vector< InvItem > Items
Definition: ItemPackets.h:236
uint8 ToPackSlot
Definition: ItemPackets.h:264
Definition: Item.h:51
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint8 FromPackSlot
Definition: ItemPackets.h:265

+ Here is the caller graph for this function:

void WorldSession::HandleStablePet ( WorldPacket recvPacket)
555 {
556  ObjectGuid npcGUID;
557 
558  recvData >> npcGUID;
559 
560  if (!GetPlayer()->IsAlive())
561  {
563  return;
564  }
565 
566  if (!CheckStableMaster(npcGUID))
567  {
569  return;
570  }
571 
572  // remove fake death
573  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
574  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
575 
576  Pet* pet = _player->GetPet();
577 
578  // can't place in stable dead pet
579  if (!pet || !pet->IsAlive() || pet->getPetType() != HUNTER_PET)
580  {
582  return;
583  }
584 
586 
587  stmt->setUInt64(0, _player->GetGUID().GetCounter());
590 
592 }
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
Definition: PetDefines.h:25
bool IsAlive() const
Definition: Unit.h:1692
Definition: SpellAuraDefines.h:126
Definition: PetDefines.h:36
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:544
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
PreparedQueryResultFuture _stablePetCallback
Definition: WorldSession.h:1732
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
bool CheckStableMaster(ObjectGuid guid)
Definition: PetHandler.cpp:434
Definition: PetDefines.h:37
Definition: Pet.h:46
PetType getPetType() const
Definition: Pet.h:57
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

void WorldSession::HandleStablePetCallback ( PreparedQueryResult  result)
595 {
596  if (!GetPlayer())
597  return;
598 
599  uint8 freeSlot = 1;
600  if (result)
601  {
602  do
603  {
604  Field* fields = result->Fetch();
605 
606  uint8 slot = fields[1].GetUInt8();
607 
608  // slots ordered in query, and if not equal then free
609  if (slot != freeSlot)
610  break;
611 
612  // this slot not free, skip
613  ++freeSlot;
614  }
615  while (result->NextRow());
616  }
617 
618  if (freeSlot > 0 && freeSlot <= GetPlayer()->m_stableSlots)
619  {
620  _player->RemovePet(_player->GetPet(), PetSaveMode(freeSlot));
622  }
623  else
625 }
Class used to access individual fields of database query result.
Definition: Field.h:56
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 GetUInt8() const
Definition: Field.h:70
PetSaveMode
Definition: PetDefines.h:32
Definition: NPCHandler.cpp:49
Player * _player
Definition: WorldSession.h:1797
Definition: NPCHandler.cpp:48
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleStableRevivePet ( WorldPacket recvPacket)
740 {
741  TC_LOG_DEBUG("network", "HandleStableRevivePet: Not implemented");
742 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void WorldSession::HandleStableSwapPet ( WorldPacket recvPacket)
745 {
746  ObjectGuid npcGUID;
747  uint32 petId;
748 
749  recvData >> npcGUID >> petId;
750 
751  if (!CheckStableMaster(npcGUID))
752  {
754  return;
755  }
756 
757  // remove fake death
758  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
759  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
760 
761  Pet* pet = _player->GetPet();
762 
763  if (!pet || pet->getPetType() != HUNTER_PET)
764  {
766  return;
767  }
768 
769  // Find swapped pet slot in stable
770 
772 
773  stmt->setUInt64(0, _player->GetGUID().GetCounter());
774  stmt->setUInt32(1, petId);
775 
778 }
void SetParam(ParamType value)
Definition: Callback.h:63
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
Definition: PetDefines.h:25
Definition: CharacterDatabase.h:547
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
QueryCallback< PreparedQueryResult, uint32 > _stableSwapCallback
Definition: WorldSession.h:1736
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
bool CheckStableMaster(ObjectGuid guid)
Definition: PetHandler.cpp:434
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
Definition: Pet.h:46
PetType getPetType() const
Definition: Pet.h:57
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

void WorldSession::HandleStableSwapPetCallback ( PreparedQueryResult  result,
uint32  petId 
)
781 {
782  if (!GetPlayer())
783  return;
784 
785  if (!result)
786  {
788  return;
789  }
790 
791  Field* fields = result->Fetch();
792 
793  uint32 slot = fields[0].GetUInt8();
794  uint32 petEntry = fields[1].GetUInt32();
795 
796  if (!petEntry)
797  {
799  return;
800  }
801 
802  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(petEntry);
803  if (!creatureInfo || !creatureInfo->IsTameable(true))
804  {
806  return;
807  }
808 
809  if (!creatureInfo->IsTameable(_player->CanTameExoticPets()))
810  {
812  return;
813  }
814 
815  Pet* pet = _player->GetPet();
816  // The player's pet could have been removed during the delay of the DB callback
817  if (!pet)
818  {
820  return;
821  }
822 
823  // move alive pet to slot or delete dead pet
824  _player->RemovePet(pet, pet->IsAlive() ? PetSaveMode(slot) : PET_SAVE_AS_DELETED);
825 
826  // summon unstabled pet
827  Pet* newPet = new Pet(_player);
828  if (!newPet->LoadPetFromDB(_player, petEntry, petId))
829  {
830  delete newPet;
832  }
833  else
835 }
Class used to access individual fields of database query result.
Definition: Field.h:56
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint8 GetUInt8() const
Definition: Field.h:70
PetSaveMode
Definition: PetDefines.h:32
Definition: NPCHandler.cpp:52
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
Player * _player
Definition: WorldSession.h:1797
bool LoadPetFromDB(Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
Definition: Pet.cpp:99
uint32 GetUInt32() const
Definition: Field.h:146
Definition: PetDefines.h:34
Definition: NPCHandler.cpp:50
bool IsTameable(bool canTameExotic) const
Definition: Creature.h:167
Definition: Creature.h:79
Definition: Pet.h:46
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleStandStateChangeOpcode ( WorldPackets::Misc::StandStateChange packet)
403 {
404  _player->SetStandState(packet.StandState);
405 }
UnitStandStateType StandState
Definition: MiscPackets.h:420
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleSummonResponseOpcode ( WorldPackets::Movement::SummonResponse packet)
512 {
513  if (!_player->IsAlive() || _player->IsInCombat())
514  return;
515 
516  _player->SummonIfPossible(packet.Accept);
517 }
bool Accept
Definition: MovementPackets.h:426
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::HandleSupportTicketSubmitBug ( WorldPackets::Ticket::SupportTicketSubmitBug packet)
46 {
47  if (!sSupportMgr->GetBugSystemStatus())
48  return;
49 
50  BugTicket* ticket = new BugTicket(GetPlayer());
51  ticket->SetPosition(packet.Header.MapID, packet.Header.Position);
52  ticket->SetFacing(packet.Header.Facing);
53  ticket->SetNote(packet.Note);
54 
55  sSupportMgr->AddTicket(ticket);
56 }
std::string Note
Definition: TicketPackets.h:102
SupportTicketHeader Header
Definition: TicketPackets.h:101
int32 MapID
Definition: TicketPackets.h:31
G3D::Vector3 Position
Definition: TicketPackets.h:32
Player * GetPlayer() const
Definition: WorldSession.h:927
void SetPosition(uint32 mapId, G3D::Vector3 &pos)
Definition: SupportMgr.h:93
Definition: SupportMgr.h:119
void SetNote(std::string const &note)
Definition: SupportMgr.h:129
float Facing
Definition: TicketPackets.h:33
void SetFacing(float facing)
Definition: SupportMgr.h:128
#define sSupportMgr
Definition: SupportMgr.h:296

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSupportTicketSubmitComplaint ( WorldPackets::Ticket::SupportTicketSubmitComplaint packet)
72 {
73  if (!sSupportMgr->GetComplaintSystemStatus())
74  return;
75 
77  comp->SetPosition(packet.Header.MapID, packet.Header.Position);
78  comp->SetFacing(packet.Header.Facing);
79  comp->SetChatLog(packet.ChatLog);
82  comp->SetNote(packet.Note);
83 
84  sSupportMgr->AddTicket(comp);
85 }
SupportTicketHeader Header
Definition: TicketPackets.h:182
std::string Note
Definition: TicketPackets.h:186
void SetNote(std::string const &note)
Definition: SupportMgr.h:161
Definition: SupportMgr.h:143
void SetTargetCharacterGuid(ObjectGuid targetCharacterGuid)
Definition: SupportMgr.h:155
ObjectGuid TargetCharacterGUID
Definition: TicketPackets.h:184
void SetChatLog(ChatLog const &log)
Definition: SupportMgr.h:160
int32 MapID
Definition: TicketPackets.h:31
G3D::Vector3 Position
Definition: TicketPackets.h:32
Player * GetPlayer() const
Definition: WorldSession.h:927
void SetPosition(uint32 mapId, G3D::Vector3 &pos)
Definition: SupportMgr.h:93
uint8 ComplaintType
Definition: TicketPackets.h:185
float Facing
Definition: TicketPackets.h:33
SupportTicketChatLog ChatLog
Definition: TicketPackets.h:183
#define sSupportMgr
Definition: SupportMgr.h:296
void SetComplaintType(GMSupportComplaintType type)
Definition: SupportMgr.h:159
GMSupportComplaintType
Definition: SupportMgr.h:34
void SetFacing(float facing)
Definition: SupportMgr.h:154

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSupportTicketSubmitSuggestion ( WorldPackets::Ticket::SupportTicketSubmitSuggestion packet)
59 {
60  if (!sSupportMgr->GetSuggestionSystemStatus())
61  return;
62 
64  ticket->SetPosition(packet.Header.MapID, packet.Header.Position);
65  ticket->SetFacing(packet.Header.Facing);
66  ticket->SetNote(packet.Note);
67 
68  sSupportMgr->AddTicket(ticket);
69 }
Definition: SupportMgr.h:179
int32 MapID
Definition: TicketPackets.h:31
G3D::Vector3 Position
Definition: TicketPackets.h:32
SupportTicketHeader Header
Definition: TicketPackets.h:112
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string Note
Definition: TicketPackets.h:113
void SetPosition(uint32 mapId, G3D::Vector3 &pos)
Definition: SupportMgr.h:93
float Facing
Definition: TicketPackets.h:33
#define sSupportMgr
Definition: SupportMgr.h:296
void SetFacing(float facing)
Definition: SupportMgr.h:189
void SetNote(std::string const &note)
Definition: SupportMgr.h:187

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSwapInvItemOpcode ( WorldPackets::Item::SwapInvItem swapInvItem)
69 {
70  if (swapInvItem.Inv.Items.size() != 2)
71  {
72  TC_LOG_ERROR("network", "HandleSwapInvItemOpcode - Invalid itemCount (" SZFMTD ")", swapInvItem.Inv.Items.size());
73  return;
74  }
75 
76  TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode: receive Slot1: %u, Slot2: %u",
77  swapInvItem.Slot1, swapInvItem.Slot2);
78 
79  // prevent attempt swap same item to current position generated by client at special checting sequence
80  if (swapInvItem.Slot1 == swapInvItem.Slot2)
81  return;
82 
83  if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot1, true))
84  {
85  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
86  return;
87  }
88 
89  if (!_player->IsValidPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot2, true))
90  {
91  _player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
92  return;
93  }
94 
95  if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot1) && !CanUseBank())
96  {
97  TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
98  return;
99  }
100 
101  if (_player->IsBankPos(INVENTORY_SLOT_BAG_0, swapInvItem.Slot2) && !CanUseBank())
102  {
103  TC_LOG_DEBUG("network", "HandleSwapInvItemOpcode - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
104  return;
105  }
106 
107  uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.Slot1);
108  uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | swapInvItem.Slot2);
109 
110  _player->SwapItem(src, dst);
111 }
#define INVENTORY_SLOT_BAG_0
#define SZFMTD
Definition: Define.h:143
uint8 Slot1
Definition: ItemPackets.h:279
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint8 Slot2
Source Slot.
Definition: ItemPackets.h:280
Definition: Item.h:71
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
uint16_t uint16
Definition: Define.h:151
std::vector< InvItem > Items
Definition: ItemPackets.h:236
Definition: Item.h:51
InvUpdate Inv
Definition: ItemPackets.h:278
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool CanUseBank(ObjectGuid bankerGUID=ObjectGuid::Empty) const
Definition: ItemHandler.cpp:1256
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSwapItem ( WorldPackets::Item::SwapItem swapItem)
130 {
131  if (swapItem.Inv.Items.size() != 2)
132  {
133  TC_LOG_ERROR("network", "HandleSwapItem - Invalid itemCount (" SZFMTD ")", swapItem.Inv.Items.size());
134  return;
135  }
136 
137  TC_LOG_DEBUG("network", "HandleSwapItem: receive ContainerSlotA: %u, SlotA: %u, ContainerSlotB: %u, SlotB: %u",
138  swapItem.ContainerSlotA, swapItem.SlotA, swapItem.ContainerSlotB, swapItem.SlotB);
139 
140  uint16 src = ((swapItem.ContainerSlotA << 8) | swapItem.SlotA);
141  uint16 dst = ((swapItem.ContainerSlotB << 8) | swapItem.SlotB);
142 
143  // prevent attempt swap same item to current position generated by client at special checting sequence
144  if (src == dst)
145  return;
146 
147  if (!_player->IsValidPos(swapItem.ContainerSlotA, swapItem.SlotA, true))
148  {
149  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND);
150  return;
151  }
152 
153  if (!_player->IsValidPos(swapItem.ContainerSlotB, swapItem.SlotB, true))
154  {
155  _player->SendEquipError(EQUIP_ERR_WRONG_SLOT);
156  return;
157  }
158 
159  if (_player->IsBankPos(swapItem.ContainerSlotA, swapItem.SlotA) && !CanUseBank())
160  {
161  TC_LOG_DEBUG("network", "HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
162  return;
163  }
164 
165  if (_player->IsBankPos(swapItem.ContainerSlotB, swapItem.SlotB) && !CanUseBank())
166  {
167  TC_LOG_DEBUG("network", "HandleSwapItem - Unit (%s) not found or you can't interact with him.", m_currentBankerGUID.ToString().c_str());
168  return;
169  }
170 
171  _player->SwapItem(src, dst);
172 }
#define SZFMTD
Definition: Define.h:143
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:71
uint8 SlotA
Definition: ItemPackets.h:291
uint8 ContainerSlotA
Definition: ItemPackets.h:294
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
uint8 SlotB
Definition: ItemPackets.h:293
uint16_t uint16
Definition: Define.h:151
InvUpdate Inv
Definition: ItemPackets.h:290
uint8 ContainerSlotB
Definition: ItemPackets.h:292
std::vector< InvItem > Items
Definition: ItemPackets.h:236
Definition: Item.h:51
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool CanUseBank(ObjectGuid bankerGUID=ObjectGuid::Empty) const
Definition: ItemHandler.cpp:1256
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleSwapSubGroupsOpcode ( WorldPackets::Party::SwapSubGroups packet)
503 {
504  Group* group = GetPlayer()->GetGroup();
505  if (!group)
506  return;
507 
508  ObjectGuid senderGuid = GetPlayer()->GetGUID();
509  if (!group->IsLeader(senderGuid) && !group->IsAssistant(senderGuid))
510  return;
511 
512  group->SwapMembersGroups(packet.FirstTarget, packet.SecondTarget);
513 }
void SwapMembersGroups(ObjectGuid firstGuid, ObjectGuid secondGuid)
Definition: Group.cpp:1798
ObjectGuid SecondTarget
Definition: PartyPackets.h:583
Player * GetPlayer() const
Definition: WorldSession.h:927
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
ObjectGuid FirstTarget
Definition: PartyPackets.h:582
Definition: ObjectGuid.h:189
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTabardVendorActivateOpcode ( WorldPackets::NPC::Hello packet)
57 {
58  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.Unit, UNIT_NPC_FLAG_TABARDDESIGNER);
59  if (!unit)
60  {
61  TC_LOG_DEBUG("network", "WORLD: HandleTabardVendorActivateOpcode - %s not found or you can not interact with him.", packet.Unit.ToString().c_str());
62  return;
63  }
64 
65  // remove fake death
66  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
67  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
68 
70 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
Definition: Unit.h:754
void SendTabardVendorActivate(ObjectGuid guid)
Definition: NPCHandler.cpp:72
Definition: Unit.h:550
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid Unit
Definition: NPCPackets.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTaxiNodeStatusQueryOpcode ( WorldPackets::Taxi::TaxiNodeStatusQuery taxiNodeStatusQuery)
39 {
40  SendTaxiStatus(taxiNodeStatusQuery.UnitGUID);
41 }
void SendTaxiStatus(ObjectGuid guid)
Definition: TaxiHandler.cpp:43
ObjectGuid UnitGUID
Definition: TaxiPackets.h:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTaxiQueryAvailableNodesOpcode ( WorldPackets::Taxi::TaxiQueryAvailableNodes taxiQueryAvailableNodes)
71 {
72  // cheating checks
73  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(taxiQueryAvailableNodes.Unit, UNIT_NPC_FLAG_FLIGHTMASTER);
74  if (!unit)
75  {
76  TC_LOG_DEBUG("network", "WORLD: HandleTaxiQueryAvailableNodes - %s not found or you can't interact with him.", taxiQueryAvailableNodes.Unit.ToString().c_str());
77  return;
78  }
79  // remove fake death
80  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
81  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
82 
83  // unknown taxi node case
84  if (SendLearnNewTaxiNode(unit))
85  return;
86 
87  // known taxi node case
88  SendTaxiMenu(unit);
89 }
void SendTaxiMenu(Creature *unit)
Definition: TaxiHandler.cpp:91
bool SendLearnNewTaxiNode(Creature *unit)
Definition: TaxiHandler.cpp:131
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
ObjectGuid Unit
Definition: TaxiPackets.h:84
Definition: Unit.h:550
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:748

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTaxiRequestEarlyLanding ( WorldPackets::Taxi::TaxiRequestEarlyLanding taxiRequestEarlyLanding)
201 {
202  if (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
203  {
204  if (GetPlayer()->m_taxi.RequestEarlyLanding())
205  {
206  FlightPathMovementGenerator* flight = static_cast<FlightPathMovementGenerator*>(GetPlayer()->GetMotionMaster()->top());
207  flight->LoadPath(GetPlayer(), flight->GetPath()[flight->GetCurrentNode()]->NodeIndex);
208  flight->Reset(GetPlayer());
209  }
210  }
211 }
uint32 GetCurrentNode() const
Definition: WaypointMovementGenerator.h:43
Definition: WaypointMovementGenerator.h:105
Definition: MotionMaster.h:45
Player * GetPlayer() const
Definition: WorldSession.h:927
void LoadPath(Player *player, uint32 startNode=0)
Definition: WaypointMovementGenerator.cpp:266
void Reset(Unit *u) override
Definition: MovementGenerator.h:66
TaxiPathNodeList const & GetPath()
Definition: WaypointMovementGenerator.h:124

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTextEmoteOpcode ( WorldPackets::Chat::CTextEmote packet)
582 {
583  if (!_player->IsAlive())
584  return;
585 
586  if (!_player->CanSpeak())
587  {
588  std::string timeStr = secsToTimeString(m_muteTime - time(NULL));
590  return;
591  }
592 
593  sScriptMgr->OnPlayerTextEmote(_player, packet.SoundIndex, packet.EmoteID, packet.Target);
594 
595  EmotesTextEntry const* em = sEmotesTextStore.LookupEntry(packet.EmoteID);
596  if (!em)
597  return;
598 
599  uint32 emoteAnim = em->EmoteID;
600 
601  switch (emoteAnim)
602  {
603  case EMOTE_STATE_SLEEP:
604  case EMOTE_STATE_SIT:
605  case EMOTE_STATE_KNEEL:
606  case EMOTE_ONESHOT_NONE:
607  break;
608  case EMOTE_STATE_DANCE:
609  case EMOTE_STATE_READ:
610  _player->SetUInt32Value(UNIT_NPC_EMOTESTATE, emoteAnim);
611  break;
612  default:
613  // Only allow text-emotes for "dead" entities (feign death included)
614  if (_player->HasUnitState(UNIT_STATE_DIED))
615  break;
616  _player->HandleEmoteCommand(emoteAnim);
617  break;
618  }
619 
621  textEmote.SourceGUID = _player->GetGUID();
622  textEmote.SourceAccountGUID = GetAccountGUID();
623  textEmote.TargetGUID = packet.Target;
624  textEmote.EmoteID = packet.EmoteID;
625  textEmote.SoundIndex = packet.SoundIndex;
626  _player->SendMessageToSetInRange(textEmote.Write(), sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), true);
627 
628  Unit* unit = ObjectAccessor::GetUnit(*_player, packet.Target);
629 
630  _player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_DO_EMOTE, packet.SoundIndex, 0, 0, unit);
631 
632  // Send scripted event call
633  if (unit)
634  if (Creature* creature = unit->ToCreature())
635  creature->AI()->ReceiveEmote(_player, packet.SoundIndex);
636 }
Definition: SharedDefines.h:2422
Definition: UpdateFields.h:136
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
std::string secsToTimeString(uint64 timeInSecs, bool shortText, bool hoursOnly)
Definition: Util.cpp:109
int32 EmoteID
Definition: ChatPackets.h:202
int32 SoundIndex
Definition: ChatPackets.h:203
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
#define sWorld
Definition: World.h:887
Definition: DBCEnums.h:246
Definition: Language.h:706
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
ObjectGuid SourceAccountGUID
Definition: ChatPackets.h:214
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
uint32 EmoteID
Definition: DBCStructure.h:392
ObjectGuid TargetGUID
Definition: ChatPackets.h:215
int32 SoundIndex
Definition: ChatPackets.h:216
time_t m_muteTime
Definition: WorldSession.h:1056
Definition: ChatPackets.h:206
Definition: DBCStructure.h:388
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:2423
ObjectGuid Target
Definition: ChatPackets.h:201
ObjectGuid SourceGUID
Definition: ChatPackets.h:213
Definition: SharedDefines.h:2461
Definition: Unit.h:550
Definition: SharedDefines.h:2593
Player * _player
Definition: WorldSession.h:1797
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:2420
Definition: World.h:191
DBCStorage< EmotesTextEntry > sEmotesTextStore(EmotesTextfmt)
#define sScriptMgr
Definition: ScriptMgr.h:837
WorldPacket const * Write() override
Definition: ChatPackets.cpp:209
int32 EmoteID
Definition: ChatPackets.h:217
Definition: Unit.h:1305
Definition: SharedDefines.h:2412
ObjectGuid GetAccountGUID() const
Definition: WorldSession.h:923

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTimeSyncResponse ( WorldPackets::Misc::TimeSyncResponse packet)
822 {
823  // Prevent crashing server if queue is empty
824  if (_player->m_timeSyncQueue.empty())
825  {
826  TC_LOG_ERROR("network", "Received CMSG_TIME_SYNC_RESPONSE from player %s without requesting it (hacker?)", _player->GetName().c_str());
827  return;
828  }
829 
830  if (packet.SequenceIndex != _player->m_timeSyncQueue.front())
831  TC_LOG_ERROR("network", "Wrong time sync counter from player %s (cheater?)", _player->GetName().c_str());
832 
833  TC_LOG_DEBUG("network", "Time sync received: counter %u, client ticks %u, time since last sync %u", packet.SequenceIndex, packet.ClientTime, packet.ClientTime - _player->m_timeSyncClient);
834 
835  uint32 ourTicks = packet.ClientTime + (getMSTime() - _player->m_timeSyncServer);
836 
837  // diff should be small
838  TC_LOG_DEBUG("network", "Our ticks: %u, diff %u, latency %u", ourTicks, ourTicks - packet.ClientTime, GetLatency());
839 
840  _player->m_timeSyncClient = packet.ClientTime;
841  _player->m_timeSyncQueue.pop();
842 }
uint32 ClientTime
Definition: MiscPackets.h:166
uint32 getMSTime()
Definition: Timer.h:24
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 SequenceIndex
Definition: MiscPackets.h:167
uint32_t uint32
Definition: Define.h:150
uint32 GetLatency() const
Definition: WorldSession.h:1063
Player * _player
Definition: WorldSession.h:1797
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTogglePvP ( WorldPackets::Misc::TogglePvP packet)
324 {
325  bool inPvP = GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP);
326 
327  GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP, !inPvP);
328  GetPlayer()->ApplyModFlag(PLAYER_FLAGS, PLAYER_FLAGS_PVP_TIMER, inPvP);
329 
330  if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP))
331  {
332  if (!GetPlayer()->IsPvP() || GetPlayer()->pvpInfo.EndTimer)
333  GetPlayer()->UpdatePvP(true, true);
334  }
335  else
336  {
337  if (!GetPlayer()->pvpInfo.IsHostile && GetPlayer()->IsPvP())
338  GetPlayer()->pvpInfo.EndTimer = time(nullptr); // start toggle-off
339  }
340 }
Definition: Player.h:526
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Player.h:535
Definition: UpdateFields.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTotemDestroyed ( WorldPackets::Totem::TotemDestroyed totemDestroyed)
431 {
432  // ignore for remote control state
433  if (_player->m_mover != _player)
434  return;
435 
436  uint8 slotId = totemDestroyed.Slot;
437  slotId += SUMMON_SLOT_TOTEM;
438 
439  if (slotId >= MAX_TOTEM_SLOT)
440  return;
441 
442  if (!_player->m_SummonSlot[slotId])
443  return;
444 
445  Creature* totem = GetPlayer()->GetMap()->GetCreature(_player->m_SummonSlot[slotId]);
446  if (totem && totem->IsTotem() && totem->GetGUID() == totemDestroyed.TotemGUID)
447  totem->ToTotem()->UnSummon();
448 }
void UnSummon(uint32 msTime=0) override
Definition: Totem.cpp:98
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
ObjectGuid TotemGUID
Definition: TotemPackets.h:35
Totem * ToTotem()
Definition: Unit.h:2203
#define SUMMON_SLOT_TOTEM
Definition: Unit.h:1281
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Player * _player
Definition: WorldSession.h:1797
bool IsTotem() const
Definition: Unit.h:1405
uint8_t uint8
Definition: Define.h:152
uint8 Slot
Definition: TotemPackets.h:36
#define MAX_TOTEM_SLOT
Definition: Unit.h:1282

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleToySetFavorite ( WorldPackets::Toy::ToySetFavorite packet)
76 {
77  _collectionMgr->ToySetFavorite(packet.ItemID, packet.Favorite);
78 }
std::unique_ptr< CollectionMgr > _collectionMgr
Definition: WorldSession.h:1845
bool Favorite
Definition: ToyPackets.h:70
uint32 ItemID
Definition: ToyPackets.h:69

+ Here is the caller graph for this function:

void WorldSession::HandleTrainerBuySpellOpcode ( WorldPackets::NPC::TrainerBuySpell packet)
190 {
191  TC_LOG_DEBUG("network", "WORLD: Received CMSG_TRAINER_BUY_SPELL %s, learn spell id is: %i", packet.TrainerGUID.ToString().c_str(), packet.SpellID);
192 
193  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(packet.TrainerGUID, UNIT_NPC_FLAG_TRAINER);
194  if (!unit)
195  {
196  TC_LOG_DEBUG("network", "WORLD: HandleTrainerBuySpellOpcode - %s not found or you can not interact with him.", packet.TrainerGUID.ToString().c_str());
197  return;
198  }
199 
200  // remove fake death
201  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
202  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
203 
204  // check present spell in trainer spell list
205  TrainerSpellData const* trainer_spells = unit->GetTrainerSpells();
206  if (!trainer_spells)
207  {
208  SendTrainerBuyFailed(packet.TrainerGUID, packet.SpellID, 0);
209  return;
210  }
211 
212  // not found, cheat?
213  TrainerSpell const* trainerSpell = trainer_spells->Find(packet.SpellID);
214  if (!trainerSpell)
215  {
216  SendTrainerBuyFailed(packet.TrainerGUID, packet.SpellID, 0);
217  return;
218  }
219 
220  // can't be learn, cheat? Or double learn with lags...
221  if (_player->GetTrainerSpellState(trainerSpell) != TRAINER_SPELL_GREEN)
222  {
223  SendTrainerBuyFailed(packet.TrainerGUID, packet.SpellID, 0);
224  return;
225  }
226 
227  // apply reputation discount
228  uint32 nSpellCost = uint32(floor(trainerSpell->MoneyCost * _player->GetReputationPriceDiscount(unit)));
229 
230  // check money requirement
231  if (!_player->HasEnoughMoney(uint64(nSpellCost)))
232  {
233  SendTrainerBuyFailed(packet.TrainerGUID, packet.SpellID, 1);
234  return;
235  }
236 
237  _player->ModifyMoney(-int64(nSpellCost));
238 
239  unit->SendPlaySpellVisualKit(179, 0); // 53 SpellCastDirected
240  _player->SendPlaySpellVisualKit(362, 1); // 113 EmoteSalute
241 
242  // learn explicitly or cast explicitly
243  if (trainerSpell->IsCastable())
244  _player->CastSpell(_player, trainerSpell->SpellID, true);
245  else
246  _player->LearnSpell(packet.SpellID, false);
247 }
static Vector3int16 floor(const Vector3 &v)
Definition: Unit.h:739
int32 SpellID
Definition: NPCPackets.h:229
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendTrainerBuyFailed(ObjectGuid trainerGUID, uint32 spellID, int32 trainerFailedReason)
Definition: NPCHandler.cpp:249
Definition: Player.h:297
Definition: Creature.h:424
TrainerSpell const * Find(uint32 spell_id) const
Definition: Creature.cpp:53
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
int64_t int64
Definition: g3dmath.h:169
uint32 SpellID
Definition: Creature.h:432
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
Definition: Creature.h:445
uint32_t uint32
Definition: g3dmath.h:168
ObjectGuid TrainerGUID
Definition: NPCPackets.h:227
bool IsCastable() const
Definition: Creature.h:440
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 MoneyCost
Definition: Creature.h:433

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTrainerListOpcode ( WorldPackets::NPC::Hello packet)
87 {
88  SendTrainerList(packet.Unit);
89 }
void SendTrainerList(ObjectGuid guid)
Definition: NPCHandler.cpp:91
ObjectGuid Unit
Definition: NPCPackets.h:45

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTransmogrifyItems ( WorldPackets::Item::TransmogrifyItems transmogrifyItems)
1103 {
1104  Player* player = GetPlayer();
1105  // Validate
1106  if (!player->GetNPCIfCanInteractWith(transmogrifyItems.Npc, UNIT_NPC_FLAG_TRANSMOGRIFIER))
1107  {
1108  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - %s not found or player can't interact with it.", transmogrifyItems.Npc.ToString().c_str());
1109  return;
1110  }
1111 
1112  int64 cost = 0;
1113  std::unordered_map<Item*, Item*> transmogItems;
1114  std::unordered_map<Item*, std::pair<VoidStorageItem*, BonusData>> transmogVoidItems;
1115  std::vector<Item*> resetAppearanceItems;
1116 
1117  for (WorldPackets::Item::TransmogrifyItem const& transmogItem : transmogrifyItems.Items)
1118  {
1119  // slot of the transmogrified item
1120  if (transmogItem.Slot >= EQUIPMENT_SLOT_END)
1121  {
1122  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify wrong slot (%u) when transmogrifying items.", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.Slot);
1123  return;
1124  }
1125 
1126  // transmogrified item
1127  Item* itemTransmogrified = player->GetItemByPos(INVENTORY_SLOT_BAG_0, transmogItem.Slot);
1128  if (!itemTransmogrified)
1129  {
1130  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify an invalid item in a valid slot (slot: %u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.Slot);
1131  return;
1132  }
1133  if (player->CanUseItem(itemTransmogrified->GetTemplate()) != EQUIP_ERR_OK)
1134  {
1135  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify an unequippable item in a valid slot (slot: %u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.Slot);
1136  return;
1137  }
1138 
1139  WorldPackets::Item::ItemInstance itemInstance;
1140  BonusData const* bonus = nullptr;
1141  if (transmogItem.SrcItemGUID)
1142  {
1143  // guid of the transmogrifier item
1144  Item* itemTransmogrifier = player->GetItemByGuid(*transmogItem.SrcItemGUID);
1145  if (!itemTransmogrifier)
1146  {
1147  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcItemGUID->ToString().c_str());
1148  return;
1149  }
1150  if (player->CanUseItem(itemTransmogrifier->GetTemplate()) != EQUIP_ERR_OK)
1151  {
1152  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an unequippable item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcItemGUID->ToString().c_str());
1153  return;
1154  }
1155 
1156  itemInstance.Initialize(itemTransmogrifier);
1157  bonus = itemTransmogrifier->GetBonus();
1158  transmogItems[itemTransmogrified] = itemTransmogrifier;
1159  }
1160  else if (transmogItem.SrcVoidItemGUID)
1161  {
1162  // guid of the transmogrifier item
1163  uint8 slot;
1164  VoidStorageItem* itemTransmogrifier = player->GetVoidStorageItem(transmogItem.SrcVoidItemGUID->GetCounter(), slot);
1165  if (!itemTransmogrifier)
1166  {
1167  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid void storage item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcVoidItemGUID->ToString().c_str());
1168  return;
1169  }
1170  ItemTemplate const * transmogrifierTemplate = sObjectMgr->GetItemTemplate(itemTransmogrifier->ItemEntry);
1171  if (player->CanUseItem(transmogrifierTemplate) != EQUIP_ERR_OK)
1172  {
1173  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an unequippable void storage item (%s).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcVoidItemGUID->ToString().c_str());
1174  return;
1175  }
1176 
1177  itemInstance.Initialize(itemTransmogrifier);
1178  std::pair<VoidStorageItem*, BonusData>& transmogData = transmogVoidItems[itemTransmogrified];
1179  transmogData.first = itemTransmogrifier;
1180  transmogData.second.Initialize(itemInstance);
1181  bonus = &transmogData.second;
1182  }
1183  else
1184  {
1185  resetAppearanceItems.push_back(itemTransmogrified);
1186  continue;
1187  }
1188 
1189  // entry of transmogrifier and from packet
1190  if (itemInstance != transmogItem.Item)
1191  {
1192  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) tried to transmogrify with an invalid item instance data for %s.", player->GetGUID().ToString().c_str(), player->GetName().c_str(), transmogItem.SrcItemGUID->ToString().c_str());
1193  return;
1194  }
1195 
1196  // validity of the transmogrification items
1197  if (!Item::CanTransmogrifyItemWithItem(itemTransmogrified, transmogItem.Item, bonus))
1198  {
1199  TC_LOG_DEBUG("network", "WORLD: HandleTransmogrifyItems - Player (%s, name: %s) failed CanTransmogrifyItemWithItem (%u with %u).", player->GetGUID().ToString().c_str(), player->GetName().c_str(), itemTransmogrified->GetEntry(), transmogItem.Item.ItemID);
1200  return;
1201  }
1202 
1203  // add cost
1204  cost += itemTransmogrified->GetSpecialPrice();
1205  }
1206 
1207  if (cost) // 0 cost if reverting look
1208  {
1209  if (!player->HasEnoughMoney(cost))
1210  return;
1211  player->ModifyMoney(-cost);
1212  }
1213 
1214  // Everything is fine, proceed
1215  for (auto& transmogPair : transmogItems)
1216  {
1217  Item* transmogrified = transmogPair.first;
1218  Item* transmogrifier = transmogPair.second;
1219 
1220  transmogrified->SetModifier(ITEM_MODIFIER_TRANSMOG_ITEM_ID, transmogrifier->GetEntry());
1221  transmogrified->SetModifier(ITEM_MODIFIER_TRANSMOG_APPEARANCE_MOD, transmogrifier->GetAppearanceModId());
1222  player->SetVisibleItemSlot(transmogrified->GetSlot(), transmogrified);
1223 
1224  transmogrified->SetNotRefundable(player);
1225  transmogrified->ClearSoulboundTradeable(player);
1226 
1227  transmogrifier->SetNotRefundable(player);
1228  transmogrifier->ClearSoulboundTradeable(player);
1229 
1230  if (transmogrifier->GetTemplate()->GetBonding() == BIND_WHEN_EQUIPED || transmogrifier->GetTemplate()->GetBonding() == BIND_WHEN_USE)
1231  transmogrifier->SetBinding(true);
1232  }
1233 
1234  for (auto& transmogVoirPair : transmogVoidItems)
1235  {
1236  Item* transmogrified = transmogVoirPair.first;
1237  VoidStorageItem* transmogrifier = transmogVoirPair.second.first;
1238  BonusData& bonus = transmogVoirPair.second.second;
1239 
1240  transmogrified->SetModifier(ITEM_MODIFIER_TRANSMOG_ITEM_ID, transmogrifier->ItemEntry);
1242  player->SetVisibleItemSlot(transmogrified->GetSlot(), transmogrified);
1243 
1244  transmogrified->SetNotRefundable(player);
1245  transmogrified->ClearSoulboundTradeable(player);
1246  }
1247 
1248  for (Item* item : resetAppearanceItems)
1249  {
1250  item->SetModifier(ITEM_MODIFIER_TRANSMOG_ITEM_ID, 0);
1251  item->SetModifier(ITEM_MODIFIER_TRANSMOG_APPEARANCE_MOD, 0);
1252  player->SetVisibleItemSlot(item->GetSlot(), item);
1253  }
1254 }
#define INVENTORY_SLOT_BAG_0
void SetBinding(bool val)
Definition: Item.h:276
uint32 GetAppearanceModId() const
Definition: Item.h:394
int64_t int64
Definition: Define.h:145
static bool CanTransmogrifyItemWithItem(Item const *transmogrified, WorldPackets::Item::ItemInstance const &transmogrifier, BonusData const *bonus)
Definition: Item.cpp:1492
Definition: ItemPackets.h:471
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 Slot
Definition: ItemPackets.h:476
#define sObjectMgr
Definition: ObjectMgr.h:1567
Optional< ObjectGuid > SrcItemGUID
Definition: ItemPackets.h:473
static uint32 GetSpecialPrice(ItemTemplate const *proto, uint32 minimumPrice=10000)
Definition: Item.cpp:1661
Optional< ObjectGuid > SrcVoidItemGUID
Definition: ItemPackets.h:474
void ClearSoulboundTradeable(Player *currentOwner)
Definition: Item.cpp:1309
Definition: Item.h:48
Definition: Item.h:225
ItemInstance Item
Definition: ItemPackets.h:475
Definition: Unit.h:763
Definition: ItemTemplate.h:121
Definition: ItemTemplate.h:122
Definition: Item.h:259
void SetModifier(ItemModifier modifier, uint32 value)
Definition: Item.cpp:1909
uint8 GetSlot() const
Definition: Item.h:329
BonusData const * GetBonus() const
Definition: Item.h:270
Definition: Item.h:240
ItemBondingType GetBonding() const
Definition: ItemTemplate.h:683
uint32 AppearanceModID
Definition: Item.h:250
void SetNotRefundable(Player *owner, bool changestate=true, SQLTransaction *trans=NULL)
Definition: Item.cpp:1241
Definition: ItemTemplate.h:647
ObjectGuid Npc
Definition: ItemPackets.h:491
void Initialize(::Item const *item)
Definition: ItemPackets.cpp:248
uint8_t uint8
Definition: Define.h:152
Array< TransmogrifyItem, MAX_TRANSMOGRIFY_ITEMS > Items
Definition: ItemPackets.h:492
uint32 GetEntry() const
Definition: Object.h:107
Definition: ItemPackets.h:40
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 ItemID
Definition: ItemPackets.h:46
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTurnInPetition ( WorldPackets::Petition::TurnInPetition packet)
444 {
445  // Check if player really has the required petition charter
446  Item* item = _player->GetItemByGuid(packet.Item);
447  if (!item)
448  return;
449 
450  TC_LOG_DEBUG("network", "Petition %s turned in by %s", packet.Item.ToString().c_str(), _player->GetGUID().ToString().c_str());
451 
452  // Get petition data from db
453  ObjectGuid ownerguid;
454  std::string name;
455 
457  stmt->setUInt64(0, packet.Item.GetCounter());
459 
460  if (result)
461  {
462  Field* fields = result->Fetch();
463  ownerguid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
464  name = fields[1].GetString();
465  }
466  else
467  {
468  TC_LOG_ERROR("network", "Player %s (%s) tried to turn in petition (%s) that is not present in the database", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.Item.ToString().c_str());
469  return;
470  }
471 
472  // Only the petition owner can turn in the petition
473  if (_player->GetGUID() != ownerguid)
474  return;
475 
476  // Check if player is already in a guild
477  if (_player->GetGuildId())
478  {
481  _player->GetSession()->SendPacket(resultPacket.Write());
482  return;
483  }
484 
485  // Check if guild name is already taken
486  if (sGuildMgr->GetGuildByName(name))
487  {
489  return;
490  }
491 
492  // Get petition signatures from db
493  uint8 signatures;
494 
496  stmt->setUInt64(0, packet.Item.GetCounter());
497  result = CharacterDatabase.Query(stmt);
498 
499  if (result)
500  signatures = uint8(result->GetRowCount());
501  else
502  signatures = 0;
503 
504  uint32 requiredSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
505 
506  // Notify player if signatures are missing
507  if (signatures < requiredSignatures)
508  {
511  SendPacket(resultPacket.Write());
512  return;
513  }
514 
515  // Proceed with guild creation
516 
517  // Delete charter item
518  _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
519 
520  // Create guild
521  Guild* guild = new Guild;
522 
523  if (!guild->Create(_player, name))
524  {
525  delete guild;
526  return;
527  }
528 
529  // Register guild and add guild master
530  sGuildMgr->AddGuild(guild);
531 
533 
534  // Add members from signatures
535  for (uint8 i = 0; i < signatures; ++i)
536  {
537  Field* fields = result->Fetch();
538  guild->AddMember(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64()));
539 
540  // Checking the return value just to be double safe
541  if (!result->NextRow())
542  break;
543  }
544 
546 
548  stmt->setUInt64(0, packet.Item.GetCounter());
549  trans->Append(stmt);
550 
552  stmt->setUInt64(0, packet.Item.GetCounter());
553  trans->Append(stmt);
554 
556 
557  // created
558  TC_LOG_DEBUG("network", "Player %s (%s) turning in petition %s", _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), packet.Item.ToString().c_str());
559 
561  resultPacket.Result = int32(PETITION_TURN_OK);
562  SendPacket(resultPacket.Write());
563 }
static void SendCommandResult(WorldSession *session, GuildCommandType type, GuildCommandError errCode, std::string const &param="")
Definition: Guild.cpp:53
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Definition: Guild.h:131
#define sGuildMgr
Definition: GuildMgr.h:61
Class used to access individual fields of database query result.
Definition: Field.h:56
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: World.h:257
Definition: PetitionPackets.h:189
#define sWorld
Definition: World.h:887
Definition: Guild.h:161
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
ObjectGuid Item
Definition: PetitionPackets.h:186
Definition: CharacterDatabase.h:264
bool Create(Player *pLeader, std::string const &name)
Definition: Guild.cpp:1078
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
Definition: Guild.h:162
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
bool AddMember(ObjectGuid guid, uint8 rankId=GUILD_RANK_NONE)
Definition: Guild.cpp:2560
uint8 GetSlot() const
Definition: Item.h:329
uint8_t uint8
Definition: g3dmath.h:164
WorldPacket const * Write() override
Definition: PetitionPackets.cpp:151
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Player * _player
Definition: WorldSession.h:1797
Definition: Guild.h:104
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
Definition: CharacterDatabase.h:427
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:189
Definition: CharacterDatabase.h:265
Definition: Guild.h:160
Definition: Guild.h:320
Definition: Guild.h:124
std::string GetString() const
Definition: Field.h:276
uint8 GetBagSlot() const
Definition: Item.cpp:759
Definition: CharacterDatabase.h:428
std::string ToString() const
Definition: ObjectGuid.cpp:99
int32 Result
Definition: PetitionPackets.h:196
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleTutorialFlag ( WorldPackets::Misc::TutorialSetFlag packet)
1199 {
1200  switch (packet.Action)
1201  {
1203  {
1204  uint8 index = uint8(packet.TutorialBit >> 5);
1205  if (index >= MAX_ACCOUNT_TUTORIAL_VALUES)
1206  {
1207  TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received bad TutorialBit %u.", packet.TutorialBit);
1208  return;
1209  }
1210  uint32 flag = GetTutorialInt(index);
1211  flag |= (1 << (packet.TutorialBit & 0x1F));
1212  SetTutorialInt(index, flag);
1213  break;
1214  }
1215  case TUTORIAL_ACTION_CLEAR:
1216  for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
1217  SetTutorialInt(i, 0xFFFFFFFF);
1218  break;
1219  case TUTORIAL_ACTION_RESET:
1220  for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
1221  SetTutorialInt(i, 0x00000000);
1222  break;
1223  default:
1224  TC_LOG_ERROR("network", "CMSG_TUTORIAL_FLAG received unknown TutorialAction %u.", packet.Action);
1225  return;
1226  }
1227 }
Definition: WorldSession.h:743
uint32 TutorialBit
Definition: MiscPackets.h:229
uint32 GetTutorialInt(uint8 index) const
Definition: WorldSession.h:1005
uint32_t uint32
Definition: Define.h:150
uint8 Action
Definition: MiscPackets.h:228
void SetTutorialInt(uint8 index, uint32 value)
Definition: WorldSession.h:1006
uint8_t uint8
Definition: g3dmath.h:164
uint8_t uint8
Definition: Define.h:152
#define MAX_ACCOUNT_TUTORIAL_VALUES
Definition: WorldSession.h:773
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: WorldSession.h:744
Definition: WorldSession.h:742

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUITimeRequest ( WorldPackets::Misc::UITimeRequest )
1024 {
1025  WorldPackets::Misc::UITime response;
1026  response.Time = time(NULL);
1027  SendPacket(response.Write());
1028 }
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 Time
UnixTime.
Definition: MiscPackets.h:205
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: MiscPackets.cpp:119
Definition: MiscPackets.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUnacceptTradeOpcode ( WorldPackets::Trade::UnacceptTrade unacceptTrade)
532 {
533  TradeData* my_trade = _player->GetTradeData();
534  if (!my_trade)
535  return;
536 
537  my_trade->SetAccepted(false, true);
538 }
Definition: TradeData.h:34
Player * _player
Definition: WorldSession.h:1797
void SetAccepted(bool state, bool forTrader=false)
Definition: TradeData.cpp:132

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUndeleteCooldownStatusCallback ( PreparedQueryResult  result)
2316 {
2318  {
2319  case 0:
2320  {
2322  stmt->setUInt32(0, GetBattlenetAccountId());
2323 
2327  break;
2328  }
2329  case 1:
2330  {
2331  uint32 cooldown = 0;
2333  if (result)
2334  {
2335  uint32 lastUndelete = result->Fetch()[0].GetUInt32();
2336  uint32 now = uint32(time(nullptr));
2337  if (lastUndelete + maxCooldown > now)
2338  cooldown = std::max<uint32>(0, lastUndelete + maxCooldown - now);
2339  }
2340 
2341  SendUndeleteCooldownStatusResponse(cooldown, maxCooldown);
2343  break;
2344  }
2345  }
2346 
2347 }
QueryCallback< PreparedQueryResult, bool, true > _undeleteCooldownStatusCallback
Definition: WorldSession.h:1742
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
Definition: LoginDatabase.h:132
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void NextStage()
Advances the callback chain to the next stage, so upper level code can act on its results accordingly...
Definition: Callback.h:83
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
uint8 GetStage()
Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid)
Definition: Callback.h:92
void Reset()
Resets all underlying variables (param, result and stage)
Definition: Callback.h:98
void SendUndeleteCooldownStatusResponse(uint32 currentCooldown, uint32 maxCooldown)
Definition: CharacterHandler.cpp:2562
uint32_t uint32
Definition: g3dmath.h:168
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
void FreeResult()
Definition: Callback.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUnlearnSkillOpcode ( WorldPackets::Spells::UnlearnSkill packet)
73 {
74  SkillRaceClassInfoEntry const* rcEntry = GetSkillRaceClassInfo(packet.SkillLine, GetPlayer()->getRace(), GetPlayer()->getClass());
75  if (!rcEntry || !(rcEntry->Flags & SKILL_FLAG_UNLEARNABLE))
76  return;
77 
78  GetPlayer()->SetSkill(packet.SkillLine, 0, 0, 0);
79 }
Definition: DBCEnums.h:613
uint32 SkillLine
Definition: SpellPackets.h:736
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 Flags
Definition: DBCStructure.h:988
Definition: DBCStructure.h:982
SkillRaceClassInfoEntry const * GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_)
Definition: DBCStores.cpp:845

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUnregisterAllAddonPrefixesOpcode ( WorldPackets::Chat::ChatUnregisterAllAddonPrefixes packet)
918 {
919  _registeredAddonPrefixes.clear();
920 }
std::vector< std::string > _registeredAddonPrefixes
Definition: WorldSession.h:1833

+ Here is the caller graph for this function:

void WorldSession::HandleUnstablePet ( WorldPacket recvPacket)
628 {
629  ObjectGuid npcGUID;
630  uint32 petnumber;
631 
632  recvData >> npcGUID >> petnumber;
633 
634  if (!CheckStableMaster(npcGUID))
635  {
637  return;
638  }
639 
640  // remove fake death
641  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
642  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
643 
645 
646  stmt->setUInt64(0, _player->GetGUID().GetCounter());
647  stmt->setUInt32(1, petnumber);
650 
651  _unstablePetCallback.SetParam(petnumber);
653 }
void SetParam(ParamType value)
Definition: Callback.h:63
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Player * GetPlayer() const
Definition: WorldSession.h:927
QueryCallback< PreparedQueryResult, uint32 > _unstablePetCallback
Definition: WorldSession.h:1735
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:546
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
Definition: PetDefines.h:36
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
bool CheckStableMaster(ObjectGuid guid)
Definition: PetHandler.cpp:434
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
Definition: PetDefines.h:37
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

void WorldSession::HandleUnstablePetCallback ( PreparedQueryResult  result,
uint32  petId 
)
656 {
657  if (!GetPlayer())
658  return;
659 
660  uint32 petEntry = 0;
661  if (result)
662  {
663  Field* fields = result->Fetch();
664  petEntry = fields[0].GetUInt32();
665  }
666 
667  if (!petEntry)
668  {
670  return;
671  }
672 
673  CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(petEntry);
674  if (!creatureInfo || !creatureInfo->IsTameable(_player->CanTameExoticPets()))
675  {
676  // if problem in exotic pet
677  if (creatureInfo && creatureInfo->IsTameable(true))
679  else
681  return;
682  }
683 
684  Pet* pet = _player->GetPet();
685  if (pet && pet->IsAlive())
686  {
688  return;
689  }
690 
691  // delete dead pet
692  if (pet)
693  _player->RemovePet(pet, PET_SAVE_AS_DELETED);
694 
695  Pet* newPet = new Pet(_player, HUNTER_PET);
696  if (!newPet->LoadPetFromDB(_player, petEntry, petId))
697  {
698  delete newPet;
699  newPet = NULL;
701  return;
702  }
703 
705 }
Class used to access individual fields of database query result.
Definition: Field.h:56
arena_t NULL
Definition: jemalloc_internal.h:624
void SendPetStableResult(uint8 guid)
Definition: NPCHandler.cpp:547
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PetDefines.h:25
Definition: NPCHandler.cpp:52
bool IsAlive() const
Definition: Unit.h:1692
uint32_t uint32
Definition: Define.h:150
Player * _player
Definition: WorldSession.h:1797
bool LoadPetFromDB(Player *owner, uint32 petentry=0, uint32 petnumber=0, bool current=false)
Definition: Pet.cpp:99
uint32 GetUInt32() const
Definition: Field.h:146
Definition: PetDefines.h:34
Definition: NPCHandler.cpp:50
bool IsTameable(bool canTameExotic) const
Definition: Creature.h:167
Definition: Creature.h:79
Definition: Pet.h:46
Definition: NPCHandler.cpp:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUpdateAccountData ( WorldPackets::ClientConfig::UserClientUpdateAccountData packet)
611 {
612  TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA: type %u, time %u, decompressedSize %u",
613  packet.DataType, packet.Time, packet.Size);
614 
615  if (packet.DataType > NUM_ACCOUNT_DATA_TYPES)
616  return;
617 
618  if (packet.Size == 0) // erase
619  {
620  SetAccountData(AccountDataType(packet.DataType), 0, "");
621  return;
622  }
623 
624  if (packet.Size > 0xFFFF)
625  {
626  TC_LOG_ERROR("network", "UAD: Account data packet too big, size %u", packet.Size);
627  return;
628  }
629 
630  ByteBuffer dest;
631  dest.resize(packet.Size);
632 
633  uLongf realSize = packet.Size;
634  if (uncompress(dest.contents(), &realSize, packet.CompressedData.contents(), packet.CompressedData.size()) != Z_OK)
635  {
636  TC_LOG_ERROR("network", "UAD: Failed to decompress account data");
637  return;
638  }
639 
640  std::string adata;
641  dest >> adata;
642 
643  SetAccountData(AccountDataType(packet.DataType), packet.Time, adata);
644 }
ByteBuffer CompressedData
Definition: ClientConfigPackets.h:100
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: ByteBuffer.h:70
void resize(size_t newsize)
Definition: ByteBuffer.h:590
uint32 Size
decompressed size
Definition: ClientConfigPackets.h:98
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetAccountData(AccountDataType type, uint32 time, std::string const &data)
Definition: WorldSession.cpp:757
size_t size() const
Definition: ByteBuffer.h:587
AccountDataType
Definition: WorldSession.h:723
uLong FAR uLongf
Definition: zconf.h:382
uint8 DataType
Definition: ClientConfigPackets.h:99
#define Z_OK
Definition: zlib.h:173
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
#define NUM_ACCOUNT_DATA_TYPES
Definition: WorldSession.h:735
uint32 Time
UnixTime.
Definition: ClientConfigPackets.h:97

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUpdateListedAuctionableTokens ( WorldPackets::Token::UpdateListedAuctionableTokens updateListedAuctionableTokens)
Todo:
: 6.x fix implementation
22 {
24 
26  response.UnkInt = updateListedAuctionableTokens.UnkInt;
27  response.Result = TOKEN_RESULT_SUCCESS;
28 
29  SendPacket(response.Write());
30 }
uint32 UnkInt
Definition: TokenPackets.h:34
WorldPacket const * Write() override
Definition: TokenPackets.cpp:25
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: SharedDefines.h:4886

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUpdateMissileTrajectory ( WorldPackets::Spells::UpdateMissileTrajectory packet)
580 {
581  Unit* caster = ObjectAccessor::GetUnit(*_player, packet.Guid);
582  Spell* spell = caster ? caster->GetCurrentSpell(CURRENT_GENERIC_SPELL) : NULL;
583  if (!spell || spell->m_spellInfo->Id != uint32(packet.SpellID) || !spell->m_targets.HasDst() || !spell->m_targets.HasSrc())
584  return;
585 
586  Position pos = *spell->m_targets.GetSrcPos();
587  pos.Relocate(packet.FirePos);
588  spell->m_targets.ModSrc(pos);
589 
590  pos = *spell->m_targets.GetDstPos();
591  pos.Relocate(packet.ImpactPos);
592  spell->m_targets.ModDst(pos);
593 
594  spell->m_targets.SetPitch(packet.Pitch);
595  spell->m_targets.SetSpeed(packet.Speed);
596 
597  if (packet.Status.is_initialized())
598  {
599  GetPlayer()->ValidateMovementInfo(packet.Status.get_ptr());
600  /*uint32 opcode;
601  recvPacket >> opcode;
602  recvPacket.SetOpcode(CMSG_MOVE_STOP); // always set to CMSG_MOVE_STOP in client SetOpcode
603  //HandleMovementOpcodes(recvPacket);*/
604  }
605 }
SpellInfo const *const m_spellInfo
Definition: Spell.h:547
Definition: Unit.h:1109
uint32 Id
Definition: SpellInfo.h:329
int32 SpellID
Definition: SpellPackets.h:863
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:163
float Speed
Definition: SpellPackets.h:865
G3D::Vector3 ImpactPos
Definition: SpellPackets.h:867
SpellCastTargets m_targets
Definition: Spell.h:584
G3D::Vector3 FirePos
Definition: SpellPackets.h:866
arena_t NULL
Definition: jemalloc_internal.h:624
WorldLocation const * GetDstPos() const
Definition: Spell.cpp:372
Player * GetPlayer() const
Definition: WorldSession.h:927
bool HasSrc() const
Definition: Spell.h:228
float Pitch
Definition: SpellPackets.h:864
void SetPitch(float pitch)
Definition: Spell.h:233
void ModDst(Position const &pos)
Definition: Spell.cpp:407
void Relocate(float x, float y)
Definition: Position.h:67
bool HasDst() const
Definition: Spell.h:229
Spell * GetCurrentSpell(CurrentSpellTypes spellType) const
Definition: Unit.h:1920
uint32_t uint32
Definition: Define.h:150
void SetSpeed(float speed)
Definition: Spell.h:235
Player * _player
Definition: WorldSession.h:1797
void ModSrc(Position const &pos)
Definition: Spell.cpp:356
Position const * GetSrcPos() const
Definition: Spell.cpp:333
ObjectGuid Guid
Definition: SpellPackets.h:861
Definition: Position.h:27
Definition: Unit.h:1305
Optional< MovementInfo > Status
Definition: SpellPackets.h:868
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUpdateRaidTargetOpcode ( WorldPackets::Party::UpdateRaidTarget packet)
426 {
427  Group* group = GetPlayer()->GetGroup();
428  if (!group)
429  return;
430 
431  if (packet.Symbol == -1) // target icon request
432  group->SendTargetIconList(this, packet.PartyIndex);
433  else // target icon update
434  {
435  if (group->isRaidGroup() && !group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
436  return;
437 
438  if (packet.Target.IsPlayer())
439  {
441  if (!target || target->IsHostileTo(GetPlayer()))
442  return;
443  }
444 
445  group->SetTargetIcon(packet.Symbol, packet.Target, GetPlayer()->GetGUID(), packet.PartyIndex);
446  }
447 }
bool IsPlayer() const
Definition: ObjectGuid.h:249
bool isRaidGroup() const
Definition: Group.cpp:2509
void SetTargetIcon(uint8 symbol, ObjectGuid target, ObjectGuid changedBy, uint8 partyIndex)
Definition: Group.cpp:1533
Player * GetPlayer() const
Definition: WorldSession.h:927
int8 PartyIndex
Definition: PartyPackets.h:304
bool IsLeader(ObjectGuid guid) const
Definition: Group.cpp:2571
int8 Symbol
Definition: PartyPackets.h:306
ObjectGuid Target
Definition: PartyPackets.h:305
void SendTargetIconList(WorldSession *session, int8 partyIndex=0)
Definition: Group.cpp:1554
bool IsAssistant(ObjectGuid guid) const
Definition: Group.cpp:2584
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUseCritterItem ( WorldPackets::Item::UseCritterItem packet)
1275 {
1276  Item* item = _player->GetItemByGuid(useCritterItem.ItemGuid);
1277  if (!item)
1278  return;
1279 
1280  ItemToBattlePetSpeciesEntry const* itemToBattlePetSpecies = sItemToBattlePetSpeciesStore.LookupEntry(item->GetEntry());
1281  if (!itemToBattlePetSpecies)
1282  return;
1283 
1284  BattlePetSpeciesEntry const* battlePetSpecies = sBattlePetSpeciesStore.LookupEntry(itemToBattlePetSpecies->BattlePetSpeciesID);
1285  if (!battlePetSpecies)
1286  return;
1287 
1288  GetBattlePetMgr()->AddPet(battlePetSpecies->ID, battlePetSpecies->CreatureID, BattlePetMgr::RollPetBreed(battlePetSpecies->ID), BattlePetMgr::GetDefaultPetQuality(battlePetSpecies->ID));
1289  _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
1290 }
Definition: DB2Structure.h:89
void AddPet(uint32 species, uint32 creatureId, uint16 breed, uint8 quality, uint16 level=1)
Definition: BattlePetMgr.cpp:310
Definition: DB2Structure.h:876
uint32 ID
Definition: DB2Structure.h:91
DB2Storage< BattlePetSpeciesEntry > sBattlePetSpeciesStore("BattlePetSpecies.db2", BattlePetSpeciesFormat, HOTFIX_SEL_BATTLE_PET_SPECIES)
static uint16 RollPetBreed(uint32 species)
Definition: BattlePetMgr.cpp:154
uint32 BattlePetSpeciesID
Definition: DB2Structure.h:879
Definition: Item.h:259
BattlePetMgr * GetBattlePetMgr() const
Definition: WorldSession.h:1089
uint8 GetSlot() const
Definition: Item.h:329
Player * _player
Definition: WorldSession.h:1797
DB2Storage< ItemToBattlePetSpeciesEntry > sItemToBattlePetSpeciesStore("ItemToBattlePetSpecies.db2", ItemToBattlePetSpeciesFormat, HOTFIX_SEL_ITEM_TO_BATTLE_PET_SPECIES)
static uint8 GetDefaultPetQuality(uint32 species)
Definition: BattlePetMgr.cpp:163
uint32 CreatureID
Definition: DB2Structure.h:92
uint32 GetEntry() const
Definition: Object.h:107
uint8 GetBagSlot() const
Definition: Item.cpp:759

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUseEquipmentSet ( WorldPackets::EquipmentSet::UseEquipmentSet useEquipmentSet)
1663 {
1664  ObjectGuid ignoredItemGuid;
1665  ignoredItemGuid.SetRawValue(0, 1);
1666 
1667  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
1668  {
1669  TC_LOG_DEBUG("entities.player.items", "%s: ContainerSlot: %u, Slot: %u", useEquipmentSet.Items[i].Item.ToString().c_str(), useEquipmentSet.Items[i].ContainerSlot, useEquipmentSet.Items[i].Slot);
1670 
1671  // check if item slot is set to "ignored" (raw value == 1), must not be unequipped then
1672  if (useEquipmentSet.Items[i].Item == ignoredItemGuid)
1673  continue;
1674 
1675  // Only equip weapons in combat
1676  if (_player->IsInCombat() && i != EQUIPMENT_SLOT_MAINHAND && i != EQUIPMENT_SLOT_OFFHAND)
1677  continue;
1678 
1679  Item* item = _player->GetItemByGuid(useEquipmentSet.Items[i].Item);
1680 
1681  uint16 dstPos = i | (INVENTORY_SLOT_BAG_0 << 8);
1682 
1683  if (!item)
1684  {
1685  Item* uItem = _player->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
1686  if (!uItem)
1687  continue;
1688 
1689  ItemPosCountVec itemPosCountVec;
1690  InventoryResult inventoryResult = _player->CanStoreItem(NULL_BAG, NULL_SLOT, itemPosCountVec, uItem, false);
1691  if (inventoryResult == EQUIP_ERR_OK)
1692  {
1693  _player->RemoveItem(INVENTORY_SLOT_BAG_0, i, true);
1694  _player->StoreItem(itemPosCountVec, uItem, true);
1695  }
1696  else
1697  _player->SendEquipError(inventoryResult, uItem, NULL);
1698  continue;
1699  }
1700 
1701  if (item->GetPos() == dstPos)
1702  continue;
1703 
1704  _player->SwapItem(item->GetPos(), dstPos);
1705  }
1706 
1708  result.Reason = 0; // 4 - equipment swap failed - inventory is full
1709  SendPacket(result.Write());
1710 }
#define INVENTORY_SLOT_BAG_0
WorldPacket const * Write() override
Definition: EquipmentSetPackets.cpp:85
Definition: Unit.h:379
uint16 GetPos() const
Definition: Item.h:333
arena_t NULL
Definition: jemalloc_internal.h:624
uint8 ContainerSlot
Definition: EquipmentSetPackets.h:79
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:48
ObjectGuid Item
Definition: EquipmentSetPackets.h:78
Definition: Unit.h:378
Definition: Item.h:259
void SetRawValue(std::vector< uint8 > const &guid)
Definition: ObjectGuid.cpp:134
uint16_t uint16
Definition: Define.h:151
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: EquipmentSetPackets.h:87
uint8 Slot
Definition: EquipmentSetPackets.h:80
Player * _player
Definition: WorldSession.h:1797
uint8_t uint8
Definition: Define.h:152
uint8 Reason
Definition: EquipmentSetPackets.h:94
Definition: ObjectGuid.h:189
InventoryResult
Definition: Item.h:46
EquipmentSetItem Items[EQUIPMENT_SLOT_END]
Definition: EquipmentSetPackets.h:84
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUseItemOpcode ( WorldPackets::Spells::UseItem packet)
38 {
39  Player* user = _player;
40 
41  // ignore for remote control state
42  if (user->m_mover != user)
43  return;
44 
45  Item* item = user->GetUseableItemByPos(packet.PackSlot, packet.Slot);
46  if (!item)
47  {
48  user->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
49  return;
50  }
51 
52  if (item->GetGUID() != packet.CastItem)
53  {
54  user->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
55  return;
56  }
57 
58  ItemTemplate const* proto = item->GetTemplate();
59  if (!proto)
60  {
61  user->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
62  return;
63  }
64 
65  // some item classes can be used only in equipped state
66  if (proto->GetInventoryType() != INVTYPE_NON_EQUIP && !item->IsEquipped())
67  {
68  user->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
69  return;
70  }
71 
72  InventoryResult msg = user->CanUseItem(item);
73  if (msg != EQUIP_ERR_OK)
74  {
75  user->SendEquipError(msg, item, NULL);
76  return;
77  }
78 
79  // only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
80  if (proto->GetClass() == ITEM_CLASS_CONSUMABLE && !(proto->GetFlags() & ITEM_FLAG_USEABLE_IN_ARENA) && user->InArena())
81  {
82  user->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, item, NULL);
83  return;
84  }
85 
86  // don't allow items banned in arena
87  if (proto->GetFlags() & ITEM_FLAG_NOT_USEABLE_IN_ARENA && user->InArena())
88  {
89  user->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, item, NULL);
90  return;
91  }
92 
93  if (user->IsInCombat())
94  {
95  for (uint32 i = 0; i < proto->Effects.size(); ++i)
96  {
97  if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(proto->Effects[i]->SpellID))
98  {
99  if (!spellInfo->CanBeUsedInCombat())
100  {
101  user->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, item, NULL);
102  return;
103  }
104  }
105  }
106  }
107 
108  // check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory)
110  {
111  if (!item->IsSoulBound())
112  {
113  item->SetState(ITEM_CHANGED, user);
114  item->SetBinding(true);
115  }
116  }
117 
118  SpellCastTargets targets(user, packet.Cast);
119 
120  // Note: If script stop casting it must send appropriate data to client to prevent stuck item in gray state.
121  if (!sScriptMgr->OnItemUse(user, item, targets))
122  {
123  // no script or script not process request by self
124  user->CastItemUseSpell(item, targets, packet.Cast.CastID, packet.Cast.Misc);
125  }
126 }
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
void SetBinding(bool val)
Definition: Item.h:276
Definition: SpellInfo.h:326
bool IsSoulBound() const
Definition: Item.h:277
bool IsEquipped() const
Definition: Item.cpp:764
Definition: ItemTemplate.h:123
SpellCastRequest Cast
Definition: SpellPackets.h:292
uint32 GetClass() const
Definition: ItemTemplate.h:653
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ItemTemplate.h:332
Definition: ItemTemplate.h:120
Definition: Item.h:108
int32 Misc[2]
Definition: SpellPackets.h:258
InventoryType GetInventoryType() const
Definition: ItemTemplate.h:664
uint8 Slot
Definition: SpellPackets.h:290
Definition: Item.h:48
Definition: Item.h:71
std::vector< ItemEffectEntry const * > Effects
Definition: ItemTemplate.h:707
Definition: ItemTemplate.h:122
Definition: Item.h:259
#define sSpellMgr
Definition: SpellMgr.h:756
uint32_t uint32
Definition: Define.h:150
Definition: Spell.h:170
ItemBondingType GetBonding() const
Definition: ItemTemplate.h:683
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Definition: ItemTemplate.h:194
Definition: ItemTemplate.h:647
Player * _player
Definition: WorldSession.h:1797
Definition: ItemTemplate.h:367
uint32 GetFlags() const
Definition: ItemTemplate.h:656
Definition: Item.h:126
#define sScriptMgr
Definition: ScriptMgr.h:837
uint8 PackSlot
Definition: SpellPackets.h:289
Definition: ItemTemplate.h:199
InventoryResult
Definition: Item.h:46
uint8 CastID
Definition: SpellPackets.h:249
ObjectGuid CastItem
Definition: SpellPackets.h:291
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleUseToy ( WorldPackets::Toy::UseToy packet)
49 {
50  ItemTemplate const* item = sObjectMgr->GetItemTemplate(packet.ItemID);
51  if (!item)
52  return;
53 
54  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(packet.Cast.SpellID);
55  if (!spellInfo)
56  {
57  TC_LOG_ERROR("network", "HandleUseToy: unknown spell id: %u used by Toy Item entry %u", packet.Cast.SpellID, packet.ItemID);
58  return;
59  }
60 
61  if (_player->isPossessing())
62  return;
63 
64  SpellCastTargets targets(_player, packet.Cast);
65 
66  Spell* spell = new Spell(_player, spellInfo, TRIGGERED_NONE, ObjectGuid::Empty, false);
67  spell->m_castItemEntry = packet.ItemID;
68  spell->m_cast_count = packet.Cast.CastID;
69  spell->m_misc.Raw.Data[0] = packet.Cast.Misc[0];
70  spell->m_misc.Raw.Data[1] = packet.Cast.Misc[1];
72  spell->prepare(&targets);
73 }
union Spell::@326 m_misc
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: Spell.h:104
Definition: SpellInfo.h:326
int32 SpellID
Definition: SpellPackets.h:250
uint32 ItemID
Definition: ToyPackets.h:48
struct Spell::@326::@328 Raw
uint32 m_castItemEntry
Definition: Spell.h:550
#define sObjectMgr
Definition: ObjectMgr.h:1567
int32 Misc[2]
Definition: SpellPackets.h:258
void prepare(SpellCastTargets const *targets, AuraEffect const *triggeredByAura=NULL)
Definition: Spell.cpp:2860
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: Spell.h:170
Definition: ItemTemplate.h:647
Player * _player
Definition: WorldSession.h:1797
uint32 m_castFlagsEx
Definition: Spell.h:553
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint8 m_cast_count
Definition: Spell.h:552
WorldPackets::Spells::SpellCastRequest Cast
Definition: ToyPackets.h:47
Definition: Unit.h:460
uint8 CastID
Definition: SpellPackets.h:249
Definition: Spell.h:294

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleViolenceLevel ( WorldPackets::Misc::ViolenceLevel violenceLevel)
1059 {
1060  // do something?
1061 }

+ Here is the caller graph for this function:

void WorldSession::HandleVoiceSessionEnable ( WorldPackets::Voice::VoiceSessionEnable packet)
23 {
24 }

+ Here is the caller graph for this function:

void WorldSession::HandleVoidStorageQuery ( WorldPackets::VoidStorage::QueryVoidStorage queryVoidStorage)
54 {
55  Creature* unit = _player->GetNPCIfCanInteractWith(queryVoidStorage.Npc, UNIT_NPC_FLAG_TRANSMOGRIFIER | UNIT_NPC_FLAG_VAULTKEEPER);
56  if (!unit)
57  {
58  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - %s not found or player can't interact with it.", queryVoidStorage.Npc.ToString().c_str());
60  return;
61  }
62 
63  if (!_player->IsVoidStorageUnlocked())
64  {
65  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageQuery - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
67  return;
68  }
69 
70  uint8 count = 0;
71  for (uint8 i = 0; i < VOID_STORAGE_MAX_SLOT; ++i)
72  if (_player->GetVoidStorageItem(i))
73  ++count;
74 
76  voidStorageContents.Items.reserve(VOID_STORAGE_MAX_SLOT);
77 
78  for (uint8 i = 0; i < VOID_STORAGE_MAX_SLOT; ++i)
79  {
80  VoidStorageItem* item = _player->GetVoidStorageItem(i);
81  if (!item)
82  continue;
83 
85  voidItem.Guid = ObjectGuid::Create<HighGuid::Item>(item->ItemId);
86  voidItem.Creator = item->CreatorGuid;
87  voidItem.Slot = i;
88  voidItem.Item.Initialize(item);
89 
90  voidStorageContents.Items.push_back(voidItem);
91  }
92 
93  SendPacket(voidStorageContents.Write());
94 }
WorldPacket const * Write() override
Definition: VoidStoragePackets.cpp:52
WorldPackets::Item::ItemInstance Item
Definition: VoidStoragePackets.h:73
ObjectGuid Creator
Definition: VoidStoragePackets.h:71
uint32 Slot
Definition: VoidStoragePackets.h:72
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: SharedDefines.h:4822
std::vector< VoidItem > Items
Definition: VoidStoragePackets.h:83
ObjectGuid Guid
Definition: VoidStoragePackets.h:70
Definition: Unit.h:763
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ObjectGuid Npc
Definition: VoidStoragePackets.h:55
Player * _player
Definition: WorldSession.h:1797
Definition: VoidStoragePackets.h:68
void Initialize(::Item const *item)
Definition: ItemPackets.cpp:248
uint8_t uint8
Definition: Define.h:152
Definition: VoidStoragePackets.h:76
Definition: VoidStoragePackets.h:58
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:764

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleVoidStorageTransfer ( WorldPackets::VoidStorage::VoidStorageTransfer voidStorageTransfer)
97 {
98  Creature* unit = _player->GetNPCIfCanInteractWith(voidStorageTransfer.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
99  if (!unit)
100  {
101  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s not found or player can't interact with it.", voidStorageTransfer.Npc.ToString().c_str());
102  return;
103  }
104 
105  if (!_player->IsVoidStorageUnlocked())
106  {
107  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
108  return;
109  }
110 
111  if (voidStorageTransfer.Deposits.size() > _player->GetNumOfVoidStorageFreeSlots())
112  {
114  return;
115  }
116 
117  uint32 freeBagSlots = 0;
118  if (!voidStorageTransfer.Withdrawals.empty())
119  {
120  // make this a Player function
121  for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++)
122  if (Bag* bag = _player->GetBagByPos(i))
123  freeBagSlots += bag->GetFreeSlots();
124 
125  for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++)
126  if (!_player->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
127  ++freeBagSlots;
128  }
129 
130  if (voidStorageTransfer.Withdrawals.size() > freeBagSlots)
131  {
133  return;
134  }
135 
136  if (!_player->HasEnoughMoney(uint64(voidStorageTransfer.Deposits.size() * VOID_STORAGE_STORE_ITEM_COST)))
137  {
139  return;
140  }
141 
143  voidStorageTransferChanges.AddedItems.reserve(VOID_STORAGE_MAX_DEPOSIT);
144  voidStorageTransferChanges.RemovedItems.reserve(VOID_STORAGE_MAX_DEPOSIT);
145 
146  uint8 depositCount = 0;
147  for (uint32 i = 0; i < voidStorageTransfer.Deposits.size(); ++i)
148  {
149  Item* item = _player->GetItemByGuid(voidStorageTransfer.Deposits[i]);
150  if (!item)
151  {
152  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s wants to deposit an invalid item (%s).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.Deposits[i].ToString().c_str());
153  continue;
154  }
155 
156  VoidStorageItem itemVS(sObjectMgr->GenerateVoidStorageItemId(), item->GetEntry(), item->GetGuidValue(ITEM_FIELD_CREATOR),
158 
160  voidItem.Guid = ObjectGuid::Create<HighGuid::Item>(itemVS.ItemId);
161  voidItem.Creator = item->GetGuidValue(ITEM_FIELD_CREATOR);
162  voidItem.Item.Initialize(&itemVS);
163  voidItem.Slot = _player->AddVoidStorageItem(std::move(itemVS));
164 
165  voidStorageTransferChanges.AddedItems.push_back(voidItem);
166 
167  _player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
168  ++depositCount;
169  }
170 
171  int64 cost = depositCount * VOID_STORAGE_STORE_ITEM_COST;
172 
173  _player->ModifyMoney(-cost);
174 
175  for (uint32 i = 0; i < voidStorageTransfer.Withdrawals.size(); ++i)
176  {
177  uint8 slot = 0;
178  VoidStorageItem* itemVS = _player->GetVoidStorageItem(voidStorageTransfer.Withdrawals[i].GetCounter(), slot);
179  if (!itemVS)
180  {
181  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s tried to withdraw an invalid item (id: %s)", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.Withdrawals[i].ToString().c_str());
182  continue;
183  }
184 
185  ItemPosCountVec dest;
186  InventoryResult msg = _player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemVS->ItemEntry, 1);
187  if (msg != EQUIP_ERR_OK)
188  {
190  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageTransfer - %s %s couldn't withdraw item id %s because inventory was full.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), voidStorageTransfer.Withdrawals[i].ToString().c_str());
191  return;
192  }
193 
194  Item* item = _player->StoreNewItem(dest, itemVS->ItemEntry, true, itemVS->ItemRandomPropertyId, GuidSet(), itemVS->BonusListIDs);
195  item->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, itemVS->ItemSuffixFactor);
196  item->SetGuidValue(ITEM_FIELD_CREATOR, itemVS->CreatorGuid);
197  item->SetModifier(ITEM_MODIFIER_UPGRADE_ID, itemVS->ItemUpgradeId);
198  item->SetBinding(true);
199 
200  voidStorageTransferChanges.RemovedItems.push_back(ObjectGuid::Create<HighGuid::Item>(itemVS->ItemId));
201 
202  _player->DeleteVoidStorageItem(slot);
203  }
204 
205  SendPacket(voidStorageTransferChanges.Write());
206 
208 }
#define INVENTORY_SLOT_BAG_0
bool empty() const
Definition: PacketUtilities.h:90
Definition: SharedDefines.h:4820
Definition: UpdateFields.h:44
void SetBinding(bool val)
Definition: Item.h:276
Definition: Unit.h:379
uint32 GetItemSuffixFactor() const
Definition: Item.h:343
int64_t int64
Definition: Define.h:145
std::vector< ObjectGuid > RemovedItems
Definition: VoidStoragePackets.h:105
Array< ObjectGuid, VOID_STORAGE_MAX_DEPOSIT > Deposits
Definition: VoidStoragePackets.h:94
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
int32 GetItemRandomPropertyId() const
Definition: Item.h:342
#define sObjectMgr
Definition: ObjectMgr.h:1567
void SendVoidStorageTransferResult(VoidTransferError result)
Definition: VoidStorageHandler.cpp:29
Definition: SharedDefines.h:4834
WorldPacket const * Write() override
Definition: VoidStoragePackets.cpp:78
Definition: SharedDefines.h:4819
std::vector< uint32 > const & GetDynamicValues(uint16 index) const
Definition: Object.cpp:1338
Definition: Item.h:48
Definition: Bag.h:28
std::vector< VoidItem > AddedItems
Definition: VoidStoragePackets.h:106
Definition: Unit.h:378
Definition: SharedDefines.h:4830
ObjectGuid Guid
Definition: VoidStoragePackets.h:70
Definition: SharedDefines.h:4827
Definition: Item.h:259
Definition: UpdateFields.h:64
Definition: UpdateFields.h:51
uint32 GetModifier(ItemModifier modifier) const
Definition: Item.h:440
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
void SetModifier(ItemModifier modifier, uint32 value)
Definition: Item.cpp:1909
uint8 GetSlot() const
Definition: Item.h:329
Definition: SharedDefines.h:4833
Definition: Item.h:226
Player * _player
Definition: WorldSession.h:1797
std::set< ObjectGuid > GuidSet
Definition: ObjectGuid.h:332
Definition: VoidStoragePackets.h:68
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
InventoryResult
Definition: Item.h:46
uint8 GetBagSlot() const
Definition: Item.cpp:759
std::string ToString() const
Definition: ObjectGuid.cpp:99
Array< ObjectGuid, VOID_STORAGE_MAX_WITHDRAW > Withdrawals
Definition: VoidStoragePackets.h:93
Definition: Unit.h:764
size_type size() const
Definition: PacketUtilities.h:89
ObjectGuid Npc
Definition: VoidStoragePackets.h:95

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleVoidStorageUnlock ( WorldPackets::VoidStorage::UnlockVoidStorage unlockVoidStorage)
35 {
36  Creature* unit = _player->GetNPCIfCanInteractWith(unlockVoidStorage.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
37  if (!unit)
38  {
39  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - %s not found or player can't interact with it.", unlockVoidStorage.Npc.ToString().c_str());
40  return;
41  }
42 
43  if (_player->IsVoidStorageUnlocked())
44  {
45  TC_LOG_DEBUG("network", "WORLD: HandleVoidStorageUnlock - Player (%s, name: %s) tried to unlock void storage a 2nd time.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
46  return;
47  }
48 
49  _player->ModifyMoney(-int64(VOID_STORAGE_UNLOCK_COST));
50  _player->UnlockVoidStorage();
51 }
ObjectGuid Npc
Definition: VoidStoragePackets.h:45
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
int64_t int64
Definition: g3dmath.h:169
Player * _player
Definition: WorldSession.h:1797
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:764
Definition: SharedDefines.h:4818

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleVoidSwapItem ( WorldPackets::VoidStorage::SwapVoidItem swapVoidItem)
211 {
212  Creature* unit = _player->GetNPCIfCanInteractWith(swapVoidItem.Npc, UNIT_NPC_FLAG_VAULTKEEPER);
213  if (!unit)
214  {
215  TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s not found or player can't interact with it.", swapVoidItem.Npc.ToString().c_str());
216  return;
217  }
218 
219  if (!_player->IsVoidStorageUnlocked())
220  {
221  TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - Player (%s, name: %s) queried void storage without unlocking it.", _player->GetGUID().ToString().c_str(), _player->GetName().c_str());
222  return;
223  }
224 
225  uint8 oldSlot;
226  if (!_player->GetVoidStorageItem(swapVoidItem.VoidItemGuid.GetCounter(), oldSlot))
227  {
228  TC_LOG_DEBUG("network", "WORLD: HandleVoidSwapItem - %s %s requested swapping an invalid item (slot: %u, itemid: %s).", _player->GetGUID().ToString().c_str(), _player->GetName().c_str(), swapVoidItem.DstSlot, swapVoidItem.VoidItemGuid.ToString().c_str());
229  return;
230  }
231 
232  bool usedDestSlot = _player->GetVoidStorageItem(swapVoidItem.DstSlot) != NULL;
233  ObjectGuid itemIdDest;
234  if (usedDestSlot)
235  itemIdDest = ObjectGuid::Create<HighGuid::Item>(_player->GetVoidStorageItem(swapVoidItem.DstSlot)->ItemId);
236 
237  if (!_player->SwapVoidStorageItem(oldSlot, swapVoidItem.DstSlot))
238  {
240  return;
241  }
242 
244  voidItemSwapResponse.VoidItemA = swapVoidItem.VoidItemGuid;
245  voidItemSwapResponse.VoidItemSlotA = swapVoidItem.DstSlot;
246  if (usedDestSlot)
247  {
248  voidItemSwapResponse.VoidItemB = itemIdDest;
249  voidItemSwapResponse.VoidItemSlotB = oldSlot;
250  }
251 
252  SendPacket(voidItemSwapResponse.Write());
253 }
WorldPacket const * Write() override
Definition: VoidStoragePackets.cpp:102
uint32 VoidItemSlotA
Definition: VoidStoragePackets.h:130
uint32 VoidItemSlotB
Definition: VoidStoragePackets.h:131
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: SharedDefines.h:4828
void SendVoidStorageTransferResult(VoidTransferError result)
Definition: VoidStorageHandler.cpp:29
ObjectGuid VoidItemB
Definition: VoidStoragePackets.h:129
uint32 DstSlot
Definition: VoidStoragePackets.h:118
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
ObjectGuid VoidItemGuid
Definition: VoidStoragePackets.h:117
Definition: VoidStoragePackets.h:121
uint8_t uint8
Definition: Define.h:152
ObjectGuid VoidItemA
Definition: VoidStoragePackets.h:128
ObjectGuid Npc
Definition: VoidStoragePackets.h:116
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Unit.h:764
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleWardenData ( WorldPackets::Warden::WardenData packet)
225 {
226  if (!_warden || packet.Data.empty())
227  return;
228 
229  _warden->DecryptData(packet.Data.contents(), packet.Data.size());
230  uint8 opcode;
231  packet.Data >> opcode;
232  TC_LOG_DEBUG("warden", "Got packet, opcode %02X, size %u", opcode, uint32(packet.Data.size()));
233  packet.Data.hexlike();
234 
235  switch (opcode)
236  {
239  break;
241  _warden->RequestHash();
242  break;
244  _warden->HandleData(packet.Data);
245  break;
247  TC_LOG_DEBUG("warden", "NYI WARDEN_CMSG_MEM_CHECKS_RESULT received!");
248  break;
250  _warden->HandleHashResult(packet.Data);
252  break;
254  TC_LOG_DEBUG("warden", "NYI WARDEN_CMSG_MODULE_FAILED received!");
255  break;
256  default:
257  TC_LOG_DEBUG("warden", "Got unknown warden opcode %02X of size %u.", opcode, uint32(packet.Data.size() - 1));
258  break;
259  }
260 }
Warden * _warden
Definition: WorldSession.h:1817
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: Warden.h:36
virtual void HandleData(ByteBuffer &buff)=0
virtual void RequestHash()=0
virtual void HandleHashResult(ByteBuffer &buff)=0
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Warden.h:35
ByteBuffer Data
Definition: WardenPackets.h:34
void DecryptData(uint8 *buffer, uint32 length)
Definition: Warden.cpp:132
bool empty() const
Definition: ByteBuffer.h:588
size_t size() const
Definition: ByteBuffer.h:587
Definition: Warden.h:33
void SendModuleToClient()
Definition: Warden.cpp:49
void hexlike() const
Definition: ByteBuffer.cpp:82
virtual void InitializeModule()=0
Definition: Warden.h:31
uint8_t uint8
Definition: Define.h:152
uint32_t uint32
Definition: g3dmath.h:168
Definition: Warden.h:32
Definition: Warden.h:34

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleWhoIsOpcode ( WorldPackets::Who::WhoIsRequest packet)
737 {
738  TC_LOG_DEBUG("network", "Received whois command from player %s for character %s",
739  GetPlayer()->GetName().c_str(), packet.CharName.c_str());
740 
742  {
744  return;
745  }
746 
747  if (packet.CharName.empty() || !normalizePlayerName(packet.CharName))
748  {
750  return;
751  }
752 
754  if (!player)
755  {
757  return;
758  }
759 
761  stmt->setUInt32(0, player->GetSession()->GetAccountId());
762 
763  PreparedQueryResult result = LoginDatabase.Query(stmt);
764  if (!result)
765  {
767  return;
768  }
769 
770  Field* fields = result->Fetch();
771  std::string acc = fields[0].GetString();
772  if (acc.empty())
773  acc = "Unknown";
774 
775  std::string email = fields[1].GetString();
776  if (email.empty())
777  email = "Unknown";
778 
779  std::string lastip = fields[2].GetString();
780  if (lastip.empty())
781  lastip = "Unknown";
782 
784  response.AccountName = packet.CharName + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip;
785  SendPacket(response.Write());
786 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
WorldPacket const * Write() override
Definition: WhoPackets.cpp:25
Definition: Language.h:771
Class used to access individual fields of database query result.
Definition: Field.h:56
TC_GAME_API Player * FindConnectedPlayerByName(std::string const &name)
Definition: ObjectAccessor.cpp:240
Definition: WhoPackets.h:39
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string CharName
Definition: WhoPackets.h:36
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:133
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
Definition: Language.h:775
Definition: LoginDatabase.h:92
Definition: Language.h:774
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: Language.h:776
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
std::string GetString() const
Definition: Field.h:276
Definition: RBAC.h:95
std::string AccountName
Definition: WhoPackets.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleWhoOpcode ( WorldPackets::Who::WhoRequestPkt whoRequest)
Todo:
: handle following packet values VirtualRealmNames ShowEnemies ShowArenaPlayers ExactName ServerInfo
78 {
79  WorldPackets::Who::WhoRequest& request = whoRequest.Request;
80 
81  TC_LOG_DEBUG("network", "WorldSession::HandleWhoOpcode: MinLevel: %u, MaxLevel: %u, Name: %s (VirtualRealmName: %s), Guild: %s (GuildVirtualRealmName: %s), RaceFilter: %d, ClassFilter: %d, Areas: " SZFMTD ", Words: " SZFMTD ".",
82  request.MinLevel, request.MaxLevel, request.Name.c_str(), request.VirtualRealmName.c_str(), request.Guild.c_str(), request.GuildVirtualRealmName.c_str(),
83  request.RaceFilter, request.ClassFilter, whoRequest.Areas.size(), request.Words.size());
84 
85  // zones count, client limit = 10 (2.0.10)
86  // can't be received from real client or broken packet
87  if (whoRequest.Areas.size() > 10)
88  return;
89 
90  // user entered strings count, client limit=4 (checked on 2.0.10)
91  // can't be received from real client or broken packet
92  if (request.Words.size() > 4)
93  return;
94 
101 
102  std::vector<std::wstring> wWords;
103  wWords.resize(request.Words.size());
104  for (size_t i = 0; i < request.Words.size(); ++i)
105  {
106  TC_LOG_DEBUG("network", "WorldSession::HandleWhoOpcode: Word: %s", request.Words[i].Word.c_str());
107 
108  // user entered string, it used as universal search pattern(guild+player name)?
109  if (!Utf8toWStr(request.Words[i].Word, wWords[i]))
110  continue;
111 
112  wstrToLower(wWords[i]);
113  }
114 
115  std::wstring wPlayerName;
116  std::wstring wGuildName;
117 
118  if (!(Utf8toWStr(request.Name, wPlayerName) && Utf8toWStr(request.Guild, wGuildName)))
119  return;
120 
121  wstrToLower(wPlayerName);
122  wstrToLower(wGuildName);
123 
124  // client send in case not set max level value 100 but Trinity supports 255 max level,
125  // update it to show GMs with characters after 100 level
126  if (whoRequest.Request.MaxLevel >= MAX_LEVEL)
127  whoRequest.Request.MaxLevel = STRONG_MAX_LEVEL;
128 
129  uint32 team = _player->GetTeam();
130 
131  uint32 gmLevelInWhoList = sWorld->getIntConfig(CONFIG_GM_LEVEL_IN_WHO_LIST);
132 
134 
135  boost::shared_lock<boost::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
136 
138  for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
139  {
140  Player* target = itr->second;
141  // player can see member of other team only if has RBAC_PERM_TWO_SIDE_WHO_LIST
142  if (target->GetTeam() != team && !HasPermission(rbac::RBAC_PERM_TWO_SIDE_WHO_LIST))
143  continue;
144 
145  // player can see MODERATOR, GAME MASTER, ADMINISTRATOR only if has RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS
146  if (target->GetSession()->GetSecurity() > AccountTypes(gmLevelInWhoList) && !HasPermission(rbac::RBAC_PERM_WHO_SEE_ALL_SEC_LEVELS))
147  continue;
148 
149  // do not process players which are not in world
150  if (!target->IsInWorld())
151  continue;
152 
153  // check if target is globally visible for player
154  if (!target->IsVisibleGloballyFor(_player))
155  continue;
156 
157  // check if target's level is in level range
158  uint8 lvl = target->getLevel();
159  if (lvl < request.MinLevel || lvl > request.MaxLevel)
160  continue;
161 
162  // check if class matches classmask
163  if (request.ClassFilter >= 0 && !(request.ClassFilter & (1 << target->getClass())))
164  continue;
165 
166  // check if race matches racemask
167  if (request.RaceFilter >= 0 && !(request.RaceFilter & (1 << target->getRace())))
168  continue;
169 
170  if (!whoRequest.Areas.empty())
171  {
172  if (std::find(whoRequest.Areas.begin(), whoRequest.Areas.end(), target->GetZoneId()) == whoRequest.Areas.end())
173  continue;
174  }
175 
176  std::wstring wTargetName;
177 
178  if (!Utf8toWStr(target->GetName(), wTargetName))
179  continue;
180 
181  wstrToLower(wTargetName);
182 
183  if (!wPlayerName.empty() && wTargetName.find(wPlayerName) == std::wstring::npos)
184  continue;
185 
186  Guild* targetGuild = target->GetGuild();
187  std::wstring wTargetGuildName;
188 
189  if (!Utf8toWStr(targetGuild ? targetGuild->GetName() : "", wTargetGuildName))
190  continue;
191 
192  wstrToLower(wTargetGuildName);
193 
194  if (!wGuildName.empty() && wTargetGuildName.find(wGuildName) == std::wstring::npos)
195  continue;
196 
197  if (!wWords.empty())
198  {
199  std::string aName;
200  if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(target->GetZoneId()))
201  aName = areaEntry->AreaName_lang;
202 
203  bool show = false;
204  for (size_t i = 0; i < wWords.size(); ++i)
205  {
206  if (!wWords[i].empty())
207  {
208  if (wTargetName.find(wWords[i]) != std::wstring::npos ||
209  wTargetGuildName.find(wWords[i]) != std::wstring::npos ||
210  Utf8FitTo(aName, wWords[i]))
211  {
212  show = true;
213  break;
214  }
215  }
216  }
217 
218  if (!show)
219  continue;
220  }
221 
223  if (!whoEntry.PlayerData.Initialize(target->GetGUID(), target))
224  continue;
225 
226  if (targetGuild)
227  {
228  whoEntry.GuildGUID = targetGuild->GetGUID();
230  whoEntry.GuildName = targetGuild->GetName();
231  }
232 
233  whoEntry.AreaID = target->GetZoneId();
234  whoEntry.IsGM = target->IsGameMaster();
235 
236  response.Response.Entries.push_back(whoEntry);
237 
238  // 50 is maximum player count sent to client - can be overridden
239  // through config, but is unstable
240  if (response.Response.Entries.size() >= sWorld->getIntConfig(CONFIG_MAX_WHO))
241  break;
242  }
243 
244  SendPacket(response.Write());
245 }
Definition: DBCStructure.h:37
std::string Guild
Definition: WhoPackets.h:67
std::string GuildVirtualRealmName
Definition: WhoPackets.h:68
Definition: World.h:313
#define SZFMTD
Definition: Define.h:143
Definition: DBCEnums.h:54
std::string const & GetName() const
Definition: Guild.h:766
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.h:306
std::vector< WhoEntry > Entries
Definition: WhoPackets.h:101
bool IsGM
Definition: WhoPackets.h:96
int32 MaxLevel
Definition: WhoPackets.h:64
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
uint32 GuildVirtualRealmAddress
Definition: WhoPackets.h:93
ObjectGuid GuildGUID
Definition: WhoPackets.h:92
std::string GuildName
Definition: WhoPackets.h:94
WhoResponse Response
Definition: WhoPackets.h:111
Definition: WhoPackets.h:89
bool Utf8FitTo(const std::string &str, std::wstring const &search)
Definition: Util.cpp:453
uint32_t uint32
Definition: Define.h:150
AccountTypes
Definition: Common.h:106
int32 RaceFilter
Definition: WhoPackets.h:69
ObjectGuid GetGUID() const
Definition: Guild.h:764
int32 AreaID
Definition: WhoPackets.h:95
Definition: DBCEnums.h:50
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool Initialize(ObjectGuid const &guid, Player const *player=nullptr)
Definition: QueryPackets.cpp:116
int32 ClassFilter
Definition: WhoPackets.h:70
std::string Name
Definition: WhoPackets.h:65
Query::PlayerGuidLookupData PlayerData
Definition: WhoPackets.h:91
WorldPacket const * Write() override
Definition: WhoPackets.cpp:124
std::vector< WhoWord > Words
Definition: WhoPackets.h:71
Definition: World.h:264
Player * _player
Definition: WorldSession.h:1797
std::vector< int32 > Areas
Definition: WhoPackets.h:86
WhoRequest Request
Definition: WhoPackets.h:85
std::string VirtualRealmName
Definition: WhoPackets.h:66
Definition: ObjectAccessor.h:45
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint8_t uint8
Definition: Define.h:152
Definition: WhoPackets.h:61
Definition: WhoPackets.h:104
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Definition: Guild.h:320
int32 MinLevel
Definition: WhoPackets.h:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleWorldTeleportOpcode ( WorldPackets::Misc::WorldTeleport worldTeleport)
719 {
720  if (GetPlayer()->IsInFlight())
721  {
722  TC_LOG_DEBUG("network", "Player '%s' (%s) in flight, ignore worldport command.",
723  GetPlayer()->GetName().c_str(), GetPlayer()->GetGUID().ToString().c_str());
724  return;
725  }
726 
727  TC_LOG_DEBUG("network", "CMSG_WORLD_TELEPORT: Player = %s, map = %u, x = %f, y = %f, z = %f, o = %f",
728  GetPlayer()->GetName().c_str(), worldTeleport.MapID, worldTeleport.Pos.x, worldTeleport.Pos.y, worldTeleport.Pos.z, worldTeleport.Facing);
729 
731  GetPlayer()->TeleportTo(worldTeleport.MapID, worldTeleport.Pos.x, worldTeleport.Pos.y, worldTeleport.Pos.z, worldTeleport.Facing);
732  else
734 }
float x
Definition: Vector3.h:62
uint32 MapID
Definition: MiscPackets.h:757
Definition: Language.h:771
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
float y
Definition: Vector3.h:62
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
string ToString(int i)
Definition: strutil.h:491
TC_GAME_API bool GetName(uint32 accountId, std::string &name)
Definition: BattlenetAccountMgr.cpp:138
float z
Definition: Vector3.h:62
float Facing
Definition: MiscPackets.h:760
G3D::Vector3 Pos
Definition: MiscPackets.h:759
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::HandleWrapItem ( WorldPackets::Item::WrapItem packet)
Todo:
: 6.x find better way for read
725 {
726  if (packet.Inv.Items.size() != 2)
727  {
728  TC_LOG_ERROR("network", "HandleWrapItem - Invalid itemCount (" SZFMTD ")", packet.Inv.Items.size());
729  return;
730  }
731 
733  // Gift
734  uint8 giftContainerSlot = packet.Inv.Items[0].ContainerSlot;
735  uint8 giftSlot = packet.Inv.Items[0].Slot;
736  // Item
737  uint8 itemContainerSlot = packet.Inv.Items[1].ContainerSlot;
738  uint8 itemSlot = packet.Inv.Items[1].Slot;
739 
740  TC_LOG_DEBUG("network", "HandleWrapItem - Receive giftContainerSlot = %u, giftSlot = %u, itemContainerSlot = %u, itemSlot = %u", giftContainerSlot, giftSlot, itemContainerSlot, itemSlot);
741 
742  Item* gift = _player->GetItemByPos(giftContainerSlot, giftSlot);
743  if (!gift)
744  {
745  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
746  return;
747  }
748 
749  if (!(gift->GetTemplate()->GetFlags() & ITEM_FLAG_WRAPPER)) // cheating: non-wrapper wrapper
750  {
751  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, gift, NULL);
752  return;
753  }
754 
755  Item* item = _player->GetItemByPos(itemContainerSlot, itemSlot);
756  if (!item)
757  {
758  _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
759  return;
760  }
761 
762  if (item == gift) // not possable with pacjket from real client
763  {
764  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
765  return;
766  }
767 
768  if (item->IsEquipped())
769  {
770  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_EQUIPPED, item, NULL);
771  return;
772  }
773 
774  if (!item->GetGuidValue(ITEM_FIELD_GIFTCREATOR).IsEmpty()) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
775  {
776  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_WRAPPED, item, NULL);
777  return;
778  }
779 
780  if (item->IsBag())
781  {
782  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_BAGS, item, NULL);
783  return;
784  }
785 
786  if (item->IsSoulBound())
787  {
788  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_BOUND, item, NULL);
789  return;
790  }
791 
792  if (item->GetMaxStackCount() != 1)
793  {
794  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_STACKABLE, item, NULL);
795  return;
796  }
797 
798  // maybe not correct check (it is better than nothing)
799  if (item->GetTemplate()->GetMaxCount() > 0)
800  {
801  _player->SendEquipError(EQUIP_ERR_CANT_WRAP_UNIQUE, item, NULL);
802  return;
803  }
804 
806 
808  stmt->setUInt64(0, item->GetOwnerGUID().GetCounter());
809  stmt->setUInt64(1, item->GetGUID().GetCounter());
810  stmt->setUInt32(2, item->GetEntry());
811  stmt->setUInt32(3, item->GetUInt32Value(ITEM_FIELD_FLAGS));
812  trans->Append(stmt);
813 
814  item->SetEntry(gift->GetEntry());
815 
816  switch (item->GetEntry())
817  {
818  case 5042:
819  item->SetEntry(5043);
820  break;
821  case 5048:
822  item->SetEntry(5044);
823  break;
824  case 17303:
825  item->SetEntry(17302);
826  break;
827  case 17304:
828  item->SetEntry(17305);
829  break;
830  case 17307:
831  item->SetEntry(17308);
832  break;
833  case 21830:
834  item->SetEntry(21831);
835  break;
836  }
837 
838  item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, _player->GetGUID());
840  item->SetState(ITEM_CHANGED, _player);
841 
842  if (item->GetState() == ITEM_NEW) // save new item, to have alway for `character_gifts` record in `item_instance`
843  {
844  // after save it will be impossible to remove the item from the queue
846  item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone
847  }
849 
850  uint32 count = 1;
851  _player->DestroyItemCount(gift, count, true);
852 }
Definition: Item.h:96
void SetState(ItemUpdateState state, Player *forplayer=NULL)
Definition: Item.cpp:686
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: ItemTemplate.h:138
bool IsSoulBound() const
Definition: Item.h:277
#define SZFMTD
Definition: Define.h:143
uint32 GetMaxStackCount() const
Definition: Item.h:324
Definition: UpdateFields.h:49
Definition: ItemTemplate.h:182
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
bool IsEquipped() const
Definition: Item.cpp:764
ItemUpdateState GetState() const
Definition: Item.h:371
Definition: Item.h:93
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
void SetEntry(uint32 entry)
Definition: Object.h:108
bool IsBag() const
Definition: Item.h:307
Definition: PreparedStatement.h:74
Definition: Item.h:92
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
virtual void SaveToDB(SQLTransaction &trans)
Definition: Item.cpp:311
Definition: Item.h:91
Definition: Item.h:71
Definition: CharacterDatabase.h:418
Definition: Item.h:259
uint32_t uint32
Definition: Define.h:150
void RemoveFromUpdateQueueOf(Player *player)
Definition: Item.cpp:738
ObjectGuid const & GetGuidValue(uint16 index) const
Definition: Object.cpp:332
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::vector< InvItem > Items
Definition: ItemPackets.h:236
InvUpdate Inv
Definition: ItemPackets.h:433
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
ObjectGuid GetOwnerGUID() const
Definition: Item.h:272
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: Item.h:217
Definition: Item.h:95
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8_t uint8
Definition: Define.h:152
uint32 GetFlags() const
Definition: ItemTemplate.h:656
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 GetMaxCount() const
Definition: ItemTemplate.h:674
Definition: UpdateFields.h:45
Definition: Item.h:218
Definition: Item.h:94
bool IsEmpty() const
Definition: ObjectGuid.h:242
LowType GetCounter() const
Definition: ObjectGuid.h:221
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool WorldSession::HasPermission ( uint32  permissionId)
1260 {
1261  if (!_RBACData)
1262  LoadPermissions();
1263 
1264  bool hasPermission = _RBACData->HasPermission(permission);
1265  TC_LOG_DEBUG("rbac", "WorldSession::HasPermission [AccountId: %u, Name: %s, realmId: %d]",
1266  _RBACData->GetId(), _RBACData->GetName().c_str(), realm.Id.Realm);
1267 
1268  return hasPermission;
1269 }
uint32 Realm
Definition: Realm.h:53
Realm realm
Definition: World.cpp:3485
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool HasPermission(uint32 permission) const
Definition: RBAC.h:811
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
Battlenet::RealmHandle Id
Definition: Realm.h:86
void LoadPermissions()
Definition: WorldSession.cpp:1092
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::InitializeQueryCallbackParameters ( )
private
945 {
946  // Callback parameters that have pointers in them should be properly
947  // initialized to nullptr here.
948 }

+ Here is the caller graph for this function:

void WorldSession::InitializeSession ( )
1190 {
1192  if (!realmHolder->Initialize(GetAccountId(), GetBattlenetAccountId()))
1193  {
1194  delete realmHolder;
1196  return;
1197  }
1198 
1200  if (!holder->Initialize(GetAccountId(), GetBattlenetAccountId()))
1201  {
1202  delete realmHolder;
1203  delete holder;
1205  return;
1206  }
1207 
1210 }
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
uint32 GetAccountId() const
Definition: WorldSession.h:922
bool Initialize(uint32 accountId, uint32 battlenetAccountId)
Definition: WorldSession.cpp:1161
Definition: BattlenetRpcErrorCodes.h:26
Definition: WorldSession.cpp:1116
LoginDatabaseWorkerPool LoginDatabase
Accessor to the realm/login database.
Definition: DatabaseEnv.cpp:22
void SendAuthResponse(uint32 code, bool queued, uint32 queuePos=0)
Definition: AuthHandler.cpp:25
bool Initialize(uint32 accountId, uint32)
Definition: WorldSession.cpp:1129
QueryResultHolderFuture DelayQueryHolder(SQLQueryHolder *holder)
Definition: DatabaseWorkerPool.cpp:169
Definition: WorldSession.cpp:1145
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
QueryResultHolderFuture _accountLoginCallback
Definition: WorldSession.h:1730
QueryResultHolderFuture _realmAccountLoginCallback
Definition: WorldSession.h:1729

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::InitializeSessionCallback ( SQLQueryHolder realmHolder,
SQLQueryHolder holder 
)
1213 {
1218 
1219  if (!m_inQueue)
1220  SendAuthResponse(ERROR_OK, false);
1221  else
1222  SendAuthWaitQue(0);
1223 
1224  SetInQueue(false);
1225  ResetTimeOutTime();
1226 
1229  SendAddonsInfo();
1232 
1234  {
1235  do
1236  {
1237  Field* fields = characterCountsResult->Fetch();
1238  _realmCharacterCounts[Battlenet::RealmHandle{ fields[3].GetUInt8(), fields[4].GetUInt8(), fields[2].GetUInt32() }.GetAddress()] = fields[1].GetUInt8();
1239 
1240  } while (characterCountsResult->NextRow());
1241  }
1242 
1244  bnetConnected.State = 1;
1245  SendPacket(bnetConnected.Write());
1246 
1249 
1250  delete realmHolder;
1251  delete holder;
1252 }
void LoadTutorialsData(PreparedQueryResult result)
Definition: WorldSession.cpp:786
#define GLOBAL_CACHE_MASK
Definition: WorldSession.h:737
void SendAddonsInfo()
Definition: WorldSession.cpp:897
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void SendAuthWaitQue(uint32 position)
Handle the authentication waiting queue (to be completed)
Definition: AuthHandler.cpp:58
Definition: WorldSession.cpp:1152
Class used to access individual fields of database query result.
Definition: Field.h:56
PreparedQueryResult GetPreparedResult(size_t index)
Definition: QueryHolder.cpp:78
void SetInQueue(bool state)
Session in auth.queue currently.
Definition: WorldSession.h:940
uint8 State
Definition: BattlenetPackets.h:69
std::unordered_map< uint32, uint8 > _realmCharacterCounts
Definition: WorldSession.h:1810
void ResetTimeOutTime()
Definition: WorldSession.h:1074
Definition: WorldSession.cpp:1153
#define sWorld
Definition: World.h:887
void LoadAccountData(PreparedQueryResult result, uint32 mask)
Definition: WorldSession.cpp:724
uint8 GetUInt8() const
Definition: Field.h:70
void SendAuthResponse(uint32 code, bool queued, uint32 queuePos=0)
Definition: AuthHandler.cpp:25
Definition: BattlenetPackets.h:62
Definition: World.h:325
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::unique_ptr< CollectionMgr > _collectionMgr
Definition: WorldSession.h:1845
Definition: WorldSession.cpp:1122
void SendFeatureSystemStatusGlueScreen()
Definition: AuthHandler.cpp:90
std::unique_ptr< BattlePetMgr > _battlePetMgr
Definition: WorldSession.h:1843
Definition: BattlenetRpcErrorCodes.h:25
Definition: WorldSession.cpp:1151
uint32 GetUInt32() const
Definition: Field.h:146
Definition: Realm.h:44
void SendTutorialsData()
Definition: WorldSession.cpp:797
void SendClientCacheVersion(uint32 version)
Definition: AuthHandler.cpp:72
bool m_inQueue
Definition: WorldSession.h:1820
Definition: WorldSession.cpp:1150
WorldPacket const * Write() override
Definition: BattlenetPackets.cpp:55
void SendSetTimeZoneInformation()
Definition: AuthHandler.cpp:80

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::InitWarden ( BigNumber k)
1076 {
1077  if (_os == "Win")
1078  {
1079  _warden = new WardenWin();
1080  _warden->Init(this, k);
1081  }
1082  else if (_os == "Wn64")
1083  {
1084  // Not implemented
1085  }
1086  else if (_os == "Mc64")
1087  {
1088  // Not implemented
1089  }
1090 }
Warden * _warden
Definition: WorldSession.h:1817
virtual void Init(WorldSession *session, BigNumber *k)=0
std::string _os
Definition: WorldSession.h:1807
Definition: WardenWin.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::InvalidateRBACData ( )
1272 {
1273  TC_LOG_DEBUG("rbac", "WorldSession::Invalidaterbac::RBACData [AccountId: %u, Name: %s, realmId: %d]",
1274  _RBACData->GetId(), _RBACData->GetName().c_str(), realm.Id.Realm);
1275  delete _RBACData;
1276  _RBACData = NULL;
1277 }
uint32 Realm
Definition: Realm.h:53
Realm realm
Definition: World.cpp:3485
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetId() const
Gets the Id of the Object.
Definition: RBAC.h:793
std::string const & GetName() const
Gets the Name of the Object.
Definition: RBAC.h:791
Battlenet::RealmHandle Id
Definition: Realm.h:86
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838

+ Here is the call graph for this function:

bool WorldSession::IsAddonRegistered ( const std::string &  prefix) const
906 {
907  if (!_filterAddonMessages) // if we have hit the softcap (64) nothing should be filtered
908  return true;
909 
910  if (_registeredAddonPrefixes.empty())
911  return false;
912 
913  std::vector<std::string>::const_iterator itr = std::find(_registeredAddonPrefixes.begin(), _registeredAddonPrefixes.end(), prefix);
914  return itr != _registeredAddonPrefixes.end();
915 }
bool _filterAddonMessages
Definition: WorldSession.h:1834
std::vector< std::string > _registeredAddonPrefixes
Definition: WorldSession.h:1833
bool WorldSession::IsARecruiter ( ) const
inline
1086 { return isRecruiter; }
bool isRecruiter
Definition: WorldSession.h:1836
bool WorldSession::IsConnectionIdle ( ) const
inline
1080  {
1081  return m_timeOutTime <= 0 && !m_inQueue;
1082  }
std::atomic< int32 > m_timeOutTime
Definition: WorldSession.h:1067
bool m_inQueue
Definition: WorldSession.h:1820

+ Here is the caller graph for this function:

bool WorldSession::IsLegitCharacterForAccount ( ObjectGuid  lowGUID)
inlineprivate
1788  {
1789  return _legitCharacters.find(lowGUID) != _legitCharacters.end();
1790  }
GuidSet _legitCharacters
Definition: WorldSession.h:1794

+ Here is the caller graph for this function:

bool WorldSession::isLogingOut ( ) const
inline

Is the user engaged in a log out process?

943 { return _logoutTime || m_playerLogout; }
time_t _logoutTime
Definition: WorldSession.h:1819
bool m_playerLogout
Definition: WorldSession.h:1822

+ Here is the caller graph for this function:

void WorldSession::KickPlayer ( )

Kick a player out of the World.

647 {
648  for (uint8 i = 0; i < 2; ++i)
649  {
650  if (m_Socket[i])
651  {
652  m_Socket[i]->CloseSocket();
653  forceExit = true;
654  }
655  }
656 }
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
uint8_t uint8
Definition: Define.h:152
bool forceExit
Definition: WorldSession.h:1840

+ Here is the caller graph for this function:

void WorldSession::LoadAccountData ( PreparedQueryResult  result,
uint32  mask 
)
725 {
726  for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
727  if (mask & (1 << i))
728  _accountData[i] = AccountData();
729 
730  if (!result)
731  return;
732 
733  do
734  {
735  Field* fields = result->Fetch();
736  uint32 type = fields[0].GetUInt8();
737  if (type >= NUM_ACCOUNT_DATA_TYPES)
738  {
739  TC_LOG_ERROR("misc", "Table `%s` have invalid account data type (%u), ignore.",
740  mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
741  continue;
742  }
743 
744  if ((mask & (1 << type)) == 0)
745  {
746  TC_LOG_ERROR("misc", "Table `%s` have non appropriate for table account data type (%u), ignore.",
747  mask == GLOBAL_CACHE_MASK ? "account_data" : "character_account_data", type);
748  continue;
749  }
750 
751  _accountData[type].Time = time_t(fields[1].GetUInt32());
752  _accountData[type].Data = fields[2].GetString();
753  }
754  while (result->NextRow());
755 }
AccountData _accountData[NUM_ACCOUNT_DATA_TYPES]
Definition: WorldSession.h:1829
#define GLOBAL_CACHE_MASK
Definition: WorldSession.h:737
Definition: WorldSession.h:775
Class used to access individual fields of database query result.
Definition: Field.h:56
std::string Data
Definition: WorldSession.h:778
uint8 GetUInt8() const
Definition: Field.h:70
uint32_t uint32
Definition: Define.h:150
time_t Time
Definition: WorldSession.h:777
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string GetString() const
Definition: Field.h:276
#define NUM_ACCOUNT_DATA_TYPES
Definition: WorldSession.h:735

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::LoadPermissions ( )
1093 {
1094  uint32 id = GetAccountId();
1095  uint8 secLevel = GetSecurity();
1096 
1097  TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]",
1098  id, _accountName.c_str(), realm.Id.Realm, secLevel);
1099 
1100  _RBACData = new rbac::RBACData(id, _accountName, realm.Id.Realm, secLevel);
1101  _RBACData->LoadFromDB();
1102 }
uint32 Realm
Definition: Realm.h:53
AccountTypes GetSecurity() const
Definition: WorldSession.h:921
Realm realm
Definition: World.cpp:3485
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: RBAC.h:783
uint32 GetAccountId() const
Definition: WorldSession.h:922
Battlenet::RealmHandle Id
Definition: Realm.h:86
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: Define.h:152
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838
std::string _accountName
Definition: WorldSession.h:1804

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PreparedQueryResultFuture WorldSession::LoadPermissionsAsync ( )
1105 {
1106  uint32 id = GetAccountId();
1107  uint8 secLevel = GetSecurity();
1108 
1109  TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]",
1110  id, _accountName.c_str(), realm.Id.Realm, secLevel);
1111 
1112  _RBACData = new rbac::RBACData(id, _accountName, realm.Id.Realm, secLevel);
1113  return _RBACData->LoadFromDBAsync();
1114 }
uint32 Realm
Definition: Realm.h:53
AccountTypes GetSecurity() const
Definition: WorldSession.h:921
Realm realm
Definition: World.cpp:3485
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: RBAC.h:783
uint32 GetAccountId() const
Definition: WorldSession.h:922
Battlenet::RealmHandle Id
Definition: Realm.h:86
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: Define.h:152
rbac::RBACData * _RBACData
Definition: WorldSession.h:1838
std::string _accountName
Definition: WorldSession.h:1804

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::LoadTutorialsData ( PreparedQueryResult  result)
787 {
788  memset(_tutorials, 0, sizeof(uint32) * MAX_ACCOUNT_TUTORIAL_VALUES);
789 
790  if (result)
791  for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
792  _tutorials[i] = (*result)[i].GetUInt32();
793 
794  _tutorialsChanged = false;
795 }
uint32_t uint32
Definition: Define.h:150
uint8_t uint8
Definition: Define.h:152
#define MAX_ACCOUNT_TUTORIAL_VALUES
Definition: WorldSession.h:773
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830
bool _tutorialsChanged
Definition: WorldSession.h:1831

+ Here is the caller graph for this function:

void WorldSession::LogoutPlayer ( bool  save)

Log the player out

  • If the player just died before logging out, make him appear as a ghost
  • Teleport to home if the player is in an invalid instance
  • If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
  • Remove pet
  • Clear whisper whitelist
  • empty buyback items and save the player in the database
  • Leave all channels before player delete...
  • If the player is in a group (or invited), remove him. If the group if then only 1 person, disband the group.

Send update to group and reset stored max enchanting level

Broadcast a logout message to the player's friends

Call script hook before deletion

Remove the player from the world

Pointer already deleted during RemovePlayerFromMap

Send the 'logout complete' packet to the client Client will respond by sending 3x CMSG_CANCEL_TRADE, which we currently dont handle

Since each account can only have one online character at any given time, ensure all characters for active account are marked as offline

499 {
500  // finish pending transfers before starting the logout
501  while (_player && _player->IsBeingTeleportedFar())
503 
504  m_playerLogout = true;
505  m_playerSave = save;
506 
507  if (_player)
508  {
509  ObjectGuid lguid = _player->GetLootGUID();
510  if (!lguid.IsEmpty())
511  DoLootRelease(lguid);
512 
514  if (_player->GetDeathTimer())
515  {
516  _player->getHostileRefManager().deleteReferences();
517  _player->BuildPlayerRepop();
518  _player->RepopAtGraveyard();
519  }
520  else if (_player->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
521  {
522  // this will kill character by SPELL_AURA_SPIRIT_OF_REDEMPTION
523  _player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
524  _player->KillPlayer();
525  _player->BuildPlayerRepop();
526  _player->RepopAtGraveyard();
527  }
528  else if (_player->HasPendingBind())
529  {
530  _player->RepopAtGraveyard();
531  _player->SetPendingBind(0, 0);
532  }
533 
534  //drop a flag if player is carrying it
535  if (Battleground* bg = _player->GetBattleground())
536  bg->EventPlayerLoggedOut(_player);
537 
539  if (!_player->m_InstanceValid && !_player->IsGameMaster())
540  _player->TeleportTo(_player->m_homebindMapId, _player->m_homebindX, _player->m_homebindY, _player->m_homebindZ, _player->GetOrientation());
541 
542  sOutdoorPvPMgr->HandlePlayerLeaveZone(_player, _player->GetZoneId());
543 
544  for (int i=0; i < PLAYER_MAX_BATTLEGROUND_QUEUES; ++i)
545  {
546  if (BattlegroundQueueTypeId bgQueueTypeId = _player->GetBattlegroundQueueTypeId(i))
547  {
548  _player->RemoveBattlegroundQueueId(bgQueueTypeId);
549  BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(bgQueueTypeId);
550  queue.RemovePlayer(_player->GetGUID(), true);
551  }
552  }
553 
554  // Repop at GraveYard or other player far teleport will prevent saving player because of not present map
555  // Teleport player immediately for correct player save
556  while (_player->IsBeingTeleportedFar())
558 
560  if (Guild* guild = sGuildMgr->GetGuildById(_player->GetGuildId()))
561  guild->HandleMemberLogout(this);
562 
564  _player->RemovePet(NULL, PET_SAVE_AS_CURRENT, true);
565 
567  _player->ClearWhisperWhiteList();
568 
570  // some save parts only correctly work in case player present in map/player_lists (pets, etc)
571  if (save)
572  {
573  uint32 eslot;
574  for (int j = BUYBACK_SLOT_START; j < BUYBACK_SLOT_END; ++j)
575  {
576  eslot = j - BUYBACK_SLOT_START;
577  _player->SetGuidValue(PLAYER_FIELD_INV_SLOT_HEAD + (j * 4), ObjectGuid::Empty);
578  _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + eslot, 0);
579  _player->SetUInt32Value(PLAYER_FIELD_BUYBACK_TIMESTAMP_1 + eslot, 0);
580  }
581  _player->SaveToDB();
582  }
583 
585  _player->CleanupChannels();
586 
588  _player->UninviteFromGroup();
589 
590  // remove player from the group if he is:
591  // a) in group; b) not in raid group; c) logging out normally (not being kicked or disconnected)
592  if (_player->GetGroup() && !_player->GetGroup()->isRaidGroup() && m_Socket[CONNECTION_TYPE_REALM])
593  _player->RemoveFromGroup();
594 
596  if (_player->GetGroup())
597  {
598  _player->GetGroup()->SendUpdate();
599  _player->GetGroup()->ResetMaxEnchantingLevel();
600  }
601 
603  sSocialMgr->SendFriendStatus(_player, FRIEND_OFFLINE, _player->GetGUID(), true);
604  _player->RemoveSocial();
605 
607  sScriptMgr->OnPlayerLogout(_player);
608 
610  // the player may not be in the world when logging out
611  // e.g if he got disconnected during a transfer to another map
612  // calls to GetMap in this case may cause crashes
613  _player->CleanupsBeforeDelete();
614  TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Logout Character:[%s] (%s) Level: %d",
615  GetAccountId(), GetRemoteAddress().c_str(), _player->GetName().c_str(), _player->GetGUID().ToString().c_str(), _player->getLevel());
616 
617  if (Map* _map = _player->FindMap())
618  _map->RemovePlayerFromMap(_player, true);
619 
620  SetPlayer(NULL);
621 
625  TC_LOG_DEBUG("network", "SESSION: Sent SMSG_LOGOUT_COMPLETE Message");
626 
629  stmt->setUInt32(0, GetAccountId());
631  }
632 
634  {
635  m_Socket[CONNECTION_TYPE_INSTANCE]->CloseSocket();
637  }
638 
639  m_playerLogout = false;
640  m_playerSave = false;
641  m_playerRecentlyLogout = true;
643 }
Definition: UpdateFields.h:270
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
Definition: CharacterPackets.h:480
#define sOutdoorPvPMgr
Definition: OutdoorPvPMgr.h:105
Definition: UpdateFields.h:210
#define sGuildMgr
Definition: GuildMgr.h:61
void SetLogoutStartTime(time_t requestTime)
Engage the logout process for the user.
Definition: WorldSession.h:946
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition: SharedDefines.h:209
Definition: UpdateFields.h:271
bool m_playerLogout
Definition: WorldSession.h:1822
arena_t NULL
Definition: jemalloc_internal.h:624
void SetPlayer(Player *player)
Definition: WorldSession.cpp:935
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
Definition: PetDefines.h:35
Definition: SpellAuraDefines.h:236
Definition: CharacterDatabase.h:328
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
Definition: BattlegroundQueue.cpp:283
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: Opcodes.h:32
Definition: Map.h:259
#define sSocialMgr
Definition: SocialMgr.h:160
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void HandleMoveWorldportAckOpcode()
Definition: MovementHandler.cpp:43
bool m_playerRecentlyLogout
Definition: WorldSession.h:1823
Definition: SocialMgr.h:72
Definition: BattlegroundQueue.h:75
BattlegroundQueueTypeId
Definition: SharedDefines.h:4732
Player * _player
Definition: WorldSession.h:1797
Definition: SpellAuraDefines.h:96
#define sBattlegroundMgr
Definition: BattlegroundMgr.h:181
void DoLootRelease(ObjectGuid lguid)
Definition: LootHandler.cpp:250
Definition: Battleground.h:235
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: ObjectGuid.h:189
Definition: Guild.h:320
Definition: Opcodes.h:31
bool IsEmpty() const
Definition: ObjectGuid.h:242
bool m_playerSave
Definition: WorldSession.h:1824

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::LogUnexpectedOpcode ( WorldPacket packet,
const char *  status,
const char *  reason 
)
private

Logging helper for unexpected opcodes.

310 {
311  TC_LOG_ERROR("network.opcode", "Received unexpected opcode %s Status: %s Reason: %s from %s",
312  GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), status, reason, GetPlayerInfo().c_str());
313 }
uint32 GetOpcode() const
Definition: WorldPacket.h:79
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::LogUnprocessedTail ( WorldPacket packet)
private

Logging helper for unexpected opcodes.

317 {
318  if (!sLog->ShouldLog("network.opcode", LOG_LEVEL_TRACE) || packet->rpos() >= packet->wpos())
319  return;
320 
321  TC_LOG_TRACE("network.opcode", "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s",
322  uint32(packet->rpos()), uint32(packet->wpos()), GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), GetPlayerInfo().c_str());
323  packet->print_storage();
324 }
Definition: Appender.h:34
uint32 GetOpcode() const
Definition: WorldPacket.h:79
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
#define sLog
Definition: Log.h:154
size_t wpos() const
Definition: ByteBuffer.h:454
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint32_t uint32
Definition: g3dmath.h:168
size_t rpos() const
Definition: ByteBuffer.h:441
void print_storage() const
Definition: ByteBuffer.cpp:51

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::moveItems ( Item myItems[],
Item hisItems[] 
)
private
98 {
99  Player* trader = _player->GetTrader();
100  if (!trader)
101  return;
102 
103  for (uint8 i = 0; i < TRADE_SLOT_TRADED_COUNT; ++i)
104  {
105  ItemPosCountVec traderDst;
106  ItemPosCountVec playerDst;
107  bool traderCanTrade = (myItems[i] == NULL || trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, myItems[i], false) == EQUIP_ERR_OK);
108  bool playerCanTrade = (hisItems[i] == NULL || _player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, hisItems[i], false) == EQUIP_ERR_OK);
109  if (traderCanTrade && playerCanTrade)
110  {
111  // Ok, if trade item exists and can be stored
112  // If we trade in both directions we had to check, if the trade will work before we actually do it
113  // A roll back is not possible after we stored it
114  if (myItems[i])
115  {
116  // logging
117  TC_LOG_DEBUG("network", "partner storing: %s", myItems[i]->GetGUID().ToString().c_str());
119  {
120  sLog->outCommand(_player->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
121  _player->GetName().c_str(), _player->GetSession()->GetAccountId(),
122  myItems[i]->GetTemplate()->GetDefaultLocaleName(), myItems[i]->GetEntry(), myItems[i]->GetCount(),
123  trader->GetName().c_str(), trader->GetSession()->GetAccountId());
124  }
125 
126  // adjust time (depends on /played)
127  if (myItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
128  myItems[i]->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, trader->GetTotalPlayedTime()-(_player->GetTotalPlayedTime()-myItems[i]->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)));
129  // store
130  trader->MoveItemToInventory(traderDst, myItems[i], true, true);
131  }
132  if (hisItems[i])
133  {
134  // logging
135  TC_LOG_DEBUG("network", "player storing: %s", hisItems[i]->GetGUID().ToString().c_str());
137  {
138  sLog->outCommand(trader->GetSession()->GetAccountId(), "GM %s (Account: %u) trade: %s (Entry: %d Count: %u) to player: %s (Account: %u)",
139  trader->GetName().c_str(), trader->GetSession()->GetAccountId(),
140  hisItems[i]->GetTemplate()->GetDefaultLocaleName(), hisItems[i]->GetEntry(), hisItems[i]->GetCount(),
141  _player->GetName().c_str(), _player->GetSession()->GetAccountId());
142  }
143 
144  // adjust time (depends on /played)
145  if (hisItems[i]->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_BOP_TRADEABLE))
146  hisItems[i]->SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, _player->GetTotalPlayedTime()-(trader->GetTotalPlayedTime()-hisItems[i]->GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME)));
147  // store
148  _player->MoveItemToInventory(playerDst, hisItems[i], true, true);
149  }
150  }
151  else
152  {
153  // in case of fatal error log error message
154  // return the already removed items to the original owner
155  if (myItems[i])
156  {
157  if (!traderCanTrade)
158  TC_LOG_ERROR("network", "trader can't store item: %s", myItems[i]->GetGUID().ToString().c_str());
159  if (_player->CanStoreItem(NULL_BAG, NULL_SLOT, playerDst, myItems[i], false) == EQUIP_ERR_OK)
160  _player->MoveItemToInventory(playerDst, myItems[i], true, true);
161  else
162  TC_LOG_ERROR("network", "player can't take item back: %s", myItems[i]->GetGUID().ToString().c_str());
163  }
164  // return the already removed items to the original owner
165  if (hisItems[i])
166  {
167  if (!playerCanTrade)
168  TC_LOG_ERROR("network", "player can't store item: %s", hisItems[i]->GetGUID().ToString().c_str());
169  if (trader->CanStoreItem(NULL_BAG, NULL_SLOT, traderDst, hisItems[i], false) == EQUIP_ERR_OK)
170  trader->MoveItemToInventory(traderDst, hisItems[i], true, true);
171  else
172  TC_LOG_ERROR("network", "trader can't take item back: %s", hisItems[i]->GetGUID().ToString().c_str());
173  }
174  }
175  }
176 }
uint32 GetCount() const
Definition: Item.h:322
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
Definition: Unit.h:379
Definition: UpdateFields.h:49
arena_t NULL
Definition: jemalloc_internal.h:624
#define sLog
Definition: Log.h:154
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Item.h:48
Definition: Unit.h:378
string ToString(int i)
Definition: strutil.h:491
Definition: UpdateFields.h:55
Player * _player
Definition: WorldSession.h:1797
Definition: RBAC.h:63
uint8_t uint8
Definition: Define.h:152
Definition: ItemTemplate.h:143
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: TradeData.h:26
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
ItemTemplate const * GetTemplate() const
Definition: Item.cpp:547
char const * GetDefaultLocaleName() const
Definition: ItemTemplate.cpp:33

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WorldSession& WorldSession::operator= ( WorldSession const right)
privatedelete
bool WorldSession::PlayerDisconnected ( ) const
185 {
188 }
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
Definition: Opcodes.h:32
Definition: Opcodes.h:31
bool WorldSession::PlayerLoading ( ) const
inline
889 { return !m_playerLoading.IsEmpty(); }
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the caller graph for this function:

bool WorldSession::PlayerLogout ( ) const
inline
890 { return m_playerLogout; }
bool m_playerLogout
Definition: WorldSession.h:1822

+ Here is the caller graph for this function:

bool WorldSession::PlayerLogoutWithSave ( ) const
inline
891 { return m_playerLogout && m_playerSave; }
bool m_playerLogout
Definition: WorldSession.h:1822
bool m_playerSave
Definition: WorldSession.h:1824
bool WorldSession::PlayerRecentlyLoggedOut ( ) const
inline
892 { return m_playerRecentlyLogout; }
bool m_playerRecentlyLogout
Definition: WorldSession.h:1823

+ Here is the caller graph for this function:

void WorldSession::ProcessQueryCallbacks ( )
private

HandleCharEnumOpcode and HandleCharUndeleteEnumOpcode

HandleCharCreateOpcode

HandleCharCustomizeOpcode

HandleCharRaceOrFactionChangeOpcode

HandlePlayerLoginOpcode

HandleAddFriendOpcode

HandleUndeleteCooldownStatusOpcode wait until no char undelete is in progress

HandleCharUndeleteOpcode

951 {
952  PreparedQueryResult result;
953 
954  if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready &&
955  _accountLoginCallback.valid() && _accountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
957 
960  {
962 
964  HandleCharUndeleteEnum(result);
965  else
966  HandleCharEnum(result);
967 
969  }
970 
973  {
976  }
977 
980  {
984  }
985 
988  {
992  }
993 
995  if (_charLoginCallback.valid() && _charLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
996  {
997  SQLQueryHolder* param = _charLoginCallback.get();
999  }
1000 
1003  {
1004  std::string param = _addFriendCallback.GetParam();
1005  _addFriendCallback.GetResult(result);
1006  HandleAddFriendOpcodeCallBack(result, param);
1008  }
1009 
1010  //- HandleCharRenameOpcode
1012  {
1016  }
1017 
1021  {
1024  }
1025 
1028  {
1031  }
1032 
1033  //- HandleCharAddIgnoreOpcode
1034  if (_addIgnoreCallback.valid() && _addIgnoreCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
1035  {
1036  result = _addIgnoreCallback.get();
1038  }
1039 
1040  //- SendStabledPet
1042  {
1045  SendStablePetCallback(result, param);
1047  }
1048 
1049  //- HandleStablePet
1050  if (_stablePetCallback.valid() && _stablePetCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
1051  {
1052  result = _stablePetCallback.get();
1053  HandleStablePetCallback(result);
1054  }
1055 
1056  //- HandleUnstablePet
1058  {
1061  HandleUnstablePetCallback(result, param);
1063  }
1064 
1065  //- HandleStableSwapPet
1067  {
1070  HandleStableSwapPetCallback(result, param);
1072  }
1073 }
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterRenameInfo > > _charRenameCallback
Definition: WorldSession.h:1739
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharRaceOrFactionChangeInfo > > _charFactionChangeCallback
Definition: WorldSession.h:1741
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
QueryCallback< PreparedQueryResult, std::string > _addFriendCallback
Definition: WorldSession.h:1734
void HandleStablePetCallback(PreparedQueryResult result)
Definition: NPCHandler.cpp:594
QueryCallback< PreparedQueryResult, bool, true > _undeleteCooldownStatusCallback
Definition: WorldSession.h:1742
Definition: QueryHolder.h:23
void SendStablePetCallback(PreparedQueryResult result, ObjectGuid guid)
Definition: NPCHandler.cpp:495
void HandleCharUndeleteEnum(PreparedQueryResult result)
Definition: CharacterHandler.cpp:331
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterCreateInfo >, true > _charCreateCallback
Definition: WorldSession.h:1738
void HandleCharUndeleteCallback(PreparedQueryResult result, WorldPackets::Character::CharacterUndeleteInfo *undeleteInfo)
Definition: CharacterHandler.cpp:2365
void GetResult(Result &res)
Definition: Callback.h:53
void HandleCharEnum(PreparedQueryResult result)
Definition: CharacterHandler.cpp:265
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharacterUndeleteInfo >, true > _charUndeleteCallback
Definition: WorldSession.h:1743
void HandleAddIgnoreOpcodeCallBack(PreparedQueryResult result)
Definition: SocialHandler.cpp:116
float seconds()
Definition: units.h:97
QueryCallback< PreparedQueryResult, uint32 > _unstablePetCallback
Definition: WorldSession.h:1735
ParamType GetParam()
Definition: Callback.h:68
QueryCallback< PreparedQueryResult, std::shared_ptr< WorldPackets::Character::CharCustomizeInfo > > _charCustomizeCallback
Definition: WorldSession.h:1740
void HandleStableSwapPetCallback(PreparedQueryResult result, uint32 petId)
Definition: NPCHandler.cpp:780
void HandleUnstablePetCallback(PreparedQueryResult result, uint32 petId)
Definition: NPCHandler.cpp:655
QueryResultHolderFuture _charLoginCallback
Definition: WorldSession.h:1744
void InitializeSessionCallback(SQLQueryHolder *realmHolder, SQLQueryHolder *holder)
Definition: WorldSession.cpp:1212
void HandleCharRaceOrFactionChangeCallback(PreparedQueryResult result, WorldPackets::Character::CharRaceOrFactionChangeInfo *factionChangeInfo)
Definition: CharacterHandler.cpp:1729
uint32_t uint32
Definition: Define.h:150
void HandleCharRenameCallBack(PreparedQueryResult result, WorldPackets::Character::CharacterRenameInfo *renameInfo)
Definition: CharacterHandler.cpp:1300
QueryCallback< PreparedQueryResult, ObjectGuid > _sendStabledPetCallback
Definition: WorldSession.h:1737
uint8 GetStage()
Returns the callback stage (or CALLBACK_STAGE_INVALID if invalid)
Definition: Callback.h:92
PreparedQueryResultFuture _stablePetCallback
Definition: WorldSession.h:1732
QueryCallback< PreparedQueryResult, uint32 > _stableSwapCallback
Definition: WorldSession.h:1736
void Reset()
Resets all underlying variables (param, result and stage)
Definition: Callback.h:98
PreparedQueryResultFuture _addIgnoreCallback
Definition: WorldSession.h:1731
QueryCallback< PreparedQueryResult, bool > _charEnumCallback
Definition: WorldSession.h:1733
Definition: CharacterHandler.cpp:58
void HandleUndeleteCooldownStatusCallback(PreparedQueryResult result)
Definition: CharacterHandler.cpp:2315
Definition: ObjectGuid.h:189
void HandleCharCreateCallback(PreparedQueryResult result, WorldPackets::Character::CharacterCreateInfo *createInfo)
Definition: CharacterHandler.cpp:502
QueryResultHolderFuture _accountLoginCallback
Definition: WorldSession.h:1730
void HandleCharCustomizeCallback(PreparedQueryResult result, WorldPackets::Character::CharCustomizeInfo *customizeInfo)
Definition: CharacterHandler.cpp:1517
void HandlePlayerLogin(LoginQueryHolder *holder)
Definition: CharacterHandler.cpp:893
void HandleAddFriendOpcodeCallBack(PreparedQueryResult result, std::string const &friendNote)
Definition: SocialHandler.cpp:46
void FreeResult()
Definition: Callback.h:58
bool IsReady()
Definition: Callback.h:48
QueryResultHolderFuture _realmAccountLoginCallback
Definition: WorldSession.h:1729

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::QueuePacket ( WorldPacket new_packet)

Add an incoming packet to the queue.

304 {
305  _recvQueue.add(new_packet);
306 }
void add(const T &item)
Adds an item to the queue.
Definition: LockedQueue.h:51
LockedQueue< WorldPacket * > _recvQueue
Definition: WorldSession.h:1837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::ReadAddonsInfo ( ByteBuffer data)
Todo:
Find out when to not use CRC/pubkey, and other possible states.
823 {
824  if (data.rpos() + 4 > data.size())
825  return;
826 
827  uint32 size;
828  data >> size;
829 
830  if (!size)
831  return;
832 
833  if (size > 0xFFFFF)
834  {
835  TC_LOG_DEBUG("addon", "WorldSession::ReadAddonsInfo: AddOnInfo too big, size %u", size);
836  return;
837  }
838 
839  uLongf uSize = size;
840 
841  uint32 pos = data.rpos();
842 
843  ByteBuffer addonInfo;
844  addonInfo.resize(size);
845 
846  m_addonsList.clear();
847 
848  if (uncompress(addonInfo.contents(), &uSize, data.contents() + pos, data.size() - pos) == Z_OK)
849  {
850  uint32 addonsCount;
851  addonInfo >> addonsCount; // addons count
852 
853  for (uint32 i = 0; i < addonsCount; ++i)
854  {
855  std::string addonName;
856  uint8 enabled;
857  uint32 crc, unk1;
858 
859  // check next addon data format correctness
860  if (addonInfo.rpos() + 1 > addonInfo.size())
861  return;
862 
863  addonInfo >> addonName;
864 
865  addonInfo >> enabled >> crc >> unk1;
866 
867  TC_LOG_DEBUG("addon", "AddOn: %s (CRC: 0x%x) - enabled: 0x%x - Unknown2: 0x%x", addonName.c_str(), crc, enabled, unk1);
868 
869  AddonInfo addon(addonName, enabled, crc, 2, true);
870 
871  SavedAddon const* savedAddon = AddonMgr::GetAddonInfo(addonName);
872  if (savedAddon)
873  {
874  if (addon.CRC != savedAddon->CRC)
875  TC_LOG_WARN("addon", " Addon: %s: modified (CRC: 0x%x) - accountID %d)", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
876  else
877  TC_LOG_DEBUG("addon", "Addon: %s: validated (CRC: 0x%x) - accountID %d", addon.Name.c_str(), savedAddon->CRC, GetAccountId());
878  }
879  else
880  {
881  AddonMgr::SaveAddon(addon);
882  TC_LOG_WARN("addon", "Addon: %s: unknown (CRC: 0x%x) - accountId %d (storing addon name and checksum to database)", addon.Name.c_str(), addon.CRC, GetAccountId());
883  }
884 
886  m_addonsList.push_back(addon);
887  }
888 
889  uint32 currentTime;
890  addonInfo >> currentTime;
891  TC_LOG_DEBUG("addon", "AddOn: CurrentTime: %u", currentTime);
892  }
893  else
894  TC_LOG_DEBUG("addon", "AddOn: Addon packet uncompress error!");
895 }
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: ByteBuffer.h:70
Definition: AddonMgr.h:40
Definition: AddonMgr.h:27
AddonsList m_addonsList
Definition: WorldSession.h:1832
void resize(size_t newsize)
Definition: ByteBuffer.h:590
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
uint32 CRC
Definition: AddonMgr.h:48
size_t size() const
Definition: ByteBuffer.h:587
uint32_t uint32
Definition: Define.h:150
uLong FAR uLongf
Definition: zconf.h:382
SavedAddon const * GetAddonInfo(const std::string &name)
Definition: AddonMgr.cpp:112
#define Z_OK
Definition: zlib.h:173
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
uint8_t uint8
Definition: Define.h:152
size_t rpos() const
Definition: ByteBuffer.h:441
void SaveAddon(AddonInfo const &addon)
Definition: AddonMgr.cpp:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::ResetClientTimeDelay ( )
inline
1065 { m_clientTimeDelay = 0; }
std::atomic< uint32 > m_clientTimeDelay
Definition: WorldSession.h:1828

+ Here is the caller graph for this function:

void WorldSession::ResetTimeOutTime ( )
inline
1075  {
1077  }
#define sWorld
Definition: World.h:887
std::atomic< int32 > m_timeOutTime
Definition: WorldSession.h:1067
Definition: World.h:217
int32_t int32
Definition: g3dmath.h:167

+ Here is the caller graph for this function:

void WorldSession::SaveTutorialsData ( SQLTransaction trans)
805 {
806  if (!_tutorialsChanged)
807  return;
808 
810  stmt->setUInt32(0, GetAccountId());
811  bool hasTutorials = bool(CharacterDatabase.Query(stmt));
812  // Modify data in DB
814  for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
815  stmt->setUInt32(i, _tutorials[i]);
816  stmt->setUInt32(MAX_ACCOUNT_TUTORIAL_VALUES, GetAccountId());
817  trans->Append(stmt);
818 
819  _tutorialsChanged = false;
820 }
Definition: CharacterDatabase.h:238
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
#define bool
Definition: CascPort.h:16
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: CharacterDatabase.h:236
uint8_t uint8
Definition: Define.h:152
Definition: CharacterDatabase.h:237
#define MAX_ACCOUNT_TUTORIAL_VALUES
Definition: WorldSession.h:773
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830
bool _tutorialsChanged
Definition: WorldSession.h:1831

+ Here is the call graph for this function:

void WorldSession::SendActivateTaxiReply ( ActivateTaxiReply  reply)
193 {
195  data.Reply = reply;
196  SendPacket(data.Write());
197  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_ACTIVATETAXIREPLY");
198 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
WorldPacket const * Write() override
Definition: TaxiPackets.cpp:68
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8 Reply
Definition: TaxiPackets.h:113
Definition: TaxiPackets.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAddonsInfo ( )
898 {
900  addonInfo.Addons = &m_addonsList;
902  SendPacket(addonInfo.Write());
903 }
std::list< BannedAddon > const * BannedAddons
Definition: ClientConfigPackets.h:39
AddonsList m_addonsList
Definition: WorldSession.h:1832
Definition: ClientConfigPackets.h:29
std::list< ::AddonInfo > const * Addons
Definition: ClientConfigPackets.h:38
BannedAddonList const * GetBannedAddons()
Definition: AddonMgr.cpp:124
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: ClientConfigPackets.cpp:40

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAttackStop ( Unit const enemy)
81 {
83 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: CombatPackets.h:69
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAuctionClosedNotification ( AuctionEntry const auction,
float  mailDelay,
bool  sold,
Item const item 
)
87 {
89  packet.Info.Initialize(auction, item);
90  packet.ProceedsMailDelay = mailDelay;
91  packet.Sold = sold;
92  SendPacket(packet.Write());
93 }
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:278
void Initialize(::AuctionEntry const *auction,::Item const *item)
Definition: AuctionHousePackets.cpp:82
AuctionOwnerNotification Info
Definition: AuctionHousePackets.h:298
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: AuctionHousePackets.h:291
float ProceedsMailDelay
Definition: AuctionHousePackets.h:299
bool Sold
Definition: AuctionHousePackets.h:300

+ Here is the call graph for this function:

void WorldSession::SendAuctionCommandResult ( AuctionEntry auction,
uint32  Action,
uint32  ErrorCode,
uint32  bidError = 0 
)

Notifies the client of the result of his last auction operation. It is called when the player bids, creates, or deletes an auction.

Parameters
auctionThe relevant auction object
ActionThe action that was performed.
ErrorCodeThe resulting error code.
bidError(Optional) the bid error.
69 {
71  auctionCommandResult.InitializeAuction(auction);
72  auctionCommandResult.Command = action;
73  auctionCommandResult.ErrorCode = errorCode;
74  SendPacket(auctionCommandResult.Write());
75 }
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:124
void InitializeAuction(::AuctionEntry *auction)
Definition: AuctionHousePackets.cpp:113
int32 ErrorCode
the error code that was generated when trying to perform the action. Possible values are AuctionError...
Definition: AuctionHousePackets.h:120
Definition: AuctionHousePackets.h:102
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 Command
the type of action that triggered this notification. Possible values are AuctionAction ...
Definition: AuctionHousePackets.h:119

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAuctionHello ( ObjectGuid  guid,
Creature unit 
)
51 {
52  if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ))
53  {
55  return;
56  }
57 
59  if (!ahEntry)
60  return;
61 
63  auctionHelloResponse.Guid = guid;
64  auctionHelloResponse.OpenForBusiness = true; // 3.3.3: 1 - AH enabled, 0 - AH disabled
65  SendPacket(auctionHelloResponse.Write());
66 }
uint32 getFaction() const
Definition: Unit.h:1466
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:101
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
ObjectGuid Guid
Definition: AuctionHousePackets.h:98
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
void SendNotification(char const *format,...) ATTR_PRINTF(2
Definition: WorldSession.cpp:658
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: World.h:293
Definition: AuctionHousePackets.h:91
Definition: DB2Structure.h:53
bool OpenForBusiness
Definition: AuctionHousePackets.h:99
Definition: Language.h:1139
static AuctionHouseEntry const * GetAuctionHouseEntry(uint32 factionTemplateId)
Definition: AuctionHouseMgr.cpp:516

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAuctionOutBidNotification ( AuctionEntry const auction,
Item const item 
)
78 {
80  packet.BidAmount = auction->bid;
81  packet.MinIncrement = auction->GetAuctionOutBid();
82  packet.Info.Initialize(auction, item);
83  SendPacket(packet.Write());
84 }
void Initialize(::AuctionEntry const *auction,::Item const *item)
Definition: AuctionHousePackets.cpp:89
AuctionBidderNotification Info
Definition: AuctionHousePackets.h:332
uint64 BidAmount
Definition: AuctionHousePackets.h:333
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:304
uint64 MinIncrement
Definition: AuctionHousePackets.h:334
Definition: AuctionHousePackets.h:325
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

void WorldSession::SendAuctionOwnerBidNotification ( AuctionEntry const auction,
Item const item 
)
103 {
105  packet.Info.Initialize(auction, item);
106  packet.Bidder = ObjectGuid::Create<HighGuid::Player>(auction->bidder);
107  packet.MinIncrement = auction->GetAuctionOutBid();
108  SendPacket(packet.Write());
109 }
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:288
void Initialize(::AuctionEntry const *auction,::Item const *item)
Definition: AuctionHousePackets.cpp:82
ObjectGuid Bidder
Definition: AuctionHousePackets.h:311
Definition: AuctionHousePackets.h:303
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
AuctionOwnerNotification Info
Definition: AuctionHousePackets.h:310
uint64 MinIncrement
Definition: AuctionHousePackets.h:312

+ Here is the call graph for this function:

void WorldSession::SendAuctionWonNotification ( AuctionEntry const auction,
Item const item 
)
96 {
98  packet.Info.Initialize(auction, item);
99  SendPacket(packet.Write());
100 }
void Initialize(::AuctionEntry const *auction,::Item const *item)
Definition: AuctionHousePackets.cpp:89
Definition: AuctionHousePackets.h:315
WorldPacket const * Write() override
Definition: AuctionHousePackets.cpp:297
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
AuctionBidderNotification Info
Definition: AuctionHousePackets.h:322

+ Here is the call graph for this function:

void WorldSession::SendAuthResponse ( uint32  code,
bool  queued,
uint32  queuePos = 0 
)
26 {
28  response.Result = code;
29 
30  if (queued)
31  {
32  response.WaitInfo = boost::in_place();
33  response.WaitInfo->WaitCount = queuePos;
34  }
35  else if (code == ERROR_OK)
36  {
37  response.SuccessInfo = boost::in_place();
38 
39  response.SuccessInfo->AccountExpansionLevel = GetExpansion();
40  response.SuccessInfo->ActiveExpansionLevel = GetExpansion();
41  response.SuccessInfo->VirtualRealmAddress = GetVirtualRealmAddress();
42 
43  // Send current home realm. Also there is no need to send it later in realm queries.
44  response.SuccessInfo->VirtualRealms.emplace_back(GetVirtualRealmAddress(), true, false,
45  sObjectMgr->GetRealmName(realm.Id.Realm), sObjectMgr->GetNormalizedRealmName(realm.Id.Realm));
46 
48  for (auto& templ : sObjectMgr->GetCharacterTemplates())
49  response.SuccessInfo->Templates.emplace_back(templ.second);
50 
51  response.SuccessInfo->AvailableClasses = &sObjectMgr->GetClassExpansionRequirements();
52  response.SuccessInfo->AvailableRaces = &sObjectMgr->GetRaceExpansionRequirements();
53  }
54 
55  SendPacket(response.Write());
56 }
uint32 Realm
Definition: Realm.h:53
Definition: AuthenticationPackets.h:72
Realm realm
Definition: World.cpp:3485
#define sObjectMgr
Definition: ObjectMgr.h:1567
Optional< AuthWaitInfo > WaitInfo
contains the queue wait information in case the account is in the login queue.
Definition: AuthenticationPackets.h:130
Battlenet::RealmHandle Id
Definition: Realm.h:86
uint8 GetExpansion() const
Definition: WorldSession.h:934
uint32 Result
the result of the authentication process, possible values are BattlenetRpcErrorCode ...
Definition: AuthenticationPackets.h:131
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: inftrees.h:24
Definition: BattlenetRpcErrorCodes.h:25
WorldPacket const * Write() override
Definition: AuthenticationPackets.cpp:63
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
bool HasPermission(uint32 permissionId)
Definition: WorldSession.cpp:1259
Optional< AuthSuccessInfo > SuccessInfo
contains the packet data in case that it has account information (It is never set when WaitInfo is se...
Definition: AuthenticationPackets.h:129

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendAuthWaitQue ( uint32  position)

Handle the authentication waiting queue (to be completed)

59 {
61  response.Result = ERROR_OK;
62 
63  if (position)
64  {
65  response.WaitInfo = boost::in_place();
66  response.WaitInfo->WaitCount = position;
67  }
68 
69  SendPacket(response.Write());
70 }
Definition: AuthenticationPackets.h:72
Optional< AuthWaitInfo > WaitInfo
contains the queue wait information in case the account is in the login queue.
Definition: AuthenticationPackets.h:130
uint32 Result
the result of the authentication process, possible values are BattlenetRpcErrorCode ...
Definition: AuthenticationPackets.h:131
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: BattlenetRpcErrorCodes.h:25
WorldPacket const * Write() override
Definition: AuthenticationPackets.cpp:63

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendBarberShopResult ( BarberShopResult  result)
2556 {
2558  packet.Result = result;
2559  SendPacket(packet.Write());
2560 }
BarberShopResult Result
Definition: CharacterPackets.h:613
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:460
Definition: CharacterPackets.h:606

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendBattlenetRequest ( uint32  serviceHash,
uint32  methodId,
pb::Message const request,
std::function< void(MessageBuffer)>  callback 
)
68 {
70  SendBattlenetRequest(serviceHash, methodId, request);
71 }
void SendBattlenetRequest(uint32 serviceHash, uint32 methodId, pb::Message const *request, std::function< void(MessageBuffer)> callback)
Definition: BattlenetHandler.cpp:67
uint32 _battlenetRequestToken
Definition: WorldSession.h:1812
std::unordered_map< uint32, std::function< void(MessageBuffer)> > _battlenetResponseCallbacks
Definition: WorldSession.h:1811
void WorldSession::SendBattlenetRequest ( uint32  serviceHash,
uint32  methodId,
pb::Message const request 
)
74 {
76  notification.Method.Type = MAKE_PAIR64(methodId, serviceHash);
77  notification.Method.ObjectId = 1;
78  notification.Method.Token = _battlenetRequestToken++;
79 
80  if (request->ByteSize())
81  {
82  notification.Data.resize(request->ByteSize());
83  request->SerializePartialToArray(notification.Data.contents(), request->ByteSize());
84  }
85 
86  SendPacket(notification.Write());
87 }
uint8 * contents()
Definition: ByteBuffer.h:573
Definition: BattlenetPackets.h:39
void resize(size_t newsize)
Definition: ByteBuffer.h:590
uint64 MAKE_PAIR64(uint32 l, uint32 h)
Definition: ObjectDefines.h:34
uint32 Token
Definition: BattlenetPackets.h:33
MethodCall Method
Definition: BattlenetPackets.h:46
uint32 _battlenetRequestToken
Definition: WorldSession.h:1812
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
ByteBuffer Data
Definition: BattlenetPackets.h:47
uint64 ObjectId
Definition: BattlenetPackets.h:32
uint64 Type
Definition: BattlenetPackets.h:31
WorldPacket const * Write() override
Definition: BattlenetPackets.cpp:36

+ Here is the call graph for this function:

void WorldSession::SendBattlenetResponse ( uint32  serviceHash,
uint32  methodId,
uint32  token,
pb::Message const response 
)
40 {
42  bnetResponse.BnetStatus = ERROR_OK;
43  bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
44  bnetResponse.Method.ObjectId = 1;
45  bnetResponse.Method.Token = token;
46 
47  if (response->ByteSize())
48  {
49  bnetResponse.Data.resize(response->ByteSize());
50  response->SerializePartialToArray(bnetResponse.Data.contents(), response->ByteSize());
51  }
52 
53  SendPacket(bnetResponse.Write());
54 }
WorldPacket const * Write() override
Definition: BattlenetPackets.cpp:45
uint8 * contents()
Definition: ByteBuffer.h:573
void resize(size_t newsize)
Definition: ByteBuffer.h:590
MethodCall Method
Definition: BattlenetPackets.h:58
uint64 MAKE_PAIR64(uint32 l, uint32 h)
Definition: ObjectDefines.h:34
uint32 Token
Definition: BattlenetPackets.h:33
BattlenetRpcErrorCode BnetStatus
Definition: BattlenetPackets.h:57
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: BattlenetPackets.h:50
Definition: BattlenetRpcErrorCodes.h:25
uint64 ObjectId
Definition: BattlenetPackets.h:32
ByteBuffer Data
Definition: BattlenetPackets.h:59
uint64 Type
Definition: BattlenetPackets.h:31

+ Here is the call graph for this function:

void WorldSession::SendBattlenetResponse ( uint32  serviceHash,
uint32  methodId,
uint32  token,
uint32  status 
)
57 {
59  bnetResponse.BnetStatus = BattlenetRpcErrorCode(status);
60  bnetResponse.Method.Type = MAKE_PAIR64(methodId, serviceHash);
61  bnetResponse.Method.ObjectId = 1;
62  bnetResponse.Method.Token = token;
63 
64  SendPacket(bnetResponse.Write());
65 }
WorldPacket const * Write() override
Definition: BattlenetPackets.cpp:45
MethodCall Method
Definition: BattlenetPackets.h:58
uint64 MAKE_PAIR64(uint32 l, uint32 h)
Definition: ObjectDefines.h:34
uint32 Token
Definition: BattlenetPackets.h:33
BattlenetRpcErrorCode BnetStatus
Definition: BattlenetPackets.h:57
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: BattlenetPackets.h:50
BattlenetRpcErrorCode
Definition: BattlenetRpcErrorCodes.h:23
uint64 ObjectId
Definition: BattlenetPackets.h:32
uint64 Type
Definition: BattlenetPackets.h:31

+ Here is the call graph for this function:

void WorldSession::SendBfEntered ( uint64  queueId,
bool  relocated,
bool  onOffense 
)

This is call when player accept to join war.

Parameters
queueIdThe queue id of Bf
relocatedWhether player is added to Bf on the spot or teleported from queue
onOffenseWhether player belongs to attacking team or not
95 {
97  bfMgrEntering.ClearedAFK = _player->isAFK();
98  bfMgrEntering.Relocated = relocated;
99  bfMgrEntering.OnOffense = onOffense;
100  bfMgrEntering.QueueID = queueId;
101  SendPacket(bfMgrEntering.Write());
102 }
bool Relocated
Definition: BattlefieldPackets.h:112
uint64 QueueID
Definition: BattlefieldPackets.h:114
bool ClearedAFK
Definition: BattlefieldPackets.h:111
WorldPacket const * Write() override
Definition: BattlefieldPackets.cpp:71
Definition: BattlefieldPackets.h:104
bool OnOffense
Definition: BattlefieldPackets.h:113
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

void WorldSession::SendBfInvitePlayerToQueue ( uint64  queueId,
int8  battleState 
)

This send invitation to player to join the queue.

Parameters
queueIdThe queue id of Bf
56 {
58  bfMgrQueueInvite.QueueID = queueId;
59  bfMgrQueueInvite.BattleState = battleState;
60  SendPacket(bfMgrQueueInvite.Write());
61 }
uint64 QueueID
Definition: BattlefieldPackets.h:58
int8 BattleState
Definition: BattlefieldPackets.h:59
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: BattlefieldPackets.h:51
WorldPacket const * Write() override
Definition: BattlefieldPackets.cpp:34

+ Here is the call graph for this function:

void WorldSession::SendBfInvitePlayerToWar ( uint64  queueId,
uint32  zoneId,
uint32  acceptTime 
)

This send to player windows for invite player to join the war.

Parameters
queueIdThe queue id of Bf
zoneIdThe zone where the battle is (4197 for wg)
acceptTimeTime in second that the player have for accept
40 {
42  bfMgrEntryInvite.QueueID = queueId;
43  bfMgrEntryInvite.AreaID = zoneId;
44  bfMgrEntryInvite.ExpireTime = time(nullptr) + acceptTime;
45  SendPacket(bfMgrEntryInvite.Write());
46 }
Definition: BattlefieldPackets.h:28
WorldPacket const * Write() override
Definition: BattlefieldPackets.cpp:20
time_t ExpireTime
Definition: BattlefieldPackets.h:37
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 AreaID
Definition: BattlefieldPackets.h:36
uint64 QueueID
Definition: BattlefieldPackets.h:35

+ Here is the call graph for this function:

void WorldSession::SendBfLeaveMessage ( uint64  queueId,
int8  battleState,
bool  relocated,
BFLeaveReason  reason = BF_LEAVE_REASON_EXITED 
)

This is call when player leave battlefield zone.

Parameters
queueIdThe queue id of Bf
battleStateBattlefield status
relocatedWhether player is added to Bf on the spot or teleported from queue
reasonReason why player left battlefield
115 {
117  bfMgrEjected.QueueID = queueId;
118  bfMgrEjected.Reason = reason;
119  bfMgrEjected.BattleState = battleState;
120  bfMgrEjected.Relocated = relocated;
121  SendPacket(bfMgrEjected.Write());
122 }
Definition: BattlefieldPackets.h:117
bool Relocated
Definition: BattlefieldPackets.h:127
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint64 QueueID
Definition: BattlefieldPackets.h:124
int8 BattleState
Definition: BattlefieldPackets.h:126
WorldPacket const * Write() override
Definition: BattlefieldPackets.cpp:80
int8 Reason
Definition: BattlefieldPackets.h:125

+ Here is the call graph for this function:

void WorldSession::SendBfQueueInviteResponse ( uint64  queueId,
uint32  zoneId,
int8  battleStatus,
bool  canQueue = true,
bool  loggingIn = false 
)

This send packet for inform player that he join queue.

Parameters
queueIdThe queue id of Bf
zoneIdThe zone where the battle is (4197 for wg)
battleStatusBattlefield status
canQueueif able to queue
loggingInon log in send queue status
75 {
77  bfMgrQueueRequestResponse.QueueID = queueId;
78  bfMgrQueueRequestResponse.AreaID = zoneId;
79  bfMgrQueueRequestResponse.Result = canQueue ? 1 : 0;
80  bfMgrQueueRequestResponse.BattleState = battleStatus;
81  bfMgrQueueRequestResponse.LoggingIn = loggingIn;
82  SendPacket(bfMgrQueueRequestResponse.Write());
83 }
Definition: BattlefieldPackets.h:79
bool LoggingIn
Definition: BattlefieldPackets.h:91
uint64 QueueID
Definition: BattlefieldPackets.h:86
int32 AreaID
Definition: BattlefieldPackets.h:87
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int8 BattleState
Definition: BattlefieldPackets.h:90
int8 Result
Definition: BattlefieldPackets.h:88
WorldPacket const * Write() override
Definition: BattlefieldPackets.cpp:54

+ Here is the call graph for this function:

void WorldSession::SendBindPoint ( Creature npc)
454 {
455  // prevent set homebind to instances in any case
456  if (GetPlayer()->GetMap()->Instanceable())
457  return;
458 
459  uint32 bindspell = 3286;
460 
461  // send spell for homebinding (3286)
462  npc->CastSpell(_player, bindspell, true);
463 
464  _player->PlayerTalkClass->SendCloseGossip();
465 }
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
Player * _player
Definition: WorldSession.h:1797
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendBlackMarketOpenResult ( ObjectGuid  guid,
Creature auctioneer 
)
41 {
43  packet.Guid = guid;
44  packet.Enable = false;
45  SendPacket(packet.Write());
46 }
bool Enable
Definition: BlackMarketPackets.h:47
WorldPacket const * Write() override
Definition: BlackMarketPackets.cpp:25
Definition: BlackMarketPackets.h:39
ObjectGuid Guid
Definition: BlackMarketPackets.h:46
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendCalendarRaidLockout ( InstanceSave const save,
bool  add 
)
516 {
517  time_t currTime = time(NULL);
518  if (add)
519  {
520  WorldPackets::Calendar::CalendarRaidLockoutAdded calendarRaidLockoutAdded;
521  calendarRaidLockoutAdded.InstanceID = save->GetInstanceId();
522  calendarRaidLockoutAdded.ServerTime = uint32(currTime);
523  calendarRaidLockoutAdded.MapID = int32(save->GetMapId());
524  calendarRaidLockoutAdded.DifficultyID = save->GetDifficultyID();
525  calendarRaidLockoutAdded.TimeRemaining = uint32(save->GetResetTime() - currTime);
526  SendPacket(calendarRaidLockoutAdded.Write());
527  }
528  else
529  {
530  WorldPackets::Calendar::CalendarRaidLockoutRemoved calendarRaidLockoutRemoved;
531  calendarRaidLockoutRemoved.InstanceID = save->GetInstanceId();
532  calendarRaidLockoutRemoved.MapID = int32(save->GetMapId());
533  calendarRaidLockoutRemoved.DifficultyID = save->GetDifficultyID();
534  SendPacket(calendarRaidLockoutRemoved.Write());
535  }
536 }
int32 MapID
Definition: CalendarPackets.h:498
uint32 ServerTime
Definition: CalendarPackets.h:486
int32 TimeRemaining
Definition: CalendarPackets.h:485
Definition: CalendarPackets.h:476
uint32 DifficultyID
Definition: CalendarPackets.h:484
arena_t NULL
Definition: jemalloc_internal.h:624
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:424
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:413
uint64 InstanceID
Definition: CalendarPackets.h:497
uint32 DifficultyID
Definition: CalendarPackets.h:499
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 MapID
Definition: CalendarPackets.h:487
int32_t int32
Definition: g3dmath.h:167
uint64 InstanceID
Definition: CalendarPackets.h:483
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

void WorldSession::SendCalendarRaidLockoutUpdated ( InstanceSave const save)
539 {
540  if (!save)
541  return;
542 
543  ObjectGuid guid = _player->GetGUID();
544  TC_LOG_DEBUG("network", "SMSG_CALENDAR_RAID_LOCKOUT_UPDATED [%s] Map: %u, Difficulty %u", guid.ToString().c_str(), save->GetMapId(), save->GetDifficultyID());
545 
546  time_t currTime = time(NULL);
547 
549  packet.DifficultyID = save->GetDifficultyID();
550  packet.MapID = save->GetMapId();
551  packet.NewTimeRemaining = 0; // FIXME
552  packet.OldTimeRemaining = save->GetResetTime() - currTime;
553 
554  SendPacket(packet.Write());
555 }
int32 MapID
Definition: CalendarPackets.h:509
int32 NewTimeRemaining
Definition: CalendarPackets.h:513
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 DifficultyID
Definition: CalendarPackets.h:512
WorldPacket const * Write() override
Definition: CalendarPackets.cpp:433
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
Definition: ObjectGuid.h:189
std::string ToString() const
Definition: ObjectGuid.cpp:99
int32 OldTimeRemaining
Definition: CalendarPackets.h:510

+ Here is the call graph for this function:

void WorldSession::SendCancelTrade ( )
553 {
555  return;
556 
559  SendTradeStatus(info);
560 }
void SendTradeStatus(WorldPackets::Trade::TradeStatus &status)
Definition: TradeHandler.cpp:34
Definition: SharedDefines.h:4651
Definition: TradePackets.h:130
bool PlayerRecentlyLoggedOut() const
Definition: WorldSession.h:892
bool PlayerLogout() const
Definition: WorldSession.h:890
::TradeStatus Status
Definition: TradePackets.h:137

+ Here is the call graph for this function:

void WorldSession::SendCharCreate ( ResponseCodes  result)
2482 {
2484  response.Code = result;
2485 
2486  SendPacket(response.Write());
2487 }
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:198
uint8 Code
Result code.
Definition: CharacterPackets.h:208
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: CharacterPackets.h:201

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendCharCustomize ( ResponseCodes  result,
WorldPackets::Character::CharCustomizeInfo const customizeInfo 
)
2509 {
2510  if (result == RESPONSE_SUCCESS)
2511  {
2512  WorldPackets::Character::CharCustomizeResponse response(customizeInfo);
2513  SendPacket(response.Write());
2514  }
2515  else
2516  {
2518  failed.Result = uint8(result);
2519  failed.CharGUID = customizeInfo->CharGUID;
2520  SendPacket(failed.Write());
2521  }
2522 }
Definition: CharacterPackets.h:710
ObjectGuid CharGUID
Definition: CharacterPackets.h:718
uint8 Result
Definition: CharacterPackets.h:717
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:543
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: SharedDefines.h:4424
uint8_t uint8
Definition: g3dmath.h:164
Definition: CharacterPackets.h:692

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendCharDelete ( ResponseCodes  result)
2490 {
2492  response.Code = result;
2493 
2494  SendPacket(response.Write());
2495 }
uint8 Code
Result code.
Definition: CharacterPackets.h:228
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:209
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: CharacterPackets.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendCharFactionChange ( ResponseCodes  result,
WorldPackets::Character::CharRaceOrFactionChangeInfo const factionChangeInfo 
)
2525 {
2527  packet.Result = result;
2528  packet.Guid = factionChangeInfo->Guid;
2529 
2530  if (result == RESPONSE_SUCCESS)
2531  {
2532  packet.Display = boost::in_place();
2533  packet.Display->Name = factionChangeInfo->Name;
2534  packet.Display->SexID = factionChangeInfo->SexID;
2535  packet.Display->SkinID = *factionChangeInfo->SkinID;
2536  packet.Display->HairColorID = *factionChangeInfo->HairColorID;
2537  packet.Display->HairStyleID = *factionChangeInfo->HairStyleID;
2538  packet.Display->FacialHairStyleID = *factionChangeInfo->FacialHairStyleID;
2539  packet.Display->FaceID = *factionChangeInfo->FaceID;
2540  packet.Display->RaceID = factionChangeInfo->RaceID;
2541  }
2542 
2543  SendPacket(packet.Write());
2544 }
ObjectGuid Guid
Definition: CharacterPackets.h:321
Definition: CharacterPackets.h:301
uint8 Result
Definition: CharacterPackets.h:320
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: SharedDefines.h:4424
Optional< CharFactionChangeDisplayInfo > Display
Definition: CharacterPackets.h:322
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:286

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendCharRename ( ResponseCodes  result,
WorldPackets::Character::CharacterRenameInfo const renameInfo 
)
2498 {
2500  packet.Result = result;
2501  packet.Name = renameInfo->NewName;
2502  if (result == RESPONSE_SUCCESS)
2503  packet.Guid = renameInfo->Guid;
2504 
2505  SendPacket(packet.Write());
2506 }
Definition: CharacterPackets.h:245
uint8 Result
Definition: CharacterPackets.h:253
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: SharedDefines.h:4424
Optional< ObjectGuid > Guid
Definition: CharacterPackets.h:254
std::string Name
Definition: CharacterPackets.h:252
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendChatPlayerNotfoundNotice ( std::string const name)
650 {
652 }
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: ChatPackets.h:238

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendChatRestricted ( ChatRestrictionType  restriction)
660 {
662  packet.Reason = restriction;
663  SendPacket(packet.Write());
664 }
WorldPacket const * Write() override
Definition: ChatPackets.cpp:283
Definition: ChatPackets.h:314
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8 Reason
Definition: ChatPackets.h:321

+ Here is the call graph for this function:

void WorldSession::SendClientCacheVersion ( uint32  version)
73 {
75  cache.CacheVersion = version;
76 
77  SendPacket(cache.Write());
78 }
Definition: ClientConfigPackets.h:54
WorldPacket const * Write() override
Definition: ClientConfigPackets.cpp:91
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 CacheVersion
Definition: ClientConfigPackets.h:61

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendConnectToInstance ( WorldPackets::Auth::ConnectToSerial  serial)
706 {
707  boost::system::error_code ignored_error;
708  boost::asio::ip::tcp::endpoint instanceAddress = realm.GetAddressForClient(boost::asio::ip::address::from_string(GetRemoteAddress(), ignored_error));
709  instanceAddress.port(sWorld->getIntConfig(CONFIG_PORT_INSTANCE));
710 
713  _instanceConnectKey.Fields.Key = urand(0, 0x7FFFFFFF);
714 
716  connectTo.Key = _instanceConnectKey.Raw;
717  connectTo.Serial = serial;
718  connectTo.Payload.Where = instanceAddress;
719  connectTo.Con = CONNECTION_TYPE_INSTANCE;
720 
721  SendPacket(connectTo.Write());
722 }
WorldPacket const * Write() override
Definition: AuthenticationPackets.cpp:305
Definition: World.h:216
Realm realm
Definition: World.cpp:3485
uint64 ConnectionType
Definition: WorldSession.h:1717
Definition: AuthenticationPackets.h:145
uint32 GetAccountId() const
Definition: WorldSession.h:922
#define sWorld
Definition: World.h:887
uint64 AccountId
Definition: WorldSession.h:1716
uint64 Key
Definition: AuthenticationPackets.h:163
uint64 Key
Definition: WorldSession.h:1718
ConnectToSerial Serial
Definition: AuthenticationPackets.h:164
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
uint64 Raw
Definition: WorldSession.h:1721
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8 Con
Definition: AuthenticationPackets.h:166
Definition: Opcodes.h:32
struct WorldSession::ConnectToKey::@321 Fields
ConnectToKey _instanceConnectKey
Definition: WorldSession.h:1847
ConnectPayload Payload
Definition: AuthenticationPackets.h:165
tcp::endpoint Where
Definition: AuthenticationPackets.h:152
ip::tcp::endpoint GetAddressForClient(ip::address const &clientAddr) const
Definition: Realm.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendDiscoverNewTaxiNode ( uint32  nodeid)
155 {
156  if (GetPlayer()->m_taxi.SetTaximaskNode(nodeid))
158 }
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: TaxiPackets.h:103
Definition: TaxiPackets.h:98

+ Here is the call graph for this function:

void WorldSession::SendDoFlight ( uint32  mountDisplayId,
uint32  path,
uint32  pathNode = 0 
)
117 {
118  // remove fake death
119  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
120  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
121 
122  while (GetPlayer()->GetMotionMaster()->GetCurrentMovementGeneratorType() == FLIGHT_MOTION_TYPE)
123  GetPlayer()->GetMotionMaster()->MovementExpired(false);
124 
125  if (mountDisplayId)
126  GetPlayer()->Mount(mountDisplayId);
127 
128  GetPlayer()->GetMotionMaster()->MoveTaxiFlight(path, pathNode);
129 }
Definition: MotionMaster.h:45
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: SpellAuraDefines.h:126
Definition: Unit.h:550

+ Here is the call graph for this function:

void WorldSession::SendEnchantmentLog ( ObjectGuid  target,
ObjectGuid  caster,
uint32  itemId,
uint32  enchantId 
)
705 {
706  WorldPacket data(SMSG_ENCHANTMENT_LOG, (8+8+4+4));
707  data << target;
708  data << caster;
709  data << uint32(itemId);
710  data << uint32(enchantId);
711  GetPlayer()->SendMessageToSet(&data, true);
712 }
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Opcodes.h:971
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendFeatureSystemStatus ( )

START OF DUMMY VALUES

END OF DUMMY VALUES

1144 {
1146 
1148  features.ComplaintStatus = 2;
1151  features.TwitterPostThrottleLimit = 60;
1152  features.TwitterPostThrottleCooldown = 20;
1153  features.CfgRealmID = 2;
1154  features.CfgRealmRecID = 0;
1155  features.TokenPollTimeSeconds = 300;
1156  features.TokenRedeemIndex = 0;
1157  features.VoiceEnabled = false;
1158  features.BrowserEnabled = false; // Has to be false, otherwise client will crash if "Customer Support" is opened
1159 
1160  features.EuropaTicketSystemStatus = boost::in_place();
1161  features.EuropaTicketSystemStatus->ThrottleState.MaxTries = 10;
1162  features.EuropaTicketSystemStatus->ThrottleState.PerMilliseconds = 60000;
1163  features.EuropaTicketSystemStatus->ThrottleState.TryCount = 1;
1164  features.EuropaTicketSystemStatus->ThrottleState.LastResetTimeBeforeNow = 111111;
1165  features.ComplaintStatus = 0;
1166  features.TutorialsEnabled = true;
1167  features.NPETutorialsEnabled = true;
1169 
1170  features.EuropaTicketSystemStatus->TicketsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_TICKETS_ENABLED);
1171  features.EuropaTicketSystemStatus->BugsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_BUGS_ENABLED);
1172  features.EuropaTicketSystemStatus->ComplaintsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_COMPLAINTS_ENABLED);
1173  features.EuropaTicketSystemStatus->SuggestionsEnabled = sWorld->getBoolConfig(CONFIG_SUPPORT_SUGGESTIONS_ENABLED);
1174 
1177 
1178  SendPacket(features.Write());
1179 }
Definition: World.h:157
int32 TokenPollTimeSeconds
Definition: SystemPackets.h:74
Definition: World.h:155
Optional< EuropaTicketConfig > EuropaTicketSystemStatus
Definition: SystemPackets.h:67
bool TutorialsEnabled
Definition: SystemPackets.h:85
uint8 ComplaintStatus
Definition: SystemPackets.h:70
int32 TwitterPostThrottleCooldown
Time in seconds the client has to wait before posting again after hitting post limit.
Definition: SystemPackets.h:73
bool CharUndeleteEnabled
Implemented.
Definition: SystemPackets.h:77
#define sWorld
Definition: World.h:887
uint32 ScrollOfResurrectionMaxRequestsPerDay
Definition: SystemPackets.h:65
bool BrowserEnabled
Definition: SystemPackets.h:60
Definition: World.h:158
uint32 ScrollOfResurrectionRequestsRemaining
Definition: SystemPackets.h:68
bool NPETutorialsEnabled
Definition: SystemPackets.h:86
int32 CfgRealmRecID
Definition: SystemPackets.h:71
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 CfgRealmID
Definition: SystemPackets.h:69
Definition: SystemPackets.h:27
bool VoiceEnabled
Definition: SystemPackets.h:59
int32 TwitterPostThrottleLimit
Number of twitter posts the client can send before they start being throttled.
Definition: SystemPackets.h:72
int32 TokenRedeemIndex
Definition: SystemPackets.h:75
WorldPacket const * Write() override
Definition: SystemPackets.cpp:20
bool BpayStoreEnabled
Definition: SystemPackets.h:63
Definition: World.h:156

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendFeatureSystemStatusGlueScreen ( )
91 {
93  features.BpayStoreAvailable = false;
94  features.BpayStoreDisabledByParentalControls = false;
97 
98  SendPacket(features.Write());
99 }
#define sWorld
Definition: World.h:887
bool BpayStoreDisabledByParentalControls
Definition: SystemPackets.h:98
bool CharUndeleteEnabled
Definition: SystemPackets.h:99
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: SystemPackets.cpp:87
bool BpayStoreAvailable
Definition: SystemPackets.h:97
bool BpayStoreEnabled
Definition: SystemPackets.h:100

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendItemEnchantTimeUpdate ( ObjectGuid  Playerguid,
ObjectGuid  Itemguid,
uint32  slot,
uint32  Duration 
)
715 {
717  data.ItemGuid = Itemguid;
718  data.DurationLeft = Duration;
719  data.Slot = slot;
720  data.OwnerGuid = Playerguid;
721  SendPacket(data.Write());
722 }
uint32 Slot
Definition: ItemPackets.h:468
Definition: ItemPackets.h:458
ObjectGuid OwnerGuid
Definition: ItemPackets.h:465
WorldPacket const * Write() override
Definition: ItemPackets.cpp:489
ObjectGuid ItemGuid
Definition: ItemPackets.h:466
uint32 DurationLeft
Definition: ItemPackets.h:467
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

bool WorldSession::SendItemInfo ( uint32  itemid,
WorldPacket  data 
)
void WorldSession::SendItemPageInfo ( ItemTemplate itemProto)
bool WorldSession::SendLearnNewTaxiNode ( Creature unit)
132 {
133  // find current node
134  uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
135 
136  if (curloc == 0)
137  return true; // `true` send to avoid WorldSession::SendTaxiMenu call with one more curlock seartch with same false result.
138 
139  if (GetPlayer()->m_taxi.SetTaximaskNode(curloc))
140  {
142 
144  data.Unit = unit->GetGUID();
145  data.Status = TAXISTATUS_LEARNED;
146  SendPacket(data.Write());
147 
148  return true;
149  }
150  else
151  return false;
152 }
Definition: SharedDefines.h:4713
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: TaxiPackets.cpp:25
ObjectGuid const & GetGUID() const
Definition: Object.h:105
ObjectGuid Unit
Definition: TaxiPackets.h:47
Definition: TaxiPackets.h:39
float GetPositionX() const
Definition: Position.h:104
Definition: TaxiPackets.h:98
uint8 Status
Definition: TaxiPackets.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendLfgBootProposalUpdate ( lfg::LfgPlayerBoot const boot)
698 {
699  ObjectGuid guid = GetPlayer()->GetGUID();
700  lfg::LfgAnswer playerVote = boot.votes.find(guid)->second;
701  uint8 votesNum = 0;
702  uint8 agreeNum = 0;
703  uint32 secsleft = uint8((boot.cancelTime - time(NULL)) / 1000);
704  for (lfg::LfgAnswerContainer::const_iterator it = boot.votes.begin(); it != boot.votes.end(); ++it)
705  {
706  if (it->second != lfg::LFG_ANSWER_PENDING)
707  {
708  ++votesNum;
709  if (it->second == lfg::LFG_ANSWER_AGREE)
710  ++agreeNum;
711  }
712  }
713  TC_LOG_DEBUG("lfg", "SMSG_LFG_BOOT_PROPOSAL_UPDATE %s inProgress: %u - "
714  "didVote: %u - agree: %u - victim: %s votes: %u - agrees: %u - left: %u - "
715  "needed: %u - reason %s",
716  GetPlayerInfo().c_str(), uint8(boot.inProgress), uint8(playerVote != lfg::LFG_ANSWER_PENDING),
717  uint8(playerVote == lfg::LFG_ANSWER_AGREE), boot.victim.ToString().c_str(), votesNum, agreeNum,
718  secsleft, lfg::LFG_GROUP_KICK_VOTES_NEEDED, boot.reason.c_str());
719  WorldPacket data(SMSG_LFG_BOOT_PLAYER, 1 + 1 + 1 + 1 + 8 + 4 + 4 + 4 + 4 + boot.reason.length());
720  data << uint8(boot.inProgress); // Vote in progress
721  data << uint8(agreeNum >= lfg::LFG_GROUP_KICK_VOTES_NEEDED); // Did succeed
722  data << uint8(playerVote != lfg::LFG_ANSWER_PENDING); // Did Vote
723  data << uint8(playerVote == lfg::LFG_ANSWER_AGREE); // Agree
724  data << boot.victim; // Victim GUID
725  data << uint32(votesNum); // Total Votes
726  data << uint32(agreeNum); // Agree Count
727  data << uint32(secsleft); // Time Left
728  data << uint32(lfg::LFG_GROUP_KICK_VOTES_NEEDED); // Needed Votes
729  data << boot.reason.c_str(); // Kick reason
730  SendPacket(&data);
731 }
Definition: LFG.h:97
Definition: LFGMgr.h:50
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
LfgAnswer
Answer state (Also used to check compatibilites)
Definition: LFG.h:95
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: LFG.h:99
uint8_t uint8
Definition: g3dmath.h:164
Definition: Opcodes.h:1158
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgDisabled ( )
844 {
845  TC_LOG_DEBUG("lfg", "SMSG_LFG_DISABLED %s", GetPlayerInfo().c_str());
847  SendPacket(&data);
848 }
Definition: Opcodes.h:1159
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgJoinResult ( lfg::LfgJoinResultData const joinData)
560 {
561  uint32 size = 0;
562  ObjectGuid guid = GetPlayer()->GetGUID();
563  uint32 queueId = sLFGMgr->GetQueueId(_player->GetGUID());
564  for (lfg::LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
565  size += 8 + 4 + uint32(it->second.size()) * (4 + 4 + 4 + 4);
566 
567  TC_LOG_DEBUG("lfg", "SMSG_LFG_JOIN_RESULT %s checkResult: %u checkValue: %u",
568  GetPlayerInfo().c_str(), joinData.result, joinData.state);
569 
570  WorldPacket data(SMSG_LFG_JOIN_RESULT, 4 + 4 + size);
571  data << uint32(3);
572  data << uint8(joinData.result); // Check Result
573  data << uint32(queueId); // Queue Id
574  data << uint8(joinData.state); // Check Value
575  data << uint32(time(NULL)); // Join date
576  data.WriteBit(guid[2]);
577  data.WriteBit(guid[7]);
578  data.WriteBit(guid[3]);
579  data.WriteBit(guid[0]);
580  data.WriteBits(joinData.lockmap.size(), 24);
581  for (lfg::LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
582  {
583  ObjectGuid playerGuid = it->first;
584  data.WriteBit(playerGuid[7]);
585  data.WriteBit(playerGuid[5]);
586  data.WriteBit(playerGuid[3]);
587  data.WriteBit(playerGuid[6]);
588  data.WriteBit(playerGuid[0]);
589  data.WriteBit(playerGuid[2]);
590  data.WriteBit(playerGuid[4]);
591  data.WriteBit(playerGuid[1]);
592  data.WriteBits(it->second.size(), 22);
593  }
594 
595  data.WriteBit(guid[4]);
596  data.WriteBit(guid[5]);
597  data.WriteBit(guid[1]);
598  data.WriteBit(guid[6]);
599  for (lfg::LfgLockPartyMap::const_iterator it = joinData.lockmap.begin(); it != joinData.lockmap.end(); ++it)
600  {
601  ObjectGuid playerGuid = it->first;
602  for (lfg::LfgLockMap::const_iterator itr = it->second.begin(); itr != it->second.end(); ++itr)
603  {
604  TC_LOG_TRACE("lfg", "SendLfgJoinResult:: %s DungeonID: %u Lock status: %u Required itemLevel: %u Current itemLevel: %f",
605  playerGuid.ToString().c_str(), (itr->first & 0x00FFFFFF), itr->second.lockStatus, itr->second.requiredItemLevel, itr->second.currentItemLevel);
606 
607  data << uint32(itr->second.lockStatus); // Lock status
608  data << uint32(itr->second.currentItemLevel); // Current itemLevel
609  data << uint32(itr->second.requiredItemLevel); // Required itemLevel
610  data << uint32(itr->first); // Dungeon entry (id + type)
611  }
612 
613  data.WriteByteSeq(playerGuid[2]);
614  data.WriteByteSeq(playerGuid[5]);
615  data.WriteByteSeq(playerGuid[1]);
616  data.WriteByteSeq(playerGuid[0]);
617  data.WriteByteSeq(playerGuid[4]);
618  data.WriteByteSeq(playerGuid[3]);
619  data.WriteByteSeq(playerGuid[6]);
620  data.WriteByteSeq(playerGuid[7]);
621  }
622 
623  data.WriteByteSeq(guid[1]);
624  data.WriteByteSeq(guid[4]);
625  data.WriteByteSeq(guid[3]);
626  data.WriteByteSeq(guid[5]);
627  data.WriteByteSeq(guid[0]);
628  data.WriteByteSeq(guid[7]);
629  data.WriteByteSeq(guid[2]);
630  data.WriteByteSeq(guid[6]);
631 
632  SendPacket(&data);
633 }
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
Definition: Opcodes.h:1160
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
Player * _player
Definition: WorldSession.h:1797
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void WorldSession::SendLfgLfrList ( bool  update)
835 {
836  //TC_LOG_DEBUG("lfg", "SMSG_LFG_LFR_LIST %s update: %u",
837  // GetPlayerInfo().c_str(), update ? 1 : 0);
838  //WorldPacket data(SMSG_LFG_UPDATE_SEARCH, 1);
839  //data << uint8(update); // In Lfg Queue?
840  //SendPacket(&data);
841 }
void WorldSession::SendLfgOfferContinue ( uint32  dungeonEntry)
851 {
852  TC_LOG_DEBUG("lfg", "SMSG_LFG_OFFER_CONTINUE %s dungeon entry: %u",
853  GetPlayerInfo().c_str(), dungeonEntry);
855  data << uint32(dungeonEntry);
856  SendPacket(&data);
857 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Opcodes.h:1166
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgPartyLockInfo ( )
356 {
357  ObjectGuid guid = GetPlayer()->GetGUID();
358  Group* group = GetPlayer()->GetGroup();
359  if (!group)
360  return;
361 
362  // Get the locked dungeons of the other party members
363  lfg::LfgLockPartyMap lockMap;
364  for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
365  {
366  Player* plrg = itr->GetSource();
367  if (!plrg)
368  continue;
369 
370  ObjectGuid pguid = plrg->GetGUID();
371  if (pguid == guid)
372  continue;
373 
374  lockMap[pguid] = sLFGMgr->GetLockedDungeons(pguid);
375  }
376 
377  uint32 size = 0;
378  for (lfg::LfgLockPartyMap::const_iterator it = lockMap.begin(); it != lockMap.end(); ++it)
379  size += 8 + 4 + uint32(it->second.size()) * (4 + 4 + 4 + 4);
380 
381  TC_LOG_DEBUG("lfg", "SMSG_LFG_PARTY_INFO %s", GetPlayerInfo().c_str());
382  WorldPacket data(SMSG_LFG_PARTY_INFO, 1 + size);
383  BuildPartyLockDungeonBlock(data, lockMap);
384  SendPacket(&data);
385 }
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Opcodes.h:1167
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
void BuildPartyLockDungeonBlock(WorldPacket &data, lfg::LfgLockPartyMap const &lockMap)
Definition: LFGHandler.cpp:41
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
std::map< ObjectGuid, LfgLockMap > LfgLockPartyMap
Definition: LFG.h:114
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
GroupReference * GetFirstMember()
Definition: Group.h:295
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26
Definition: Group.h:191
Definition: GroupReference.h:27

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendLfgPlayerLockInfo ( )
284 {
285  ObjectGuid guid = GetPlayer()->GetGUID();
286 
287  // Get Random dungeons that can be done at a certain level and expansion
288  uint8 level = GetPlayer()->getLevel();
289  lfg::LfgDungeonSet const& randomDungeons =
290  sLFGMgr->GetRandomAndSeasonalDungeons(level, GetExpansion());
291 
292  // Get player locked Dungeons
293  lfg::LfgLockMap const& lock = sLFGMgr->GetLockedDungeons(guid);
294  uint32 rsize = uint32(randomDungeons.size());
295  uint32 lsize = uint32(lock.size());
296 
297  TC_LOG_DEBUG("lfg", "SMSG_LFG_PLAYER_INFO %s", GetPlayerInfo().c_str());
298  WorldPacket data(SMSG_LFG_PLAYER_INFO, 1 + rsize * (4 + 1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4) + 4 + lsize * (1 + 4 + 4 + 4 + 4 + 1 + 4 + 4 + 4));
299 
300  data << uint8(randomDungeons.size()); // Random Dungeon count
301  for (lfg::LfgDungeonSet::const_iterator it = randomDungeons.begin(); it != randomDungeons.end(); ++it)
302  {
303  data << uint32(*it); // Dungeon Entry (id + type)
304  lfg::LfgReward const* reward = sLFGMgr->GetRandomDungeonReward(*it, level);
305  Quest const* quest = NULL;
306  bool done = false;
307  if (reward)
308  {
309  quest = sObjectMgr->GetQuestTemplate(reward->firstQuest);
310  if (quest)
311  {
312  done = !GetPlayer()->CanRewardQuest(quest, false);
313  if (done)
314  quest = sObjectMgr->GetQuestTemplate(reward->otherQuest);
315  }
316  }
317 
318  data << uint8(done);
319  data << uint32(0); // currencyQuantity
320  data << uint32(0); // some sort of overall cap/weekly cap
321  data << uint32(0); // currencyID
322  data << uint32(0); // tier1Quantity
323  data << uint32(0); // tier1Limit
324  data << uint32(0); // overallQuantity
325  data << uint32(0); // overallLimit
326  data << uint32(0); // periodPurseQuantity
327  data << uint32(0); // periodPurseLimit
328  data << uint32(0); // purseQuantity
329  data << uint32(0); // purseLimit
330  data << uint32(0); // some sort of reward for completion
331  data << uint32(0); // completedEncounters
332  data << uint8(0); // Call to Arms eligible
333 
334  for (uint32 i = 0; i < 3; ++i)
335  {
336  data << uint32(0); // Call to Arms Role
337  //if (role)
338  // BuildQuestReward(data, ctaRoleQuest, GetPlayer());
339  }
340 
341  if (quest)
342  BuildQuestReward(data, quest, GetPlayer());
343  else
344  {
345  data << uint32(0); // Money
346  data << uint32(0); // XP
347  data << uint8(0); // Reward count
348  }
349  }
350 
351  BuildPlayerLockDungeonBlock(data, lock);
352  SendPacket(&data);
353 }
Definition: QuestDef.h:279
void BuildQuestReward(WorldPacket &data, Quest const *quest, Player *player)
Definition: LFGHandler.cpp:51
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
std::map< uint32, LfgLockInfoData > LfgLockMap
Definition: LFG.h:113
uint8 GetExpansion() const
Definition: WorldSession.h:934
#define sLFGMgr
Definition: LFGMgr.h:481
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
Reward info.
Definition: LFGMgr.h:208
void BuildPlayerLockDungeonBlock(WorldPacket &data, lfg::LfgLockMap const &lock)
Definition: LFGHandler.cpp:26
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint32 otherQuest
Definition: LFGMgr.h:215
Definition: Opcodes.h:1168
uint8_t uint8
Definition: Define.h:152
uint32 firstQuest
Definition: LFGMgr.h:214
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendLfgPlayerReward ( lfg::LfgPlayerRewardData const lfgPlayerRewardData)
681 {
682  if (!rewardData.rdungeonEntry || !rewardData.sdungeonEntry || !rewardData.quest)
683  return;
684 
685  TC_LOG_DEBUG("lfg", "SMSG_LFG_PLAYER_REWARD %s rdungeonEntry: %u, sdungeonEntry: %u, done: %u",
686  GetPlayerInfo().c_str(), rewardData.rdungeonEntry, rewardData.sdungeonEntry, rewardData.done);
687 
688  uint8 itemNum = rewardData.quest->GetRewItemsCount() + rewardData.quest->GetRewCurrencyCount();
689 
690  WorldPacket data(SMSG_LFG_PLAYER_REWARD, 4 + 4 + 1 + 4 + 4 + 4 + 4 + 4 + 1 + itemNum * (4 + 4 + 4));
691  data << uint32(rewardData.rdungeonEntry); // Random Dungeon Finished
692  data << uint32(rewardData.sdungeonEntry); // Dungeon Finished
693  BuildQuestReward(data, rewardData.quest, GetPlayer());
694  SendPacket(&data);
695 }
Definition: Opcodes.h:1169
void BuildQuestReward(WorldPacket &data, Quest const *quest, Player *player)
Definition: LFGHandler.cpp:51
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgQueueStatus ( lfg::LfgQueueStatusData const queueData)
636 {
637  TC_LOG_DEBUG("lfg", "SMSG_LFG_QUEUE_STATUS %s state: %s, dungeon: %u, waitTime: %d, "
638  "avgWaitTime: %d, waitTimeTanks: %d, waitTimeHealer: %d, waitTimeDps: %d, "
639  "queuedTime: %u, tanks: %u, healers: %u, dps: %u",
640  GetPlayerInfo().c_str(), lfg::GetStateString(sLFGMgr->GetState(GetPlayer()->GetGUID())).c_str(), queueData.dungeonId, queueData.waitTime, queueData.waitTimeAvg,
641  queueData.waitTimeTank, queueData.waitTimeHealer, queueData.waitTimeDps,
642  queueData.queuedTime, queueData.tanks, queueData.healers, queueData.dps);
643 
644  ObjectGuid guid = _player->GetGUID();
645  WorldPacket data(SMSG_LFG_QUEUE_STATUS, 4 + 4 + 4 + 4 + 4 + 4 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 8);
646  data.WriteBit(guid[3]);
647  data.WriteBit(guid[0]);
648  data.WriteBit(guid[2]);
649  data.WriteBit(guid[6]);
650  data.WriteBit(guid[5]);
651  data.WriteBit(guid[7]);
652  data.WriteBit(guid[1]);
653  data.WriteBit(guid[4]);
654 
655  data.WriteByteSeq(guid[0]);
656  data << uint8(queueData.tanks); // Tanks needed
657  data << int32(queueData.waitTimeTank); // Wait Tanks
658  data << uint8(queueData.healers); // Healers needed
659  data << int32(queueData.waitTimeHealer); // Wait Healers
660  data << uint8(queueData.dps); // Dps needed
661  data << int32(queueData.waitTimeDps); // Wait Dps
662  data.WriteByteSeq(guid[4]);
663  data.WriteByteSeq(guid[6]);
664  data << int32(queueData.waitTime); // Wait Time
665  data << uint32(queueData.joinTime); // Join time
666  data << uint32(queueData.dungeonId); // Dungeon
667  data << uint32(queueData.queuedTime); // Player wait time in queue
668  data.WriteByteSeq(guid[5]);
669  data.WriteByteSeq(guid[7]);
670  data.WriteByteSeq(guid[3]);
671  data << uint32(queueData.queueId); // Queue Id
672  data.WriteByteSeq(guid[1]);
673  data.WriteByteSeq(guid[2]);
674  data << int32(queueData.waitTimeAvg); // Average Wait time
675  data << uint32(3);
676 
677  SendPacket(&data);
678 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
std::string GetStateString(LfgState state)
Definition: LFG.cpp:74
#define sLFGMgr
Definition: LFGMgr.h:481
Definition: Opcodes.h:1171
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
Player * _player
Definition: WorldSession.h:1797
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
int32_t int32
Definition: g3dmath.h:167
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgRoleCheckUpdate ( lfg::LfgRoleCheck const pRoleCheck)
513 {
514  lfg::LfgDungeonSet dungeons;
515  if (roleCheck.rDungeonId)
516  dungeons.insert(roleCheck.rDungeonId);
517  else
518  dungeons = roleCheck.dungeons;
519 
520  TC_LOG_DEBUG("lfg", "SMSG_LFG_ROLE_CHECK_UPDATE %s", GetPlayerInfo().c_str());
521  WorldPacket data(SMSG_LFG_ROLE_CHECK_UPDATE, 4 + 1 + 1 + dungeons.size() * 4 + 1 + roleCheck.roles.size() * (8 + 1 + 4 + 1));
522 
523  data << uint32(roleCheck.state); // Check result
524  data << uint8(roleCheck.state == lfg::LFG_ROLECHECK_INITIALITING);
525  data << uint8(dungeons.size()); // Number of dungeons
526  if (!dungeons.empty())
527  for (lfg::LfgDungeonSet::iterator it = dungeons.begin(); it != dungeons.end(); ++it)
528  data << uint32(sLFGMgr->GetLFGDungeonEntry(*it)); // Dungeon
529 
530  data << uint8(roleCheck.roles.size()); // Players in group
531  if (!roleCheck.roles.empty())
532  {
533  // Leader info MUST be sent 1st :S
534  ObjectGuid guid = roleCheck.leader;
535  uint8 roles = roleCheck.roles.find(guid)->second;
537  data << guid; // Guid
538  data << uint8(roles > 0); // Ready
539  data << uint32(roles); // Roles
540  data << uint8(player ? player->getLevel() : 0); // Level
541 
542  for (lfg::LfgRolesMap::const_iterator it = roleCheck.roles.begin(); it != roleCheck.roles.end(); ++it)
543  {
544  if (it->first == roleCheck.leader)
545  continue;
546 
547  guid = it->first;
548  roles = it->second;
550  data << guid; // Guid
551  data << uint8(roles > 0); // Ready
552  data << uint32(roles); // Roles
553  data << uint8(player ? player->getLevel() : 0);// Level
554  }
555  }
556  SendPacket(&data);
557 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Opcodes.h:1174
#define sLFGMgr
Definition: LFGMgr.h:481
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
Definition: WorldPacket.h:26
Definition: LFGMgr.h:121

+ Here is the call graph for this function:

void WorldSession::SendLfgRoleChosen ( ObjectGuid  guid,
uint8  roles 
)
501 {
502  TC_LOG_DEBUG("lfg", "SMSG_LFG_ROLE_CHOSEN %s guid: %s roles: %u",
503  GetPlayerInfo().c_str(), guid.ToString().c_str(), roles);
504 
505  WorldPacket data(SMSG_ROLE_CHOSEN, 8 + 1 + 4);
506  data << guid; // Guid
507  data << uint8(roles > 0); // Ready
508  data << uint32(roles); // Roles
509  SendPacket(&data);
510 }
Definition: Opcodes.h:1463
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void WorldSession::SendLfgTeleportError ( uint8  err)
860 {
861  TC_LOG_DEBUG("lfg", "SMSG_LFG_TELEPORT_DENIED %s reason: %u",
862  GetPlayerInfo().c_str(), err);
864  data << uint32(err); // Error
865  SendPacket(&data);
866 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Definition: Opcodes.h:1177
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgUpdateProposal ( lfg::LfgProposal const proposal)
734 {
735  ObjectGuid guid = GetPlayer()->GetGUID();
736  ObjectGuid gguid = proposal.players.find(guid)->second.group;
737  bool silent = !proposal.isNew && gguid == proposal.group;
738  uint32 dungeonEntry = proposal.dungeonId;
739  uint32 queueId = sLFGMgr->GetQueueId(_player->GetGUID());
740  time_t joinTime = sLFGMgr->GetQueueJoinTime(_player->GetGUID());
741 
742  TC_LOG_DEBUG("lfg", "SMSG_LFG_PROPOSAL_UPDATE %s state: %u",
743  GetPlayerInfo().c_str(), proposal.state);
744 
745  // show random dungeon if player selected random dungeon and it's not lfg group
746  if (!silent)
747  {
748  lfg::LfgDungeonSet const& playerDungeons = sLFGMgr->GetSelectedDungeons(guid);
749  if (playerDungeons.find(proposal.dungeonId) == playerDungeons.end())
750  dungeonEntry = (*playerDungeons.begin());
751  }
752 
753  dungeonEntry = sLFGMgr->GetLFGDungeonEntry(dungeonEntry);
754 
755  WorldPacket data(SMSG_LFG_PROPOSAL_UPDATE, 4 + 1 + 4 + 4 + 1 + 1 + proposal.players.size() * (4 + 1 + 1 + 1 + 1 +1));
756  data << uint32(joinTime);
757  data << uint32(proposal.encounters); // Encounters done
758  data << uint32(queueId); // Queue Id
759  data << uint32(3); // Always 3
760  data << uint32(dungeonEntry); // Dungeon
761  data << uint32(proposal.id); // Proposal Id
762  data << uint8(proposal.state); // State
763 
764  ObjectGuid guid1 = guid;
765  ObjectGuid guid2 = gguid;
766 
767  data.WriteBit(guid2[4]);
768  data.WriteBit(guid1[3]);
769  data.WriteBit(guid1[7]);
770  data.WriteBit(guid1[0]);
771  data.WriteBit(guid2[1]);
772  data.WriteBit(silent);
773  data.WriteBit(guid1[4]);
774  data.WriteBit(guid1[5]);
775  data.WriteBit(guid2[3]);
776  data.WriteBits(proposal.players.size(), 23);
777  data.WriteBit(guid2[7]);
778 
779  for (lfg::LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
780  {
781  lfg::LfgProposalPlayer const& player = it->second;
782 
783  if (!player.group)
784  {
785  data.WriteBit(0);
786  data.WriteBit(0);
787  }
788  else
789  {
790  data.WriteBit(player.group == proposal.group); // Is group in dungeon
791  data.WriteBit(player.group == gguid); // Same group as the player
792  }
793 
794  data.WriteBit(player.accept == lfg::LFG_ANSWER_AGREE);
795  data.WriteBit(player.accept != lfg::LFG_ANSWER_PENDING);
796  data.WriteBit(it->first == guid);
797  }
798 
799  data.WriteBit(guid2[5]);
800  data.WriteBit(guid1[6]);
801  data.WriteBit(guid2[2]);
802  data.WriteBit(guid2[6]);
803  data.WriteBit(guid1[2]);
804  data.WriteBit(guid1[1]);
805  data.WriteBit(guid2[0]);
806 
807  data.WriteByteSeq(guid1[5]);
808  data.WriteByteSeq(guid2[3]);
809  data.WriteByteSeq(guid2[6]);
810  data.WriteByteSeq(guid1[6]);
811  data.WriteByteSeq(guid1[0]);
812  data.WriteByteSeq(guid2[5]);
813  data.WriteByteSeq(guid1[1]);
814 
815  for (lfg::LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
816  {
817  lfg::LfgProposalPlayer const& player = it->second;
818  data << uint32(player.role);
819  }
820 
821  data.WriteByteSeq(guid2[7]);
822  data.WriteByteSeq(guid1[4]);
823  data.WriteByteSeq(guid2[0]);
824  data.WriteByteSeq(guid2[1]);
825  data.WriteByteSeq(guid1[2]);
826  data.WriteByteSeq(guid1[7]);
827  data.WriteByteSeq(guid2[2]);
828  data.WriteByteSeq(guid1[3]);
829  data.WriteByteSeq(guid2[4]);
830 
831  SendPacket(&data);
832 }
Definition: LFG.h:97
LfgAnswer accept
Accept status (-1 not answer | 0 Not agree | 1 agree)
Definition: LFGMgr.h:223
uint8 role
Proposed role.
Definition: LFGMgr.h:222
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sLFGMgr
Definition: LFGMgr.h:481
std::set< uint32 > LfgDungeonSet
Definition: LFG.h:112
uint32_t uint32
Definition: Define.h:150
ObjectGuid group
Original group guid. 0 if no original group.
Definition: LFGMgr.h:224
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: LFG.h:99
uint8_t uint8
Definition: g3dmath.h:164
Player * _player
Definition: WorldSession.h:1797
Definition: Opcodes.h:1170
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
Stores player data related to proposal to join.
Definition: LFGMgr.h:219
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendLfgUpdateStatus ( lfg::LfgUpdateData const updateData,
bool  party 
)
430 {
431  bool join = false;
432  bool queued = false;
433  uint8 size = uint8(updateData.dungeons.size());
434  ObjectGuid guid = _player->GetGUID();
435  time_t joinTime = sLFGMgr->GetQueueJoinTime(_player->GetGUID());
436  uint32 queueId = sLFGMgr->GetQueueId(_player->GetGUID());
437 
438  switch (updateData.updateType)
439  {
440  case lfg::LFG_UPDATETYPE_JOIN_QUEUE_INITIAL: // Joined queue outside the dungeon
441  join = true;
442  break;
444  case lfg::LFG_UPDATETYPE_ADDED_TO_QUEUE: // Rolecheck Success
445  join = true;
446  queued = true;
447  break;
449  join = true;
450  break;
452  join = updateData.state != lfg::LFG_STATE_ROLECHECK && updateData.state != lfg::LFG_STATE_NONE;
453  queued = updateData.state == lfg::LFG_STATE_QUEUED;
454  break;
455  default:
456  break;
457  }
458 
459  TC_LOG_DEBUG("lfg", "SMSG_LFG_UPDATE_STATUS %s updatetype: %u, party %s",
460  GetPlayerInfo().c_str(), updateData.updateType, party ? "true" : "false");
461 
462  WorldPacket data(SMSG_LFG_UPDATE_STATUS, 1 + 8 + 3 + 2 + 1 + updateData.comment.length() + 4 + 4 + 1 + 1 + 1 + 4 + size);
463  data.WriteBit(guid[1]);
464  data.WriteBit(party);
465  data.WriteBits(size, 24);
466  data.WriteBit(guid[6]);
467  data.WriteBit(size > 0); // Extra info
468  data.WriteBits(updateData.comment.length(), 9);
469  data.WriteBit(guid[4]);
470  data.WriteBit(guid[7]);
471  data.WriteBit(guid[2]);
472  data.WriteBit(join); // LFG Join
473  data.WriteBit(guid[0]);
474  data.WriteBit(guid[3]);
475  data.WriteBit(guid[5]);
476  data.WriteBit(queued); // Join the queue
477 
478  data << uint8(updateData.updateType); // Lfg Update type
479  data.WriteString(updateData.comment);
480  data << uint32(queueId); // Queue Id
481  data << uint32(joinTime); // Join date
482  data.WriteByteSeq(guid[6]);
483  for (uint8 i = 0; i < 3; ++i)
484  data << uint8(0); // unk - Always 0
485 
486  data.WriteByteSeq(guid[1]);
487  data.WriteByteSeq(guid[2]);
488  data.WriteByteSeq(guid[4]);
489  data.WriteByteSeq(guid[3]);
490  data.WriteByteSeq(guid[5]);
491  data.WriteByteSeq(guid[0]);
492  data << uint32(3);
493  data.WriteByteSeq(guid[7]);
494  for (lfg::LfgDungeonSet::const_iterator it = updateData.dungeons.begin(); it != updateData.dungeons.end(); ++it)
495  data << uint32(*it);
496 
497  SendPacket(&data);
498 }
Definition: LFG.h:68
Definition: LFG.h:48
Definition: LFG.h:67
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: LFG.h:69
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
#define sLFGMgr
Definition: LFGMgr.h:481
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
Player * _player
Definition: WorldSession.h:1797
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
uint8_t uint8
Definition: Define.h:152
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
Definition: Opcodes.h:1178
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendListInventory ( ObjectGuid  guid)
541 {
542  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_LIST_INVENTORY");
543 
544  Creature* vendor = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
545  if (!vendor)
546  {
547  TC_LOG_DEBUG("network", "WORLD: SendListInventory - %s not found or you can not interact with him.", vendorGuid.ToString().c_str());
549  return;
550  }
551 
552  // remove fake death
553  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
554  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
555 
556  // Stop the npc if moving
557  if (vendor->HasUnitState(UNIT_STATE_MOVING))
558  vendor->StopMoving();
559 
560  VendorItemData const* vendorItems = vendor->GetVendorItems();
561  uint32 rawItemCount = vendorItems ? vendorItems->GetItemCount() : 0;
562 
564  packet.Vendor = vendor->GetGUID();
565 
566  packet.Items.resize(rawItemCount);
567 
568  const float discountMod = _player->GetReputationPriceDiscount(vendor);
569  uint8 count = 0;
570  for (uint32 slot = 0; slot < rawItemCount; ++slot)
571  {
572  VendorItem const* vendorItem = vendorItems->GetItem(slot);
573  if (!vendorItem)
574  continue;
575 
576  WorldPackets::NPC::VendorItem& item = packet.Items[count];
577 
578  if (vendorItem->Type == ITEM_VENDOR_TYPE_ITEM)
579  {
580  ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(vendorItem->item);
581  if (!itemTemplate)
582  continue;
583 
584  int32 leftInStock = !vendorItem->maxcount ? -1 : vendor->GetVendorItemCurrentCount(vendorItem);
585  if (!_player->IsGameMaster()) // ignore conditions if GM on
586  {
587  // Respect allowed class
588  if (!(itemTemplate->GetAllowableClass() & _player->getClassMask()) && itemTemplate->GetBonding() == BIND_WHEN_PICKED_UP)
589  continue;
590 
591  // Only display items in vendor lists for the team the player is on
592  if ((itemTemplate->GetFlags2() & ITEM_FLAG2_HORDE_ONLY && _player->GetTeam() == ALLIANCE) ||
593  (itemTemplate->GetFlags2() & ITEM_FLAG2_ALLIANCE_ONLY && _player->GetTeam() == HORDE))
594  continue;
595 
596  // Items sold out are not displayed in list
597  if (leftInStock == 0)
598  continue;
599  }
600 
601  if (!sConditionMgr->IsObjectMeetingVendorItemConditions(vendor->GetEntry(), vendorItem->item, _player, vendor))
602  {
603  TC_LOG_DEBUG("condition", "SendListInventory: conditions not met for creature entry %u item %u", vendor->GetEntry(), vendorItem->item);
604  continue;
605  }
606 
607  int32 price = vendorItem->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->GetBuyPrice() * discountMod)) : 0;
608 
609  if (int32 priceMod = _player->GetTotalAuraModifier(SPELL_AURA_MOD_VENDOR_ITEMS_PRICES))
610  price -= CalculatePct(price, priceMod);
611 
612  item.MuID = slot + 1; // client expects counting to start at 1
613  item.Durability = itemTemplate->MaxDurability;
614  item.ExtendedCostID = vendorItem->ExtendedCost;
615  item.Type = vendorItem->Type;
616  item.Quantity = leftInStock;
617  item.StackCount = itemTemplate->GetBuyCount();
618  item.Price = price;
619 
620  item.Item.ItemID = vendorItem->item;
621  }
622  else if (vendorItem->Type == ITEM_VENDOR_TYPE_CURRENCY)
623  {
624  CurrencyTypesEntry const* currencyTemplate = sCurrencyTypesStore.LookupEntry(vendorItem->item);
625  if (!currencyTemplate)
626  continue;
627 
628  if (!vendorItem->ExtendedCost)
629  continue; // there's no price defined for currencies, only extendedcost is used
630 
631  item.MuID = slot + 1; // client expects counting to start at 1
632  item.ExtendedCostID = vendorItem->ExtendedCost;
633  item.Item.ItemID = vendorItem->item;
634  item.Type = vendorItem->Type;
635  item.StackCount = vendorItem->maxcount;
636  }
637  else
638  continue;
639 
640  if (++count >= MAX_VENDOR_ITEMS)
641  break;
642  }
643 
644  // Resize vector to real size (some items can be skipped due to checks)
645  packet.Items.resize(count);
646 
647  SendPacket(packet.Write());
648 }
VendorItem * GetItem(uint32 slot) const
Definition: Creature.h:387
#define MAX_VENDOR_ITEMS
Definition: Creature.h:461
Definition: Unit.h:586
int32 Durability
Definition: NPCPackets.h:111
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
int32 GetAllowableClass() const
Definition: ItemTemplate.h:665
uint8 Type
Definition: Creature.h:376
uint32 maxcount
Definition: Creature.h:373
Definition: Item.h:165
int32 ExtendedCostID
Definition: NPCPackets.h:113
DB2Storage< CurrencyTypesEntry > sCurrencyTypesStore("CurrencyTypes.db2", CurrencyTypesFormat, HOTFIX_SEL_CURRENCY_TYPES)
Definition: Unit.h:742
static Vector3int16 floor(const Vector3 &v)
std::vector< VendorItem > Items
Definition: NPCPackets.h:126
int32 StackCount
Definition: NPCPackets.h:112
ObjectGuid Vendor
Definition: NPCPackets.h:127
Definition: SpellAuraDefines.h:397
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32 GetBuyCount() const
Definition: ItemTemplate.h:661
Definition: ItemTemplate.h:120
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: NPCPackets.h:118
Definition: Creature.h:367
Definition: NPCPackets.h:104
Definition: DB2Structure.h:330
Definition: SharedDefines.h:1000
uint32 GetFlags2() const
Definition: ItemTemplate.h:657
WorldPacket const * Write() override
Definition: NPCPackets.cpp:68
Definition: ItemTemplate.h:209
Definition: ItemTemplate.h:292
VendorItemData const * GetVendorItems() const
Definition: Creature.cpp:2432
int32_t int32
Definition: Define.h:146
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
#define sConditionMgr
Definition: ConditionMgr.h:307
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
T CalculatePct(T base, U pct)
Definition: Util.h:92
Definition: SharedDefines.h:999
uint32 GetItemCount() const
Definition: Creature.h:395
uint32 MaxDurability
Definition: ItemTemplate.h:706
int32 Quantity
Definition: NPCPackets.h:109
bool IsGoldRequired(ItemTemplate const *pProto) const
Definition: Creature.h:379
ItemBondingType GetBonding() const
Definition: ItemTemplate.h:683
ObjectGuid const & GetGUID() const
Definition: Object.h:105
int32 Type
Definition: NPCPackets.h:107
Definition: ItemTemplate.h:210
int32 MuID
Definition: NPCPackets.h:106
Definition: ItemTemplate.h:647
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
int32 Price
Definition: NPCPackets.h:110
uint32 item
Definition: Creature.h:372
WorldPackets::Item::ItemInstance Item
Definition: NPCPackets.h:108
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
uint8_t uint8
Definition: Define.h:152
uint32 GetEntry() const
Definition: Object.h:107
uint32 GetVendorItemCurrentCount(VendorItem const *vItem)
Definition: Creature.cpp:2437
uint32_t uint32
Definition: g3dmath.h:168
uint32 ExtendedCost
Definition: Creature.h:375
Definition: Creature.h:383
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743
uint32 ItemID
Definition: ItemPackets.h:46
uint32 GetBuyPrice() const
Definition: ItemTemplate.h:662
Definition: ItemTemplate.h:293

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendLoadCUFProfiles ( )
1103 {
1104  Player* player = GetPlayer();
1105 
1106  WorldPackets::Misc::LoadCUFProfiles loadCUFProfiles;
1107 
1108  for (uint8 i = 0; i < MAX_CUF_PROFILES; i++)
1109  if (CUFProfile* cufProfile = player->GetCUFProfile(i))
1110  loadCUFProfiles.CUFProfiles.push_back(cufProfile);
1111  SendPacket(loadCUFProfiles.Write());
1112 }
#define MAX_CUF_PROFILES
Maximum number of CompactUnitFrames profiles.
Definition: Player.h:202
Player * GetPlayer() const
Definition: WorldSession.h:927
std::vector< CUFProfile const * > CUFProfiles
Definition: MiscPackets.h:666
WorldPacket const * Write() override
Definition: MiscPackets.cpp:494
Definition: MiscPackets.h:659
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: Define.h:152
Represents a CompactUnitFrame profile.
Definition: Player.h:239

+ Here is the call graph for this function:

void WorldSession::SendNameQueryOpcode ( ObjectGuid  guid)
33 {
35 
37  response.Player = guid;
38 
39  if (response.Data.Initialize(guid, player))
40  response.Result = RESPONSE_SUCCESS; // name known
41  else
42  response.Result = RESPONSE_FAILURE; // name unknown
43 
44  SendPacket(response.Write());
45 }
ObjectGuid Player
Definition: QueryPackets.h:116
PlayerGuidLookupData Data
Definition: QueryPackets.h:118
uint8 Result
Definition: QueryPackets.h:117
Definition: QueryPackets.h:109
Definition: SharedDefines.h:4425
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool Initialize(ObjectGuid const &guid, Player const *player=nullptr)
Definition: QueryPackets.cpp:116
Definition: SharedDefines.h:4424
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215
WorldPacket const * Write() override
Definition: QueryPackets.cpp:182

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendNotification ( char const format,
  ... 
)
659 {
660  if (format)
661  {
662  va_list ap;
663  char szStr[1024];
664  szStr[0] = '\0';
665  va_start(ap, format);
666  vsnprintf(szStr, 1024, format, ap);
667  va_end(ap);
668 
670  }
671 }
void format(BasicFormatter< Char > &f, const Char *&format_str, const T &value)
Definition: format.h:2963
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
#define vsnprintf
Definition: Common.h:78
Definition: ChatPackets.h:220

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendNotification ( uint32  stringId,
  ... 
)
674 {
675  char const* format = GetTrinityString(stringId);
676  if (format)
677  {
678  va_list ap;
679  char szStr[1024];
680  szStr[0] = '\0';
681  va_start(ap, stringId);
682  vsnprintf(szStr, 1024, format, ap);
683  va_end(ap);
684 
686  }
687 }
void format(BasicFormatter< Char > &f, const Char *&format_str, const T &value)
Definition: format.h:2963
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
#define vsnprintf
Definition: Common.h:78
Definition: ChatPackets.h:220

+ Here is the call graph for this function:

void WorldSession::SendNotInArenaTeamPacket ( uint8  type)
25 {
26  WorldPacket data(SMSG_ARENA_ERROR, 4+1);
27  uint32 error = 0;
28  data << uint32(error); // 0 = ERR_ARENA_NO_TEAM_II, 1 = ERR_ARENA_EXPIRED_CAIS, 2 = ERR_LFG_CANT_USE_BATTLEGROUND
29  if (!error)
30  data << uint8(type); // team type (2=2v2, 3=3v3, 5=5v5), can be used for custom types...
31  SendPacket(&data);
32 }
Definition: Opcodes.h:753
uint32_t uint32
Definition: Define.h:150
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void WorldSession::SendPacket ( WorldPacket const packet,
bool  forced = false 
)

Send a packet to the client.

212 {
213  if (packet->GetOpcode() == NULL_OPCODE)
214  {
215  TC_LOG_ERROR("network.opcode", "Prevented sending of NULL_OPCODE to %s", GetPlayerInfo().c_str());
216  return;
217  }
218  else if (packet->GetOpcode() == UNKNOWN_OPCODE)
219  {
220  TC_LOG_ERROR("network.opcode", "Prevented sending of UNKNOWN_OPCODE to %s", GetPlayerInfo().c_str());
221  return;
222  }
223 
224  ServerOpcodeHandler const* handler = opcodeTable[static_cast<OpcodeServer>(packet->GetOpcode())];
225 
226  if (!handler)
227  {
228  TC_LOG_ERROR("network.opcode", "Prevented sending of opcode %u with non existing handler to %s", packet->GetOpcode(), GetPlayerInfo().c_str());
229  return;
230  }
231 
232  // Default connection index defined in Opcodes.cpp table
233  ConnectionType conIdx = handler->ConnectionIndex;
234 
235  // Override connection index
236  if (packet->GetConnection() != CONNECTION_TYPE_DEFAULT)
237  {
238  if (packet->GetConnection() != CONNECTION_TYPE_INSTANCE && IsInstanceOnlyOpcode(packet->GetOpcode()))
239  {
240  TC_LOG_ERROR("network.opcode", "Prevented sending of instance only opcode %u with connection type %u to %s", packet->GetOpcode(), packet->GetConnection(), GetPlayerInfo().c_str());
241  return;
242  }
243 
244  conIdx = packet->GetConnection();
245  }
246 
247  if (!m_Socket[conIdx])
248  {
249  TC_LOG_ERROR("network.opcode", "Prevented sending of %s to non existent socket %u to %s", GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet->GetOpcode())).c_str(), conIdx, GetPlayerInfo().c_str());
250  return;
251  }
252 
253  if (!forced)
254  {
255  if (handler->Status == STATUS_UNHANDLED)
256  {
257  TC_LOG_ERROR("network.opcode", "Prevented sending disabled opcode %s to %s", GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet->GetOpcode())).c_str(), GetPlayerInfo().c_str());
258  return;
259  }
260  }
261 
262 #ifdef TRINITY_DEBUG
263  // Code for network use statistic
264  static uint64 sendPacketCount = 0;
265  static uint64 sendPacketBytes = 0;
266 
267  static time_t firstTime = time(NULL);
268  static time_t lastTime = firstTime; // next 60 secs start time
269 
270  static uint64 sendLastPacketCount = 0;
271  static uint64 sendLastPacketBytes = 0;
272 
273  time_t cur_time = time(NULL);
274 
275  if ((cur_time - lastTime) < 60)
276  {
277  sendPacketCount+=1;
278  sendPacketBytes+=packet->size();
279 
280  sendLastPacketCount+=1;
281  sendLastPacketBytes+=packet->size();
282  }
283  else
284  {
285  uint64 minTime = uint64(cur_time - lastTime);
286  uint64 fullTime = uint64(lastTime - firstTime);
287  TC_LOG_DEBUG("misc", "Send all time packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f time: %u", sendPacketCount, sendPacketBytes, float(sendPacketCount)/fullTime, float(sendPacketBytes)/fullTime, uint32(fullTime));
288  TC_LOG_DEBUG("misc", "Send last min packets count: " UI64FMTD " bytes: " UI64FMTD " avr.count/sec: %f avr.bytes/sec: %f", sendLastPacketCount, sendLastPacketBytes, float(sendLastPacketCount)/minTime, float(sendLastPacketBytes)/minTime);
289 
290  lastTime = cur_time;
291  sendLastPacketCount = 1;
292  sendLastPacketBytes = packet->wpos(); // wpos is real written size
293  }
294 #endif // !TRINITY_DEBUG
295 
296  sScriptMgr->OnPacketSend(this, *packet);
297 
298  TC_LOG_TRACE("network.opcode", "S->C: %s %s", GetPlayerInfo().c_str(), GetOpcodeNameForLogging(static_cast<OpcodeServer>(packet->GetOpcode())).c_str());
299  m_Socket[conIdx]->SendPacket(*packet);
300 }
OpcodeTable opcodeTable
Definition: Opcodes.cpp:49
bool IsInstanceOnlyOpcode(uint32 opcode)
Definition: Opcodes.h:1655
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Opcodes.h:42
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint64_t uint64
Definition: g3dmath.h:170
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
Definition: Opcodes.h:1683
Definition: Opcodes.h:43
OpcodeServer
Definition: Opcodes.h:725
#define TC_LOG_TRACE(filterType__,...)
Definition: Log.h:195
#define UI64FMTD
Definition: Define.h:137
uint64_t uint64
Definition: Define.h:149
Definition: Opcodes.h:32
ConnectionType ConnectionIndex
Definition: Opcodes.h:1725
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
Definition: Opcodes.h:1719
SessionStatus Status
Definition: Opcodes.h:1705
ConnectionType
Definition: Opcodes.h:29
Definition: Opcodes.h:35

+ Here is the call graph for this function:

void WorldSession::SendPartyResult ( PartyOperation  operation,
std::string const member,
PartyResult  res,
uint32  val = 0 
)
49 {
51 
52  packet.Name = member;
53  packet.Command = uint8(operation);
54  packet.Result = uint8(res);
55  packet.ResultData = val;
57 
58  SendPacket(packet.Write());
59 }
uint8 Command
Definition: PartyPackets.h:37
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
uint8 Result
Definition: PartyPackets.h:38
WorldPacket const * Write() override
Definition: PartyPackets.cpp:27
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 ResultData
Definition: PartyPackets.h:39
ObjectGuid ResultGUID
Definition: PartyPackets.h:40
uint8_t uint8
Definition: g3dmath.h:164
std::string Name
Definition: PartyPackets.h:36
Definition: PartyPackets.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendPetitionQueryOpcode ( ObjectGuid  petitionguid)
189 {
190  ObjectGuid ownerGUID;
191  std::string title = "NO_NAME_FOR_GUID";
192 
194  responsePacket.PetitionID = uint32(petitionGUID.GetCounter()); // PetitionID (in Trinity always same as GUID_LOPART(petition guid))
195 
197 
198  stmt->setUInt64(0, petitionGUID.GetCounter());
199 
201 
202  if (result)
203  {
204  Field* fields = result->Fetch();
205  ownerGUID = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt64());
206  title = fields[1].GetString();
207  }
208  else
209  {
210  responsePacket.Allow = false;
211  SendPacket(responsePacket.Write());
212 
213  TC_LOG_DEBUG("network", "CMSG_PETITION_QUERY failed for petition (%s)", petitionGUID.ToString().c_str());
214  return;
215  }
216 
217  int32 reqSignatures = sWorld->getIntConfig(CONFIG_MIN_PETITION_SIGNS);
218 
220  petitionInfo.PetitionID = int32(petitionGUID.GetCounter());
221  petitionInfo.Petitioner = ownerGUID;
222  petitionInfo.MinSignatures = reqSignatures;
223  petitionInfo.MaxSignatures = reqSignatures;
224  petitionInfo.Title = title;
225 
226  responsePacket.Allow = true;
227  responsePacket.Info = petitionInfo;
228 
229  SendPacket(responsePacket.Write());
230 }
Definition: PetitionPackets.h:40
PetitionInfo Info
Definition: PetitionPackets.h:71
Definition: PetitionPackets.h:62
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
uint32 PetitionID
Definition: PetitionPackets.h:69
WorldPacket const * Write() override
Definition: PetitionPackets.cpp:62
Class used to access individual fields of database query result.
Definition: Field.h:56
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
std::string Title
Definition: PetitionPackets.h:44
Definition: World.h:257
#define sWorld
Definition: World.h:887
Definition: PreparedStatement.h:74
int32 MaxSignatures
Definition: PetitionPackets.h:47
Definition: CharacterDatabase.h:264
int32_t int32
Definition: Define.h:146
ObjectGuid Petitioner
Definition: PetitionPackets.h:43
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
int32 MinSignatures
Definition: PetitionPackets.h:46
bool Allow
Definition: PetitionPackets.h:70
int32 PetitionID
Definition: PetitionPackets.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
int32_t int32
Definition: g3dmath.h:167
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: ObjectGuid.h:189
uint32_t uint32
Definition: g3dmath.h:168
std::string GetString() const
Definition: Field.h:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendPetitionShowList ( ObjectGuid  guid)
571 {
572  Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_PETITIONER);
573  if (!creature)
574  {
575  TC_LOG_DEBUG("network", "WORLD: HandlePetitionShowListOpcode - %s not found or you can't interact with him.", guid.ToString().c_str());
576  return;
577  }
578 
580  packet.Unit = guid;
581  packet.Price = uint32(sWorld->getIntConfig(CONFIG_CHARTER_COST_GUILD));
582  SendPacket(packet.Write());
583 
584  TC_LOG_DEBUG("network", "Sent SMSG_PETITION_SHOW_LIST");
585 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: World.h:371
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sWorld
Definition: World.h:887
uint32 Price
Definition: PetitionPackets.h:92
ObjectGuid Unit
Definition: PetitionPackets.h:91
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: Unit.h:753
Definition: PetitionPackets.h:84
uint32_t uint32
Definition: g3dmath.h:168
WorldPacket const * Write() override
Definition: PetitionPackets.cpp:79
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendPetNameInvalid ( uint32  error,
std::string const name,
DeclinedName declinedName 
)
716 {
717  WorldPackets::Pet::PetNameInvalid petNameInvalid;
718  petNameInvalid.Result = error;
719  petNameInvalid.RenameData.NewName = name;
720  for (int i = 0; i < MAX_DECLINED_NAME_CASES; i++)
721  petNameInvalid.RenameData.DeclinedNames.name[i] = declinedName[i].name[i];
722 
723  SendPacket(petNameInvalid.Write());
724 }
uint8 Result
Definition: PetPackets.h:179
#define MAX_DECLINED_NAME_CASES
Definition: Unit.h:1099
WorldPacket const * Write() override
Definition: PetPackets.cpp:95
PetRenameData RenameData
Definition: PetPackets.h:177
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: PetPackets.h:170
std::string NewName
Definition: PetPackets.h:165
std::string name[MAX_DECLINED_NAME_CASES]
Definition: Unit.h:1103
DeclinedName DeclinedNames
Definition: PetPackets.h:167

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendPetStableResult ( uint8  guid)
548 {
550  data << uint8(res);
551  SendPacket(&data);
552 }
Definition: Opcodes.h:1362
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint8_t uint8
Definition: g3dmath.h:164
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendPlayerAmbiguousNotice ( std::string const name)
655 {
657 }
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: ChatPackets.h:304

+ Here is the call graph for this function:

void WorldSession::SendQueryPetNameResponse ( ObjectGuid  guid)
410 {
412 
413  response.UnitGUID = guid;
414 
416  {
417  response.Allow = true;
418  response.Timestamp = unit->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP);
419  response.Name = unit->GetName();
420 
421  if (Pet* pet = unit->ToPet())
422  {
423  if (DeclinedName const* names = pet->GetDeclinedNames())
424  {
425  response.HasDeclined = true;
426  response.DeclinedNames = *names;
427  }
428  }
429  }
430 
431  _player->GetSession()->SendPacket(response.Write());
432 }
ObjectGuid UnitGUID
Definition: QueryPackets.h:414
Pet * ToPet()
Definition: Unit.h:2200
Definition: QueryPackets.h:407
std::string Name
Definition: QueryPackets.h:420
Definition: Creature.h:467
Definition: UpdateFields.h:126
bool Allow
Definition: QueryPackets.h:415
bool HasDeclined
Definition: QueryPackets.h:417
uint32 Timestamp
Definition: QueryPackets.h:419
WorldPacket const * Write() override
Definition: QueryPackets.cpp:443
Player * _player
Definition: WorldSession.h:1797
TC_GAME_API Creature * GetCreatureOrPetOrVehicle(WorldObject const &, ObjectGuid const &)
Definition: ObjectAccessor.cpp:198
Definition: Unit.h:1101
DeclinedName DeclinedNames
Definition: QueryPackets.h:418
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendQueryTimeResponse ( )
58 {
60  queryTimeResponse.CurrentTime = time(nullptr);
61  queryTimeResponse.TimeOutRequest = sWorld->GetNextDailyQuestsResetTime() - queryTimeResponse.CurrentTime;
62  SendPacket(queryTimeResponse.Write());
63 }
WorldPacket const * Write() override
Definition: QueryPackets.cpp:358
time_t CurrentTime
Definition: QueryPackets.h:317
#define sWorld
Definition: World.h:887
int32 TimeOutRequest
Definition: QueryPackets.h:318
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: QueryPackets.h:310

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendSetPhaseShift ( std::set< uint32 > const phaseIds,
std::set< uint32 > const terrainswaps,
std::set< uint32 > const worldMapAreaSwaps 
)
1031 {
1032  WorldPackets::Misc::PhaseShift phaseShift;
1033  phaseShift.ClientGUID = _player->GetGUID();
1034  phaseShift.PersonalGUID = _player->GetGUID();
1035  phaseShift.PhaseShifts = phaseIds;
1036  phaseShift.VisibleMapIDs = terrainswaps;
1037  phaseShift.UiWorldMapAreaIDSwaps = worldMapAreaSwaps;
1038  SendPacket(phaseShift.Write());
1039 }
std::set< uint32 > PhaseShifts
Definition: MiscPackets.h:555
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::set< uint32 > UiWorldMapAreaIDSwaps
Definition: MiscPackets.h:557
std::set< uint32 > VisibleMapIDs
Definition: MiscPackets.h:558
Player * _player
Definition: WorldSession.h:1797
WorldPacket const * Write() override
Definition: MiscPackets.cpp:387
Definition: MiscPackets.h:546
ObjectGuid PersonalGUID
Definition: MiscPackets.h:554
ObjectGuid ClientGUID
Definition: MiscPackets.h:553

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendSetPlayerDeclinedNamesResult ( DeclinedNameResult  result,
ObjectGuid  guid 
)
2547 {
2549  packet.ResultCode = result;
2550  packet.Player = guid;
2551 
2552  SendPacket(packet.Write());
2553 }
ObjectGuid Player
Definition: CharacterPackets.h:739
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:564
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 ResultCode
Definition: CharacterPackets.h:740

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendSetTimeZoneInformation ( )
Todo:
: replace dummy values
81 {
84  packet.ServerTimeTZ = "Europe/Paris";
85  packet.GameTimeTZ = "Europe/Paris";
86 
87  SendPacket(packet.Write());
88 }
std::string ServerTimeTZ
Definition: SystemPackets.h:126
WorldPacket const * Write() override
Definition: SystemPackets.cpp:121
Definition: SystemPackets.h:119
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::string GameTimeTZ
Definition: SystemPackets.h:127

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendShowBank ( ObjectGuid  guid)
166 {
167  m_currentBankerGUID = guid;
169  packet.Guid = guid;
170  SendPacket(packet.Write());
171 }
ObjectGuid m_currentBankerGUID
Definition: WorldSession.h:1841
ObjectGuid Guid
Definition: NPCPackets.h:162
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: NPCPackets.h:155
WorldPacket const * Write() override
Definition: NPCPackets.cpp:121

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendShowMailBox ( ObjectGuid  guid)
80 {
82  packet.PostmasterGUID = guid;
83  SendPacket(packet.Write());
84 }
WorldPacket const * Write() override
Definition: MailPackets.cpp:274
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Definition: MailPackets.h:247
ObjectGuid PostmasterGUID
Definition: MailPackets.h:254

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendSpiritResurrect ( )
401 {
402  _player->ResurrectPlayer(0.5f, true);
403  _player->DurabilityLossAll(0.25f, true);
404 
405  // get corpse nearest graveyard
406  WorldSafeLocsEntry const* corpseGrave = NULL;
407  WorldLocation corpseLocation = _player->GetCorpseLocation();
408  if (_player->HasCorpse())
409  {
410  corpseGrave = sObjectMgr->GetClosestGraveYard(corpseLocation.GetPositionX(), corpseLocation.GetPositionY(),
411  corpseLocation.GetPositionZ(), corpseLocation.GetMapId(), _player->GetTeam());
412  }
413 
414  // now can spawn bones
415  _player->SpawnCorpseBones();
416 
417  // teleport to nearest from corpse graveyard, if different from nearest to player ghost
418  if (corpseGrave)
419  {
420  WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveYard(
421  _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeam());
422 
423  if (corpseGrave != ghostGrave)
424  _player->TeleportTo(corpseGrave->MapID, corpseGrave->Loc.X, corpseGrave->Loc.Y, corpseGrave->Loc.Z, (corpseGrave->Facing * M_PI) / 180); // Orientation is initially in degrees
425  // or update at original position
426  else
427  _player->UpdateObjectVisibility();
428  }
429  // or update at original position
430  else
431  _player->UpdateObjectVisibility();
432 }
float Z
Definition: DBCEnums.h:36
Definition: Position.h:228
float Y
Definition: DBCEnums.h:35
#define M_PI
Definition: Common.h:163
float Facing
Definition: DBCStructure.h:1439
Definition: DBCStructure.h:1434
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 MapID
Definition: DBCStructure.h:1437
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32 GetMapId() const
Definition: Position.h:254
float X
Definition: DBCEnums.h:34
DBCPosition3D Loc
Definition: DBCStructure.h:1438
Player * _player
Definition: WorldSession.h:1797
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendStablePet ( ObjectGuid  guid)
484 {
486 
487  stmt->setUInt64(0, _player->GetGUID().GetCounter());
490 
493 }
void SetParam(ParamType value)
Definition: Callback.h:63
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
QueryResultFuture AsyncQuery(const char *sql)
Definition: DatabaseWorkerPool.cpp:149
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:545
Definition: PetDefines.h:36
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryCallback< PreparedQueryResult, ObjectGuid > _sendStabledPetCallback
Definition: WorldSession.h:1737
Player * _player
Definition: WorldSession.h:1797
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
void SetFutureResult(std::future< Result > value)
The parameter of this function should be a resultset returned from either .AsyncQuery or ...
Definition: Callback.h:38
Definition: PetDefines.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendStablePetCallback ( PreparedQueryResult  result,
ObjectGuid  guid 
)
496 {
497  if (!GetPlayer())
498  return;
499 
501 
502  packet.StableMaster = guid;
503 
504  Pet* pet = _player->GetPet();
505 
506  int32 petSlot = 0;
507  // not let move dead pet in slot
508  if (pet && pet->IsAlive() && pet->getPetType() == HUNTER_PET)
509  {
511  stableEntry.PetSlot = petSlot;
512  stableEntry.PetNumber = pet->GetCharmInfo()->GetPetNumber();
513  stableEntry.CreatureID = pet->GetEntry();
514  stableEntry.DisplayID = pet->GetDisplayId();
515  stableEntry.ExperienceLevel = pet->getLevel();
516  stableEntry.PetFlags = PET_STABLE_ACTIVE;
517  stableEntry.PetName = pet->GetName();
518  ++petSlot;
519 
520  packet.Pets.push_back(stableEntry);
521  }
522 
523  if (result)
524  {
525  do
526  {
527  Field* fields = result->Fetch();
529 
530  stableEntry.PetSlot = petSlot;
531  stableEntry.PetNumber = fields[1].GetUInt32(); // petnumber
532  stableEntry.CreatureID = fields[2].GetUInt32(); // creature entry
533  stableEntry.DisplayID = fields[5].GetUInt32(); // creature displayid
534  stableEntry.ExperienceLevel = fields[3].GetUInt16(); // level
535  stableEntry.PetFlags = PET_STABLE_INACTIVE;
536  stableEntry.PetName = fields[4].GetString(); // Name
537 
538  ++petSlot;
539  packet.Pets.push_back(stableEntry);
540  }
541  while (result->NextRow());
542  }
543 
544  SendPacket(packet.Write());
545 }
uint32 PetNumber
Definition: PetPackets.h:121
uint32 PetSlot
Definition: PetPackets.h:120
uint32 ExperienceLevel
Definition: PetPackets.h:124
uint32 GetDisplayId() const
Definition: Unit.h:2012
Class used to access individual fields of database query result.
Definition: Field.h:56
std::string const & GetName() const
Definition: Object.h:479
Player * GetPlayer() const
Definition: WorldSession.h:927
CharmInfo * GetCharmInfo()
Definition: Unit.h:1748
Definition: PetDefines.h:25
Definition: PetPackets.h:129
uint32 PetFlags
Definition: PetPackets.h:125
uint8 getLevel() const
Definition: Unit.h:1408
Definition: PetPackets.h:118
uint32 GetPetNumber() const
Definition: Unit.h:1207
uint32 DisplayID
Definition: PetPackets.h:123
bool IsAlive() const
Definition: Unit.h:1692
int32_t int32
Definition: Define.h:146
uint16 GetUInt16() const
Definition: Field.h:108
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797
Definition: Pet.h:38
uint32 CreatureID
Definition: PetPackets.h:122
Definition: Pet.h:37
std::vector< PetStableInfo > Pets
Definition: PetPackets.h:137
uint32 GetUInt32() const
Definition: Field.h:146
WorldPacket const * Write() override
Definition: PetPackets.cpp:58
uint32 GetEntry() const
Definition: Object.h:107
std::string PetName
Definition: PetPackets.h:126
ObjectGuid StableMaster
Definition: PetPackets.h:136
std::string GetString() const
Definition: Field.h:276
Definition: Pet.h:46
PetType getPetType() const
Definition: Pet.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTabardVendorActivate ( ObjectGuid  guid)
73 {
75  packet.Vendor = guid;
76  SendPacket(packet.Write());
77 }
ObjectGuid Vendor
Definition: NPCPackets.h:172
WorldPacket const * Write() override
Definition: NPCPackets.cpp:138
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTaxiMenu ( Creature unit)
92 {
93  // find current node
94  uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
95  if (!curloc)
96  return;
97 
98  bool lastTaxiCheaterState = GetPlayer()->isTaxiCheater();
99  if (unit->GetEntry() == 29480)
100  GetPlayer()->SetTaxiCheater(true); // Grimwing in Ebon Hold, special case. NOTE: Not perfect, Zul'Aman should not be included according to WoWhead, and I think taxicheat includes it.
101 
102  TC_LOG_DEBUG("network", "WORLD: CMSG_TAXINODE_STATUS_QUERY %u ", curloc);
103 
105  data.WindowInfo = boost::in_place();
106  data.WindowInfo->UnitGUID = unit->GetGUID();
107  data.WindowInfo->CurrentNode = curloc;
108 
109  GetPlayer()->m_taxi.AppendTaximaskTo(data, lastTaxiCheaterState);
110 
111  SendPacket(data.Write());
112 
113  GetPlayer()->SetTaxiCheater(lastTaxiCheaterState);
114 }
Definition: TaxiPackets.h:56
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
WorldPacket const * Write() override
Definition: TaxiPackets.cpp:34
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Optional< ShowTaxiNodesWindowInfo > WindowInfo
Definition: TaxiPackets.h:63
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTaxiStatus ( ObjectGuid  guid)
44 {
45  // cheating checks
46  Creature* unit = GetPlayer()->GetMap()->GetCreature(guid);
47  if (!unit)
48  {
49  TC_LOG_DEBUG("network", "WorldSession::SendTaxiStatus - %s not found.", guid.ToString().c_str());
50  return;
51  }
52 
53  uint32 curloc = sObjectMgr->GetNearestTaxiNode(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetMapId(), GetPlayer()->GetTeam());
54 
56  data.Unit = guid;
57 
58  if (!curloc)
59  data.Status = TAXISTATUS_NONE;
60  else if (unit->GetReactionTo(GetPlayer()) >= REP_NEUTRAL)
61  data.Status = GetPlayer()->m_taxi.IsTaximaskNodeKnown(curloc) ? TAXISTATUS_LEARNED : TAXISTATUS_UNLEARNED;
62  else
64 
65  SendPacket(data.Write());
66 
67  TC_LOG_DEBUG("network", "WORLD: Sent SMSG_TAXI_NODE_STATUS");
68 }
ReputationRank GetReactionTo(Unit const *target) const
Definition: Unit.cpp:7035
Definition: SharedDefines.h:4713
Definition: SharedDefines.h:4712
Definition: SharedDefines.h:4714
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: SharedDefines.h:4715
Definition: SharedDefines.h:216
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint32 GetMapId() const
Definition: Position.h:254
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
WorldPacket const * Write() override
Definition: TaxiPackets.cpp:25
ObjectGuid Unit
Definition: TaxiPackets.h:47
Definition: TaxiPackets.h:39
float GetPositionX() const
Definition: Position.h:104
uint8 Status
Definition: TaxiPackets.h:46
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTradeStatus ( WorldPackets::Trade::TradeStatus status)
35 {
36  info.Clear(); // reuse packet
37  Player* trader = _player->GetTrader();
38  info.PartnerIsSameBnetAccount = trader && trader->GetSession()->GetBattlenetAccountId() == GetBattlenetAccountId();
39  SendPacket(info.Write());
40 }
uint32 GetBattlenetAccountId() const
Definition: WorldSession.h:925
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
Player * _player
Definition: WorldSession.h:1797

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTrainerBuyFailed ( ObjectGuid  trainerGUID,
uint32  spellID,
int32  trainerFailedReason 
)
250 {
251  WorldPackets::NPC::TrainerBuyFailed trainerBuyFailed;
252  trainerBuyFailed.TrainerGUID = trainerGUID;
253  trainerBuyFailed.SpellID = spellID; // should be same as in packet from client
254  trainerBuyFailed.TrainerFailedReason = trainerFailedReason; // 1 == "Not enough money for trainer service." 0 == "Trainer service %d unavailable."
255  SendPacket(trainerBuyFailed.Write());
256 }
int32 SpellID
Definition: NPCPackets.h:240
Definition: NPCPackets.h:232
WorldPacket const * Write() override
Definition: NPCPackets.cpp:186
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
int32 TrainerFailedReason
Definition: NPCPackets.h:241
ObjectGuid TrainerGUID
Definition: NPCPackets.h:239

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTrainerList ( ObjectGuid  guid)
92 {
93  std::string str = GetTrinityString(LANG_NPC_TAINER_HELLO);
94  SendTrainerList(guid, str);
95 }
char const * GetTrinityString(uint32 entry) const
Definition: WorldSession.cpp:689
void SendTrainerList(ObjectGuid guid)
Definition: NPCHandler.cpp:91
Definition: Language.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendTrainerList ( ObjectGuid  guid,
std::string const strTitle 
)
98 {
99  TC_LOG_DEBUG("network", "WORLD: SendTrainerList");
100 
101  Creature* unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
102  if (!unit)
103  {
104  TC_LOG_DEBUG("network", "WORLD: SendTrainerList - %s not found or you can not interact with him.", guid.ToString().c_str());
105  return;
106  }
107 
108  // remove fake death
109  if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
110  GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
111 
112  TrainerSpellData const* trainer_spells = unit->GetTrainerSpells();
113  if (!trainer_spells)
114  {
115  TC_LOG_DEBUG("network", "WORLD: SendTrainerList - Training spells not found for %s", guid.ToString().c_str());
116  return;
117  }
118 
120  packet.TrainerGUID = guid;
121  packet.TrainerType = trainer_spells->trainerType;
122  packet.Greeting = strTitle;
123 
124  // reputation discount
125  float fDiscountMod = _player->GetReputationPriceDiscount(unit);
126 
127  packet.Spells.reserve(trainer_spells->spellList.size());
128  for (TrainerSpellMap::const_iterator itr = trainer_spells->spellList.begin(); itr != trainer_spells->spellList.end(); ++itr)
129  {
130  TrainerSpell const* tSpell = &itr->second;
131 
132  bool valid = true;
133  for (uint8 i = 0; i < MAX_TRAINERSPELL_ABILITY_REQS; ++i)
134  {
135  if (!tSpell->ReqAbility[i])
136  continue;
137  if (!_player->IsSpellFitByClassAndRace(tSpell->ReqAbility[i]))
138  {
139  valid = false;
140  break;
141  }
142  }
143 
144  if (!valid)
145  continue;
146 
147  TrainerSpellState state = _player->GetTrainerSpellState(tSpell);
148 
150  spell.SpellID = tSpell->SpellID;
151  spell.MoneyCost = floor(tSpell->MoneyCost * fDiscountMod);
152  spell.ReqSkillLine = tSpell->ReqSkillLine;
153  spell.ReqSkillRank = tSpell->ReqSkillRank;
154  spell.ReqLevel = tSpell->ReqLevel;
155  spell.Usable = (state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state);
156 
157  uint8 maxReq = 0;
158  for (uint8 i = 0; i < MAX_TRAINERSPELL_ABILITY_REQS; ++i)
159  {
160  if (!tSpell->ReqAbility[i])
161  continue;
162 
163  if (uint32 prevSpellId = sSpellMgr->GetPrevSpellInChain(tSpell->ReqAbility[i]))
164  {
165  spell.ReqAbility[maxReq] = prevSpellId;
166  ++maxReq;
167  }
168 
169  if (maxReq == 2)
170  break;
171 
172  SpellsRequiringSpellMapBounds spellsRequired = sSpellMgr->GetSpellsRequiredForSpellBounds(tSpell->ReqAbility[i]);
173  for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequired.first; itr2 != spellsRequired.second && maxReq < MAX_TRAINERSPELL_ABILITY_REQS; ++itr2)
174  {
175  spell.ReqAbility[maxReq] = itr2->second;
176  ++maxReq;
177  }
178 
179  if (maxReq == 2)
180  break;
181  }
182 
183  packet.Spells.push_back(spell);
184  }
185 
186  SendPacket(packet.Write());
187 }
ObjectGuid TrainerGUID
Definition: NPCPackets.h:150
Definition: NPCPackets.h:130
TrainerSpellState
Definition: Player.h:294
static Vector3int16 floor(const Vector3 &v)
int32 TrainerType
Definition: NPCPackets.h:149
uint32 trainerType
Definition: Creature.h:451
Definition: Player.h:299
TrainerSpellData const * GetTrainerSpells() const
Definition: Creature.cpp:2507
Definition: Unit.h:739
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 ReqSkillRank
Definition: Creature.h:435
#define MAX_TRAINERSPELL_ABILITY_REQS
Definition: Creature.h:422
Definition: Creature.h:467
Player * GetPlayer() const
Definition: WorldSession.h:927
uint8 ReqLevel
Definition: NPCPackets.h:138
uint32 ReqSkillLine
Definition: Creature.h:434
Definition: Player.h:297
WorldPacket const * Write() override
Definition: NPCPackets.cpp:93
Definition: Creature.h:424
std::vector< TrainerListSpell > Spells
Definition: NPCPackets.h:152
uint32 ReqAbility[MAX_TRAINERSPELL_ABILITY_REQS]
Definition: Creature.h:437
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellAuraDefines.h:126
uint32_t uint32
Definition: Define.h:150
std::string Greeting
Definition: NPCPackets.h:148
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::pair< SpellsRequiringSpellMap::const_iterator, SpellsRequiringSpellMap::const_iterator > SpellsRequiringSpellMapBounds
Definition: SpellMgr.h:524
uint32 ReqLevel
Definition: Creature.h:436
int32 ReqAbility[MAX_TRAINERSPELL_ABILITY_REQS]
Definition: NPCPackets.h:136
uint32 SpellID
Definition: Creature.h:432
Definition: Unit.h:550
Player * _player
Definition: WorldSession.h:1797
Definition: NPCPackets.h:141
TrainerSpellMap spellList
Definition: Creature.h:450
int32 ReqSkillLine
Definition: NPCPackets.h:134
uint8_t uint8
Definition: Define.h:152
int32 MoneyCost
Definition: NPCPackets.h:133
Definition: Creature.h:445
uint8 Usable
Definition: NPCPackets.h:137
int32 SpellID
Definition: NPCPackets.h:132
int32 ReqSkillRank
Definition: NPCPackets.h:135
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 MoneyCost
Definition: Creature.h:433

+ Here is the call graph for this function:

void WorldSession::SendTutorialsData ( )
798 {
800  memcpy(packet.TutorialData, _tutorials, sizeof(_tutorials));
801  SendPacket(packet.Write());
802 }
Definition: MiscPackets.h:208
uint32 TutorialData[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: MiscPackets.h:218
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830
WorldPacket const * Write() override
Definition: MiscPackets.cpp:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendUndeleteCharacterResponse ( CharacterUndeleteResult  result,
WorldPackets::Character::CharacterUndeleteInfo const undeleteInfo 
)
2573 {
2575  response.UndeleteInfo = undeleteInfo;
2576  response.Result = result;
2577 
2578  SendPacket(response.Write());
2579 }
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:349
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
CharacterUndeleteInfo const * UndeleteInfo
Definition: CharacterPackets.h:388
Definition: CharacterPackets.h:377
uint32 Result
Definition: CharacterPackets.h:389

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendUndeleteCooldownStatusResponse ( uint32  currentCooldown,
uint32  maxCooldown 
)
2563 {
2565  response.OnCooldown = (currentCooldown > 0);
2566  response.MaxCooldown = maxCooldown;
2567  response.CurrentCooldown = currentCooldown;
2568 
2569  SendPacket(response.Write());
2570 }
WorldPacket const * Write() override
Definition: CharacterPackets.cpp:358
uint32 MaxCooldown
Max. cooldown until next free character restoration. Displayed in undelete confirm message...
Definition: CharacterPackets.h:408
uint32 CurrentCooldown
Current cooldown until next free character restoration. (in sec)
Definition: CharacterPackets.h:409
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
bool OnCooldown
Definition: CharacterPackets.h:407

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SendUpdateTrade ( bool  trader_data = true)
51 {
52  TradeData* view_trade = trader_data ? _player->GetTradeData()->GetTraderData() : _player->GetTradeData();
53 
55  tradeUpdated.WhichPlayer = trader_data;
56  tradeUpdated.ClientStateIndex = view_trade->GetClientStateIndex();
57  tradeUpdated.CurrentStateIndex = view_trade->GetServerStateIndex();
58  tradeUpdated.Gold = view_trade->GetMoney();
59  tradeUpdated.ProposedEnchantment = view_trade->GetSpell();
60 
61  for (uint8 i = 0; i < TRADE_SLOT_COUNT; ++i)
62  {
63  if (Item* item = view_trade->GetItem(TradeSlots(i)))
64  {
66  tradeItem.Slot = i;
67  tradeItem.EntryID = item->GetEntry();
68  tradeItem.StackCount = item->GetCount();
69  tradeItem.GiftCreator = item->GetGuidValue(ITEM_FIELD_GIFTCREATOR);
70  if (!item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
71  {
72  tradeItem.Unwrapped = boost::in_place();
73 
74  tradeItem.Unwrapped->Item.Initialize(item);
75  tradeItem.Unwrapped->EnchantID = item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT);
76  tradeItem.Unwrapped->OnUseEnchantmentID = item->GetEnchantmentId(USE_ENCHANTMENT_SLOT);
77  tradeItem.Unwrapped->Creator = item->GetGuidValue(ITEM_FIELD_CREATOR);
78  tradeItem.Unwrapped->Charges = item->GetSpellCharges();
79  tradeItem.Unwrapped->Lock = item->GetTemplate()->GetLockID() && !item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_UNLOCKED);
80  tradeItem.Unwrapped->MaxDurability = item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY);
81  tradeItem.Unwrapped->Durability = item->GetUInt32Value(ITEM_FIELD_DURABILITY);
82 
83  for (uint32 s = SOCK_ENCHANTMENT_SLOT; s < MAX_GEM_SOCKETS; ++s)
84  tradeItem.Unwrapped->SocketEnchant[s] = item->GetEnchantmentId(EnchantmentSlot(s + SOCK_ENCHANTMENT_SLOT));
85  }
86 
87  tradeUpdated.Items.push_back(tradeItem);
88  }
89  }
90 
91  SendPacket(tradeUpdated.Write());
92 }
#define MAX_GEM_SOCKETS
Definition: Item.h:195
int32 ProposedEnchantment
Definition: TradePackets.h:186
Definition: UpdateFields.h:44
Definition: Item.h:174
uint64 Gold
Definition: TradePackets.h:179
Definition: ItemTemplate.h:138
Definition: TradePackets.h:150
uint8 WhichPlayer
Definition: TradePackets.h:181
EnchantmentSlot
Definition: Item.h:172
Definition: UpdateFields.h:49
Definition: UpdateFields.h:53
Optional< UnwrappedTradeItem > Unwrapped
Definition: TradePackets.h:172
int32 StackCount
Definition: TradePackets.h:170
ObjectGuid GiftCreator
Definition: TradePackets.h:171
Item * GetItem(TradeSlots slot) const
Definition: TradeData.cpp:27
Definition: Item.h:181
uint32 GetSpell() const
Definition: TradeData.h:49
Definition: TradeData.h:34
TradeSlots
Definition: TradeData.h:23
Definition: Item.h:259
uint32 GetClientStateIndex() const
Definition: TradeData.h:64
uint32_t uint32
Definition: Define.h:150
Definition: Item.h:176
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
std::vector< TradeItem > Items
Definition: TradePackets.h:183
Definition: TradePackets.h:166
uint32 ClientStateIndex
Definition: TradePackets.h:182
Player * _player
Definition: WorldSession.h:1797
Definition: TradeData.h:25
uint8 Slot
Definition: TradePackets.h:168
uint32 GetServerStateIndex() const
Definition: TradeData.h:67
uint8_t uint8
Definition: Define.h:152
int32 EntryID
Definition: TradePackets.h:169
Definition: UpdateFields.h:45
uint32 CurrentStateIndex
Definition: TradePackets.h:180
Definition: UpdateFields.h:54
WorldPacket const * Write() override
Definition: TradePackets.cpp:113
uint64 GetMoney() const
Definition: TradeData.h:55
Definition: ItemTemplate.h:137

+ Here is the call graph for this function:

void WorldSession::SendVoidStorageTransferResult ( VoidTransferError  result)
30 {
32 }
Definition: VoidStoragePackets.h:28
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SetAccountData ( AccountDataType  type,
uint32  time,
std::string const data 
)
758 {
759  if ((1 << type) & GLOBAL_CACHE_MASK)
760  {
762  stmt->setUInt32(0, GetAccountId());
763  stmt->setUInt8(1, type);
764  stmt->setUInt32(2, time);
765  stmt->setString(3, data);
767  }
768  else
769  {
770  // _player can be NULL and packet received after logout but m_GUID still store correct guid
771  if (!m_GUIDLow)
772  return;
773 
775  stmt->setUInt64(0, m_GUIDLow);
776  stmt->setUInt8(1, type);
777  stmt->setUInt32(2, time);
778  stmt->setString(3, data);
780  }
781 
782  _accountData[type].Time = time_t(time);
783  _accountData[type].Data = data;
784 }
AccountData _accountData[NUM_ACCOUNT_DATA_TYPES]
Definition: WorldSession.h:1829
#define GLOBAL_CACHE_MASK
Definition: WorldSession.h:737
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
uint32 GetAccountId() const
Definition: WorldSession.h:922
Definition: PreparedStatement.h:74
std::string Data
Definition: WorldSession.h:778
ObjectGuid::LowType m_GUIDLow
Definition: WorldSession.h:1796
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
Definition: CharacterDatabase.h:232
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
time_t Time
Definition: WorldSession.h:777
Definition: CharacterDatabase.h:229
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::SetInQueue ( bool  state)
inline

Session in auth.queue currently.

940 { m_inQueue = state; }
bool m_inQueue
Definition: WorldSession.h:1820

+ Here is the caller graph for this function:

void WorldSession::SetLatency ( uint32  latency)
inline
1064 { m_latency = latency; }
std::atomic< uint32 > m_latency
Definition: WorldSession.h:1827

+ Here is the caller graph for this function:

void WorldSession::SetLogoutStartTime ( time_t  requestTime)
inline

Engage the logout process for the user.

947  {
948  _logoutTime = requestTime;
949  }
time_t _logoutTime
Definition: WorldSession.h:1819

+ Here is the caller graph for this function:

void WorldSession::SetPlayer ( Player player)
936 {
937  _player = player;
938 
939  // set m_GUID that can be used while player loggined and later until m_playerRecentlyLogout not reset
940  if (_player)
941  m_GUIDLow = _player->GetGUID().GetCounter();
942 }
ObjectGuid::LowType m_GUIDLow
Definition: WorldSession.h:1796
Player * _player
Definition: WorldSession.h:1797

+ Here is the caller graph for this function:

void WorldSession::SetRealmListSecret ( std::array< uint8, 32 > const secret)
inline
1708 { memcpy(_realmListSecret.data(), secret.data(), secret.size()); }
std::array< uint8, 32 > _realmListSecret
Definition: WorldSession.h:1809

+ Here is the caller graph for this function:

void WorldSession::SetSecurity ( AccountTypes  security)
inline
931 { _security = security; }
AccountTypes _security
Definition: WorldSession.h:1802
void WorldSession::SetTutorialInt ( uint8  index,
uint32  value 
)
inline
1007  {
1008  if (_tutorials[index] != value)
1009  {
1010  _tutorials[index] = value;
1011  _tutorialsChanged = true;
1012  }
1013  }
const FieldDescriptor value
Definition: descriptor.h:1522
uint32 _tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
Definition: WorldSession.h:1830
bool _tutorialsChanged
Definition: WorldSession.h:1831

+ Here is the caller graph for this function:

bool WorldSession::ShouldLogOut ( time_t  currTime) const
inline

Is logout cooldown expired?

953  {
954  return (_logoutTime > 0 && currTime >= _logoutTime + 20);
955  }
time_t _logoutTime
Definition: WorldSession.h:1819

+ Here is the caller graph for this function:

bool WorldSession::Update ( uint32  diff,
PacketFilter updater 
)

Update the WorldSession (triggered by World update)

Update Timeout timer.

  • Before we process anything: If necessary, kick the player from the character select screen
  • Retrieve packets from the receive queue and call the appropriate handlers not process packets if socket already closed

Delete packet after processing by default

If player didn't log out a while ago, it means packets are being sent while the server does not recognize the client to be in world yet. We will re-add the packets to the bottom of the queue and process them later.

  • If necessary, log the player out
  • Cleanup socket pointer if need
328 {
330  UpdateTimeOutTime(diff);
331 
334  if (IsConnectionIdle())
335  m_Socket[CONNECTION_TYPE_REALM]->CloseSocket();
336 
337  if (updater.ProcessUnsafe())
338  while (_player && _player->IsBeingTeleportedSeamlessly())
340 
343  WorldPacket* packet = NULL;
345  bool deletePacket = true;
346  std::vector<WorldPacket*> requeuePackets;
347  uint32 processedPackets = 0;
348  time_t currentTime = time(NULL);
349 
350  while (m_Socket[CONNECTION_TYPE_REALM] && _recvQueue.next(packet, updater))
351  {
352  ClientOpcodeHandler const* opHandle = opcodeTable[static_cast<OpcodeClient>(packet->GetOpcode())];
353  try
354  {
355  switch (opHandle->Status)
356  {
357  case STATUS_LOGGEDIN:
358  if (!_player)
359  {
360  // skip STATUS_LOGGEDIN opcode unexpected errors if player logout sometime ago - this can be network lag delayed packets
364  {
365  requeuePackets.push_back(packet);
366  deletePacket = false;
367  TC_LOG_DEBUG("network", "Re-enqueueing packet with opcode %s with with status STATUS_LOGGEDIN. "
368  "Player is currently not in world yet.", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str());
369  }
370  }
371  else if (_player->IsInWorld() && AntiDOS.EvaluateOpcode(*packet, currentTime))
372  {
373  sScriptMgr->OnPacketReceive(this, *packet);
374  opHandle->Call(this, *packet);
375  LogUnprocessedTail(packet);
376  }
377  // lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
378  break;
380  if (!_player && !m_playerRecentlyLogout && !m_playerLogout) // There's a short delay between _player = null and m_playerRecentlyLogout = true during logout
381  LogUnexpectedOpcode(packet, "STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT",
382  "the player has not logged in yet and not recently logout");
383  else if (AntiDOS.EvaluateOpcode(*packet, currentTime))
384  {
385  // not expected _player or must checked in packet hanlder
386  sScriptMgr->OnPacketReceive(this, *packet);
387  opHandle->Call(this, *packet);
388  LogUnprocessedTail(packet);
389  }
390  break;
391  case STATUS_TRANSFER:
392  if (!_player)
393  LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player has not logged in yet");
394  else if (_player->IsInWorld())
395  LogUnexpectedOpcode(packet, "STATUS_TRANSFER", "the player is still in world");
396  else if(AntiDOS.EvaluateOpcode(*packet, currentTime))
397  {
398  sScriptMgr->OnPacketReceive(this, *packet);
399  opHandle->Call(this, *packet);
400  LogUnprocessedTail(packet);
401  }
402  break;
403  case STATUS_AUTHED:
404  // prevent cheating with skip queue wait
405  if (m_inQueue)
406  {
407  LogUnexpectedOpcode(packet, "STATUS_AUTHED", "the player not pass queue yet");
408  break;
409  }
410 
411  // some auth opcodes can be recieved before STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT opcodes
412  // however when we recieve CMSG_CHAR_ENUM we are surely no longer during the logout process.
413  if (packet->GetOpcode() == CMSG_ENUM_CHARACTERS)
414  m_playerRecentlyLogout = false;
415 
416  if (AntiDOS.EvaluateOpcode(*packet, currentTime))
417  {
418  sScriptMgr->OnPacketReceive(this, *packet);
419  opHandle->Call(this, *packet);
420  LogUnprocessedTail(packet);
421  }
422  break;
423  case STATUS_NEVER:
424  TC_LOG_ERROR("network.opcode", "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str()
425  , GetPlayerInfo().c_str());
426  break;
427  case STATUS_UNHANDLED:
428  TC_LOG_ERROR("network.opcode", "Received not handled opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str()
429  , GetPlayerInfo().c_str());
430  break;
431  }
432  }
434  {
435  TC_LOG_ERROR("network", "PacketArrayMaxCapacityException: %s while parsing %s from %s.",
436  pamce.what(), GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), GetPlayerInfo().c_str());
437  }
438  catch (ByteBufferException const&)
439  {
440  TC_LOG_ERROR("network", "WorldSession::Update ByteBufferException occured while parsing a packet (opcode: %u) from client %s, accountid=%i. Skipped packet.",
441  packet->GetOpcode(), GetRemoteAddress().c_str(), GetAccountId());
442  packet->hexlike();
443  }
444 
445  if (deletePacket)
446  delete packet;
447 
448  deletePacket = true;
449 
450 #define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE 100
451  processedPackets++;
452 
453  //process only a max amout of packets in 1 Update() call.
454  //Any leftover will be processed in next update
456  break;
457  }
458 
459  _recvQueue.readd(requeuePackets.begin(), requeuePackets.end());
460 
462  _warden->Update();
463 
465 
466  //check if we are safe to proceed with logout
467  //logout procedure should happen only in World::UpdateSessions() method!!!
468  if (updater.ProcessUnsafe())
469  {
470  time_t currTime = time(NULL);
472  if (ShouldLogOut(currTime) && m_playerLoading.IsEmpty())
473  LogoutPlayer(true);
474 
476  _warden->Update();
477 
481  {
482  expireTime -= expireTime > diff ? diff : expireTime;
483  if (expireTime < diff || forceExit || !GetPlayer())
484  {
487  }
488  }
489 
491  return false; //Will remove this session from the world session map
492  }
493 
494  return true;
495 }
Warden * _warden
Definition: WorldSession.h:1817
OpcodeTable opcodeTable
Definition: Opcodes.cpp:49
void Update()
Definition: Warden.cpp:95
Definition: Opcodes.h:263
bool m_playerLogout
Definition: WorldSession.h:1822
char const * what() const override
Definition: ByteBuffer.h:45
uint32 GetOpcode() const
Definition: WorldPacket.h:79
std::string GetOpcodeNameForLogging(T id)
Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer) ...
Definition: Opcodes.h:1777
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetAccountId() const
Definition: WorldSession.h:922
Player * GetPlayer() const
Definition: WorldSession.h:927
virtual void Call(WorldSession *session, WorldPacket &packet) const =0
void LogUnexpectedOpcode(WorldPacket *packet, const char *status, const char *reason)
Logging helper for unexpected opcodes.
Definition: WorldSession.cpp:309
Definition: Opcodes.h:1679
std::shared_ptr< WorldSocket > m_Socket[MAX_CONNECTION_TYPES]
Definition: WorldSession.h:1798
uint32 expireTime
Definition: WorldSession.h:1839
Definition: Opcodes.h:1683
Definition: Opcodes.h:1680
void LogoutPlayer(bool save)
Log the player out
Definition: WorldSession.cpp:498
#define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE
Definition: Opcodes.h:1681
bool next(T &result)
Gets the next result in the queue, if any.
Definition: LockedQueue.h:69
virtual bool ProcessUnsafe() const
Definition: WorldSession.h:843
ObjectGuid m_playerLoading
Definition: WorldSession.h:1821
std::string const & GetRemoteAddress() const
Definition: WorldSession.h:932
uint32_t uint32
Definition: Define.h:150
void readd(Iterator begin, Iterator end)
Adds items back to front of the queue.
Definition: LockedQueue.h:62
Definition: Opcodes.h:1682
Definition: PacketUtilities.h:53
Definition: Opcodes.h:32
void hexlike() const
Definition: ByteBuffer.cpp:82
void HandleMoveWorldportAckOpcode()
Definition: MovementHandler.cpp:43
bool m_playerRecentlyLogout
Definition: WorldSession.h:1823
void UpdateTimeOutTime(uint32 diff)
Definition: WorldSession.h:1069
void ProcessQueryCallbacks()
Definition: WorldSession.cpp:950
class WorldSession::DosProtection AntiDOS
Player * _player
Definition: WorldSession.h:1797
LockedQueue< WorldPacket * > _recvQueue
Definition: WorldSession.h:1837
Definition: ByteBuffer.h:40
std::string GetPlayerInfo() const
Definition: WorldSession.cpp:195
void LogUnprocessedTail(WorldPacket *packet)
Logging helper for unexpected opcodes.
Definition: WorldSession.cpp:316
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
OpcodeClient
Definition: Opcodes.h:46
bool m_inQueue
Definition: WorldSession.h:1820
bool forceExit
Definition: WorldSession.h:1840
Definition: Opcodes.h:1678
Definition: Opcodes.h:1708
SessionStatus Status
Definition: Opcodes.h:1705
bool ShouldLogOut(time_t currTime) const
Is logout cooldown expired?
Definition: WorldSession.h:952
Definition: Opcodes.h:31
Definition: WorldPacket.h:26
bool EvaluateOpcode(WorldPacket &p, time_t time) const
Definition: WorldSession.cpp:1279
bool IsConnectionIdle() const
Definition: WorldSession.h:1079
bool IsEmpty() const
Definition: ObjectGuid.h:242

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldSession::UpdateTimeOutTime ( uint32  diff)
inline
1070  {
1071  m_timeOutTime -= int32(diff);
1072  }
std::atomic< int32 > m_timeOutTime
Definition: WorldSession.h:1067
int32_t int32
Definition: g3dmath.h:167

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class World
friend

Member Data Documentation

AccountData WorldSession::_accountData[NUM_ACCOUNT_DATA_TYPES]
private
uint32 WorldSession::_accountId
private
QueryResultHolderFuture WorldSession::_accountLoginCallback
private
std::string WorldSession::_accountName
private
QueryCallback<PreparedQueryResult, std::string> WorldSession::_addFriendCallback
private
PreparedQueryResultFuture WorldSession::_addIgnoreCallback
private
uint32 WorldSession::_battlenetAccountId
private
uint32 WorldSession::_battlenetRequestToken
private
std::unordered_map<uint32, std::function<void(MessageBuffer)> > WorldSession::_battlenetResponseCallbacks
private
std::unique_ptr<BattlePetMgr> WorldSession::_battlePetMgr
private
QueryCallback<PreparedQueryResult, std::shared_ptr<WorldPackets::Character::CharacterCreateInfo>, true> WorldSession::_charCreateCallback
private
QueryCallback<PreparedQueryResult, std::shared_ptr<WorldPackets::Character::CharCustomizeInfo> > WorldSession::_charCustomizeCallback
private
QueryCallback<PreparedQueryResult, bool> WorldSession::_charEnumCallback
private
QueryCallback<PreparedQueryResult, std::shared_ptr<WorldPackets::Character::CharRaceOrFactionChangeInfo> > WorldSession::_charFactionChangeCallback
private
QueryResultHolderFuture WorldSession::_charLoginCallback
private
QueryCallback<PreparedQueryResult, std::shared_ptr<WorldPackets::Character::CharacterRenameInfo> > WorldSession::_charRenameCallback
private
QueryCallback<PreparedQueryResult, std::shared_ptr<WorldPackets::Character::CharacterUndeleteInfo>, true> WorldSession::_charUndeleteCallback
private
std::unique_ptr<CollectionMgr> WorldSession::_collectionMgr
private
bool WorldSession::_filterAddonMessages
private
ConnectToKey WorldSession::_instanceConnectKey
private
GuidSet WorldSession::_legitCharacters
private
time_t WorldSession::_logoutTime
private
std::string WorldSession::_os
private
Player* WorldSession::_player
private
rbac::RBACData* WorldSession::_RBACData
private
QueryResultHolderFuture WorldSession::_realmAccountLoginCallback
private
std::unordered_map<uint32 , uint8> WorldSession::_realmCharacterCounts
private
std::array<uint8, 32> WorldSession::_realmListSecret
private
LockedQueue<WorldPacket*> WorldSession::_recvQueue
private
std::vector<std::string> WorldSession::_registeredAddonPrefixes
private
AccountTypes WorldSession::_security
private
QueryCallback<PreparedQueryResult, ObjectGuid> WorldSession::_sendStabledPetCallback
private
PreparedQueryResultFuture WorldSession::_stablePetCallback
private
QueryCallback<PreparedQueryResult, uint32> WorldSession::_stableSwapCallback
private
uint32 WorldSession::_tutorials[MAX_ACCOUNT_TUTORIAL_VALUES]
private
bool WorldSession::_tutorialsChanged
private
QueryCallback<PreparedQueryResult, bool, true> WorldSession::_undeleteCooldownStatusCallback
private
QueryCallback<PreparedQueryResult, uint32> WorldSession::_unstablePetCallback
private
Warden* WorldSession::_warden
private
class WorldSession::DosProtection WorldSession::AntiDOS
protected
uint32 WorldSession::expireTime
private
bool WorldSession::forceExit
private
bool WorldSession::isRecruiter
private
AddonsList WorldSession::m_addonsList
private
std::string WorldSession::m_Address
private
std::atomic<uint32> WorldSession::m_clientTimeDelay
private
ObjectGuid WorldSession::m_currentBankerGUID
private
uint8 WorldSession::m_expansion
private
ObjectGuid::LowType WorldSession::m_GUIDLow
private
bool WorldSession::m_inQueue
private
std::atomic<uint32> WorldSession::m_latency
private
time_t WorldSession::m_muteTime
ObjectGuid WorldSession::m_playerLoading
private
bool WorldSession::m_playerLogout
private
bool WorldSession::m_playerRecentlyLogout
private
bool WorldSession::m_playerSave
private
LocaleConstant WorldSession::m_sessionDbcLocale
private
LocaleConstant WorldSession::m_sessionDbLocaleIndex
private
std::shared_ptr<WorldSocket> WorldSession::m_Socket[MAX_CONNECTION_TYPES]
private
std::atomic<int32> WorldSession::m_timeOutTime
uint32 WorldSession::recruiterId
private

The documentation for this class was generated from the following files: