public void On_CMSG_CHAR_ENUM(PacketClass packet, ClientClass client) { _clusterServiceLocator.WorldCluster.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_CHAR_ENUM", client.IP, client.Port); // DONE: Query _WorldCluster.CHARACTERs DB var response = new PacketClass(Opcodes.SMSG_CHAR_ENUM); var mySqlQuery = new DataTable(); int accountId; try { _clusterServiceLocator.WorldCluster.GetAccountDatabase().Query(string.Format("SELECT id FROM account WHERE username = '******';", client.Account), ref mySqlQuery); accountId = mySqlQuery.Rows[0].As <int>("id"); mySqlQuery.Clear(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT * FROM characters WHERE account_id = '{0}' ORDER BY char_guid;", accountId), ref mySqlQuery); // DONE: Make The Packet response.AddInt8((byte)mySqlQuery.Rows.Count); for (int i = 0, loopTo = mySqlQuery.Rows.Count - 1; i <= loopTo; i++) { var dead = false; var deadMySqlQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT COUNT(*) FROM corpse WHERE player = {0};", mySqlQuery.Rows[i]["char_guid"]), ref deadMySqlQuery); if (deadMySqlQuery.Rows[0].As <int>(0) > 0) { dead = true; } var petQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT modelid, level, entry FROM character_pet WHERE owner = '{0}';", mySqlQuery.Rows[i]["char_guid"]), ref petQuery); response.AddInt64(mySqlQuery.Rows[i].As <long>("char_guid")); response.AddString(mySqlQuery.Rows[i].As <string>("char_name")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_race")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_class")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_gender")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_skin")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_face")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_hairStyle")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_hairColor")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_facialHair")); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_level")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_zone_id")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_map_id")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionX")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionY")); response.AddSingle(mySqlQuery.Rows[i].As <float>("char_positionZ")); response.AddInt32(mySqlQuery.Rows[i].As <int>("char_guildId")); var playerState = (uint)CharacterFlagState.CHARACTER_FLAG_NONE; var forceRestrictions = mySqlQuery.Rows[i].As <uint>("force_restrictions"); if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_TRANSFER) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_LOCKED_FOR_TRANSFER; } if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_BILLING) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_LOCKED_BY_BILLING; } if ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_RENAME) != 0) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_RENAME; } if (dead) { playerState += (uint)CharacterFlagState.CHARACTER_FLAG_GHOST; } response.AddUInt32(playerState); response.AddInt8(mySqlQuery.Rows[i].As <byte>("char_restState")); var petModel = 0; var petLevel = 0; var petFamily = 0; if (petQuery.Rows.Count > 0) { petModel = petQuery.Rows[0].As <int>("modelid"); petLevel = petQuery.Rows[0].As <int>("level"); var petFamilyQuery = new DataTable(); _clusterServiceLocator.WorldCluster.GetWorldDatabase().Query(string.Format("SELECT family FROM creature_template WHERE entry = '{0}'", petQuery.Rows[0]["entry"]), ref petFamilyQuery); petFamily = petFamilyQuery.Rows[0].As <int>("family"); } response.AddInt32(petModel); response.AddInt32(petLevel); response.AddInt32(petFamily); // DONE: Get items var guid = mySqlQuery.Rows[i].As <long>("char_guid"); var itemsMySqlQuery = new DataTable(); var characterDb = _clusterServiceLocator.WorldCluster.GetCharacterDatabase().SQLDBName; var worldDb = _clusterServiceLocator.WorldCluster.GetWorldDatabase().SQLDBName; _clusterServiceLocator.WorldCluster.GetCharacterDatabase().Query(string.Format("SELECT item_slot, displayid, inventorytype FROM " + characterDb + ".characters_inventory, " + worldDb + ".item_template WHERE item_bag = {0} AND item_slot <> 255 AND entry = item_id ORDER BY item_slot;", guid), ref itemsMySqlQuery); var e = itemsMySqlQuery.Rows.GetEnumerator(); e.Reset(); e.MoveNext(); var row = (DataRow)e.Current; // DONE: Add model info for (byte slot = 0, loopTo1 = (byte)EquipmentSlots.EQUIPMENT_SLOT_END; slot <= loopTo1; slot++) // - 1 { if (row is null || row.As <int>("item_slot") != slot) { // No equiped item in this slot response.AddInt32(0); // Item Model response.AddInt8(0); // Item Slot } else { // DONE: Do not show helmet or cloak if (((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_HIDECLOAK) != 0) && (EquipmentSlots)row.As <byte>("item_slot") == EquipmentSlots.EQUIPMENT_SLOT_BACK || ((forceRestrictions & (uint)ForceRestrictionFlags.RESTRICT_HIDEHELM) != 0) && (EquipmentSlots)row.As <byte>("item_slot") == EquipmentSlots.EQUIPMENT_SLOT_HEAD) { response.AddInt32(0); // Item Model response.AddInt8(0); // Item Slot } else { response.AddInt32(row.As <int>("displayid")); // Item Model response.AddInt8(row.As <byte>("inventorytype")); } // Item Slot e.MoveNext(); row = (DataRow)e.Current; } }