public CharacterInfo(SQLFields fields) { Guid = ObjectGuid.Create(HighGuid.Player, fields.Read <ulong>(0)); Name = fields.Read <string>(1); RaceId = fields.Read <byte>(2); ClassId = (Class)fields.Read <byte>(3); SexId = fields.Read <byte>(4); ExperienceLevel = fields.Read <byte>(5); ZoneId = fields.Read <uint>(6); MapId = fields.Read <uint>(7); PreloadPos = new Vector3(fields.Read <float>(8), fields.Read <float>(9), fields.Read <float>(10)); ulong guildId = fields.Read <ulong>(11); if (guildId != 0) { GuildGuid = ObjectGuid.Create(HighGuid.Guild, guildId); } PlayerFlags playerFlags = (PlayerFlags)fields.Read <uint>(12); AtLoginFlags atLoginFlags = (AtLoginFlags)fields.Read <ushort>(13); if (atLoginFlags.HasAnyFlag(AtLoginFlags.Resurrect)) { playerFlags &= ~PlayerFlags.Ghost; } if (playerFlags.HasAnyFlag(PlayerFlags.Ghost)) { Flags |= CharacterFlags.Ghost; } if (atLoginFlags.HasAnyFlag(AtLoginFlags.Rename)) { Flags |= CharacterFlags.Rename; } if (fields.Read <uint>(18) != 0) { Flags |= CharacterFlags.LockedByBilling; } if (WorldConfig.GetBoolValue(WorldCfg.DeclinedNamesUsed) && !string.IsNullOrEmpty(fields.Read <string>(23))) { Flags |= CharacterFlags.Declined; } if (atLoginFlags.HasAnyFlag(AtLoginFlags.Customize)) { Flags2 = CharacterCustomizeFlags.Customize; } else if (atLoginFlags.HasAnyFlag(AtLoginFlags.ChangeFaction)) { Flags2 = CharacterCustomizeFlags.Faction; } else if (atLoginFlags.HasAnyFlag(AtLoginFlags.ChangeRace)) { Flags2 = CharacterCustomizeFlags.Race; } Flags3 = 0; Flags4 = 0; FirstLogin = atLoginFlags.HasAnyFlag(AtLoginFlags.FirstLogin); // show pet at selection character in character list only for non-ghost character if (!playerFlags.HasAnyFlag(PlayerFlags.Ghost) && (ClassId == Class.Warlock || ClassId == Class.Hunter || ClassId == Class.Deathknight)) { CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(fields.Read <uint>(14)); if (creatureInfo != null) { PetCreatureDisplayId = fields.Read <uint>(15); PetExperienceLevel = fields.Read <ushort>(16); PetCreatureFamilyId = (uint)creatureInfo.Family; } } BoostInProgress = false; ProfessionIds[0] = 0; ProfessionIds[1] = 0; StringArguments equipment = new(fields.Read <string>(17)); ListPosition = fields.Read <byte>(19); LastPlayedTime = fields.Read <long>(20); var spec = Global.DB2Mgr.GetChrSpecializationByIndex(ClassId, fields.Read <byte>(21)); if (spec != null) { SpecID = (ushort)spec.Id; } LastLoginVersion = fields.Read <uint>(22); for (byte slot = 0; slot < InventorySlots.BagEnd; ++slot) { VisualItems[slot].InvType = (byte)equipment.NextUInt32(); VisualItems[slot].DisplayId = equipment.NextUInt32(); VisualItems[slot].DisplayEnchantId = equipment.NextUInt32(); VisualItems[slot].Subclass = (byte)equipment.NextUInt32(); } }
public CharacterInfo(SQLFields fields) { // 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 // "characters.hairColor, characters.facialStyle, characters.customDisplay1, characters.customDisplay2, characters.customDisplay3, characters.level, " // 14 15 16 17 18 // "characters.zone, characters.map, characters.position_x, characters.position_y, characters.position_z, " // 19 20 21 22 23 24 25 // "guild_member.guildid, characters.playerFlags, characters.at_login, character_pet.entry, character_pet.modelid, character_pet.level, characters.equipmentCache, " // 26 27 28 29 30 31 // "character_banned.guid, characters.slot, characters.logout_time, characters.activeTalentGroup, characters.lastLoginBuild, character_declinedname.genitive" Guid = ObjectGuid.Create(HighGuid.Player, fields.Read <ulong>(0)); Name = fields.Read <string>(1); RaceId = fields.Read <byte>(2); ClassId = (Class)fields.Read <byte>(3); SexId = fields.Read <byte>(4); SkinId = fields.Read <byte>(5); FaceId = fields.Read <byte>(6); HairStyle = fields.Read <byte>(7); HairColor = fields.Read <byte>(8); FacialHair = fields.Read <byte>(9); CustomDisplay[0] = fields.Read <byte>(10); CustomDisplay[1] = fields.Read <byte>(11); CustomDisplay[2] = fields.Read <byte>(12); ExperienceLevel = fields.Read <byte>(13); ZoneId = fields.Read <uint>(14); MapId = fields.Read <uint>(15); PreloadPos = new Vector3(fields.Read <float>(16), fields.Read <float>(17), fields.Read <float>(18)); ulong guildId = fields.Read <ulong>(19); if (guildId != 0) { GuildGuid = ObjectGuid.Create(HighGuid.Guild, guildId); } PlayerFlags playerFlags = (PlayerFlags)fields.Read <uint>(20); AtLoginFlags atLoginFlags = (AtLoginFlags)fields.Read <ushort>(21); if (atLoginFlags.HasAnyFlag(AtLoginFlags.Resurrect)) { playerFlags &= ~PlayerFlags.Ghost; } if (playerFlags.HasAnyFlag(PlayerFlags.Ghost)) { Flags |= CharacterFlags.Ghost; } if (atLoginFlags.HasAnyFlag(AtLoginFlags.Rename)) { Flags |= CharacterFlags.Rename; } if (fields.Read <uint>(26) != 0) { Flags |= CharacterFlags.LockedByBilling; } if (WorldConfig.GetBoolValue(WorldCfg.DeclinedNamesUsed) && !string.IsNullOrEmpty(fields.Read <string>(31))) { Flags |= CharacterFlags.Declined; } if (atLoginFlags.HasAnyFlag(AtLoginFlags.Customize)) { Flags2 = CharacterCustomizeFlags.Customize; } else if (atLoginFlags.HasAnyFlag(AtLoginFlags.ChangeFaction)) { Flags2 = CharacterCustomizeFlags.Faction; } else if (atLoginFlags.HasAnyFlag(AtLoginFlags.ChangeRace)) { Flags2 = CharacterCustomizeFlags.Race; } Flags3 = 0; Flags4 = 0; FirstLogin = atLoginFlags.HasAnyFlag(AtLoginFlags.FirstLogin); // show pet at selection character in character list only for non-ghost character if (!playerFlags.HasAnyFlag(PlayerFlags.Ghost) && (ClassId == Class.Warlock || ClassId == Class.Hunter || ClassId == Class.Deathknight)) { CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(fields.Read <uint>(22)); if (creatureInfo != null) { PetCreatureDisplayId = fields.Read <uint>(23); PetExperienceLevel = fields.Read <ushort>(24); PetCreatureFamilyId = (uint)creatureInfo.Family; } } BoostInProgress = false; ProfessionIds[0] = 0; ProfessionIds[1] = 0; StringArguments equipment = new StringArguments(fields.Read <string>(25)); ListPosition = fields.Read <byte>(27); LastPlayedTime = fields.Read <uint>(28); var spec = Global.DB2Mgr.GetChrSpecializationByIndex(ClassId, fields.Read <byte>(29)); if (spec != null) { SpecID = (ushort)spec.Id; } LastLoginVersion = fields.Read <uint>(30); for (byte slot = 0; slot < InventorySlots.BagEnd; ++slot) { VisualItems[slot].InvType = (byte)equipment.NextUInt32(); VisualItems[slot].DisplayId = equipment.NextUInt32(); VisualItems[slot].DisplayEnchantId = equipment.NextUInt32(); VisualItems[slot].Subclass = (byte)equipment.NextUInt32(); } }
public static bool BuildEnumData(SQLResult result, ref PacketWriter data) { for (int c = 0; c < result.Count; c++) { ObjectGuid guid = new ObjectGuid(result.Read <ulong>(c, 0)); ObjectGuid guildGuid = new ObjectGuid();//result.Read<uint>(c, 13)); string name = result.Read <string>(c, 1); data.WriteBit(guid[7]); data.WriteBit(guid[0]); data.WriteBit(guid[4]); data.WriteBit(guildGuid[2]); data.WriteBit(guid[5]); data.WriteBit(guid[3]); data.WriteBits(name.Length, 7); data.WriteBit(guildGuid[0]); data.WriteBit(guildGuid[5]); data.WriteBit(guildGuid[3]); data.WriteBit(0); data.WriteBit(guildGuid[6]); data.WriteBit(guildGuid[7]); data.WriteBit(guid[1]); data.WriteBit(guildGuid[4]); data.WriteBit(guildGuid[1]); data.WriteBit(guid[2]); data.WriteBit(guid[6]); } data.WriteBit(1); data.BitFlush(); for (int c = 0; c < result.Count; c++) { ObjectGuid guid = new ObjectGuid(result.Read <ulong>(c, 0)); string name = result.Read <string>(c, 1); byte plrRace = result.Read <byte>(c, 2); Class plrClass = (Class)result.Read <byte>(c, 3); byte gender = result.Read <byte>(c, 4); byte skin = (byte)(result.Read <uint>(c, 5) & 0xFF); byte face = (byte)((result.Read <uint>(c, 5) >> 8) & 0xFF); byte hairStyle = (byte)((result.Read <uint>(c, 5) >> 16) & 0xFF); byte hairColor = (byte)((result.Read <uint>(c, 5) >> 24) & 0xFF); byte facialHair = (byte)(result.Read <uint>(c, 6) & 0xFF); byte level = result.Read <byte>(c, 7); uint zone = result.Read <uint>(c, 8); uint mapId = result.Read <uint>(c, 9); float x = result.Read <float>(c, 10); float y = result.Read <float>(c, 11); float z = result.Read <float>(c, 12); ObjectGuid guildGuid = new ObjectGuid();//result.Read<ulong>(c, 13)); PlayerFlags playerFlags = (PlayerFlags)result.Read <uint>(c, 14); AtLoginFlags atLoginFlags = (AtLoginFlags)result.Read <uint>(c, 15); string[] equipment = result.Read <string>(c, 19).Split(' '); byte slot = result.Read <byte>(c, 21); CharacterFlags charFlags = 0; if (Convert.ToBoolean(playerFlags & PlayerFlags.HideHelm)) { charFlags |= CharacterFlags.HideHelm; } if (Convert.ToBoolean(playerFlags & PlayerFlags.HideCloak)) { charFlags |= CharacterFlags.HideCloak; } if (Convert.ToBoolean(playerFlags & PlayerFlags.Ghost)) { charFlags |= CharacterFlags.Ghost; } if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Rename)) { charFlags |= CharacterFlags.Rename; } //if (result.Read<uint>(c, 20) != 0) //charFlags |= CharacterFlags.LockedByBilling; //if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED) && !fields[22].GetString().empty()) //charFlags |= CHARACTER_FLAG_DECLINED; CharacterCustomizeFlags customizationFlag = 0; if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.Customize)) { customizationFlag = CharacterCustomizeFlags.Customize; } else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeFaction)) { customizationFlag = CharacterCustomizeFlags.Faction; } else if (Convert.ToBoolean(atLoginFlags & AtLoginFlags.ChangeRace)) { customizationFlag = CharacterCustomizeFlags.Race; } uint petDisplayId = 0; uint petLevel = 0; uint petFamily = 0; // show pet at selection character in character list only for non-ghost character if (!Convert.ToBoolean(playerFlags & PlayerFlags.Ghost) && (plrClass == Class.Warlock || plrClass == Class.Hunter || plrClass == Class.Deathknight)) { //uint entry = result.Read<uint>(c, 16); //var creatureInfo = ObjMgr.GetCreatureTemplate(entry); //if (creatureInfo != null) { //petDisplayId = result.Read<uint>(c, 17); //petLevel = result.Read<uint>(c, 18); //petFamily = creatureInfo.Family; } } data.WriteUInt32(charFlags); data.WriteUInt32(petFamily); data.WriteFloat(z); data.WriteByteSeq(guid[7]); data.WriteByteSeq(guildGuid[6]); for (uint i = 0; i < InventorySlots.BagEnd; ++i) { uint index = i * 2; uint itemId; uint.TryParse(equipment[index], out itemId); var entry = ObjMgr.GetItemTemplate(itemId); if (entry == null) { data.WriteInt32(0); data.WriteInt8(0); data.WriteInt32(0); continue; } uint enchants; SpellItemEnchantmentEntry enchant = null; uint.TryParse(equipment[index + 1], out enchants); for (int enchantSlot = (int)EnchantmentSlot.PERM_ENCHANTMENT_SLOT; enchantSlot <= (int)EnchantmentSlot.TEMP_ENCHANTMENT_SLOT; enchantSlot++) { // values stored in 2 uint16 uint enchantId = 0x0000FFFF & (enchants >> enchantSlot * 16); if (enchantId == 0) { continue; } enchant = DBCStorage.SpellItemEnchantmentStorage.LookupByKey(enchantId); if (enchant != null) { break; } } data.WriteInt32(0);//enchant != null ? enchant.aura_id : 0); data.WriteInt8(entry.inventoryType); data.WriteInt32(entry.DisplayInfoID); } data.WriteFloat(x); data.WriteUInt8(plrClass); data.WriteByteSeq(guid[5]); data.WriteFloat(y); data.WriteByteSeq(guildGuid[3]); data.WriteByteSeq(guid[6]); data.WriteUInt32(petLevel); data.WriteUInt32(petDisplayId); data.WriteByteSeq(guid[2]); data.WriteByteSeq(guid[1]); data.WriteUInt8(hairColor); data.WriteUInt8(facialHair); data.WriteByteSeq(guildGuid[2]); data.WriteUInt32(zone); data.WriteUInt8(slot); // List order data.WriteByteSeq(guid[0]); data.WriteByteSeq(guildGuid[1]); data.WriteUInt8(skin); data.WriteByteSeq(guid[4]); data.WriteByteSeq(guildGuid[5]); data.WriteString(name); data.WriteByteSeq(guildGuid[0]); data.WriteUInt8(level); data.WriteByteSeq(guid[3]); data.WriteByteSeq(guildGuid[7]); data.WriteUInt8(hairStyle); data.WriteByteSeq(guildGuid[4]); data.WriteUInt8(gender); data.WriteUInt32(mapId); data.WriteUInt32((uint)customizationFlag); data.WriteUInt8(plrRace); data.WriteUInt8(face); } return(true); }