Core/Packets: converted SMSG_UPDATE_INSTANCE_ENCOUNTER_UNIT to packet class
This commit is contained in:
1 parent
90b267764e
commit
20fdb215db
5 files changed
+57
-21
No files matched your search
@@ -26,6 +26,7 @@
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "InstancePackets.h"
|
||||
#include "LFGMgr.h"
|
||||
#include "Log.h"
|
||||
#include "Map.h"
|
||||
@@ -683,9 +684,10 @@ bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player con
|
||||
|
||||
void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= nullptr*/, uint8 param1 /*= 0*/, uint8 param2 /*= 0*/)
|
||||
{
|
||||
// size of this packet is at most 15 (usually less)
|
||||
WorldPacket data(SMSG_UPDATE_INSTANCE_ENCOUNTER_UNIT, 15);
|
||||
data << uint32(type);
|
||||
WorldPackets::Instance::UpdateInstanceEncounterUnit packet;
|
||||
packet.Type = type;
|
||||
packet.Param1 = param1;
|
||||
packet.Param2 = param2;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
@@ -694,27 +696,14 @@ void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= nullptr*/, ui
|
||||
case ENCOUNTER_FRAME_UPDATE_PRIORITY:
|
||||
if (!unit)
|
||||
return;
|
||||
data.appendPackGUID(unit->GetGUID());
|
||||
data << uint8(param1);
|
||||
|
||||
packet.Unit = unit->GetGUID();
|
||||
break;
|
||||
case ENCOUNTER_FRAME_ADD_TIMER:
|
||||
case ENCOUNTER_FRAME_ENABLE_OBJECTIVE:
|
||||
case ENCOUNTER_FRAME_DISABLE_OBJECTIVE:
|
||||
case ENCOUNTER_FRAME_SET_COMBAT_RES_LIMIT:
|
||||
data << uint8(param1);
|
||||
break;
|
||||
case ENCOUNTER_FRAME_UPDATE_OBJECTIVE:
|
||||
data << uint8(param1);
|
||||
data << uint8(param2);
|
||||
break;
|
||||
case ENCOUNTER_FRAME_UNK7:
|
||||
case ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT:
|
||||
case ENCOUNTER_FRAME_RESET_COMBAT_RES_LIMIT:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
instance->SendToPlayers(&data);
|
||||
instance->SendToPlayers(packet.Write());
|
||||
}
|
||||
|
||||
void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 creditEntry, Unit* /*source*/)
|
||||
|
||||
@@ -3595,7 +3595,7 @@ uint32 Map::GetPlayersCountExceptGMs() const
|
||||
return count;
|
||||
}
|
||||
|
||||
void Map::SendToPlayers(WorldPacket* data) const
|
||||
void Map::SendToPlayers(WorldPacket const* data) const
|
||||
{
|
||||
for (MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
|
||||
itr->GetSource()->SendDirectMessage(data);
|
||||
|
||||
@@ -536,7 +536,7 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
|
||||
void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
|
||||
void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
|
||||
|
||||
void SendToPlayers(WorldPacket* data) const;
|
||||
void SendToPlayers(WorldPacket const* data) const;
|
||||
|
||||
typedef MapRefManager PlayerList;
|
||||
PlayerList const& GetPlayers() const { return m_mapRefManager; }
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "InstancePackets.h"
|
||||
#include "InstanceScript.h"
|
||||
#include "Player.h"
|
||||
|
||||
WorldPacket const* WorldPackets::Instance::UpdateLastInstance::Write()
|
||||
@@ -96,3 +97,36 @@ WorldPacket const* WorldPackets::Instance::RaidGroupOnly::Write()
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
WorldPacket const* WorldPackets::Instance::UpdateInstanceEncounterUnit::Write()
|
||||
{
|
||||
_worldPacket << uint32(Type);
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case ENCOUNTER_FRAME_ENGAGE:
|
||||
case ENCOUNTER_FRAME_DISENGAGE:
|
||||
case ENCOUNTER_FRAME_UPDATE_PRIORITY:
|
||||
_worldPacket << Unit.WriteAsPacked();
|
||||
_worldPacket << uint8(Param1);
|
||||
break;
|
||||
case ENCOUNTER_FRAME_ADD_TIMER:
|
||||
case ENCOUNTER_FRAME_ENABLE_OBJECTIVE:
|
||||
case ENCOUNTER_FRAME_DISABLE_OBJECTIVE:
|
||||
case ENCOUNTER_FRAME_SET_COMBAT_RES_LIMIT:
|
||||
_worldPacket << uint8(Param1);
|
||||
break;
|
||||
case ENCOUNTER_FRAME_UPDATE_OBJECTIVE:
|
||||
_worldPacket << uint8(Param1);
|
||||
_worldPacket << uint8(Param2);
|
||||
break;
|
||||
case ENCOUNTER_FRAME_UNK7:
|
||||
case ENCOUNTER_FRAME_ADD_COMBAT_RES_LIMIT:
|
||||
case ENCOUNTER_FRAME_RESET_COMBAT_RES_LIMIT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
@@ -116,6 +116,19 @@ namespace WorldPackets
|
||||
uint32 Reason = 0;
|
||||
int32 Delay = 0;
|
||||
};
|
||||
|
||||
class UpdateInstanceEncounterUnit final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
UpdateInstanceEncounterUnit() : ServerPacket(SMSG_UPDATE_INSTANCE_ENCOUNTER_UNIT, 4 + 8 + 1 + 1) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint32 Type = 0;
|
||||
ObjectGuid Unit;
|
||||
uint8 Param1 = 0;
|
||||
uint8 Param2 = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user