diff --git a/src/game/Battlegrounds/BattleGroundMgr.cpp b/src/game/Battlegrounds/BattleGroundMgr.cpp index e697837de..04bab2a71 100644 --- a/src/game/Battlegrounds/BattleGroundMgr.cpp +++ b/src/game/Battlegrounds/BattleGroundMgr.cpp @@ -140,7 +140,7 @@ bool BattleGroundQueue::SelectionPool::AddGroup(GroupQueueInfo *ginfo, uint32 de /*********************************************************/ // add group or player (grp == NULL) to bg queue with the given leader and bg specifications -GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleGroundTypeId BgTypeId, BattleGroundBracketId bracketId, bool isPremade) +GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleGroundTypeId BgTypeId, BattleGroundBracketId bracketId, bool isPremade, std::vector* excludedMembers) { // create new ginfo GroupQueueInfo* ginfo = new GroupQueueInfo; @@ -173,6 +173,9 @@ GroupQueueInfo * BattleGroundQueue::AddGroup(Player *leader, Group* grp, BattleG Player *member = itr->getSource(); if (!member) continue; // this should never happen + + if (excludedMembers && (std::find(excludedMembers->begin(), excludedMembers->end(), member->GetGUIDLow()) != excludedMembers->end())) + continue; if (grp->GetMembersCount() > group_limit) // queue players solo if group size is above limit set in config { @@ -1061,10 +1064,11 @@ void BattleGroundMgr::BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg) } } -void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, uint32 mapId) +void BattleGroundMgr::BuildGroupJoinedBattlegroundPacket(WorldPacket *data, int32 status) { data->Initialize(SMSG_GROUP_JOINED_BATTLEGROUND, 4); - *data << uint32(mapId); + // for status, see enum BattleGroundGroupJoinStatus + *data << int32(status); } void BattleGroundMgr::BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value) diff --git a/src/game/Battlegrounds/BattleGroundMgr.h b/src/game/Battlegrounds/BattleGroundMgr.h index 76b2deda7..4c543e9f0 100644 --- a/src/game/Battlegrounds/BattleGroundMgr.h +++ b/src/game/Battlegrounds/BattleGroundMgr.h @@ -71,6 +71,13 @@ enum BattleGroundQueueGroupTypes }; #define BG_QUEUE_GROUP_TYPES_COUNT 4 +enum BattleGroundGroupJoinStatus +{ + BG_GROUPJOIN_DESERTERS = -2, + BG_GROUPJOIN_FAILED = -1 // actually, any negative except 2 + // any other value is a MapID meaning successful join +}; + class BattleGround; class BattleGroundQueue { @@ -83,7 +90,7 @@ class BattleGroundQueue void FillPlayersToBG(BattleGround* bg, BattleGroundBracketId bracket_id); bool CheckPremadeMatch(BattleGroundBracketId bracket_id, uint32 MaxPlayersPerTeam, uint32 MinPlayersPerTeam); bool CheckNormalMatch(BattleGroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers); - GroupQueueInfo * AddGroup(Player* leader, Group* group, BattleGroundTypeId bgTypeId, BattleGroundBracketId bracketId, bool isPremade); + GroupQueueInfo * AddGroup(Player* leader, Group* group, BattleGroundTypeId bgTypeId, BattleGroundBracketId bracketId, bool isPremade, std::vector* excludedMembers = nullptr); void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id); uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattleGroundBracketId bracket_id); @@ -196,7 +203,7 @@ class BattleGroundMgr void BuildPlayerJoinedBattleGroundPacket(WorldPacket *data, Player *plr); void BuildPlayerLeftBattleGroundPacket(WorldPacket *data, ObjectGuid guid); void BuildBattleGroundListPacket(WorldPacket *data, ObjectGuid guid, Player *plr, BattleGroundTypeId bgTypeId); - void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, uint32 mapId); + void BuildGroupJoinedBattlegroundPacket(WorldPacket *data, int32 status); void BuildUpdateWorldStatePacket(WorldPacket *data, uint32 field, uint32 value); void BuildPvpLogDataPacket(WorldPacket *data, BattleGround *bg); void BuildBattleGroundStatusPacket(WorldPacket *data, BattleGround *bg, uint8 QueueSlot, uint8 StatusID, uint32 Time1, uint32 Time2); diff --git a/src/game/Chat/Channel.cpp b/src/game/Chat/Channel.cpp index d598f6860..a8702ea4a 100644 --- a/src/game/Chat/Channel.cpp +++ b/src/game/Chat/Channel.cpp @@ -468,13 +468,12 @@ void Channel::List(PlayerPointer player) } else { - WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1)); - data << uint8(1); // channel type? + WorldPacket data(SMSG_CHANNEL_LIST, (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1)); // guess size data << GetName(); // channel name data << uint8(GetFlags()); // channel flags? size_t pos = data.wpos(); - data << uint32(0); // size of list, placeholder + data << int32(0); // size of list, placeholder AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST); @@ -510,7 +509,7 @@ void Channel::List(PlayerPointer player) } } - data.put(pos, count); + data.put(pos, count); SendToOne(&data, p); } @@ -772,17 +771,17 @@ void Channel::MakeLeft(WorldPacket *data, ObjectGuid guid) void Channel::MakeYouJoined(WorldPacket *data) { MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE); - *data << uint8(GetFlags()); - *data << uint32(GetChannelId()); - *data << uint32(0); + *data << uint32(GetFlags()); + *data << uint32(0); // the non-zero number will be appended to the channel name + *data << uint8(0); // CString max length 512, conditional read } // done 0x03 void Channel::MakeYouLeft(WorldPacket *data) { MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE); - *data << uint32(GetChannelId()); - *data << uint8(0); // can be 0x00 and 0x01 + //*data << uint32(GetChannelId()); //[-ZERO] + //*data << uint8(0); //[-ZERO] can be 0x00 and 0x01 (bool) } // done 0x04 @@ -797,6 +796,12 @@ void Channel::MakeNotMember(WorldPacket *data) MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE); } +void Channel::MakeNotOnPacket(WorldPacket* data, const std::string &name) +{ + data->Initialize(SMSG_CHANNEL_NOTIFY, (1 + name.length() + 1)); + (*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name; +} + // done 0x06 void Channel::MakeNotModerator(WorldPacket *data) { diff --git a/src/game/Chat/Channel.h b/src/game/Chat/Channel.h index e2794d903..54e29f4ff 100644 --- a/src/game/Chat/Channel.h +++ b/src/game/Chat/Channel.h @@ -186,6 +186,11 @@ class Channel void JoinNotify(ObjectGuid guid); // invisible notify void LeaveNotify(ObjectGuid guid); // invisible notify + /** + * This creates the packet informing client that the player is not on requested \ref name channel. + * See also \ref MakeNotMember for non-static version. + */ + static void MakeNotOnPacket(WorldPacket* data, const std::string &name); private: // initial packet data (notify type and channel name) void MakeNotifyPacket(WorldPacket *data, uint8 notify_type); diff --git a/src/game/Chat/ChannelMgr.cpp b/src/game/Chat/ChannelMgr.cpp index 6be7426d1..46649c4a1 100644 --- a/src/game/Chat/ChannelMgr.cpp +++ b/src/game/Chat/ChannelMgr.cpp @@ -81,7 +81,7 @@ Channel *ChannelMgr::GetChannel(std::string name, PlayerPointer p, bool pkt) if (pkt) { WorldPacket data; - MakeNotOnPacket(&data, name); + Channel::MakeNotOnPacket(&data, name); p->GetSession()->SendPacket(&data); } @@ -111,12 +111,6 @@ void ChannelMgr::LeftChannel(std::string name) } } -void ChannelMgr::MakeNotOnPacket(WorldPacket *data, std::string name) -{ - data->Initialize(SMSG_CHANNEL_NOTIFY, (1 + 10)); // we guess size - (*data) << (uint8)CHAT_NOT_MEMBER_NOTICE << name; -} - void ChannelMgr::CreateDefaultChannels() { GetJoinChannel("Warden")->SetSecurityLevel(SEC_GAMEMASTER); diff --git a/src/game/Chat/ChannelMgr.h b/src/game/Chat/ChannelMgr.h index 37e747235..3a6aa137e 100644 --- a/src/game/Chat/ChannelMgr.h +++ b/src/game/Chat/ChannelMgr.h @@ -48,7 +48,6 @@ class ChannelMgr static void AnnounceBothFactionsChannel(std::string channelName, ObjectGuid playerGuid, const char* message); private: ChannelMap channels; - void MakeNotOnPacket(WorldPacket *data, std::string name); }; class AllianceChannelMgr : public ChannelMgr {}; diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index 2b773efd9..e3696574f 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -228,6 +228,7 @@ ChatCommand * ChatHandler::getCommandTable() { NODE, "chanvisual", SEC_GAMEMASTER, true, &ChatHandler::HandleSendSpellChannelVisualCommand, "", nullptr }, { NODE, "chanvisualnext", SEC_GAMEMASTER, true, &ChatHandler::HandleDebugSendNextChannelSpellVisualCommand, "", nullptr }, { NODE, "impact", SEC_GAMEMASTER, true, &ChatHandler::HandleSendSpellImpactCommand, "", nullptr }, + { NODE, "openbag", SEC_GAMEMASTER, false, &ChatHandler::HandleDebugSendOpenBagCommand, "", nullptr }, { MSTR, nullptr, 0, false, nullptr, "", nullptr } }; diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index addaaa4a3..7512bd957 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -419,6 +419,7 @@ class MANGOS_DLL_SPEC ChatHandler bool HandleDebugSendQuestInvalidMsgCommand(char* args); bool HandleDebugSendSellErrorCommand(char* args); bool HandleDebugSendSpellFailCommand(char* args); + bool HandleDebugSendOpenBagCommand(char* args); /* Send the visual of the next channeled spell after args, suggested macro : diff --git a/src/game/Commands/debugcmds.cpp b/src/game/Commands/debugcmds.cpp index 47c12dbd0..816a52418 100644 --- a/src/game/Commands/debugcmds.cpp +++ b/src/game/Commands/debugcmds.cpp @@ -57,7 +57,7 @@ bool ChatHandler::HandleDebugSendSpellFailCommand(char* args) char* unk = strtok(NULL, " "); uint8 unkI = unk ? (uint8)atoi(unk) : 2; - WorldPacket data(SMSG_CAST_FAILED, 4 + 1 + 1); + WorldPacket data(SMSG_CAST_RESULT, 4 + 1 + 1); data << uint32(133); data << uint8(unkI); data << uint8(failnum); @@ -195,6 +195,20 @@ bool ChatHandler::HandleDebugSendBuyErrorCommand(char* args) return true; } +bool ChatHandler::HandleDebugSendOpenBagCommand(char *args) +{ + Player *pTarget = getSelectedPlayer(); + if (!pTarget) + { + SendSysMessage(LANG_PLAYER_NOT_FOUND); + SetSentErrorMessage(true); + return false; + } + + pTarget->SendOpenContainer(); + return true; +} + bool ChatHandler::HandleDebugSendOpcodeCommand(char* /*args*/) { Unit *unit = getSelectedUnit(); @@ -431,8 +445,10 @@ bool ChatHandler::HandleDebugSendQuestPartyMsgCommand(char* args) uint32 msg; if (!ExtractUInt32(&args, msg)) return false; + if (msg > 0xFF) + return false; - m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), msg); + m_session->GetPlayer()->SendPushToPartyResponse(m_session->GetPlayer(), uint8(msg)); return true; } diff --git a/src/game/GossipDef.cpp b/src/game/GossipDef.cpp index 8aaa53cee..6db1e9db5 100644 --- a/src/game/GossipDef.cpp +++ b/src/game/GossipDef.cpp @@ -158,7 +158,7 @@ void PlayerMenu::SendGossipMenu(uint32 TitleTextId, ObjectGuid objectGuid) WorldPacket data(SMSG_GOSSIP_MESSAGE, (100)); // guess size data << ObjectGuid(objectGuid); data << uint32(TitleTextId); - data << uint32(mGossipMenu.MenuItemCount()); // max count 0x20 + data << uint32(mGossipMenu.MenuItemCount()); // [ZERO] max count 15 for (uint32 iI = 0; iI < mGossipMenu.MenuItemCount(); ++iI) { @@ -811,7 +811,7 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const *pQuest, ObjectGuid npcG data << uint32(0x04); // flags2 data << uint32(0x08); // flags3 - data << uint32(0x10); // flags4 + //data << uint32(0x10); // [-ZERO] flags4 GetMenuSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_REQUEST_ITEMS NPCGuid = %s, questid = %u", npcGUID.GetString().c_str(), pQuest->GetQuestId()); diff --git a/src/game/Group/Group.cpp b/src/game/Group/Group.cpp index 42179a9e7..ce6e49dc9 100644 --- a/src/game/Group/Group.cpp +++ b/src/game/Group/Group.cpp @@ -1644,7 +1644,7 @@ void Group::SwapMembersGroup(Player *player, Player *swapPlayer) } } -uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount) +uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, Player* Leader, std::vector* excludedMembers) { // check for min / max count uint32 memberscount = GetMembersCount(); @@ -1653,14 +1653,12 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGround if (memberscount > MaxPlayerCount) return BG_JOIN_ERR_GROUP_TOO_MANY; - // get a player as reference, to compare other players' stats to (queue id based on level, etc.) - Player * reference = GetFirstMember()->getSource(); // no reference found, can't join this way - if (!reference) + if (!Leader) return BG_JOIN_ERR_OFFLINE_MEMBER; - BattleGroundBracketId bracket_id = reference->GetBattleGroundBracketIdFromLevel(bgTypeId); - Team team = reference->GetTeam(); + BattleGroundBracketId bracket_id = Leader->GetBattleGroundBracketIdFromLevel(bgTypeId); + Team team = Leader->GetTeam(); // check every member of the group to be able to join for (GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next()) @@ -1674,7 +1672,10 @@ uint32 Group::CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGround return BG_JOIN_ERR_MIXED_FACTION; // not in the same battleground level bracket, don't let join if (member->GetBattleGroundBracketIdFromLevel(bgTypeId) != bracket_id) - return BG_JOIN_ERR_MIXED_LEVELS; + { + if (excludedMembers && (std::find(excludedMembers->begin(), excludedMembers->end(), member->GetGUIDLow()) == excludedMembers->end())) + excludedMembers->push_back(member->GetGUIDLow()); + } // don't let join if someone from the group is already in that bg queue if (member->InBattleGroundQueueForBattleGroundQueueType(bgQueueTypeId)) return BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE; @@ -1726,6 +1727,27 @@ void Group::ResetInstances(InstanceResetMethod method, Player* SendMsgTo) ++itr; continue; } + + if (SendMsgTo) + { + bool offline_players = false; + for (member_citerator citr = m_memberSlots.begin(); citr != m_memberSlots.end(); ++citr) + { + Player *pl = sObjectMgr.GetPlayer(citr->guid); + if (!pl || !pl->GetSession()) + { + offline_players = true; + break; + } + } + + if (offline_players) + { + SendMsgTo->SendResetInstanceFailed(INSTANCERESET_FAIL_OFFLINE, state->GetMapId()); + ++itr; + continue; + } + } } bool isEmpty = true; @@ -1739,7 +1761,7 @@ void Group::ResetInstances(InstanceResetMethod method, Player* SendMsgTo) if (isEmpty) SendMsgTo->SendResetInstanceSuccess(state->GetMapId()); else - SendMsgTo->SendResetInstanceFailed(0, state->GetMapId()); + SendMsgTo->SendResetInstanceFailed(INSTANCERESET_FAIL_GENERAL, state->GetMapId()); } if (isEmpty || method == INSTANCE_RESET_GROUP_DISBAND) diff --git a/src/game/Group/Group.h b/src/game/Group/Group.h index 03c568ca3..584fec4a4 100644 --- a/src/game/Group/Group.h +++ b/src/game/Group/Group.h @@ -256,7 +256,7 @@ class MANGOS_DLL_SPEC Group void ConvertToRaid(); void SetBattlegroundGroup(BattleGround *bg) { m_bgGroup = bg; } - uint32 CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount); + uint32 CanJoinBattleGroundQueue(BattleGroundTypeId bgTypeId, BattleGroundQueueTypeId bgQueueTypeId, uint32 MinPlayerCount, uint32 MaxPlayerCount, Player* Leader, std::vector* excludedMembers = nullptr); void ChangeMembersGroup(ObjectGuid guid, uint8 group); void ChangeMembersGroup(Player *player, uint8 group); diff --git a/src/game/Guild/Guild.cpp b/src/game/Guild/Guild.cpp index 9fcb7c398..7c04b7b3d 100644 --- a/src/game/Guild/Guild.cpp +++ b/src/game/Guild/Guild.cpp @@ -762,7 +762,7 @@ void Guild::Roster(WorldSession *session /*= NULL*/) void Guild::Query(WorldSession *session) { - WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (8 * 32 + 200)); // we can only guess size + WorldPacket data(SMSG_GUILD_QUERY_RESPONSE, (4 + 48 + 10 * 32 + 5 * 4)); // guess size; max: name(96), rankname(64) data << uint32(m_Id); data << m_Name; diff --git a/src/game/Guild/Guild.h b/src/game/Guild/Guild.h index e730f8b46..7abe121dd 100644 --- a/src/game/Guild/Guild.h +++ b/src/game/Guild/Guild.h @@ -79,11 +79,10 @@ enum Typecommand GUILD_CREATE_S = 0x00, GUILD_INVITE_S = 0x01, GUILD_QUIT_S = 0x03, - // 0x05? GUILD_FOUNDER_S = 0x0E, - // [-ZERO] tbc enumerations [?] - GUILD_UNK1 = 0x10, - GUILD_UNK3 = 0x16 + GUILD_UNK19 = 0x13, + GUILD_UNK20 = 0x14 + // [ZERO] in SMSG_GUILD_COMMAND_RESULT: 2,4-13,15-18 no effect for no error }; enum class GuildAddStatus @@ -97,7 +96,7 @@ enum class GuildAddStatus enum CommandErrors { - ERR_PLAYER_NO_MORE_IN_GUILD = 0x00, + ERR_PLAYER_NO_MORE_IN_GUILD = 0x00, // no message/error ERR_GUILD_INTERNAL = 0x01, ERR_ALREADY_IN_GUILD = 0x02, ERR_ALREADY_IN_GUILD_S = 0x03, @@ -105,18 +104,19 @@ enum CommandErrors ERR_ALREADY_INVITED_TO_GUILD_S = 0x05, ERR_GUILD_NAME_INVALID = 0x06, ERR_GUILD_NAME_EXISTS_S = 0x07, - ERR_GUILD_LEADER_LEAVE = 0x08, - ERR_GUILD_PERMISSIONS = 0x08, + ERR_GUILD_LEADER_LEAVE = 0x08, // for Typecommand 0x03 + ERR_GUILD_PERMISSIONS = 0x08, // for another Typecommand ERR_GUILD_PLAYER_NOT_IN_GUILD = 0x09, ERR_GUILD_PLAYER_NOT_IN_GUILD_S = 0x0A, ERR_GUILD_PLAYER_NOT_FOUND_S = 0x0B, ERR_GUILD_NOT_ALLIED = 0x0C, - // [-ZERO] tbc enumerations ? ERR_GUILD_RANK_TOO_HIGH_S = 0x0D, ERR_GUILD_RANK_TOO_LOW_S = 0x0E, + // [ZERO] 0x0F, 0x10 unused ERR_GUILD_RANKS_LOCKED = 0x11, ERR_GUILD_RANK_IN_USE = 0x12, ERR_GUILD_IGNORING_YOU_S = 0x13, + ERR_GUILD_UNK20 = 0x14 // for Typecommand 0x05 only }; enum GuildEvents @@ -137,20 +137,14 @@ enum GuildEvents GE_SIGNED_OFF = 0x0D, // ERR_FRIEND_OFFLINE_S }; -enum PetitionTurns -{ - PETITION_TURN_OK = 0, - PETITION_TURN_ALREADY_IN_GUILD = 2, - PETITION_TURN_NEED_MORE_SIGNATURES = 4, -}; - enum PetitionSigns { PETITION_SIGN_OK = 0, PETITION_SIGN_ALREADY_SIGNED = 1, PETITION_SIGN_ALREADY_IN_GUILD = 2, PETITION_SIGN_CANT_SIGN_OWN = 3, - PETITION_SIGN_NOT_SERVER = 4, + PETITION_SIGN_NEED_MORE = 4, + PETITION_SIGN_NOT_SERVER = 5 }; enum GuildEventLogTypes @@ -170,7 +164,7 @@ enum GuildEmblem ERR_GUILDEMBLEM_NOGUILD = 2, ERR_GUILDEMBLEM_NOTGUILDMASTER = 3, ERR_GUILDEMBLEM_NOTENOUGHMONEY = 4, - ERR_GUILDEMBLEM_INVALIDVENDOR = 5 + ERR_GUILDEMBLEM_FAIL_NO_MESSAGE = 5 }; struct GuildEventLogEntry diff --git a/src/game/Handlers/BattleGroundHandler.cpp b/src/game/Handlers/BattleGroundHandler.cpp index 159d3b4a5..b6375b3a3 100644 --- a/src/game/Handlers/BattleGroundHandler.cpp +++ b/src/game/Handlers/BattleGroundHandler.cpp @@ -170,53 +170,11 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) // check if has free queue slots if (!_player->HasFreeBattleGroundQueueId()) return; - } - else - { - grp = _player->GetGroup(); - // no group found, error - if (!grp) - return; - uint32 err = grp->CanJoinBattleGroundQueue(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam()); - isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) && - (grp->GetMembersCount() >= sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_QUEUE_GROUP_MIN_SIZE)); - if (err != BG_JOIN_ERR_OK) - { - SendBattleGroundJoinError(err); - return; - } - } - // if we're here, then the conditions to join a bg are met. We can proceed in joining. - // _player->GetGroup() was already checked, grp is already initialized - BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; - if (joinAsGroup) - { - DEBUG_LOG("Battleground: the following players are joining as group:"); - GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bgBracketId, isPremade); - uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId)); - for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) - { - Player *member = itr->getSource(); - if (!member) continue; // this should never happen + // if we're here, then the conditions to join a bg are met. We can proceed in joining. + // _player->GetGroup() was already checked, grp is already initialized + BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; - uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue - - // store entry point coords - member->SetBattleGroundEntryPoint(_player, queuedAtBGPortal); - - WorldPacket data; - // send status packet (in queue) - sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0); - member->GetSession()->SendPacket(&data); - sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bg->GetMapId()); - member->GetSession()->SendPacket(&data); - DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); - } - DEBUG_LOG("Battleground: group end"); - } - else - { GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, NULL, bgTypeId, bgBracketId, isPremade); uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId)); // already checked if queueSlot is valid, now just get it @@ -230,6 +188,67 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data) SendPacket(&data); DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, _player->GetGUIDLow(), _player->GetName()); } + else + { + grp = _player->GetGroup(); + // no group found, error + if (!grp) + return; + + std::vector excludedMembers; + uint32 err = grp->CanJoinBattleGroundQueue(bgTypeId, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), _player, &excludedMembers); + isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) && + (grp->GetMembersCount() >= sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_QUEUE_GROUP_MIN_SIZE)); + + if (err == BG_JOIN_ERR_GROUP_DESERTER) + { + WorldPacket data; + sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, BG_GROUPJOIN_DESERTERS); + _player->GetSession()->SendPacket(&data); + SendBattleGroundJoinError(err); + return; + } + else if (err != BG_JOIN_ERR_OK) + { + SendBattleGroundJoinError(err); + return; + } + + // if we're here, then the conditions to join a bg are met. We can proceed in joining. + + // _player->GetGroup() was already checked, grp is already initialized + BattleGroundQueue& bgQueue = sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId]; + DEBUG_LOG("Battleground: the following players are joining as group:"); + GroupQueueInfo * ginfo = bgQueue.AddGroup(_player, grp, bgTypeId, bgBracketId, isPremade, &excludedMembers); + uint32 avgTime = bgQueue.GetAverageQueueWaitTime(ginfo, _player->GetBattleGroundBracketIdFromLevel(bgTypeId)); + for (GroupReference *itr = grp->GetFirstMember(); itr != NULL; itr = itr->next()) + { + Player *member = itr->getSource(); + if (!member) continue; // this should never happen + + if (std::find(excludedMembers.begin(), excludedMembers.end(), member->GetGUIDLow()) != excludedMembers.end()) + { + WorldPacket data; + sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, BG_GROUPJOIN_FAILED); + member->GetSession()->SendPacket(&data); + SendBattleGroundJoinError(err); + continue; + } + + uint32 queueSlot = member->AddBattleGroundQueueId(bgQueueTypeId); // add to queue + member->SetBattleGroundEntryPoint(_player, queuedAtBGPortal); // store entry point coords + + WorldPacket data; + // send status packet (in queue) + sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, bg, queueSlot, STATUS_WAIT_QUEUE, avgTime, 0); + member->GetSession()->SendPacket(&data); + sBattleGroundMgr.BuildGroupJoinedBattlegroundPacket(&data, bg->GetMapId()); + member->GetSession()->SendPacket(&data); + DEBUG_LOG("Battleground: player joined queue for bg queue type %u bg type %u: GUID %u, NAME %s", bgQueueTypeId, bgTypeId, member->GetGUIDLow(), member->GetName()); + } + DEBUG_LOG("Battleground: group end"); + } + sBattleGroundMgr.ScheduleQueueUpdate(bgQueueTypeId, bgTypeId, _player->GetBattleGroundBracketIdFromLevel(bgTypeId)); } diff --git a/src/game/Handlers/CharacterHandler.cpp b/src/game/Handlers/CharacterHandler.cpp index d726dd936..a318376dc 100644 --- a/src/game/Handlers/CharacterHandler.cpp +++ b/src/game/Handlers/CharacterHandler.cpp @@ -384,7 +384,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data) if (sGuildMgr.GetGuildByLeader(guid)) { WorldPacket data(SMSG_CHAR_DELETE, 1); - data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER; + data << (uint8)CHAR_DELETE_FAILED; SendPacket(&data); return; } @@ -943,4 +943,5 @@ void WorldSession::HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uin session->SendPacket(&data); sObjectMgr.ChangePlayerNameInCache(guidLow, oldname, newname); + sWorld.InvalidatePlayerDataToAllClient(guid); } diff --git a/src/game/Handlers/GroupHandler.cpp b/src/game/Handlers/GroupHandler.cpp index 56216ab1e..f99e58b1e 100644 --- a/src/game/Handlers/GroupHandler.cpp +++ b/src/game/Handlers/GroupHandler.cpp @@ -586,36 +586,6 @@ void WorldSession::HandleGroupAssistantLeaderOpcode(WorldPacket & recv_data) group->SetAssistant(guid, (flag == 0 ? false : true)); } -void WorldSession::HandlePartyAssignmentOpcode(WorldPacket & recv_data) -{ - uint8 flag1, flag2; - ObjectGuid guid; - recv_data >> flag1 >> flag2; - recv_data >> guid; - - DEBUG_LOG("MSG_PARTY_ASSIGNMENT"); - - Group *group = GetPlayer()->GetGroup(); - if (!group) - return; - - // if(flag1) Main Assist - // 0x4 - // if(flag2) Main Tank - // 0x2 - - /** error handling **/ - if (!group->IsLeader(GetPlayer()->GetObjectGuid())) - return; - /********************/ - - // everything is fine, do it - if (flag1 == 1) - group->SetMainAssistant(guid); - if (flag2 == 1) - group->SetMainTank(guid); -} - void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) { if (recv_data.empty()) // request @@ -655,18 +625,6 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket & recv_data) } } -void WorldSession::HandleRaidReadyCheckFinishedOpcode(WorldPacket & /*recv_data*/) -{ - //Group* group = GetPlayer()->GetGroup(); - //if(!group) - // return; - - //if(!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID())) - // return; - - // Is any reaction need? -} - void WorldSession::BuildPartyMemberStatsPacket(Player* player, WorldPacket* data, uint32 mask, bool sendAllAuras) { *data << player->GetPackGUID(); @@ -842,7 +800,7 @@ void WorldSession::HandleRequestPartyMemberStatsOpcode(WorldPacket &recv_data) if (!player || player->GetGroup() != _player->GetGroup()) { - WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 2); + WorldPacket data(SMSG_PARTY_MEMBER_STATS_FULL, 3 + 4 + 1); data << guid.WriteAsPacked(); data << uint32(GROUP_UPDATE_FLAG_STATUS); data << uint8(MEMBER_STATUS_OFFLINE); @@ -860,22 +818,3 @@ void WorldSession::HandleRequestRaidInfoOpcode(WorldPacket & /*recv_data*/) // every time the player checks the character screen _player->SendRaidInfo(); } - -void WorldSession::HandleOptOutOfLootOpcode(WorldPacket & recv_data) -{ - DEBUG_LOG("WORLD: Received CMSG_OPT_OUT_OF_LOOT"); - - uint32 unkn; - recv_data >> unkn; - - // ignore if player not loaded - if (!GetPlayer()) // needed because STATUS_AUTHED - { - if (unkn != 0) - sLog.outError("CMSG_GROUP_PASS_ON_LOOT value<>0 for not-loaded character!"); - return; - } - - if (unkn != 0) - sLog.outError("CMSG_GROUP_PASS_ON_LOOT: activation not implemented!"); -} diff --git a/src/game/Handlers/GuildHandler.cpp b/src/game/Handlers/GuildHandler.cpp index 40a65ca2a..aea1312f2 100644 --- a/src/game/Handlers/GuildHandler.cpp +++ b/src/game/Handlers/GuildHandler.cpp @@ -730,8 +730,8 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) Creature *pCreature = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_TABARDDESIGNER); if (!pCreature) { - //"That's not an emblem vendor!" - SendSaveGuildEmblem(ERR_GUILDEMBLEM_INVALIDVENDOR); + //[-ZERO] fails silently, not "That's not an emblem vendor!" + SendSaveGuildEmblem(ERR_GUILDEMBLEM_FAIL_NO_MESSAGE); DEBUG_LOG("WORLD: HandleSaveGuildEmblemOpcode - %s not found or you can't interact with him.", vendorGuid.GetString().c_str()); return; } @@ -771,16 +771,6 @@ void WorldSession::HandleSaveGuildEmblemOpcode(WorldPacket& recvPacket) guild->Query(this); } -void WorldSession::HandleGuildEventLogQueryOpcode(WorldPacket& /* recvPacket */) -{ - // empty - DEBUG_LOG("WORLD: Received (MSG_GUILD_EVENT_LOG_QUERY)"); - - if (uint32 GuildId = GetPlayer()->GetGuildId()) - if (Guild* pGuild = sGuildMgr.GetGuildById(GuildId)) - pGuild->DisplayGuildEventLog(this); -} - void WorldSession::SendSaveGuildEmblem(uint32 msg) { WorldPacket data(MSG_SAVE_GUILD_EMBLEM, 4); diff --git a/src/game/Handlers/ItemHandler.cpp b/src/game/Handlers/ItemHandler.cpp index 3994a3f7d..21b6059e2 100644 --- a/src/game/Handlers/ItemHandler.cpp +++ b/src/game/Handlers/ItemHandler.cpp @@ -326,7 +326,7 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recv_data) data << pProto->Class; // client known only 0 subclass (and 1-2 obsolute subclasses) data << (pProto->Class == ITEM_CLASS_CONSUMABLE ? uint32(0) : pProto->SubClass); - data << Name; + data << Name; // max length of any of 4 names: 256 bytes data << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name... data << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00); data << uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00); @@ -463,11 +463,14 @@ void WorldSession::HandleReadItemOpcode(WorldPacket & recv_data) if (msg == EQUIP_ERR_OK) { data.Initialize(SMSG_READ_ITEM_OK, 8); + data << ObjectGuid(pItem->GetObjectGuid()); DETAIL_LOG("STORAGE: Item page sent"); } else { - data.Initialize(SMSG_READ_ITEM_FAILED, 8); + data.Initialize(SMSG_READ_ITEM_FAILED, 8 + 1); + data << ObjectGuid(pItem->GetObjectGuid()); + data << uint8(0); // 0..2, read failure reason? if == 1, use next command DETAIL_LOG("STORAGE: Unable to read item"); _player->SendEquipError(msg, pItem, NULL); } @@ -915,8 +918,14 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) ObjectGuid guid; recvPacket >> guid; + WorldPacket data(SMSG_BUY_BANK_SLOT_RESULT, 4); + if (!CheckBanker(guid)) + { + data << uint32(ERR_BANKSLOT_NOTBANKER); + SendPacket(&data); return; + } uint32 slot = _player->GetBankBagSlotCount(); @@ -927,8 +936,6 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) BankBagSlotPricesEntry const* slotEntry = sBankBagSlotPricesStore.LookupEntry(slot); - WorldPacket data(SMSG_BUY_BANK_SLOT_RESULT, 4); - if (!slotEntry) { data << uint32(ERR_BANKSLOT_FAILED_TOO_MANY); @@ -947,9 +954,6 @@ void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket) _player->SetBankBagSlotCount(slot); _player->ModifyMoney(-int32(price)); - - data << uint32(ERR_BANKSLOT_OK); - SendPacket(&data); } void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket) @@ -1108,7 +1112,7 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data) WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4 + 10)); data << uint32(pProto->ItemId); data << Name; - data << uint32(pProto->InventoryType); + //data << uint32(pProto->InventoryType); [-ZERO] SendPacket(&data); return; } @@ -1240,30 +1244,6 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data) _player->DestroyItemCount(gift, count, true); } -void WorldSession::HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data) -{ - DEBUG_LOG("WORLD: CMSG_CANCEL_TEMP_ENCHANTMENT"); - - uint32 eslot; - - recv_data >> eslot; - - // apply only to equipped item - if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, eslot)) - return; - - Item* item = GetPlayer()->GetItemByPos(INVENTORY_SLOT_BAG_0, eslot); - - if (!item) - return; - - if (!item->GetEnchantmentId(TEMP_ENCHANTMENT_SLOT)) - return; - - GetPlayer()->ApplyEnchantment(item, TEMP_ENCHANTMENT_SLOT, false); - item->ClearEnchantment(TEMP_ENCHANTMENT_SLOT); -} - bool WorldSession::CanUseBank(ObjectGuid bankerGUID) const { // bankerGUID parameter is optional, set to 0 by default. diff --git a/src/game/Handlers/MailHandler.cpp b/src/game/Handlers/MailHandler.cpp index 1725e28b7..5948da65f 100644 --- a/src/game/Handlers/MailHandler.cpp +++ b/src/game/Handlers/MailHandler.cpp @@ -756,19 +756,23 @@ void WorldSession::HandleGetMailList(WorldPacket & recv_data) // 1.12.1 can have only single item Item *item = (*itr)->items.size() > 0 ? pl->GetMItem((*itr)->items[0].item_guid) : NULL; - data << uint32(item ? item->GetEntry() : 0); // entry - // permanent enchantment - data << uint32(item ? item->GetEnchantmentId((EnchantmentSlot)PERM_ENCHANTMENT_SLOT) : 0); - // can be negative - data << uint32(item ? item->GetItemRandomPropertyId() : 0); - // unk - data << uint32(item ? item->GetItemSuffixFactor() : 0); - data << uint8(item ? item->GetCount() : 0); // stack count - data << uint32(item ? item->GetSpellCharges() : 0); // charges - // durability - data << uint32(item ? item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY) : 0); - // durability - data << uint32(item ? item->GetUInt32Value(ITEM_FIELD_DURABILITY) : 0); + + if (item) + { + data << uint32(item->GetEntry()); + data << uint32(item->GetEnchantmentId((EnchantmentSlot)PERM_ENCHANTMENT_SLOT)); // permanent enchantment + data << uint32(item->GetItemRandomPropertyId()); // can be negative + data << uint32(item->GetItemSuffixFactor()); // unk + data << uint8(item->GetCount()); // stack count + data << uint32(item->GetSpellCharges()); // charges + data << uint32(item->GetUInt32Value(ITEM_FIELD_MAXDURABILITY)); // durability max + data << uint32(item->GetUInt32Value(ITEM_FIELD_DURABILITY)); // durability current + } + else + { + data << uint32(0) << uint32(0) << uint32(0) << uint32(0) << uint8(0) << uint32(0) << uint32(0) << uint32(0); + } + data << uint32((*itr)->money); // copper data << uint32((*itr)->COD); // Cash on delivery data << uint32((*itr)->checked); // flags diff --git a/src/game/Handlers/MiscHandler.cpp b/src/game/Handlers/MiscHandler.cpp index 6ec1d85d8..eb615f3c5 100644 --- a/src/game/Handlers/MiscHandler.cpp +++ b/src/game/Handlers/MiscHandler.cpp @@ -307,15 +307,19 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) if (ObjectGuid lootGuid = GetPlayer()->GetLootGuid()) DoLootRelease(lootGuid); - //Can not logout if... - if (GetPlayer()->isInCombat() || //...is in combat - GetPlayer()->duel || //...is in Duel - //...is jumping ...is falling - GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_JUMPING | MOVEFLAG_FALLINGFAR))) + uint8 reason = 0; + + if (GetPlayer()->isInCombat()) + reason = 1; + else if (GetPlayer()->m_movementInfo.HasMovementFlag(MovementFlags(MOVEFLAG_JUMPING | MOVEFLAG_FALLINGFAR))) + reason = 3; // is jumping or falling + else if (GetPlayer()->duel || GetPlayer()->HasAura(9454)) // is dueling or frozen by GM via freeze command + reason = 2; // FIXME - Need the correct value + + if (reason) { - WorldPacket data(SMSG_LOGOUT_RESPONSE, (2 + 4)) ; - data << (uint8)0xC; - data << uint32(0); + WorldPacket data(SMSG_LOGOUT_RESPONSE, 1 + 4); + data << uint32(reason); data << uint8(0); SendPacket(&data); LogoutRequest(0); @@ -326,6 +330,10 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) if (GetPlayer()->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING) || GetPlayer()->IsTaxiFlying() || GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_INSTANT_LOGOUT)) { + WorldPacket data(SMSG_LOGOUT_RESPONSE, 1 + 4); + data << uint32(0); + data << uint8(1); + SendPacket(&data); LogoutPlayer(true); return; } @@ -341,7 +349,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } - WorldPacket data(SMSG_LOGOUT_RESPONSE, 5); + WorldPacket data(SMSG_LOGOUT_RESPONSE, 1 + 4); data << uint32(0); data << uint8(0); SendPacket(&data); @@ -1129,6 +1137,27 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) DEBUG_LOG("Received worldport command from player %s", GetPlayer()->GetName()); } +void WorldSession::HandleMoveSetRawPosition(WorldPacket& recv_data) +{ + DEBUG_LOG("WORLD: Received opcode CMSG_MOVE_SET_RAW_POSITION from %s", GetPlayer()->GetGuidStr().c_str()); + // write in client console: setrawpos x y z o + // For now, it is implemented like worldport but on the same map. Consider using MSG_MOVE_SET_RAW_POSITION_ACK. + float PosX, PosY, PosZ, PosO; + recv_data >> PosX >> PosY >> PosZ >> PosO; + //DEBUG_LOG("Set to: X=%f, Y=%f, Z=%f, orient=%f", PosX, PosY, PosZ, PosO); + + if (!GetPlayer()->IsInWorld() || GetPlayer()->IsTaxiFlying()) + { + DEBUG_LOG("Player '%s' (GUID: %u) in a transfer, ignore setrawpos command.", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow()); + return; + } + + if (GetSecurity() >= SEC_ADMINISTRATOR) + GetPlayer()->NearTeleportTo(PosX, PosY, PosZ, PosO); + else + SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); +} + void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) { DEBUG_LOG("Received opcode CMSG_WHOIS"); @@ -1177,7 +1206,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) std::string msg = charname + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip; - WorldPacket data(SMSG_WHOIS, msg.size() + 1); + WorldPacket data(SMSG_WHOIS, msg.size() + 1); // max CString length allowed: 256 data << msg; _player->GetSession()->SendPacket(&data); @@ -1224,27 +1253,6 @@ void WorldSession::HandleResetInstancesOpcode(WorldPacket & /*recv_data*/) _player->ResetInstances(INSTANCE_RESET_ALL); } -void WorldSession::HandleCancelMountAuraOpcode(WorldPacket & /*recv_data*/) -{ - DEBUG_LOG("WORLD: CMSG_CANCEL_MOUNT_AURA"); - - //If player is not mounted, so go out :) - if (!_player->IsMounted()) // not blizz like; no any messages on blizz - { - ChatHandler(this).SendSysMessage(LANG_CHAR_NON_MOUNTED); - return; - } - - if (_player->IsTaxiFlying()) // not blizz like; no any messages on blizz - { - ChatHandler(this).SendSysMessage(LANG_YOU_IN_FLIGHT); - return; - } - - _player->Unmount(_player->HasAuraType(SPELL_AURA_MOUNTED)); - _player->RemoveSpellsCausingAura(SPELL_AURA_MOUNTED); -} - void WorldSession::HandleRequestPetInfoOpcode(WorldPacket & /*recv_data */) { DEBUG_LOG("WORLD: CMSG_REQUEST_PET_INFO"); @@ -1255,14 +1263,6 @@ void WorldSession::HandleRequestPetInfoOpcode(WorldPacket & /*recv_data */) _player->CharmSpellInitialize(); } -void WorldSession::HandleSetTaxiBenchmarkOpcode(WorldPacket & recv_data) -{ - uint8 mode; - recv_data >> mode; - - DEBUG_LOG("Client used \"/timetest %d\" command", mode); -} - void WorldSession::HandleWardenDataOpcode(WorldPacket & recv_data) { if (!m_warden) diff --git a/src/game/Handlers/NPCHandler.cpp b/src/game/Handlers/NPCHandler.cpp index 2086f78db..54a64d6c4 100644 --- a/src/game/Handlers/NPCHandler.cpp +++ b/src/game/Handlers/NPCHandler.cpp @@ -515,11 +515,6 @@ void WorldSession::SendBindPoint(Creature *npc) // send spell for bind 3286 bind magic npc->CastSpell(_player, 3286, true); // Bind - WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, (8 + 4)); - data << npc->GetObjectGuid(); - data << uint32(3286); // Bind - SendPacket(&data); - _player->PlayerTalkClass->CloseGossip(); } diff --git a/src/game/Handlers/PetHandler.cpp b/src/game/Handlers/PetHandler.cpp index 9c70f69b2..ccdf8885c 100644 --- a/src/game/Handlers/PetHandler.cpp +++ b/src/game/Handlers/PetHandler.cpp @@ -727,10 +727,6 @@ void WorldSession::HandlePetCastSpellOpcode(WorldPacket& recvPacket) void WorldSession::SendPetNameInvalid(uint32 error, const std::string& name) { - // [-ZERO] Need check - WorldPacket data(SMSG_PET_NAME_INVALID, 4 + name.size() + 1 + 1); - data << uint32(error); - data << name; - data << uint8(0); // possible not exist in 1.12.* + WorldPacket data(SMSG_PET_NAME_INVALID, 0); SendPacket(&data); } diff --git a/src/game/Handlers/PetitionsHandler.cpp b/src/game/Handlers/PetitionsHandler.cpp index 141890756..8bceee472 100644 --- a/src/game/Handlers/PetitionsHandler.cpp +++ b/src/game/Handlers/PetitionsHandler.cpp @@ -271,7 +271,7 @@ void WorldSession::SendPetitionQueryOpcode(uint32 petitionguid) data << uint32(petitionguid); // petition guid data << ObjectGuid(ownerGuid); // charter owner guid data << name; // name (guild/arena team) - data << uint8(0); // 1 + data << uint8(0); // CString data << uint32(1); data << uint32(9); data << uint32(9); // bypass client - side limitation, a different value is needed here for each petition @@ -279,11 +279,13 @@ void WorldSession::SendPetitionQueryOpcode(uint32 petitionguid) data << uint32(0); // 6 data << uint32(0); // 7 data << uint32(0); // 8 - data << uint16(0); // 9 2 bytes field - data << uint32(0); // 10 + data << uint32(0); // 9 + data << uint16(0); // 10 2 bytes field data << uint32(0); // 11 - data << uint32(0); // 13 count of next strings? - data << uint32(0); // 14 + data << uint32(0); // 12 + data << uint32(0); // 13 count of next strings; if 0, no data for strings, only 1 uint32 below + // for (int i=0; iGetObjectGuid()) + { + WorldPacket data(SMSG_PETITION_SIGN_RESULTS, (8 + 8 + 4)); + data << ObjectGuid(itemGuid); + data << ObjectGuid(_player->GetObjectGuid()); + data << uint32(PETITION_SIGN_CANT_SIGN_OWN); + SendPacket(&data); return; + } + // not let enemies sign guild charter if (!sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_GUILD) && @@ -517,7 +527,7 @@ void WorldSession::HandleOfferPetitionOpcode(WorldPacket & recv_data) signs = (uint8)result->GetRowCount(); /// Send response - WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + signs + signs * 12)); + WorldPacket data(SMSG_PETITION_SHOW_SIGNATURES, (8 + 8 + 4 + 1 + signs * 12)); data << ObjectGuid(itemGuid); // item guid data << ObjectGuid(_player->GetObjectGuid()); // owner guid data << uint32(petitionguid); // petition guid @@ -575,7 +585,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) if (_player->GetGuildId()) { WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4); - data << uint32(PETITION_TURN_ALREADY_IN_GUILD); // already in guild + data << uint32(PETITION_SIGN_ALREADY_IN_GUILD); // already in guild _player->GetSession()->SendPacket(&data); return; } @@ -591,7 +601,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) if (signs < count) { WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4); - data << uint32(PETITION_TURN_NEED_MORE_SIGNATURES); // need more signatures... + data << uint32(PETITION_SIGN_NEED_MORE); // need more signatures... SendPacket(&data); delete result; return; @@ -644,7 +654,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data) DEBUG_LOG("TURN IN PETITION %s", petitionguid); WorldPacket data(SMSG_TURN_IN_PETITION_RESULTS, 4); - data << uint32(PETITION_TURN_OK); + data << uint32(PETITION_SIGN_OK); SendPacket(&data); } @@ -676,21 +686,20 @@ void WorldSession::SendPetitionShowList(ObjectGuid guid) WorldPacket data(SMSG_PETITION_SHOWLIST, 8 + 1 + 4 * 6); data << ObjectGuid(guid); // npc guid - data << count; // count + data << count; // count; allowed values 1-10 data << uint32(1); // index data << uint32(GUILD_CHARTER); // charter entry data << uint32(CHARTER_DISPLAY_ID); // charter display id data << uint32(GUILD_CHARTER_COST); // charter cost data << uint32(1); // unknown - data << uint32(9); // required signs? + //data << uint32(9); // [-ZERO] required signs? //for(uint8 i = 0; i < count; ++i) //{ // data << uint32(i); // index // data << uint32(GUILD_CHARTER); // charter entry // data << uint32(CHARTER_DISPLAY_ID); // charter display id // data << uint32(GUILD_CHARTER_COST+i); // charter cost - // data << uint32(0); // unknown - // data << uint32(9); // required signs? + // data << uint32(1); // unknown //} SendPacket(&data); DEBUG_LOG("Sent SMSG_PETITION_SHOWLIST"); diff --git a/src/game/Handlers/QueryHandler.cpp b/src/game/Handlers/QueryHandler.cpp index e2bab6c28..f5dc974ed 100644 --- a/src/game/Handlers/QueryHandler.cpp +++ b/src/game/Handlers/QueryHandler.cpp @@ -42,10 +42,10 @@ void WorldSession::SendNameQueryOpcode(Player *p) return; // guess size - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 4 + 4 + 4 + 10)); + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 25 + 1 + 4 + 4 + 4)); // guess size data << ObjectGuid(p->GetObjectGuid()); - data << p->GetName(); - data << uint8(0); // realm name for cross realm BG usage + data << p->GetName(); // CString(48): played name + data << uint8(0); // CString(256): realm name for cross realm BG usage data << uint32(p->getRace()); data << uint32(p->getGender()); data << uint32(p->getClass()); @@ -59,10 +59,8 @@ void WorldSession::SendNameQueryOpcodeFromDB(ObjectGuid guid) if (PlayerCacheData* pData = sObjectMgr.GetPlayerDataByGUID(guid.GetCounter())) { std::string name = pData->sName; - if (name == "") - name = GetMangosString(LANG_NON_EXIST_CHARACTER); - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 4 + 4 + 4 + 10)); + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + (name.size() + 1) + 1 + 4 + 4 + 4)); data << ObjectGuid(HIGHGUID_PLAYER, pData->uiGuid); data << name; data << uint8(0); @@ -99,9 +97,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 uint32 lowguid = fields[0].GetUInt32(); std::string name = fields[1].GetCppString(); uint8 pRace = 0, pGender = 0, pClass = 0; - if (name == "") - name = session->GetMangosString(LANG_NON_EXIST_CHARACTER); - else + if (!name.empty()) { pRace = fields[2].GetUInt8(); pGender = fields[3].GetUInt8(); @@ -109,7 +105,7 @@ void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 } // guess size - WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 4 + 4 + 4 + 10)); + WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + (name.size() + 1) + 1 + 4 + 4 + 4)); data << ObjectGuid(HIGHGUID_PLAYER, lowguid); data << name; data << uint8(0); // realm name for cross realm BG usage @@ -238,9 +234,10 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recv_data) data << uint32(info->type); data << uint32(info->displayId); data << Name; - data << uint16(0) << uint8(0) << uint8(0); // name2, name3, name4 - data.append(info->raw.data, 24); - //data << float(info->size); // go size , to check + data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4 + data << uint8(0); // one more name, client handles it a bit differently + data.append(info->raw.data, 24); // these are read as int32 + //data << float(info->size); // [-ZERO] go size: not in Zero SendPacket(&data); DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE"); } diff --git a/src/game/Handlers/QuestHandler.cpp b/src/game/Handlers/QuestHandler.cpp index e3a3d2c08..068c38d4e 100644 --- a/src/game/Handlers/QuestHandler.cpp +++ b/src/game/Handlers/QuestHandler.cpp @@ -514,10 +514,9 @@ void WorldSession::HandleQuestPushResult(WorldPacket& recvPacket) if (Player *pPlayer = ObjectAccessor::FindPlayer(_player->GetDividerGuid())) { - WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 4 + 1)); - data << ObjectGuid(guid); - data << uint32(msg); // valid values: 0-8 - data << uint8(0); + WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 1)); + data << _player->GetObjectGuid(); + data << uint8(msg); // enum QuestShareMessages pPlayer->GetSession()->SendPacket(&data); _player->ClearDividerGuid(); } diff --git a/src/game/Handlers/SpellHandler.cpp b/src/game/Handlers/SpellHandler.cpp index 0dc3260ff..9e7deb8a6 100644 --- a/src/game/Handlers/SpellHandler.cpp +++ b/src/game/Handlers/SpellHandler.cpp @@ -531,23 +531,6 @@ void WorldSession::HandleCancelChanneling(WorldPacket & recv_data) } } -void WorldSession::HandleTotemDestroyed(WorldPacket& recvPacket) -{ - uint8 slotId; - - recvPacket >> slotId; - - // ignore for remote control state - if (!_player->IsSelfMover()) - return; - - if (int(slotId) >= MAX_TOTEM_SLOT) - return; - - if (Totem* totem = GetPlayer()->GetTotem(TotemSlot(slotId))) - totem->UnSummon(); -} - void WorldSession::HandleSelfResOpcode(WorldPacket & /*recv_data*/) { DEBUG_FILTER_LOG(LOG_FILTER_SPELL_CAST, "WORLD: CMSG_SELF_RES"); // empty opcode diff --git a/src/game/Maps/Map.cpp b/src/game/Maps/Map.cpp index 54821bfa6..4fd3220a5 100644 --- a/src/game/Maps/Map.cpp +++ b/src/game/Maps/Map.cpp @@ -1784,7 +1784,7 @@ bool DungeonMap::CanEnter(Player *player) if (!player->isGameMaster() && GetPlayersCountExceptGMs() >= maxPlayers) { DETAIL_LOG("MAP: Instance '%u' of map '%s' cannot have more than '%u' players. Player '%s' rejected", GetInstanceId(), GetMapName(), maxPlayers, player->GetName()); - player->SendTransferAborted(GetId(), TRANSFER_ABORT_MAX_PLAYERS); + player->SendTransferAborted(TRANSFER_ABORT_MAX_PLAYERS); return false; } @@ -1801,7 +1801,7 @@ bool DungeonMap::CanEnter(Player *player) if (GetId() == 249 || GetId() == 531 || GetId() == 533) // Hack : Ustaag : concerne uniquement Onyxia's Lair { - player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); + player->SendTransferAborted(TRANSFER_ABORT_ZONE_IN_COMBAT); return false; } } diff --git a/src/game/Maps/MapManager.cpp b/src/game/Maps/MapManager.cpp index 7c3d17727..12e941956 100644 --- a/src/game/Maps/MapManager.cpp +++ b/src/game/Maps/MapManager.cpp @@ -204,7 +204,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) if (!player->CheckInstanceCount(instanceId)) { DEBUG_LOG("MAP: Player '%s' can't enter instance %u on map %u. Has already entered too many instances.", player->GetName(), instanceId, mapid); - player->SendTransferAborted(mapid, TRANSFER_ABORT_TOO_MANY_INSTANCES, 0); + player->SendTransferAborted(TRANSFER_ABORT_TOO_MANY_INSTANCES); return false; } @@ -212,7 +212,7 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player) /*if(i_data && i_data->IsEncounterInProgress()) { DEBUG_LOG("MAP: Player '%s' can't enter instance '%s' while an encounter is in progress.", player->GetName(), GetMapName()); - player->SendTransferAborted(GetId(), TRANSFER_ABORT_ZONE_IN_COMBAT); + player->SendTransferAborted(TRANSFER_ABORT_ZONE_IN_COMBAT); return(false); }*/ } diff --git a/src/game/Maps/MapPersistentStateMgr.h b/src/game/Maps/MapPersistentStateMgr.h index 0a061da76..b62c7be1e 100644 --- a/src/game/Maps/MapPersistentStateMgr.h +++ b/src/game/Maps/MapPersistentStateMgr.h @@ -250,6 +250,14 @@ enum ResetEventType RESET_EVENT_INFORM_LAST = 4, }; +enum InstanceResetFailReason +{ + INSTANCERESET_FAIL_GENERAL = 0, + INSTANCERESET_FAIL_OFFLINE = 1, + INSTANCERESET_FAIL_ZONING = 2, + INSTANCERESET_FAIL_SILENTLY = 3 // as well as any above this +}; + #define MAX_RESET_EVENT_TYPE 5 /* resetTime is a global propery of each (raid/heroic) map diff --git a/src/game/Objects/GameObject.cpp b/src/game/Objects/GameObject.cpp index 41e71fa9b..16ce04a86 100644 --- a/src/game/Objects/GameObject.cpp +++ b/src/game/Objects/GameObject.cpp @@ -274,7 +274,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) // Play splash sound PlayDistanceSound(3355); - SendGameObjectCustomAnim(GetObjectGuid()); + SendGameObjectCustomAnim(); } m_lootState = GO_READY; // can be successfully open with some chance @@ -333,9 +333,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) m_respawnDelayTime = -1; //spawn animation GetMap()->Add(this); m_respawnDelayTime = 0; - WorldPacket data(SMSG_GAMEOBJECT_RESET_STATE, 8); - data << GetObjectGuid(); - SendObjectMessageToSet(&data,true); + SendGameObjectReset(); } else GetMap()->Add(this); @@ -444,7 +442,7 @@ void GameObject::Update(uint32 update_diff, uint32 /*p_time*/) case 4491: case 6785: case 6747: //sapphiron birth - SendGameObjectCustomAnim(GetObjectGuid()); + SendGameObjectCustomAnim(); break; } } @@ -1430,7 +1428,7 @@ void GameObject::Use(Unit* user) // this appear to be ok, however others exist in addition to this that should have custom (ex: 190510, 188692, 187389) if (time_to_restore && info->goober.customAnim) - SendGameObjectCustomAnim(GetObjectGuid()); + SendGameObjectCustomAnim(); else SetGoState(GO_STATE_ACTIVE); @@ -2222,6 +2220,21 @@ GameObjectData const * GameObject::GetGOData() const return sObjectMgr.GetGOData(GetGUIDLow()); } +void GameObject::SendGameObjectCustomAnim(uint32 animId /*= 0*/) +{ + WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8 + 4); + data << GetObjectGuid(); + data << uint32(animId); + SendMessageToSet(&data, true); +} + +void GameObject::SendGameObjectReset() +{ + WorldPacket data(SMSG_GAMEOBJECT_RESET_STATE, 8); + data << GetObjectGuid(); + SendMessageToSet(&data, true); +} + void GameObject::Despawn() { SendObjectDeSpawnAnim(GetObjectGuid()); diff --git a/src/game/Objects/GameObject.h b/src/game/Objects/GameObject.h index c7271664c..533ceb35a 100644 --- a/src/game/Objects/GameObject.h +++ b/src/game/Objects/GameObject.h @@ -520,7 +520,7 @@ struct GameObjectData }; // For containers: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY -> ... -// For bobber: GO_NOT_READY ->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-> +// For bobber: [GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED-> // For door(closed):[GO_NOT_READY]->GO_READY (close)->GO_ACTIVATED (open) ->GO_JUST_DEACTIVATED->GO_READY(close) -> ... // For door(open): [GO_NOT_READY]->GO_READY (open) ->GO_ACTIVATED (close)->GO_JUST_DEACTIVATED->GO_READY(open) -> ... enum LootState @@ -638,6 +638,9 @@ class MANGOS_DLL_SPEC GameObject : public WorldObject uint32 GetDisplayId() const { return GetUInt32Value(GAMEOBJECT_DISPLAYID); } void SetDisplayId(uint32 modelId); + void SendGameObjectCustomAnim(uint32 animId = 0); + void SendGameObjectReset(); + float GetObjectBoundingRadius() const; // overwrite WorldObject version void Use(Unit* user); diff --git a/src/game/Objects/Object.cpp b/src/game/Objects/Object.cpp index 2d13cc559..f7b775a38 100644 --- a/src/game/Objects/Object.cpp +++ b/src/game/Objects/Object.cpp @@ -2006,14 +2006,6 @@ void WorldObject::SendObjectDeSpawnAnim(ObjectGuid guid) SendObjectMessageToSet(&data, true); } -void WorldObject::SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId /*= 0*/) -{ - WorldPacket data(SMSG_GAMEOBJECT_CUSTOM_ANIM, 8 + 4); - data << ObjectGuid(guid); - data << uint32(animId); - SendObjectMessageToSet(&data, true); -} - bool WorldObject::isWithinVisibilityDistanceOf(Unit const* viewer, WorldObject const* viewPoint, bool inVisibleList) const { if (viewer->IsTaxiFlying()) diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index bfffb23b5..9abaedc54 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -839,7 +839,6 @@ m_obj->m_updateTracker.Reset(); void PlayDirectMusic(uint32 music_id, Player* target = nullptr); void SendObjectDeSpawnAnim(ObjectGuid guid); - void SendGameObjectCustomAnim(ObjectGuid guid, uint32 animId = 0); virtual bool IsHostileTo(Unit const* unit) const =0; virtual bool IsFriendlyTo(Unit const* unit) const =0; diff --git a/src/game/Objects/Pet.h b/src/game/Objects/Pet.h index bb690af18..0ba759aef 100644 --- a/src/game/Objects/Pet.h +++ b/src/game/Objects/Pet.h @@ -90,10 +90,11 @@ struct PetSpell enum ActionFeedback { - FEEDBACK_NONE = 0, + FEEDBACK_PET_NONE = 0, // custom, not to be sent FEEDBACK_PET_DEAD = 1, FEEDBACK_NOTHING_TO_ATT = 2, - FEEDBACK_CANT_ATT_TARGET = 3 + FEEDBACK_CANT_ATT_TARGET = 3, + FEEDBACK_NO_PATH_TO = 4 }; enum PetTalk diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 4142f4bc1..dc407a191 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -11251,26 +11251,34 @@ void Player::SendEquipError(InventoryResult msg, Item* pItem, Item *pItem2, uint GetSession()->SendPacket(&data); } -void Player::SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 param) +void Player::SendOpenContainer() +{ + DEBUG_LOG("WORLD: Sent SMSG_OPEN_CONTAINER"); + WorldPacket data(SMSG_OPEN_CONTAINER, 8); // opens the main bag in the UI + data << GetObjectGuid(); + GetSession()->SendPacket(&data); +} + +void Player::SendBuyError(BuyResult msg, Creature* pCreature, uint32 item, uint32 /*param*/) { DEBUG_LOG("WORLD: Sent SMSG_BUY_FAILED"); - WorldPacket data(SMSG_BUY_FAILED, (8 + 4 + 4 + 1)); + WorldPacket data(SMSG_BUY_FAILED, (8 + 4 + 1)); data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << uint32(item); - if (param > 0) - data << uint32(param); + //if (param > 0) + // data << uint32(param); // [-ZERO] data << uint8(msg); GetSession()->SendPacket(&data); } -void Player::SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param) +void Player::SendSellError(SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 /*param*/) { DEBUG_LOG("WORLD: Sent SMSG_SELL_ITEM"); - WorldPacket data(SMSG_SELL_ITEM, (8 + 8 + (param ? 4 : 0) + 1)); // last check 2.0.10 + WorldPacket data(SMSG_SELL_ITEM, (8 + 8 + /*(param ? 4 : 0) +*/ 1)); // last check [ZERO] data << (pCreature ? pCreature->GetObjectGuid() : ObjectGuid()); data << ObjectGuid(itemGuid); - if (param > 0) - data << uint32(param); + //if (param > 0) + // data << uint32(param); // [-ZERO] data << uint8(msg); GetSession()->SendPacket(&data); } @@ -11608,7 +11616,7 @@ void Player::SendNewItem(Item *item, uint32 count, bool received, bool created, data << uint32(item->GetItemSuffixFactor()); // SuffixFactor data << uint32(item->GetItemRandomPropertyId()); // random item property id data << uint32(count); // count of items - data << uint32(GetItemCount(item->GetEntry())); // count of items in inventory + //data << uint32(GetItemCount(item->GetEntry())); // [-ZERO] count of items in inventory if (broadcast && GetGroup()) GetGroup()->BroadcastPacket(&data, true); @@ -13188,28 +13196,43 @@ bool Player::CanGiveQuestSourceItemIfNeed(Quest const *pQuest, ItemPosCountVec* { if (uint32 srcitem = pQuest->GetSrcItemId()) { - uint32 count = pQuest->GetSrcItemCount(); - - // player already have max amount required item (including bank), just report success - uint32 has_count = GetItemCount(srcitem, true); - if (has_count >= count) - return true; - - count -= has_count; // real need amount - - InventoryResult msg; - if (!dest) + + if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(srcitem)) { - ItemPosCountVec destTemp; - msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, destTemp, srcitem, count); - } - else - msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, *dest, srcitem, count); + uint32 count = pQuest->GetSrcItemCount(); + uint32 has_count = GetItemCount(srcitem, true); + + if (pProto->MaxCount && pProto->StartQuest != pQuest->GetQuestId() && (has_count >= pProto->MaxCount)) + { + // player already have max amount of source item (including bank) + SendQuestFailedAtTaker(pQuest->GetQuestId(), INVALIDREASON_QUEST_FAILED_DUPLICATE_ITEM); + return false; + } + + count -= has_count; // real need amount + + InventoryResult msg; + if (!dest) + { + ItemPosCountVec destTemp; + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, destTemp, srcitem, count); + } + else + msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, *dest, srcitem, count); + + if (msg == EQUIP_ERR_OK) + return true; + else + { + if (msg == EQUIP_ERR_INVENTORY_FULL) + SendQuestFailedAtTaker(pQuest->GetQuestId(), INVALIDREASON_QUEST_FAILED_INVENTORY_FULL); + else if (msg == EQUIP_ERR_CANT_CARRY_MORE_OF_THIS) + SendQuestFailedAtTaker(pQuest->GetQuestId(), INVALIDREASON_QUEST_FAILED_DUPLICATE_ITEM); + else + SendEquipError(msg, NULL, NULL, srcitem); + } + } - if (msg == EQUIP_ERR_OK) - return true; - else - SendEquipError(msg, NULL, NULL, srcitem); return false; } @@ -13902,14 +13925,29 @@ void Player::SendQuestReward(Quest const *pQuest, uint32 XP, Object * questGiver GetSession()->SendPacket(&data); } +/// Sent when a quest is failed to be given off at questtaker. Specifically handled reasons: +/// INVALIDREASON_QUEST_FAILED_INVENTORY_FULL=4 (or 50) +/// INVALIDREASON_QUEST_FAILED_DUPLICATE_ITEM=17 +void Player::SendQuestFailedAtTaker(uint32 quest_id, uint32 reason) const +{ + if (quest_id) + { + WorldPacket data(SMSG_QUESTGIVER_QUEST_FAILED, 8); + data << uint32(quest_id); + data << uint32(reason); + GetSession()->SendPacket(&data); + DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_FAILED"); + } +} + void Player::SendQuestFailed(uint32 quest_id) { if (quest_id) { - WorldPacket data(SMSG_QUESTGIVER_QUEST_FAILED, 4); + WorldPacket data(SMSG_QUESTUPDATE_FAILED, 4); data << quest_id; GetSession()->SendPacket(&data); - DEBUG_LOG("WORLD: Sent SMSG_QUESTGIVER_QUEST_FAILED"); + DEBUG_LOG("WORLD: Sent SMSG_QUESTUPDATE_FAILED"); } } @@ -13959,14 +13997,13 @@ void Player::SendQuestConfirmAccept(const Quest* pQuest, Player* pReceiver) } } -void Player::SendPushToPartyResponse(Player *pPlayer, uint32 msg) +void Player::SendPushToPartyResponse(Player *pPlayer, uint8 msg) { if (pPlayer) { - WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 4 + 1)); + WorldPacket data(MSG_QUEST_PUSH_RESULT, (8 + 1)); data << pPlayer->GetObjectGuid(); - data << uint32(msg); // valid values: 0-8 - data << uint8(0); + data << uint8(msg); // enum QuestShareMessages GetSession()->SendPacket(&data); DEBUG_LOG("WORLD: Sent MSG_QUEST_PUSH_RESULT"); } @@ -15434,7 +15471,7 @@ void Player::SendSavedInstances() } //Send opcode 811. true or false means, whether you have current raid instances - data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP); + data.Initialize(SMSG_UPDATE_INSTANCE_OWNERSHIP, 4); data << uint32(hasBeenSaved); GetSession()->SendPacket(&data); @@ -15445,7 +15482,7 @@ void Player::SendSavedInstances() { if (itr->second.perm) { - data.Initialize(SMSG_UPDATE_LAST_INSTANCE); + data.Initialize(SMSG_UPDATE_LAST_INSTANCE, 4); data << uint32(itr->second.state->GetMapId()); GetSession()->SendPacket(&data); } @@ -16314,8 +16351,8 @@ void Player::SendResetInstanceSuccess(uint32 MapId) void Player::SendResetInstanceFailed(uint32 reason, uint32 MapId) { - // TODO: find what other fail reasons there are besides players in the instance - WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 4); + // reason: see enum InstanceResetFailReason + WorldPacket data(SMSG_INSTANCE_RESET_FAILED, 8); data << uint32(reason); data << uint32(MapId); GetSession()->SendPacket(&data); @@ -17121,6 +17158,71 @@ void Player::ContinueTaxiFlight() GetSession()->SendDoFlight(mountDisplayId, path, startNode); } +void Player::Mount(uint32 mount, uint32 spellId) +{ + if (!mount) + { + SendMountResult(MOUNTRESULT_NOTMOUNTABLE); + return; + } + + Unit::Mount(mount, spellId); + + // Called by Taxi system / GM command + if (!spellId) + UnsummonPetTemporaryIfAny(); + // Called by mount aura + else + { + // Normal case (Unsummon only permanent pet) + if (Pet* pet = GetPet()) + { + if (pet->IsPermanentPetFor((Player*)this) && + sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT)) + UnsummonPetTemporaryIfAny(); + else + pet->SetEnabled(false); + } + } + + SendMountResult(MOUNTRESULT_OK); +} + +void Player::Unmount(bool from_aura) +{ + if (!IsMounted()) + { + SendDismountResult(DISMOUNTRESULT_NOTMOUNTED); + return; + } + + Unit::Unmount(from_aura); + + // only resummon old pet if the player is already added to a map + // this prevents adding a pet to a not created map which would otherwise cause a crash + // (it could probably happen when logging in after a previous crash) + if (Pet* pet = GetPet()) + pet->SetEnabled(true); + else + ResummonPetTemporaryUnSummonedIfAny(); + + SendDismountResult(DISMOUNTRESULT_OK); +} + +void Player::SendMountResult(PlayerMountResult result) +{ + WorldPacket data(SMSG_MOUNTRESULT, 4); + data << uint32(result); + GetSession()->SendPacket(&data); +} + +void Player::SendDismountResult(PlayerDismountResult result) +{ + WorldPacket data(SMSG_DISMOUNTRESULT, 4); + data << uint32(result); + GetSession()->SendPacket(&data); +} + void Player::InitDataForForm(bool reapplyMods) { ShapeshiftForm form = GetShapeshiftForm(); @@ -17333,7 +17435,7 @@ void Player::UpdateHomebindTime(uint32 time) // hide reminder WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(0); - data << uint32(ERR_RAID_GROUP_NONE); // error used only when timer = 0 + data << uint32(ERR_RAID_GROUP_REQUIRED); // error used only when timer = 0 GetSession()->SendPacket(&data); } // instance is valid, reset homebind timer @@ -17356,7 +17458,7 @@ void Player::UpdateHomebindTime(uint32 time) // send message to player WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(m_HomebindTimer); - data << uint32(ERR_RAID_GROUP_NONE); // error used only when timer = 0 + data << uint32(ERR_RAID_GROUP_REQUIRED); // error used only when timer = 0 GetSession()->SendPacket(&data); DEBUG_LOG("PLAYER: Player '%s' (GUID: %u) will be teleported to homebind in 60 seconds", GetName(), GetGUIDLow()); } @@ -17739,7 +17841,7 @@ void Player::SetGroup(Group *group, int8 subgroup) void Player::SendInitialPacketsBeforeAddToMap() { WorldPacket data(SMSG_SET_REST_START, 4); - data << uint32(0); // unknown, may be rest state time or experience + data << uint32(0); // rest state time GetSession()->SendPacket(&data); // Homebind @@ -17833,12 +17935,10 @@ void Player::SendUpdateToOutOfRangeGroupMembers() pet->ResetAuraUpdateMask(); } -void Player::SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg) +void Player::SendTransferAborted(uint8 reason) { - WorldPacket data(SMSG_TRANSFER_ABORTED, 4 + 2); - data << uint32(mapid); + WorldPacket data(SMSG_TRANSFER_ABORTED, 1); data << uint8(reason); // transfer abort reason - data << uint8(0); // arg. not used GetSession()->SendPacket(&data); } diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index f2abea412..0464a5415 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -309,11 +309,8 @@ typedef std::list ItemDurationList; enum RaidGroupError { - ERR_RAID_GROUP_NONE = 0, - ERR_RAID_GROUP_LOWLEVEL = 1, - ERR_RAID_GROUP_ONLY = 2, - ERR_RAID_GROUP_FULL = 3, - ERR_RAID_GROUP_REQUIREMENTS_UNMATCH = 4 + ERR_RAID_GROUP_REQUIRED = 1, + ERR_RAID_GROUP_FULL = 2 }; enum DrunkenState @@ -546,13 +543,12 @@ enum TradeSlots TRADE_SLOT_INVALID = -1 }; -// [-ZERO] Need fix, or maybe not exists enum TransferAbortReason { - TRANSFER_ABORT_NONE = 0x00, TRANSFER_ABORT_MAX_PLAYERS = 0x01, // Transfer Aborted: instance is full TRANSFER_ABORT_NOT_FOUND = 0x02, // Transfer Aborted: instance not found TRANSFER_ABORT_TOO_MANY_INSTANCES = 0x03, // You have entered too many instances recently. + TRANSFER_ABORT_SILENTLY = 0x04, // no message shown; the same effect give values above 5 TRANSFER_ABORT_ZONE_IN_COMBAT = 0x05, // Unable to zone in while an encounter is in progress. }; @@ -634,6 +630,29 @@ enum PlayerDelayedOperations DELAYED_END }; +enum PlayerMountResult +{ + MOUNTRESULT_INVALIDMOUNTEE = 0, // You can't mount that unit! + MOUNTRESULT_TOOFARAWAY = 1, // That mount is too far away! + MOUNTRESULT_ALREADYMOUNTED = 2, // You're already mounted! + MOUNTRESULT_NOTMOUNTABLE = 3, // That unit can't be mounted! + MOUNTRESULT_NOTYOURPET = 4, // That mount isn't your pet! + MOUNTRESULT_OTHER = 5, // internal + MOUNTRESULT_LOOTING = 6, // You can't mount while looting! + MOUNTRESULT_RACECANTMOUNT = 7, // You can't mount because of your race! + MOUNTRESULT_SHAPESHIFTED = 8, // You can't mount while shapeshifted! + MOUNTRESULT_FORCEDDISMOUNT = 9, // You dismount before continuing. + MOUNTRESULT_OK = 10 // no error +}; + +enum PlayerDismountResult +{ + DISMOUNTRESULT_NOPET = 0, // internal + DISMOUNTRESULT_NOTMOUNTED = 1, // You're not mounted! + DISMOUNTRESULT_NOTYOURPET = 2, // internal + DISMOUNTRESULT_OK = 3 // no error +}; + enum ReputationSource { REPUTATION_SOURCE_KILL, @@ -901,7 +920,7 @@ class MANGOS_DLL_SPEC Player final: public Unit void SendInitialPacketsBeforeAddToMap(); void SendInitialPacketsAfterAddToMap(bool login = true); - void SendTransferAborted(uint32 mapid, uint8 reason, uint8 arg = 0); + void SendTransferAborted(uint8 reason); void SendInstanceResetWarning(uint32 mapid, uint32 time); Creature* GetNPCIfCanInteractWith(ObjectGuid guid, uint32 npcflagmask); @@ -933,6 +952,10 @@ class MANGOS_DLL_SPEC Player final: public Unit // mount_id can be used in scripting calls void TaxiStepFinished(); void ContinueTaxiFlight(); + void Mount(uint32 mount, uint32 spellId = 0) override; + void Unmount(bool from_aura = false) override; + void SendMountResult(PlayerMountResult result); + void SendDismountResult(PlayerDismountResult result); bool isAcceptTickets() const { return GetSession()->GetSecurity() >= SEC_GAMEMASTER && (m_ExtraFlags & PLAYER_EXTRA_GM_ACCEPT_TICKETS); } void SetAcceptTicket(bool on) { if(on) m_ExtraFlags |= PLAYER_EXTRA_GM_ACCEPT_TICKETS; else m_ExtraFlags &= ~PLAYER_EXTRA_GM_ACCEPT_TICKETS; } @@ -1141,6 +1164,7 @@ class MANGOS_DLL_SPEC Player final: public Unit void SendEquipError( InventoryResult msg, Item* pItem, Item *pItem2 = NULL, uint32 itemid = 0 ) const; void SendBuyError( BuyResult msg, Creature* pCreature, uint32 item, uint32 param ); void SendSellError( SellResult msg, Creature* pCreature, ObjectGuid itemGuid, uint32 param ); + void SendOpenContainer(); void AddWeaponProficiency(uint32 newflag) { m_WeaponProficiency |= newflag; } void AddArmorProficiency(uint32 newflag) { m_ArmorProficiency |= newflag; } uint32 GetWeaponProficiency() const { return m_WeaponProficiency; } @@ -1289,10 +1313,11 @@ class MANGOS_DLL_SPEC Player final: public Unit void SendQuestCompleteEvent(uint32 quest_id); void SendQuestReward( Quest const *pQuest, uint32 XP, Object* questGiver ); void SendQuestFailed( uint32 quest_id); + void SendQuestFailedAtTaker(uint32 quest_id, uint32 reason = INVALIDREASON_DONT_HAVE_REQ) const; void SendQuestTimerFailed( uint32 quest_id ); void SendCanTakeQuestResponse( uint32 msg ) const; void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver); - void SendPushToPartyResponse( Player *pPlayer, uint32 msg ); + void SendPushToPartyResponse( Player *pPlayer, uint8 msg ); void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count ); void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count); diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index a9ad09021..e3e960a03 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -2747,7 +2747,7 @@ void Unit::SendMeleeAttackStop(Unit* victim) if (!victim) return; - WorldPacket data(SMSG_ATTACKSTOP, (4 + 16)); // we guess size + WorldPacket data(SMSG_ATTACKSTOP, (8 + 8 + 4)); // guess size, max is 9+9+4 data << GetPackGUID(); data << victim->GetPackGUID(); // can be 0x00... data << uint32(0); // can be 0x1 @@ -6241,7 +6241,7 @@ void Unit::SendHealSpellLog(Unit *pVictim, uint32 SpellID, uint32 Damage, bool c data << uint32(SpellID); data << uint32(Damage); data << uint8(critical ? 1 : 0); - data << uint8(0); // unused in client? + // data << uint8(0); // [-ZERO] SendMessageToSet(&data, true); } @@ -7237,26 +7237,6 @@ void Unit::Mount(uint32 mount, uint32 spellId) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_MOUNTING); SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, mount); - - if (GetTypeId() == TYPEID_PLAYER) - { - // Called by Taxi system / GM command - if (!spellId) - ((Player*)this)->UnsummonPetTemporaryIfAny(); - // Called by mount aura - else - { - // Normal case (Unsummon only permanent pet) - if (Pet* pet = GetPet()) - { - if (pet->IsPermanentPetFor((Player*)this) && - sWorld.getConfig(CONFIG_BOOL_PET_UNSUMMON_AT_MOUNT)) - ((Player*)this)->UnsummonPetTemporaryIfAny(); - else - pet->SetEnabled(false); - } - } - } } void Unit::Unmount(bool from_aura) @@ -7267,17 +7247,6 @@ void Unit::Unmount(bool from_aura) RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_MOUNTED); SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 0); - - // only resummon old pet if the player is already added to a map - // this prevents adding a pet to a not created map which would otherwise cause a crash - // (it could probably happen when logging in after a previous crash) - if (GetTypeId() == TYPEID_PLAYER) - { - if (Pet* pet = GetPet()) - pet->SetEnabled(true); - else - ((Player*)this)->ResummonPetTemporaryUnSummonedIfAny(); - } } void Unit::SetInCombatWith(Unit* enemy) @@ -9506,7 +9475,7 @@ void Unit::SendPetCastFail(uint32 spellid, SpellCastResult msg) WorldPacket data(SMSG_PET_CAST_FAILED, 4 + 1 + 1); data << uint32(spellid); - data << uint8(2); // 1.12: comme SMSG_CAST_FAILED je suppose. 2 = echec, 0 = reussi. + data << uint8(2); // 1.12: comme SMSG_CAST_RESULT je suppose. 2 = echec, 0 = reussi. data << uint8(msg); ((Player*)owner)->GetSession()->SendPacket(&data); } diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 6fffbc4ae..66487ea1c 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -531,7 +531,7 @@ enum NPCFlags { UNIT_NPC_FLAG_NONE = 0x00000000, UNIT_NPC_FLAG_GOSSIP = 0x00000001, // 100% - UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // guessed, probably ok + UNIT_NPC_FLAG_QUESTGIVER = 0x00000002, // 100% UNIT_NPC_FLAG_VENDOR = 0x00000004, // 100% UNIT_NPC_FLAG_FLIGHTMASTER = 0x00000008, // 100% UNIT_NPC_FLAG_TRAINER = 0x00000010, // 100% @@ -1163,8 +1163,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsMounted() const { return (GetMountID() != 0); } uint32 GetMountID() const { return GetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID); } - void Mount(uint32 mount, uint32 spellId = 0); - void Unmount(bool from_aura = false); + virtual void Mount(uint32 mount, uint32 spellId = 0); + virtual void Unmount(bool from_aura = false); // Tuer cette unite. void DoKillUnit(Unit *victim = nullptr); diff --git a/src/game/Protocol/Opcodes.cpp b/src/game/Protocol/Opcodes.cpp index 939bcb6e2..6a3844f43 100644 --- a/src/game/Protocol/Opcodes.cpp +++ b/src/game/Protocol/Opcodes.cpp @@ -278,7 +278,7 @@ void Opcodes::BuildOpcodeList() /*0x0DE*/ StoreOpcode(SMSG_MOVE_WATER_WALK, "SMSG_MOVE_WATER_WALK", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0DF*/ StoreOpcode(SMSG_MOVE_LAND_WALK, "SMSG_MOVE_LAND_WALK", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0E0*/ StoreOpcode(MSG_MOVE_SET_RAW_POSITION_ACK, "MSG_MOVE_SET_RAW_POSITION_ACK", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); - /*0x0E1*/ StoreOpcode(CMSG_MOVE_SET_RAW_POSITION, "CMSG_MOVE_SET_RAW_POSITION", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); + /*0x0E1*/ StoreOpcode(CMSG_MOVE_SET_RAW_POSITION, "CMSG_MOVE_SET_RAW_POSITION", STATUS_LOGGEDIN, PACKET_PROCESS_MAP, &WorldSession::HandleMoveSetRawPosition); /*0x0E2*/ StoreOpcode(SMSG_FORCE_RUN_SPEED_CHANGE, "SMSG_FORCE_RUN_SPEED_CHANGE", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0E3*/ StoreOpcode(CMSG_FORCE_RUN_SPEED_CHANGE_ACK, "CMSG_FORCE_RUN_SPEED_CHANGE_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleForceSpeedChangeAckOpcodes); /*0x0E4*/ StoreOpcode(SMSG_FORCE_RUN_BACK_SPEED_CHANGE, "SMSG_FORCE_RUN_BACK_SPEED_CHANGE", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); @@ -357,7 +357,7 @@ void Opcodes::BuildOpcodeList() /*0x12D*/ StoreOpcode(CMSG_NEW_SPELL_SLOT, "CMSG_NEW_SPELL_SLOT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); /*0x12E*/ StoreOpcode(CMSG_CAST_SPELL, "CMSG_CAST_SPELL", STATUS_LOGGEDIN, PACKET_PROCESS_SPELLS, &WorldSession::HandleCastSpellOpcode); /*0x12F*/ StoreOpcode(CMSG_CANCEL_CAST, "CMSG_CANCEL_CAST", STATUS_LOGGEDIN, PACKET_PROCESS_SPELLS, &WorldSession::HandleCancelCastOpcode); - /*0x130*/ StoreOpcode(SMSG_CAST_FAILED, "SMSG_CAST_FAILED", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); + /*0x130*/ StoreOpcode(SMSG_CAST_RESULT, "SMSG_CAST_RESULT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x131*/ StoreOpcode(SMSG_SPELL_START, "SMSG_SPELL_START", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x132*/ StoreOpcode(SMSG_SPELL_GO, "SMSG_SPELL_GO", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x133*/ StoreOpcode(SMSG_SPELL_FAILURE, "SMSG_SPELL_FAILURE", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); diff --git a/src/game/Protocol/Opcodes.h b/src/game/Protocol/Opcodes.h index 9ec48c589..f79a2d4dd 100644 --- a/src/game/Protocol/Opcodes.h +++ b/src/game/Protocol/Opcodes.h @@ -341,7 +341,7 @@ enum OpcodesList CMSG_NEW_SPELL_SLOT = 0x12D, CMSG_CAST_SPELL = 0x12E, CMSG_CANCEL_CAST = 0x12F, - SMSG_CAST_FAILED = 0x130, + SMSG_CAST_RESULT = 0x130, SMSG_SPELL_START = 0x131, SMSG_SPELL_GO = 0x132, SMSG_SPELL_FAILURE = 0x133, diff --git a/src/game/QuestDef.h b/src/game/QuestDef.h index fbbd8923c..eea2b443f 100644 --- a/src/game/QuestDef.h +++ b/src/game/QuestDef.h @@ -43,19 +43,19 @@ class ObjectMgr; #define QUEST_REPUTATIONS_COUNT 5 #define QUEST_EMOTE_COUNT 4 -// [-ZERO] need update enum QuestFailedReasons { - INVALIDREASON_DONT_HAVE_REQ = 0, - INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1, //You are not high enough level for that quest. - INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6, //That quest is not available to your race. - INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12, //You can only be on one timed quest at a time. - INVALIDREASON_QUEST_ALREADY_ON = 13, //You are already on that quest - INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 21, //You don't have the required items with you. Check storage. - INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 23, //You don't have enough money for that quest. - //[-ZERO] tbc enumerations [?] - INVALIDREASON_QUEST_ALREADY_ON2 = 18, //You are already on that quest - INVALIDREASON_QUEST_ALREADY_DONE = 7, //You have completed that quest. + INVALIDREASON_DONT_HAVE_REQ = 0, // this is default case + INVALIDREASON_QUEST_FAILED_LOW_LEVEL = 1, // You are not high enough level for that quest. + INVALIDREASON_QUEST_FAILED_REQS = 2, // You don't meet the requirements for that quest. + INVALIDREASON_QUEST_FAILED_INVENTORY_FULL = 4, // Inventory is full. (Also 50. From SMSG_QUESTGIVER_QUEST_FAILED) + INVALIDREASON_QUEST_FAILED_WRONG_RACE = 6, // That quest is not available to your race. + INVALIDREASON_QUEST_ONLY_ONE_TIMED = 12, // You can only be on one timed quest at a time. + INVALIDREASON_QUEST_ALREADY_ON = 13, // You are already on that quest + INVALIDREASON_QUEST_FAILED_DUPLICATE_ITEM = 17, // Duplicate item found. (From SMSG_QUESTGIVER_QUEST_FAILED) + INVALIDREASON_QUEST_FAILED_MISSING_ITEMS = 20, // You don't have the required items with you. Check storage. + INVALIDREASON_QUEST_FAILED_NOT_ENOUGH_MONEY = 22 // You don't have enough money for that quest. + // INVALIDREASON_QUEST_FAILED_REQS = 3,4,5,7-11,14-19,21 }; enum QuestShareMessages diff --git a/src/game/ReputationMgr.cpp b/src/game/ReputationMgr.cpp index 6c33591e5..b842b6aae 100644 --- a/src/game/ReputationMgr.cpp +++ b/src/game/ReputationMgr.cpp @@ -348,7 +348,12 @@ void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) else faction->Flags &= ~FACTION_FLAG_AT_WAR; - faction->needSend = true; + WorldPacket data(SMSG_SET_FACTION_ATWAR, 4 + 1); + data << uint32(faction->ID); + data << uint8(faction->Flags & FACTION_FLAG_AT_WAR); // the client tests only FACTION_FLAG_AT_WAR + m_player->SendDirectMessage(&data); + + faction->needSend = false; faction->needSave = true; } diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h index 6eb1ce031..976dc0cce 100644 --- a/src/game/SharedDefines.h +++ b/src/game/SharedDefines.h @@ -2242,7 +2242,6 @@ enum ResponseCodes AUTH_DB_BUSY = 0x1F, AUTH_SUSPENDED = 0x20, AUTH_PARENTAL_CONTROL = 0x21, - AUTH_LOCKED_ENFORCED = 0x02, /// Unsure REALM_LIST_IN_PROGRESS = 0x22, REALM_LIST_SUCCESS = 0x23, @@ -2263,47 +2262,42 @@ enum ResponseCodes CHAR_CREATE_ERROR = 0x2F, CHAR_CREATE_FAILED = 0x30, CHAR_CREATE_NAME_IN_USE = 0x31, - CHAR_CREATE_DISABLED = 0x3A, + CHAR_CREATE_DISABLED = 0x32, CHAR_CREATE_PVP_TEAMS_VIOLATION = 0x33, CHAR_CREATE_SERVER_LIMIT = 0x34, CHAR_CREATE_ACCOUNT_LIMIT = 0x35, - CHAR_CREATE_SERVER_QUEUE = 0x30,/// UNSURE - CHAR_CREATE_ONLY_EXISTING = 0x30,/// UNSURE + CHAR_CREATE_SERVER_QUEUE = 0x36, + CHAR_CREATE_ONLY_EXISTING = 0x37, CHAR_DELETE_IN_PROGRESS = 0x38, CHAR_DELETE_SUCCESS = 0x39, CHAR_DELETE_FAILED = 0x3A, - CHAR_DELETE_FAILED_LOCKED_FOR_TRANSFER = 0x3A,/// UNSURE - CHAR_DELETE_FAILED_GUILD_LEADER = 0x3A,/// UNSURE + CHAR_DELETE_FAILED_LOCKED_FOR_TRANSFER = 0x3B, - CHAR_LOGIN_IN_PROGRESS = 0x3B, - CHAR_LOGIN_SUCCESS = 0x3C, - CHAR_LOGIN_NO_WORLD = 0x3D, - CHAR_LOGIN_DUPLICATE_CHARACTER = 0x3E, - CHAR_LOGIN_NO_INSTANCES = 0x3F, - CHAR_LOGIN_FAILED = 0x40, - CHAR_LOGIN_DISABLED = 0x41, - CHAR_LOGIN_NO_CHARACTER = 0x42, - CHAR_LOGIN_LOCKED_FOR_TRANSFER = 0x40, ///UNSURE - CHAR_LOGIN_LOCKED_BY_BILLING = 0x40, ///UNSURE + CHAR_LOGIN_IN_PROGRESS = 0x3C, + CHAR_LOGIN_SUCCESS = 0x3D, + CHAR_LOGIN_NO_WORLD = 0x3E, + CHAR_LOGIN_DUPLICATE_CHARACTER = 0x3F, + CHAR_LOGIN_NO_INSTANCES = 0x40, + CHAR_LOGIN_FAILED = 0x41, + CHAR_LOGIN_DISABLED = 0x42, + CHAR_LOGIN_NO_CHARACTER = 0x43, + CHAR_LOGIN_LOCKED_FOR_TRANSFER = 0x44, - CHAR_NAME_SUCCESS = 0x50, - CHAR_NAME_FAILURE = 0x4F, - CHAR_NAME_NO_NAME = 0x43, - CHAR_NAME_TOO_SHORT = 0x44, - CHAR_NAME_TOO_LONG = 0x45, - CHAR_NAME_INVALID_CHARACTER = 0x46, - CHAR_NAME_MIXED_LANGUAGES = 0x47, - CHAR_NAME_PROFANE = 0x48, - CHAR_NAME_RESERVED = 0x49, - CHAR_NAME_INVALID_APOSTROPHE = 0x4A, - CHAR_NAME_MULTIPLE_APOSTROPHES = 0x4B, - CHAR_NAME_THREE_CONSECUTIVE = 0x4C, - CHAR_NAME_INVALID_SPACE = 0x4D, - CHAR_NAME_CONSECUTIVE_SPACES = 0x4E, - CHAR_NAME_RUSSIAN_CONSECUTIVE_SILENT_CHARACTERS = 0x4E,///UNSURE - CHAR_NAME_RUSSIAN_SILENT_CHARACTER_AT_BEGINNING_OR_END = 0x4E,///UNSURE - CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 0x4E,///UNSURE + CHAR_NAME_NO_NAME = 0x45, + CHAR_NAME_TOO_SHORT = 0x46, + CHAR_NAME_TOO_LONG = 0x47, + CHAR_NAME_INVALID_CHARACTER = 0x48, + CHAR_NAME_MIXED_LANGUAGES = 0x49, + CHAR_NAME_PROFANE = 0x4A, + CHAR_NAME_RESERVED = 0x4B, + CHAR_NAME_INVALID_APOSTROPHE = 0x4C, + CHAR_NAME_MULTIPLE_APOSTROPHES = 0x4D, + CHAR_NAME_THREE_CONSECUTIVE = 0x4E, + CHAR_NAME_INVALID_SPACE = 0x4F, + CHAR_NAME_CONSECUTIVE_SPACES = 0x50, + CHAR_NAME_FAILURE = 0x51, + CHAR_NAME_SUCCESS = 0x52, }; /// Ban function modes @@ -2426,11 +2420,11 @@ enum TradeStatus TRADE_STATUS_NO_TARGET = 6, TRADE_STATUS_BACK_TO_TRADE = 7, TRADE_STATUS_TRADE_COMPLETE = 8, - // 9? + TRADE_STATUS_TRADE_REJECTED = 9, TRADE_STATUS_TARGET_TO_FAR = 10, TRADE_STATUS_WRONG_FACTION = 11, TRADE_STATUS_CLOSE_WINDOW = 12, - // 13? + TRADE_STATUS_UNKNOWN_13 = 13, // handled with TRADE_STATUS_TRADE_CANCELED TRADE_STATUS_IGNORE_YOU = 14, TRADE_STATUS_YOU_STUNNED = 15, TRADE_STATUS_TARGET_STUNNED = 16, diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 6b50098eb..c7f188dc2 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -4154,7 +4154,7 @@ void Spell::SendCastResult(SpellCastResult result) void Spell::SendCastResult(Player* caster, SpellEntry const* spellInfo, SpellCastResult result) { - WorldPacket data(SMSG_CAST_FAILED, (4 + 1 + 1)); + WorldPacket data(SMSG_CAST_RESULT, (4 + 1 + 1)); data << uint32(spellInfo->Id); if (result != SPELL_CAST_OK) diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index 5d7f9c314..e42bbdadd 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -6161,7 +6161,7 @@ void Spell::EffectBind(SpellEffectIndex eff_idx) // zone update data.Initialize(SMSG_PLAYERBOUND, 8 + 4); - data << player->GetObjectGuid(); + data << m_caster->GetObjectGuid(); data << uint32(area_id); player->SendDirectMessage(&data); } diff --git a/src/game/World.cpp b/src/game/World.cpp index b5bafa201..55bdfc1c8 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -2660,6 +2660,13 @@ bool World::configNoReload(bool reload, eConfigBoolValues index, char const* fie return false; } +void World::InvalidatePlayerDataToAllClient(ObjectGuid guid) +{ + WorldPacket data(SMSG_INVALIDATE_PLAYER, 8); + data << guid; + SendGlobalMessage(&data); +} + void World::SetSessionDisconnected(WorldSession* sess) { SessionMap::iterator itr = m_sessions.find(sess->GetAccountId()); diff --git a/src/game/World.h b/src/game/World.h index aa6a19102..9608faf24 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -779,6 +779,18 @@ class World }; uint32 InsertLog(std::string const& message, AccountTypes sec); ArchivedLogMessage* GetLog(uint32 logId, AccountTypes my_sec); + + /** + * \brief: force all client to request player data + * \param: ObjectGuid guid : guid of the specified player + * \returns: void + * + * Description: InvalidatePlayerDataToAllClient force all connected clients to clear specified player cache + * FullName: World::InvalidatePlayerDataToAllClient + * Access: public + **/ + void InvalidatePlayerDataToAllClient(ObjectGuid guid); + protected: void _UpdateGameTime(); // callback for UpdateRealmCharacters diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 12cfb15d7..5bd411ae3 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -655,18 +655,15 @@ class MANGOS_DLL_SPEC WorldSession void HandleGroupUninviteGuidOpcode(WorldPacket& recvPacket); void HandleGroupSetLeaderOpcode(WorldPacket& recvPacket); void HandleGroupDisbandOpcode(WorldPacket& recvPacket); - void HandleOptOutOfLootOpcode( WorldPacket &recv_data ); void HandleLootMethodOpcode(WorldPacket& recvPacket); void HandleLootRoll( WorldPacket &recv_data ); void HandleRequestPartyMemberStatsOpcode( WorldPacket &recv_data ); void HandleRaidTargetUpdateOpcode( WorldPacket & recv_data ); void HandleRaidReadyCheckOpcode( WorldPacket & recv_data ); - void HandleRaidReadyCheckFinishedOpcode( WorldPacket & recv_data ); void HandleGroupRaidConvertOpcode( WorldPacket & recv_data ); void HandleGroupChangeSubGroupOpcode( WorldPacket & recv_data ); void HandleGroupSwapSubGroupOpcode( WorldPacket & recv_data ); void HandleGroupAssistantLeaderOpcode( WorldPacket & recv_data ); - void HandlePartyAssignmentOpcode( WorldPacket & recv_data ); void HandlePetitionBuyOpcode(WorldPacket& recv_data); void HandlePetitionShowSignOpcode(WorldPacket& recv_data); @@ -684,7 +681,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleGuildAcceptOpcode(WorldPacket& recvPacket); void HandleGuildDeclineOpcode(WorldPacket& recvPacket); void HandleGuildInfoOpcode(WorldPacket& recvPacket); - void HandleGuildEventLogQueryOpcode(WorldPacket& recvPacket); void HandleGuildRosterOpcode(WorldPacket& recvPacket); void HandleGuildPromoteOpcode(WorldPacket& recvPacket); void HandleGuildDemoteOpcode(WorldPacket& recvPacket); @@ -868,8 +864,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleCharRenameOpcode(WorldPacket& recv_data); static void HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname); - void HandleTotemDestroyed(WorldPacket& recv_data); - //BattleGround void HandleBattlefieldJoinOpcode( WorldPacket &recv_data ); void HandleBattlemasterHelloOpcode(WorldPacket &recv_data); @@ -883,6 +877,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleWardenDataOpcode(WorldPacket& recv_data); void HandleWorldTeleportOpcode(WorldPacket& recv_data); + void HandleMoveSetRawPosition(WorldPacket& recv_data); void HandleMinimapPingOpcode(WorldPacket& recv_data); void HandleRandomRollOpcode(WorldPacket& recv_data); void HandleFarSightOpcode(WorldPacket& recv_data); @@ -891,13 +886,8 @@ class MANGOS_DLL_SPEC WorldSession void HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data); void HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data); - void HandleCancelMountAuraOpcode(WorldPacket& recv_data); void HandleSelfResOpcode(WorldPacket& recv_data); void HandleRequestPetInfoOpcode(WorldPacket& recv_data); - - void HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data); - - void HandleSetTaxiBenchmarkOpcode(WorldPacket& recv_data); private: // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); diff --git a/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/instance_blackwing_lair.cpp b/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/instance_blackwing_lair.cpp index 9563af9b8..2333490dd 100644 --- a/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/instance_blackwing_lair.cpp +++ b/src/scripts/eastern_kingdoms/burning_steppes/blackwing_lair/instance_blackwing_lair.cpp @@ -995,7 +995,7 @@ struct go_engin_suppressionAI: public GameObjectAI void ApplyAura() { - me->SendGameObjectCustomAnim(me->GetObjectGuid()); + me->SendGameObjectCustomAnim(); Map::PlayerList const &liste = me->GetMap()->GetPlayers(); for (Map::PlayerList::const_iterator i = liste.begin(); i != liste.end(); ++i) { diff --git a/src/scripts/eastern_kingdoms/dun_morogh/dun_morogh.cpp b/src/scripts/eastern_kingdoms/dun_morogh/dun_morogh.cpp index 8544afd38..ea5bc4c04 100644 --- a/src/scripts/eastern_kingdoms/dun_morogh/dun_morogh.cpp +++ b/src/scripts/eastern_kingdoms/dun_morogh/dun_morogh.cpp @@ -1409,7 +1409,7 @@ struct go_mortarAI : GameObjectAI bool OnUse(Unit* pCaster) override { - me->SendGameObjectCustomAnim(me->GetObjectGuid()); + me->SendGameObjectCustomAnim(); return true; } diff --git a/src/scripts/kalimdor/feralas/dire_maul/dreadsteed_ritual.cpp b/src/scripts/kalimdor/feralas/dire_maul/dreadsteed_ritual.cpp index 045a5c114..7cd9fc2c5 100644 --- a/src/scripts/kalimdor/feralas/dire_maul/dreadsteed_ritual.cpp +++ b/src/scripts/kalimdor/feralas/dire_maul/dreadsteed_ritual.cpp @@ -333,7 +333,7 @@ struct go_pedestal_of_immol_tharAI: public GameObjectAI { gobj->SetSpawnedByDefault(true); gobj->Refresh(); - gobj->SendGameObjectCustomAnim(gobj->GetObjectGuid()); + gobj->SendGameObjectCustomAnim(); } gobjTimer = 0; gobjStep++; diff --git a/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp b/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp index 6a7588313..3524822ee 100644 --- a/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp +++ b/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp @@ -1437,7 +1437,7 @@ struct go_fixed_trap : public GameObjectAI pSlipkik->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); pSlipkik->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); pSlipkik->CastSpell(pSlipkik, SPELL_ICE_LOCK, true, NULL); - me->SendGameObjectCustomAnim(me->GetObjectGuid()); + me->SendGameObjectCustomAnim(); me->Delete(); } } diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_ouro.cpp b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_ouro.cpp index 7c76e8a89..dd4d13ce2 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_ouro.cpp +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_ouro.cpp @@ -614,7 +614,7 @@ struct go_sandworm_baseAI: public GameObjectAI if (m_bActive) { m_bActive = false; - me->SendGameObjectCustomAnim(me->GetObjectGuid()); + me->SendGameObjectCustomAnim(); } else { diff --git a/src/scripts/world/npcs_special.cpp b/src/scripts/world/npcs_special.cpp index 1dad9481f..ec86b7f88 100644 --- a/src/scripts/world/npcs_special.cpp +++ b/src/scripts/world/npcs_special.cpp @@ -1902,7 +1902,7 @@ struct npc_pats_firework_guyAI : ScriptedAI { if (auto pGo = GetClosestGameObjectWithEntry(m_creature, Launcher[l], CONTACT_DISTANCE)) { - pGo->SendGameObjectCustomAnim(pGo->GetObjectGuid()); + pGo->SendGameObjectCustomAnim(); break; } } diff --git a/src/scripts/world/world_event_naxxramas.cpp b/src/scripts/world/world_event_naxxramas.cpp index 4a8d09226..d079864f6 100644 --- a/src/scripts/world/world_event_naxxramas.cpp +++ b/src/scripts/world/world_event_naxxramas.cpp @@ -145,7 +145,7 @@ struct NecropolisRelayAI : public ScriptedAI necropolis->SendObjectDeSpawnAnim(necropolis->GetObjectGuid()); } else - necropolis->SendGameObjectCustomAnim(necropolis->GetObjectGuid()); + necropolis->SendGameObjectCustomAnim(); } } } @@ -307,6 +307,8 @@ struct npc_necrotic_shard : public ScriptedAI void JustDied(Unit* pKiller) { + if (GameObject* necropolis = m_creature->GetMap()->GetGameObject(_necropolisGuid)) + necropolis->SendGameObjectCustomAnim(); // buff players around DoCastSpellIfCan(m_creature, SPELL_DMG_BOOST_AT_PYLON_DEATH, CAST_TRIGGERED);