Skip to content

Commit

Permalink
Further WorldPacket pointers replaced with references
Browse files Browse the repository at this point in the history
  • Loading branch information
namreeb committed Nov 8, 2016
1 parent c3b9437 commit bf2bb58
Show file tree
Hide file tree
Showing 24 changed files with 311 additions and 311 deletions.
26 changes: 13 additions & 13 deletions src/game/AddonHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AddonHandler::~AddonHandler()
{
}

bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)
bool AddonHandler::BuildAddonPacket(WorldPacket& Source, WorldPacket& Target)
{
ByteBuffer AddOnPacked;
uLongf AddonRealSize;
Expand Down Expand Up @@ -61,10 +61,10 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)
};

// broken addon packet, can't be received from real client
if (Source->rpos() + 4 > Source->size())
if (Source.rpos() + 4 > Source.size())
return false;

*Source >> TempValue; // get real size of the packed structure
Source >> TempValue; // get real size of the packed structure

// empty addon packet, nothing process, can't be received from real client
if (!TempValue)
Expand All @@ -78,13 +78,13 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)

AddonRealSize = TempValue; // temp value because ZLIB only excepts uLongf

CurrentPosition = Source->rpos(); // get the position of the pointer in the structure
CurrentPosition = Source.rpos(); // get the position of the pointer in the structure

AddOnPacked.resize(AddonRealSize); // resize target for zlib action

if (uncompress(const_cast<uint8*>(AddOnPacked.contents()), &AddonRealSize, const_cast<uint8*>((*Source).contents() + CurrentPosition), (*Source).size() - CurrentPosition) == Z_OK)
if (uncompress(const_cast<uint8*>(AddOnPacked.contents()), &AddonRealSize, const_cast<uint8*>(Source.contents() + CurrentPosition), Source.size() - CurrentPosition) == Z_OK)
{
Target->Initialize(SMSG_ADDON_INFO);
Target.Initialize(SMSG_ADDON_INFO);

while (AddOnPacked.rpos() < AddOnPacked.size())
{
Expand All @@ -98,22 +98,22 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)

// sLog.outDebug("ADDON: Name:%s CRC:%x Unknown1 :%x Unknown2 :%x", AddonNames.c_str(), crc, unk7, unk6);

*Target << (uint8)2;
Target << (uint8)2;

uint8 unk1 = 1;
*Target << (uint8)unk1;
Target << (uint8)unk1;
if (unk1)
{
uint8 unk2 = crc != uint64(0x1c776d01); // If addon is Standard addon CRC
*Target << (uint8)unk2;
Target << (uint8)unk2;
if (unk2)
Target->append(tdata, sizeof(tdata));
Target.append(tdata, sizeof(tdata));

*Target << (uint32)0;
Target << (uint32)0;
}

uint8 unk3 = 0;
*Target << (uint8)unk3;
Target << (uint8)unk3;
if (unk3)
{
// String, 256
Expand All @@ -129,7 +129,7 @@ bool AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target)
}

/* Code use in 1.10.2 when client not ignore ban state sended for addons. Saved for reference if client switch to use server ban state information
void AddonHandler::BuildAddonPacket(WorldPacket* Source, WorldPacket* Target, uint32 Packetoffset)
void AddonHandler::BuildAddonPacket(WorldPacket& Source, WorldPacket& Target, uint32 Packetoffset)
{
ByteBuffer AddOnPacked;
uLongf AddonRealSize;
Expand Down
2 changes: 1 addition & 1 deletion src/game/AddonHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AddonHandler
AddonHandler();
~AddonHandler();
// built addon packet
bool BuildAddonPacket(WorldPacket* Source, WorldPacket* Target);
bool BuildAddonPacket(WorldPacket& Source, WorldPacket& Target);
};
#define sAddOnHandler MaNGOS::Singleton<AddonHandler>::Instance()
#endif
Loading

0 comments on commit bf2bb58

Please sign in to comment.