Core/PacketIO: Reimplemented SMSG_SET_FORCED_REACTIONS as a response to client request instead of sending it automatically during map change

This commit is contained in:
Shauren
2015-04-09 00:05:31 +02:00
parent e651dbec0e
commit 3e063be399
9 changed files with 72 additions and 14 deletions

View File

@@ -408,7 +408,7 @@ void ArenaTeam::NotifyStatsChanged()
SendStats(player->GetSession());
}
void ArenaTeam::Inspect(WorldSession* session, ObjectGuid guid)
void ArenaTeam::Inspect(WorldSession* /*session*/, ObjectGuid guid)
{
ArenaTeamMember* member = GetMember(guid);
if (!member)

View File

@@ -22472,8 +22472,6 @@ void Player::SendInitialPacketsBeforeAddToMap()
/// SMSG_INITIALIZE_FACTIONS
m_reputationMgr->SendInitialReputations();
/// SMSG_SET_FORCED_REACTIONS
m_reputationMgr->SendForceReactions();
/// SMSG_SETUP_CURRENCY
SendCurrencies();
/// SMSG_EQUIPMENT_SET_LIST

View File

@@ -1198,6 +1198,11 @@ void WorldSession::HandleSetFactionInactiveOpcode(WorldPacket& recvData)
_player->GetReputationMgr().SetInactive(replistid, inactive != 0);
}
void WorldSession::HandleRequestForcedReactionsOpcode(WorldPackets::Reputation::RequestForcedReactions& /*requestForcedReactions*/)
{
_player->GetReputationMgr().SendForceReactions();
}
void WorldSession::HandleShowingHelmOpcode(WorldPackets::Character::ShowingHelm& packet)
{
if (packet.ShowHelm)

View File

@@ -406,7 +406,7 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Query::DBQueryBulk& packet)
DB2StorageBase const* store = sDB2Manager.GetStorage(packet.TableHash);
if (!store)
{
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: Received unknown hotfix type: %u", packet.TableHash);
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: %s requested unsupported unknown hotfix type: %u", GetPlayerInfo().c_str(), packet.TableHash);
return;
}
@@ -423,7 +423,7 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Query::DBQueryBulk& packet)
}
else
{
TC_LOG_ERROR("network", "CMSG_DB_QUERY_BULK: Entry %u does not exist in datastore: %u", rec.RecordID, packet.TableHash);
TC_LOG_TRACE("network", "CMSG_DB_QUERY_BULK: %s requested non-existing entry %u in datastore: %u", GetPlayerInfo().c_str(), rec.RecordID, packet.TableHash);
response.RecordID = -int32(rec.RecordID);
response.Timestamp = time(NULL);
}

View File

@@ -157,15 +157,18 @@ uint32 ReputationMgr::GetDefaultStateFlags(FactionEntry const* factionEntry) con
void ReputationMgr::SendForceReactions()
{
WorldPacket data;
data.Initialize(SMSG_SET_FORCED_REACTIONS, 4+_forcedReactions.size()*(4+4));
data << uint32(_forcedReactions.size());
WorldPackets::Reputation::SetForcedReactions setForcedReactions;
setForcedReactions.Reactions.resize(_forcedReactions.size());
std::size_t i = 0;
for (ForcedReactions::const_iterator itr = _forcedReactions.begin(); itr != _forcedReactions.end(); ++itr)
{
data << uint32(itr->first); // faction_id (Faction.dbc)
data << uint32(itr->second); // reputation rank
WorldPackets::Reputation::ForcedReaction& forcedReaction = setForcedReactions.Reactions[i++];
forcedReaction.Faction = int32(itr->first);
forcedReaction.Reaction = int32(itr->second);
}
_player->SendDirectMessage(&data);
_player->SendDirectMessage(setForcedReactions.Write());
}
void ReputationMgr::SendState(FactionState const* faction)

View File

@@ -32,3 +32,21 @@ WorldPacket const* WorldPackets::Reputation::InitializeFactions::Write()
return &_worldPacket;
}
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Reputation::ForcedReaction const& forcedReaction)
{
data << int32(forcedReaction.Faction);
data << int32(forcedReaction.Reaction);
return data;
}
WorldPacket const* WorldPackets::Reputation::SetForcedReactions::Write()
{
_worldPacket.WriteBits(Reactions.size(), 6);
for (ForcedReaction const& reaction : Reactions)
_worldPacket << reaction;
_worldPacket.FlushBits();
return &_worldPacket;
}

