Core/Packets: convert CMSG_ENUM_CHARACTERS and SMSG_ENUM_CHARACTERS_R… (#24)

* Core/Packets: convert CMSG_ENUM_CHARACTERS and SMSG_ENUM_CHARACTERS_RESULT to packet class

* Cleanup some excessive large spaces

* These entire spaces must be purged

* Order members by type size and alphabetical

* Change TaggedPosition into Position
This commit is contained in:
Ghaster authored and Ovah committed 2020-01-19 23:17:26 +01:00
1 parent 135eb3e5a0
commit 2587802100
11 files changed
+416 -287

No files matched your search

-239
View File
@@ -105,51 +105,6 @@
#define ZONE_UPDATE_INTERVAL (1*IN_MILLISECONDS)
enum CharacterFlags
{
CHARACTER_FLAG_NONE = 0x00000000,
CHARACTER_FLAG_UNK1 = 0x00000001,
CHARACTER_FLAG_UNK2 = 0x00000002,
CHARACTER_LOCKED_FOR_TRANSFER = 0x00000004,
CHARACTER_FLAG_UNK4 = 0x00000008,
CHARACTER_FLAG_UNK5 = 0x00000010,
CHARACTER_FLAG_UNK6 = 0x00000020,
CHARACTER_FLAG_UNK7 = 0x00000040,
CHARACTER_FLAG_UNK8 = 0x00000080,
CHARACTER_FLAG_UNK9 = 0x00000100,
CHARACTER_FLAG_UNK10 = 0x00000200,
CHARACTER_FLAG_HIDE_HELM = 0x00000400,
CHARACTER_FLAG_HIDE_CLOAK = 0x00000800,
CHARACTER_FLAG_UNK13 = 0x00001000,
CHARACTER_FLAG_GHOST = 0x00002000,
CHARACTER_FLAG_RENAME = 0x00004000,
CHARACTER_FLAG_UNK16 = 0x00008000,
CHARACTER_FLAG_UNK17 = 0x00010000,
CHARACTER_FLAG_UNK18 = 0x00020000,
CHARACTER_FLAG_UNK19 = 0x00040000,
CHARACTER_FLAG_UNK20 = 0x00080000,
CHARACTER_FLAG_UNK21 = 0x00100000,
CHARACTER_FLAG_UNK22 = 0x00200000,
CHARACTER_FLAG_UNK23 = 0x00400000,
CHARACTER_FLAG_UNK24 = 0x00800000,
CHARACTER_FLAG_LOCKED_BY_BILLING = 0x01000000,
CHARACTER_FLAG_DECLINED = 0x02000000,
CHARACTER_FLAG_UNK27 = 0x04000000,
CHARACTER_FLAG_UNK28 = 0x08000000,
CHARACTER_FLAG_UNK29 = 0x10000000,
CHARACTER_FLAG_UNK30 = 0x20000000,
CHARACTER_FLAG_UNK31 = 0x40000000,
CHARACTER_FLAG_UNK32 = 0x80000000
};
enum CharacterCustomizeFlags
{
CHAR_CUSTOMIZE_FLAG_NONE = 0x00000000,
CHAR_CUSTOMIZE_FLAG_CUSTOMIZE = 0x00000001, // name, gender, etc...
CHAR_CUSTOMIZE_FLAG_FACTION = 0x00010000, // name, gender, faction, etc...
CHAR_CUSTOMIZE_FLAG_RACE = 0x00100000 // name, gender, race, etc...
};
// corpse reclaim times
#define DEATH_EXPIRE_STEP (5*MINUTE)
#define MAX_DEATH_COUNT 3
@@ -1452,200 +1407,6 @@ void Player::setDeathState(DeathState s)
SetUInt32Value(PLAYER_SELF_RES_SPELL, 0);
}
bool Player::BuildEnumData(PreparedQueryResult result, ByteBuffer* dataBuffer, ByteBuffer* bitBuffer)
{
// 0 1 2 3 4 5 6 7
// SELECT characters.guid, characters.name, characters.race, characters.class, characters.gender, characters.skin, characters.face, characters.hairStyle,
// 8 9 10 11 12 13 14 15
// characters.hairColor, characters.facialStyle, characters.level, characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z,
// 16 17 18 19 20 21 22
// guild_member.guildid, characters.playerFlags, characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.data,
// 23 24 25
// character_banned.guid, characters.slot, character_declinedname.genitive
Field* fields = result->Fetch();
ObjectGuid guid(HighGuid::Player, fields[0].GetUInt32());
std::string name = fields[1].GetString();
uint8 plrRace = fields[2].GetUInt8();
uint8 plrClass = fields[3].GetUInt8();
uint8 gender = fields[4].GetUInt8();
uint8 skin = fields[5].GetUInt8();
uint8 face = fields[6].GetUInt8();
uint8 hairStyle = fields[7].GetUInt8();
uint8 hairColor = fields[8].GetUInt8();
uint8 facialStyle = fields[9].GetUInt8();
uint8 level = fields[10].GetUInt8();
uint32 zone = fields[11].GetUInt16();
uint32 mapId = uint32(fields[12].GetUInt16());
float x = fields[13].GetFloat();
float y = fields[14].GetFloat();
float z = fields[15].GetFloat();
uint32 guildId = fields[16].GetUInt32();
ObjectGuid guildGuid;
if (guildId)
guildGuid = ObjectGuid(HighGuid::Guild, guildId);
uint32 playerFlags = fields[17].GetUInt32();
uint32 atLoginFlags = fields[18].GetUInt16();
Tokenizer equipment(fields[22].GetString(), ' ');
uint8 slot = fields[24].GetUInt8();
if (!ValidateAppearance(uint8(plrRace), uint8(plrClass), gender, hairStyle, hairColor, face, facialStyle, skin))
{
TC_LOG_ERROR("entities.player.loading", "Player %s has wrong Appearance values (Hair/Skin/Color), forcing recustomize", guid.ToString().c_str());
// Make sure customization always works properly - send all zeroes instead
skin = 0, face = 0, hairStyle = 0, hairColor = 0, facialStyle = 0;
if (!(atLoginFlags & AT_LOGIN_CUSTOMIZE))
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG);
stmt->setUInt16(0, uint16(AT_LOGIN_CUSTOMIZE));
stmt->setUInt32(1, guid);
CharacterDatabase.Execute(stmt);
atLoginFlags |= AT_LOGIN_CUSTOMIZE;
}
}
uint32 charFlags = 0;
if (atLoginFlags & AT_LOGIN_RESURRECT)
playerFlags &= ~PLAYER_FLAGS_GHOST;
if (playerFlags & PLAYER_FLAGS_HIDE_HELM)
charFlags |= CHARACTER_FLAG_HIDE_HELM;
if (playerFlags & PLAYER_FLAGS_HIDE_CLOAK)
charFlags |= CHARACTER_FLAG_HIDE_CLOAK;
if (playerFlags & PLAYER_FLAGS_GHOST)
charFlags |= CHARACTER_FLAG_GHOST;
if (atLoginFlags & AT_LOGIN_RENAME)
charFlags |= CHARACTER_FLAG_RENAME;
if (fields[23].GetUInt32())
charFlags |= CHARACTER_FLAG_LOCKED_BY_BILLING;
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED) && !fields[22].GetString().empty())
charFlags |= CHARACTER_FLAG_DECLINED;
uint32 customizationFlag = 0;
if (atLoginFlags & AT_LOGIN_CUSTOMIZE)
customizationFlag = CHAR_CUSTOMIZE_FLAG_CUSTOMIZE;
else if (atLoginFlags & AT_LOGIN_CHANGE_FACTION)
customizationFlag = CHAR_CUSTOMIZE_FLAG_FACTION;
else if (atLoginFlags & AT_LOGIN_CHANGE_RACE)
customizationFlag = CHAR_CUSTOMIZE_FLAG_RACE;
uint32 petDisplayId = 0;
uint32 petLevel = 0;
CreatureFamily petFamily = CREATURE_FAMILY_NONE;
// show pet at selection character in character list only for non-ghost character
if (result && !(playerFlags & PLAYER_FLAGS_GHOST) && (plrClass == CLASS_WARLOCK || plrClass == CLASS_HUNTER || plrClass == CLASS_DEATH_KNIGHT))
{
uint32 entry = fields[19].GetUInt32();
CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(entry);
if (creatureInfo)
{
petDisplayId = fields[20].GetUInt32();
petLevel = fields[21].GetUInt16();
petFamily = creatureInfo->family;
}
}
// Packet content flags
bitBuffer->WriteBit(guid[3]);
bitBuffer->WriteBit(guildGuid[1]);
bitBuffer->WriteBit(guildGuid[7]);
bitBuffer->WriteBit(guildGuid[2]);
bitBuffer->WriteBits(uint32(name.length()), 7);
bitBuffer->WriteBit(guid[4]);
bitBuffer->WriteBit(guid[7]);
bitBuffer->WriteBit(guildGuid[3]);
bitBuffer->WriteBit(guid[5]);
bitBuffer->WriteBit(guildGuid[6]);
bitBuffer->WriteBit(guid[1]);
bitBuffer->WriteBit(guildGuid[5]);
bitBuffer->WriteBit(guildGuid[4]);
bitBuffer->WriteBit(atLoginFlags & AT_LOGIN_FIRST);
bitBuffer->WriteBit(guid[0]);
bitBuffer->WriteBit(guid[2]);
bitBuffer->WriteBit(guid[6]);
bitBuffer->WriteBit(guildGuid[0]);
// Character data
*dataBuffer << uint8(plrClass); // Class
for (uint8 slot = 0; slot < INVENTORY_SLOT_BAG_END; ++slot)
{
uint32 visualbase = slot * 2;
uint32 itemId = GetUInt32ValueFromArray(equipment, visualbase);
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(itemId);
if (!proto)
{
*dataBuffer << uint8(0);
*dataBuffer << uint32(0);
*dataBuffer << uint32(0);
continue;
}
SpellItemEnchantmentEntry const* enchant = nullptr;
uint32 enchants = GetUInt32ValueFromArray(equipment, visualbase + 1);
for (uint8 enchantSlot = PERM_ENCHANTMENT_SLOT; enchantSlot <= TEMP_ENCHANTMENT_SLOT; ++enchantSlot)
{
// values stored in 2 uint16
uint32 enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16);
if (!enchantId)
continue;
enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId);
if (enchant)
break;
}
*dataBuffer << uint8(proto->InventoryType);
*dataBuffer << uint32(proto->DisplayInfoID);
*dataBuffer << uint32(enchant ? enchant->aura_id : 0);
}
*dataBuffer << uint32(petFamily); // Pet family
dataBuffer->WriteByteSeq(guildGuid[2]);
*dataBuffer << uint8(slot); // List order
*dataBuffer << uint8(hairStyle); // Hair style
dataBuffer->WriteByteSeq(guildGuid[3]);
*dataBuffer << uint32(petDisplayId); // Pet DisplayID
*dataBuffer << uint32(charFlags); // Character flags
*dataBuffer << uint8(hairColor); // Hair color
dataBuffer->WriteByteSeq(guid[4]);
*dataBuffer << uint32(mapId); // Map Id
dataBuffer->WriteByteSeq(guildGuid[5]);
*dataBuffer << float(z); // Z
dataBuffer->WriteByteSeq(guildGuid[6]);
*dataBuffer << uint32(petLevel); // Pet level
dataBuffer->WriteByteSeq(guid[3]);
*dataBuffer << float(y); // Y
*dataBuffer << uint32(customizationFlag); // Character customization flags
*dataBuffer << uint8(facialStyle); // Facial hair
dataBuffer->WriteByteSeq(guid[7]);
*dataBuffer << uint8(gender); // Gender
dataBuffer->append(name.c_str(), name.length()); // Name
*dataBuffer << uint8(face); // Face
dataBuffer->WriteByteSeq(guid[0]);
dataBuffer->WriteByteSeq(guid[2]);
dataBuffer->WriteByteSeq(guildGuid[1]);
dataBuffer->WriteByteSeq(guildGuid[7]);
*dataBuffer << float(x); // X
*dataBuffer << uint8(skin); // Skin
*dataBuffer << uint8(plrRace); // Race
*dataBuffer << uint8(level); // Level
dataBuffer->WriteByteSeq(guid[6]);
dataBuffer->WriteByteSeq(guildGuid[4]);
dataBuffer->WriteByteSeq(guildGuid[0]);
dataBuffer->WriteByteSeq(guid[5]);
dataBuffer->WriteByteSeq(guid[1]);
*dataBuffer << uint32(zone); // Zone id
return true;
}
void Player::ToggleAFK()
{
ToggleFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);