Files
TCPlayerbotCore/src/server/game/Server/Packets/QueryPackets.cpp
T

156 lines
4.5 KiB
C++
Raw Normal View History

/*
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "QueryPackets.h"
void WorldPackets::Query::QueryCreature::Read()
{
_worldPacket >> CreatureID;
}
WorldPacket const* WorldPackets::Query::QueryCreatureResponse::Write()
{
_worldPacket << CreatureID;
_worldPacket.WriteBit(Allow);
2014-11-15 06:40:16 +01:00
_worldPacket.FlushBits();
if (Allow)
{
2014-11-15 06:40:16 +01:00
_worldPacket.WriteBits(Stats.Title.length() + 1, 11);
_worldPacket.WriteBits(Stats.TitleAlt.length() + 1, 11);
_worldPacket.WriteBits(Stats.CursorName.length() + 1, 6);
_worldPacket.WriteBit(Stats.Leader);
for (uint32 i = 0; i < MAX_CREATURE_NAMES; ++i)
{
2014-11-15 06:40:16 +01:00
_worldPacket.WriteBits(Stats.Name[i].length() + 1, 11);
_worldPacket.WriteBits(Stats.NameAlt[i].length() + 1, 11);
}
for (uint32 i = 0; i < MAX_CREATURE_NAMES; ++i)
{
if (!Stats.Name[i].empty())
_worldPacket << Stats.Name[i];
2014-11-15 06:40:16 +01:00
if (!Stats.NameAlt[i].empty())
_worldPacket << Stats.NameAlt[i];
}
2014-11-15 06:40:16 +01:00
for (uint8 i = 0; i < 2; ++i)
_worldPacket << Stats.Flags[i];
_worldPacket << Stats.CreatureType;
_worldPacket << Stats.CreatureFamily;
_worldPacket << Stats.Classification;
for (uint32 i = 0; i < MAX_KILL_CREDIT; ++i)
_worldPacket << Stats.ProxyCreatureID[i];
for (uint32 i = 0; i < MAX_CREATURE_MODELS; ++i)
_worldPacket << Stats.CreatureDisplayID[i];
_worldPacket << Stats.HpMulti;
_worldPacket << Stats.EnergyMulti;
_worldPacket << int32(Stats.QuestItems.size());
_worldPacket << Stats.CreatureMovementInfoID;
_worldPacket << Stats.RequiredExpansion;
_worldPacket << int32(0); // FlagQuest
2014-11-15 06:40:16 +01:00
if (!Stats.Title.empty())
_worldPacket << Stats.Title;
2014-11-15 06:40:16 +01:00
if (!Stats.TitleAlt.empty())
_worldPacket << Stats.TitleAlt;
2014-11-15 06:40:16 +01:00
if (!Stats.CursorName.empty())
_worldPacket << Stats.CursorName;
2014-11-15 06:40:16 +01:00
for (int32 questItem : Stats.QuestItems)
_worldPacket << questItem;
}
return &_worldPacket;
}
void WorldPackets::Query::QueryPlayerName::Read()
{
_worldPacket >> Player;
Hint.VirtualRealmAddress.HasValue = _worldPacket.ReadBit();
Hint.NativeRealmAddress.HasValue = _worldPacket.ReadBit();
if (Hint.VirtualRealmAddress.HasValue)
_worldPacket >> Hint.VirtualRealmAddress.Value;
if (Hint.NativeRealmAddress.HasValue)
_worldPacket >> Hint.NativeRealmAddress.Value;
}
WorldPacket const* WorldPackets::Query::QueryPlayerNameResponse::Write()
{
_worldPacket << Result;
_worldPacket << Player;
2014-11-16 06:08:46 +01:00
if (Result == RESPONSE_SUCCESS)
{
_worldPacket.WriteBits(Data.Name.length(), 7);
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
_worldPacket.WriteBits(Data.DeclinedNames.name[i].length(), 7);
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
_worldPacket.WriteString(Data.DeclinedNames.name[i]);
_worldPacket << Data.AccountID;
_worldPacket << Data.BnetAccountID;
_worldPacket << Data.GuidActual;
_worldPacket << Data.VirtualRealmAddress;
_worldPacket << Data.Race;
_worldPacket << Data.Sex;
_worldPacket << Data.ClassID;
_worldPacket << Data.Level;
_worldPacket.WriteString(Data.Name);
}
return &_worldPacket;
}
void WorldPackets::Query::QueryPageText::Read()
{
_worldPacket >> PageTextID;
_worldPacket >> ItemGUID;
}
WorldPacket const* WorldPackets::Query::QueryPageTextResponse::Write()
{
_worldPacket << PageTextID;
_worldPacket.WriteBit(Allow);
2014-11-16 06:08:46 +01:00
if (Allow)
{
_worldPacket << Info.ID;
_worldPacket << Info.NextPageID;
_worldPacket.WriteBits(Info.Text.length(), 12);
_worldPacket.WriteString(Info.Text);
}
return &_worldPacket;
}