View File

@@ -15,7 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef ReputationPackets_h__
#define ReputationPackets_h__
#include "Packet.h"
@@ -44,5 +45,31 @@ namespace WorldPackets
bool FactionHasBonus[FactionCount]; ///< @todo: implement faction bonus
uint8 FactionFlags[FactionCount]; ///< @see enum FactionFlags
};
class RequestForcedReactions final : public ClientPacket
{
public:
RequestForcedReactions(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_FORCED_REACTIONS, std::move(packet)) { }
void Read() override { }
};
struct ForcedReaction
{
int32 Faction = 0;
int32 Reaction = 0;
};
class SetForcedReactions final : public ServerPacket
{
public:
SetForcedReactions() : ServerPacket(SMSG_SET_FORCED_REACTIONS) { }
WorldPacket const* Write() override;
std::vector<ForcedReaction> Reactions;
};
}
}
#endif // ReputationPackets_h__

View File

@@ -43,6 +43,7 @@
#include "Packets/QueryPackets.h"
#include "Packets/QuestPackets.h"
#include "Packets/ReferAFriendPackets.h"
#include "Packets/ReputationPackets.h"
#include "Packets/SocialPackets.h"
#include "Packets/TalentPackets.h"
#include "Packets/TradePackets.h"
@@ -665,7 +666,7 @@ void OpcodeTable::Initialize()
DEFINE_HANDLER(CMSG_REQUEST_CATEGORY_COOLDOWNS, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Spells::RequestCategoryCooldowns, &WorldSession::HandleRequestCategoryCooldowns);
DEFINE_HANDLER(CMSG_REQUEST_CEMETERY_LIST, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Misc::RequestCemeteryList, &WorldSession::HandleRequestCemeteryList);
DEFINE_OPCODE_HANDLER_OLD(CMSG_REQUEST_CONQUEST_FORMULA_CONSTANTS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_OPCODE_HANDLER_OLD(CMSG_REQUEST_FORCED_REACTIONS, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL );
DEFINE_HANDLER(CMSG_REQUEST_FORCED_REACTIONS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Reputation::RequestForcedReactions, &WorldSession::HandleRequestForcedReactionsOpcode);
DEFINE_HANDLER(CMSG_REQUEST_GUILD_PARTY_STATE, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::Guild::RequestGuildPartyState, &WorldSession::HandleGuildRequestPartyState);
DEFINE_HANDLER(CMSG_REQUEST_GUILD_REWARDS_LIST, STATUS_UNHANDLED, PROCESS_INPLACE, WorldPackets::Guild::RequestGuildRewardsList, &WorldSession::HandleRequestGuildRewardsList);
DEFINE_HANDLER(CMSG_REQUEST_HONOR_STATS, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, WorldPackets::Inspect::RequestHonorStats, &WorldSession::HandleRequestHonorStatsOpcode);
@@ -1608,7 +1609,7 @@ void OpcodeTable::Initialize()
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_FACTION_STANDING, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_FACTION_VISIBLE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_FLAT_SPELL_MODIFIER, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_FORCED_REACTIONS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_FORCED_REACTIONS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_ITEM_PURCHASE_DATA, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_LFG_TIME_WALKER, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);
DEFINE_SERVER_OPCODE_HANDLER(SMSG_SET_LOOT_METHOD_FAILED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM);

View File

@@ -362,6 +362,11 @@ namespace WorldPackets
class GrantLevel;
}
namespace Reputation
{
class RequestForcedReactions;
}
namespace Social
{
class AddFriend;
@@ -940,6 +945,7 @@ class WorldSession
void HandleSetFactionCheat(WorldPacket& recvData);
void HandleSetWatchedFactionOpcode(WorldPacket& recvData);
void HandleSetFactionInactiveOpcode(WorldPacket& recvData);
void HandleRequestForcedReactionsOpcode(WorldPackets::Reputation::RequestForcedReactions& requestForcedReactions);
void HandleUpdateAccountData(WorldPackets::ClientConfig::UserClientUpdateAccountData& packet);
void HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request);