public static void Process(ReceivablePacket packet) { // Server information. long objectId = packet.ReadLong(); CharacterDataHolder npcTemplate = NpcData.GetNpc(packet.ReadInt()); CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); characterData.SetCurrentHp(packet.ReadLong()); // Client information. characterData.SetName(npcTemplate.GetName()); characterData.SetRace(npcTemplate.GetRace()); characterData.SetHeight(npcTemplate.GetHeight()); characterData.SetBelly(npcTemplate.GetBelly());; characterData.SetHairType(npcTemplate.GetHairType()); characterData.SetHairColor(npcTemplate.GetHairColor()); characterData.SetSkinColor(npcTemplate.GetSkinColor()); characterData.SetEyeColor(npcTemplate.GetEyeColor()); characterData.SetHeadItem(npcTemplate.GetHeadItem()); characterData.SetChestItem(npcTemplate.GetChestItem()); characterData.SetLegsItem(npcTemplate.GetLegsItem()); characterData.SetHandsItem(npcTemplate.GetHandsItem()); characterData.SetFeetItem(npcTemplate.GetFeetItem()); characterData.SetLeftHandItem(npcTemplate.GetLeftHandItem()); characterData.SetRightHandItem(npcTemplate.GetRightHandItem()); characterData.SetMaxHp(npcTemplate.GetMaxHp()); characterData.SetTargetable(npcTemplate.IsTargetable()); WorldManager.Instance.UpdateObject(objectId, characterData); }
public static void Notify(ReceivablePacket packet) { long objectId = packet.ReadLong(); CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(packet.ReadString()); characterData.SetRace((byte)packet.ReadByte()); characterData.SetHeight(packet.ReadFloat()); characterData.SetBelly(packet.ReadFloat()); characterData.SetHairType((byte)packet.ReadByte()); characterData.SetHairColor(packet.ReadInt()); characterData.SetSkinColor(packet.ReadInt()); characterData.SetEyeColor(packet.ReadInt()); characterData.SetHeadItem(packet.ReadInt()); characterData.SetChestItem(packet.ReadInt()); characterData.SetLegsItem(packet.ReadInt()); characterData.SetHandsItem(packet.ReadInt()); characterData.SetFeetItem(packet.ReadInt()); characterData.SetLeftHandItem(packet.ReadInt()); characterData.SetRightHandItem(packet.ReadInt()); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); WorldManager.Instance.UpdateObject(objectId, characterData); }
public CharacterSelectionInfoResult(string accountName) { // Local data. List <CharacterDataHolder> characterList = new List <CharacterDataHolder>(); // Get data from database. try { MySqlConnection con = DatabaseManager.GetConnection(); MySqlCommand cmd = new MySqlCommand(CHARACTER_QUERY, con); cmd.Parameters.AddWithValue("account", accountName); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(reader.GetString("name")); characterData.SetSlot((byte)reader.GetInt16("slot")); // TODO: Remove cast? characterData.SetSelected(reader.GetBoolean("selected")); characterData.SetClassId((byte)reader.GetInt16("class_id")); // TODO: Remove cast? characterData.SetLocationName(reader.GetString("location_name")); characterData.SetX(reader.GetFloat("x")); characterData.SetY(reader.GetFloat("y")); characterData.SetZ(reader.GetFloat("z")); characterData.SetHeading(reader.GetFloat("heading")); characterData.SetExperience(reader.GetInt64("experience")); characterData.SetHp(reader.GetInt64("hp")); characterData.SetMp(reader.GetInt64("mp")); characterData.SetAccessLevel((byte)reader.GetInt16("access_level")); // TODO: Remove cast? characterList.Add(characterData); } con.Close(); } catch (Exception e) { LogManager.Log(e.ToString()); } // Send the data. WriteShort(2); // Packet id. WriteByte(characterList.Count); foreach (CharacterDataHolder characterData in characterList) { WriteString(characterData.GetName()); WriteByte(characterData.GetSlot()); WriteByte(characterData.IsSelected() ? 1 : 0); WriteByte(characterData.GetClassId()); WriteString(characterData.GetLocationName()); WriteFloat(characterData.GetX()); WriteFloat(characterData.GetY()); WriteFloat(characterData.GetZ()); WriteFloat(characterData.GetHeading()); WriteLong(characterData.GetExperience()); WriteLong(characterData.GetHp()); WriteLong(characterData.GetMp()); WriteByte(characterData.GetAccessLevel()); } }
public static void Notify(ReceivablePacket packet) { // Get player list size. int listSize = packet.ReadByte(); // Read the data. List <CharacterDataHolder> characterList = new List <CharacterDataHolder>(listSize); for (int i = 0; i < listSize; i++) { CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(packet.ReadString()); characterData.SetSlot((byte)packet.ReadByte()); characterData.SetSelected(packet.ReadByte() == 1 ? true : false); characterData.SetRace((byte)packet.ReadByte()); characterData.SetHeight(packet.ReadFloat()); characterData.SetBelly(packet.ReadFloat()); characterData.SetHairType(packet.ReadByte()); characterData.SetHairColor(packet.ReadInt()); characterData.SetSkinColor(packet.ReadInt()); characterData.SetEyeColor(packet.ReadInt()); characterData.SetHeadItem(packet.ReadInt()); characterData.SetChestItem(packet.ReadInt()); characterData.SetLegsItem(packet.ReadInt()); characterData.SetHandsItem(packet.ReadInt()); characterData.SetFeetItem(packet.ReadInt()); characterData.SetLeftHandItem(packet.ReadInt()); characterData.SetRightHandItem(packet.ReadInt()); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadFloat()); characterData.SetExperience(packet.ReadLong()); characterData.SetCurrentHp(packet.ReadLong()); characterData.SetMaxHp(packet.ReadLong()); characterData.SetCurrentMp(packet.ReadLong()); characterData.SetMaxMp(packet.ReadLong()); characterData.SetAccessLevel((byte)packet.ReadByte()); characterList.Add(characterData); } // Send the data. MainManager.Instance.SetCharacterList(characterList); // Enable player selection. CharacterSelectionManager.Instance.SetWaitingServer(false); }
public static void notify(ReceivablePacket packet) { // Get player list size. int listSize = packet.ReadByte(); // Read the data. ArrayList characterList = new ArrayList(listSize); for (int i = 0; i < listSize; i++) { CharacterDataHolder characterData = new CharacterDataHolder(); characterData.SetName(packet.ReadString()); characterData.SetSlot((byte)packet.ReadByte()); characterData.SetSelected(packet.ReadByte() == 1 ? true : false); characterData.SetClassId((byte)packet.ReadByte()); characterData.SetLocationName(packet.ReadString()); characterData.SetX(packet.ReadFloat()); characterData.SetY(packet.ReadFloat()); characterData.SetZ(packet.ReadFloat()); characterData.SetHeading(packet.ReadInt()); characterData.SetExperience(packet.ReadLong()); characterData.SetHp(packet.ReadLong()); characterData.SetMp(packet.ReadLong()); characterData.SetAccessLevel((byte)packet.ReadByte()); characterData.SetItemHead(packet.ReadInt()); characterData.SetItemChest(packet.ReadInt()); characterData.SetItemGloves(packet.ReadInt()); characterData.SetItemLegs(packet.ReadInt()); characterData.SetItemBoots(packet.ReadInt()); characterData.SetItemRightHand(packet.ReadInt()); characterData.SetItemLeftHand(packet.ReadInt()); characterList.Add(characterData); } // Send the data. PlayerManager.instance.characterList = characterList; // Enable player selection. CharacterSelectionManager.instance.waitingServer = false; }
private static readonly string VISIBLE_ITEMS_QUERY = "SELECT * FROM character_items WHERE owner=@owner AND slot_id>'0' AND slot_id<'8' ORDER BY slot_id ASC"; // Visible equipment slots are 1 to 7. public CharacterSelectionInfoResult(string accountName) { // Local data. List <CharacterDataHolder> characterList = new List <CharacterDataHolder>(); // Get data from database. try { MySqlConnection con = DatabaseManager.GetConnection(); MySqlCommand cmd = new MySqlCommand(CHARACTER_QUERY, con); cmd.Parameters.AddWithValue("account", accountName); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { CharacterDataHolder characterData = new CharacterDataHolder(); string name = reader.GetString("name"); characterData.SetName(name); characterData.SetSlot((byte)reader.GetInt16("slot")); // TODO: Remove cast? characterData.SetSelected(reader.GetBoolean("selected")); characterData.SetRace((byte)reader.GetInt16("race")); // TODO: Remove cast? characterData.SetHeight(reader.GetFloat("height")); characterData.SetBelly(reader.GetFloat("belly")); characterData.SetHairType((byte)reader.GetInt16("hair_type")); // TODO: Remove cast? characterData.SetHairColor(reader.GetInt32("hair_color")); characterData.SetSkinColor(reader.GetInt32("skin_color")); characterData.SetEyeColor(reader.GetInt32("eye_color")); characterData.SetX(reader.GetFloat("x")); characterData.SetY(reader.GetFloat("y")); characterData.SetZ(reader.GetFloat("z")); characterData.SetHeading(reader.GetFloat("heading")); characterData.SetExperience(reader.GetInt64("experience")); characterData.SetHp(reader.GetInt64("hp")); characterData.SetMp(reader.GetInt64("mp")); characterData.SetAccessLevel((byte)reader.GetInt16("access_level")); // TODO: Remove cast? // Also get items for this character. try { MySqlConnection con2 = DatabaseManager.GetConnection(); MySqlCommand cmd2 = new MySqlCommand(VISIBLE_ITEMS_QUERY, con2); cmd2.Parameters.AddWithValue("owner", name); MySqlDataReader reader2 = cmd2.ExecuteReader(); while (reader2.Read()) { int slotId = reader2.GetInt32("slot_id"); int itemId = reader2.GetInt32("item_id"); switch (slotId) { case 1: characterData.SetHeadItem(itemId); break; case 2: characterData.SetChestItem(itemId); break; case 3: characterData.SetLegsItem(itemId); break; case 4: characterData.SetHandsItem(itemId); break; case 5: characterData.SetFeetItem(itemId); break; case 6: characterData.SetLeftHandItem(itemId); break; case 7: characterData.SetRightHandItem(itemId); break; } } con2.Close(); } catch (Exception e) { LogManager.Log(e.ToString()); } // Add gathered data to character list. characterList.Add(characterData); } con.Close(); } catch (Exception e) { LogManager.Log(e.ToString()); } // Send the data. WriteShort(2); // Packet id. WriteByte(characterList.Count); foreach (CharacterDataHolder characterData in characterList) { WriteString(characterData.GetName()); WriteByte(characterData.GetSlot()); WriteByte(characterData.IsSelected() ? 1 : 0); WriteByte(characterData.GetRace()); WriteFloat(characterData.GetHeight()); WriteFloat(characterData.GetBelly()); WriteByte(characterData.GetHairType()); WriteInt(characterData.GetHairColor()); WriteInt(characterData.GetSkinColor()); WriteInt(characterData.GetEyeColor()); WriteInt(characterData.GetHeadItem()); WriteInt(characterData.GetChestItem()); WriteInt(characterData.GetLegsItem()); WriteInt(characterData.GetHandsItem()); WriteInt(characterData.GetFeetItem()); WriteInt(characterData.GetLeftHandItem()); WriteInt(characterData.GetRightHandItem()); WriteFloat(characterData.GetX()); WriteFloat(characterData.GetY()); WriteFloat(characterData.GetZ()); WriteFloat(characterData.GetHeading()); WriteLong(characterData.GetExperience()); WriteLong(characterData.GetHp()); WriteLong(characterData.GetMp()); WriteByte(characterData.GetAccessLevel()); } }