mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 00:48:56 +01:00
[8382] Implement ByteArray functions for skip read of fields not needed for server in received packets. Author: VladimirMangos
* Use this fucntions in some case.
* Change some packets to form: read fields first check later for better control recieved packets structure.
* Fix CMSG_STAND_STATE_CHANGE packet structure to more correct.
--HG--
branch : trunk
This commit is contained in:
@@ -617,11 +617,7 @@ void WorldSession::HandleAreaSpiritHealerQueueOpcode( WorldPacket & recv_data )
|
||||
void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_BATTLEMASTER_JOIN_ARENA");
|
||||
recv_data.hexlike();
|
||||
|
||||
// ignore if we already in BG or BG queue
|
||||
if (_player->InBattleGround())
|
||||
return;
|
||||
//recv_data.hexlike();
|
||||
|
||||
uint64 guid; // arena Battlemaster guid
|
||||
uint8 arenaslot; // 2v2, 3v3 or 5v5
|
||||
@@ -631,6 +627,10 @@ void WorldSession::HandleBattlemasterJoinArena( WorldPacket & recv_data )
|
||||
|
||||
recv_data >> guid >> arenaslot >> asGroup >> isRated;
|
||||
|
||||
// ignore if we already in BG or BG queue
|
||||
if (_player->InBattleGround())
|
||||
return;
|
||||
|
||||
Creature *unit = GetPlayer()->GetMap()->GetCreature(guid);
|
||||
if (!unit)
|
||||
return;
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
|
||||
void WorldSession::HandleCalendarGetCalendar(WorldPacket &recv_data)
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR");
|
||||
recv_data.hexlike();
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_CALENDAR"); // empty
|
||||
|
||||
time_t cur_time = time(NULL);
|
||||
|
||||
@@ -75,27 +74,23 @@ void WorldSession::HandleCalendarGetEvent(WorldPacket &recv_data)
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_EVENT");
|
||||
recv_data.hexlike();
|
||||
//uint64 unk1;
|
||||
//recv_data >> (uint64)unk1;
|
||||
recv_data.read_skip<uint64>(); // unk
|
||||
}
|
||||
|
||||
void WorldSession::HandleCalendarGuildFilter(WorldPacket &recv_data)
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GUILD_FILTER");
|
||||
recv_data.hexlike();
|
||||
//uint32 unk1, unk2, unk3;
|
||||
//recv_data >> (uint32)unk1;
|
||||
//recv_data >> (uint32)unk2;
|
||||
//recv_data >> (uint32)unk3;
|
||||
recv_data.read_skip<uint32>(); // unk1
|
||||
recv_data.read_skip<uint32>(); // unk2
|
||||
recv_data.read_skip<uint32>(); // unk3
|
||||
}
|
||||
|
||||
void WorldSession::HandleCalendarArenaTeam(WorldPacket &recv_data)
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_ARENA_TEAM");
|
||||
recv_data.hexlike();
|
||||
//uint32 unk;
|
||||
//recv_data >> (uint32)unk;
|
||||
|
||||
recv_data.read_skip<uint32>(); // unk
|
||||
}
|
||||
|
||||
void WorldSession::HandleCalendarAddEvent(WorldPacket &recv_data)
|
||||
@@ -242,10 +237,9 @@ void WorldSession::HandleCalendarComplain(WorldPacket &recv_data)
|
||||
//recv_data >> uint64
|
||||
}
|
||||
|
||||
void WorldSession::HandleCalendarGetNumPending(WorldPacket &recv_data)
|
||||
void WorldSession::HandleCalendarGetNumPending(WorldPacket & /*recv_data*/)
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_NUM_PENDING");
|
||||
recv_data.hexlike();
|
||||
sLog.outDebug("WORLD: CMSG_CALENDAR_GET_NUM_PENDING"); // empty
|
||||
|
||||
WorldPacket data(SMSG_CALENDAR_SEND_NUM_PENDING, 4);
|
||||
data << uint32(0); // 0 - no pending invites, 1 - some pending invites
|
||||
|
||||
@@ -608,8 +608,6 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket)
|
||||
std::string rankname;
|
||||
uint32 rankId;
|
||||
uint32 rights, MoneyPerDay;
|
||||
uint32 BankRights;
|
||||
uint32 BankSlotPerDay;
|
||||
|
||||
//sLog.outDebug("WORLD: Received CMSG_GUILD_RANK");
|
||||
|
||||
@@ -633,10 +631,14 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket)
|
||||
|
||||
for (int i = 0; i < GUILD_BANK_MAX_TABS; ++i)
|
||||
{
|
||||
uint32 BankRights;
|
||||
uint32 BankSlotPerDay;
|
||||
|
||||
recvPacket >> BankRights;
|
||||
recvPacket >> BankSlotPerDay;
|
||||
guild->SetBankRightsAndSlots(rankId, uint8(i), uint16(BankRights & 0xFF), uint16(BankSlotPerDay), true);
|
||||
}
|
||||
|
||||
sLog.outDebug("WORLD: Changed RankName to %s , Rights to 0x%.4X", rankname.c_str(), rights);
|
||||
|
||||
guild->SetBankMoneyPerDay(rankId, MoneyPerDay);
|
||||
|
||||
@@ -495,8 +495,8 @@ void WorldSession::HandleSetSelectionOpcode( WorldPacket & recv_data )
|
||||
|
||||
void WorldSession::HandleStandStateChangeOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
sLog.outDebug( "WORLD: Received CMSG_STAND_STATE_CHANGE" );
|
||||
uint8 animstate;
|
||||
// sLog.outDebug( "WORLD: Received CMSG_STANDSTATECHANGE" ); -- too many spam in log at lags/debug stop
|
||||
uint32 animstate;
|
||||
recv_data >> animstate;
|
||||
|
||||
_player->SetStandState(animstate);
|
||||
@@ -1035,11 +1035,12 @@ void WorldSession::HandleNextCinematicCamera( WorldPacket & /*recv_data*/ )
|
||||
DEBUG_LOG( "WORLD: Which movie to play" );
|
||||
}
|
||||
|
||||
void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & /*recv_data*/ )
|
||||
void WorldSession::HandleMoveTimeSkippedOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
/* WorldSession::Update( getMSTime() );*/
|
||||
DEBUG_LOG( "WORLD: Time Lag/Synchronization Resent/Update" );
|
||||
|
||||
recv_data.read_skip2<uint64,uint32>();
|
||||
/*
|
||||
uint64 guid;
|
||||
uint32 time_skipped;
|
||||
@@ -1060,19 +1061,20 @@ void WorldSession::HandleFeatherFallAck(WorldPacket &/*recv_data*/)
|
||||
DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK");
|
||||
}
|
||||
|
||||
void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/)
|
||||
void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data)
|
||||
{
|
||||
/*
|
||||
sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
|
||||
|
||||
sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_UNROOT_ACK" );
|
||||
recv_data.read_skip<uint64>(); // guid
|
||||
recv_data.read_skip<uint64>(); // unknown1
|
||||
recv_data.read_skip<uint32>(); // unknown2
|
||||
recv_data.read_skip<float>(); // PositionX
|
||||
recv_data.read_skip<float>(); // PositionY
|
||||
recv_data.read_skip<float>(); // PositionZ
|
||||
recv_data.read_skip<float>(); // Orientation
|
||||
|
||||
/*
|
||||
recv_data.hexlike();
|
||||
uint64 guid;
|
||||
uint64 unknown1;
|
||||
uint32 unknown2;
|
||||
float PositionX;
|
||||
float PositionY;
|
||||
float PositionZ;
|
||||
float Orientation;
|
||||
|
||||
recv_data >> guid;
|
||||
recv_data >> unknown1;
|
||||
@@ -1093,8 +1095,16 @@ void WorldSession::HandleMoveUnRootAck(WorldPacket&/* recv_data*/)
|
||||
*/
|
||||
}
|
||||
|
||||
void WorldSession::HandleMoveRootAck(WorldPacket&/* recv_data*/)
|
||||
void WorldSession::HandleMoveRootAck(WorldPacket& recv_data)
|
||||
{
|
||||
recv_data.read_skip<uint64>(); // guid
|
||||
recv_data.read_skip<uint64>(); // unknown1
|
||||
recv_data.read_skip<uint32>(); // unknown2
|
||||
recv_data.read_skip<float>(); // PositionX
|
||||
recv_data.read_skip<float>(); // PositionY
|
||||
recv_data.read_skip<float>(); // PositionZ
|
||||
recv_data.read_skip<float>(); // Orientation
|
||||
|
||||
/*
|
||||
sLog.outDebug( "WORLD: CMSG_FORCE_MOVE_ROOT_ACK" );
|
||||
recv_data.hexlike();
|
||||
@@ -1141,8 +1151,9 @@ void WorldSession::HandleSetActionBarToggles(WorldPacket& recv_data)
|
||||
GetPlayer()->SetByteValue(PLAYER_FIELD_BYTES, 2, ActionBar);
|
||||
}
|
||||
|
||||
void WorldSession::HandleWardenDataOpcode(WorldPacket& /*recv_data*/)
|
||||
void WorldSession::HandleWardenDataOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
recv_data.read_skip<uint8>();
|
||||
/*
|
||||
uint8 tmp;
|
||||
recv_data >> tmp;
|
||||
|
||||
@@ -154,6 +154,7 @@ void WorldSession::HandleCreatureQueryOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
uint32 entry;
|
||||
recv_data >> entry;
|
||||
recv_data.read_skip<uint64>(); // guid
|
||||
|
||||
CreatureInfo const *ci = objmgr.GetCreatureTemplate(entry);
|
||||
if (ci)
|
||||
@@ -221,6 +222,7 @@ void WorldSession::HandleGameObjectQueryOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
uint32 entryID;
|
||||
recv_data >> entryID;
|
||||
recv_data.read_skip<uint64>(); // guid
|
||||
|
||||
const GameObjectInfo *info = objmgr.GetGameObjectInfo(entryID);
|
||||
if(info)
|
||||
|
||||
@@ -355,10 +355,9 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
|
||||
|
||||
void WorldSession::HandleCancelCastOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
// increments with every CANCEL packet, don't use for now
|
||||
uint8 counter;
|
||||
uint32 spellId;
|
||||
recvPacket >> counter;
|
||||
|
||||
recvPacket.read_skip<uint8>(); // counter, increments with every CANCEL packet, don't use for now
|
||||
recvPacket >> spellId;
|
||||
|
||||
if(_player->IsNonMeleeSpellCasted(false))
|
||||
|
||||
@@ -28,6 +28,7 @@ void WorldSession::HandleVoiceSessionEnableOpcode( WorldPacket & recv_data )
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_VOICE_SESSION_ENABLE");
|
||||
// uint8 isVoiceEnabled, uint8 isMicrophoneEnabled
|
||||
recv_data.read_skip2<uint8,uint8>();
|
||||
recv_data.hexlike();
|
||||
}
|
||||
|
||||
@@ -41,7 +42,8 @@ void WorldSession::HandleChannelVoiceOnOpcode( WorldPacket & recv_data )
|
||||
void WorldSession::HandleSetActiveVoiceChannel( WorldPacket & recv_data )
|
||||
{
|
||||
sLog.outDebug("WORLD: CMSG_SET_ACTIVE_VOICE_CHANNEL");
|
||||
// uint32, string
|
||||
recv_data.read_skip<uint32>();
|
||||
recv_data.read_skip<char*>();
|
||||
recv_data.hexlike();
|
||||
}
|
||||
|
||||
|
||||
@@ -261,6 +261,32 @@ class ByteBuffer
|
||||
return _wpos;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void read_skip() { read_skip(sizeof(T)); }
|
||||
|
||||
template<typename T1, typename T2>
|
||||
void read_skip2() { read_skip(sizeof(T1)+sizeof(T2)); }
|
||||
|
||||
template<>
|
||||
void read_skip<char*>()
|
||||
{
|
||||
uint8 size = read<uint8>();
|
||||
read_skip(size);
|
||||
}
|
||||
|
||||
template<>
|
||||
void read_skip<char const*>() { read_skip<char*>(); }
|
||||
|
||||
template<>
|
||||
void read_skip<std::string>() { read_skip<char*>(); }
|
||||
|
||||
void read_skip(size_t skip)
|
||||
{
|
||||
if(_rpos + skip > size())
|
||||
throw ByteBufferException(false, _rpos, skip, size());
|
||||
_rpos += skip;
|
||||
}
|
||||
|
||||
template <typename T> T read()
|
||||
{
|
||||
T r = read<T>(_rpos);
|
||||
|
||||
Reference in New Issue
Block a user