public Packets.PacketClass BuildPartyMemberStats(ref WS_PlayerData.CharacterObject objCharacter, uint flag) { Opcodes opCode = Opcodes.SMSG_PARTY_MEMBER_STATS; if (flag == 1015 || flag == 524279) { opCode = Opcodes.SMSG_PARTY_MEMBER_STATS_FULL; if (objCharacter.ManaType != 0) { flag |= 8u; } } Packets.PacketClass packet = new Packets.PacketClass(opCode); packet.AddPackGUID(objCharacter.GUID); packet.AddUInt32(flag); if ((flag & (true ? 1u : 0u)) != 0) { byte memberFlags = 1; if (objCharacter.isPvP) { memberFlags = (byte)(memberFlags | 2); } if (objCharacter.DEAD) { memberFlags = (byte)(memberFlags | 0x10); } packet.AddInt8(memberFlags); } checked { if ((flag & 2u) != 0) { packet.AddUInt16((ushort)objCharacter.Life.Current); } if ((flag & 4u) != 0) { packet.AddUInt16((ushort)objCharacter.Life.Maximum); } if ((flag & 8u) != 0) { packet.AddInt8((byte)objCharacter.ManaType); } if ((flag & 0x10u) != 0) { if (objCharacter.ManaType == ManaTypes.TYPE_RAGE) { packet.AddUInt16((ushort)objCharacter.Rage.Current); } else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY) { packet.AddUInt16((ushort)objCharacter.Energy.Current); } else { packet.AddUInt16((ushort)objCharacter.Mana.Current); } } if ((flag & 0x20u) != 0) { if (objCharacter.ManaType == ManaTypes.TYPE_RAGE) { packet.AddUInt16((ushort)objCharacter.Rage.Maximum); } else if (objCharacter.ManaType == ManaTypes.TYPE_ENERGY) { packet.AddUInt16((ushort)objCharacter.Energy.Maximum); } else { packet.AddUInt16((ushort)objCharacter.Mana.Maximum); } } if ((flag & 0x40u) != 0) { packet.AddUInt16(objCharacter.Level); } if ((flag & 0x80u) != 0) { packet.AddUInt16((ushort)objCharacter.ZoneID); } if ((flag & 0x100u) != 0) { packet.AddInt16((short)objCharacter.positionX); packet.AddInt16((short)objCharacter.positionY); } if ((flag & 0x200u) != 0) { ulong auraMask2 = 0uL; int auraPos2 = packet.Data.Length; packet.AddUInt64(0uL); int num = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1; for (int j = 0; j <= num; j++) { if (objCharacter.ActiveSpells[j] != null) { unchecked { auraMask2 |= (ulong)(1L << checked ((int)(ulong)j)); } packet.AddUInt16((ushort)objCharacter.ActiveSpells[j].SpellID); packet.AddInt8(1); } } packet.AddUInt64(auraMask2, auraPos2); } if ((flag & 0x400u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt64(objCharacter.Pet.GUID); } else { packet.AddInt64(0L); } } if ((flag & 0x800u) != 0) { if (objCharacter.Pet != null) { packet.AddString(objCharacter.Pet.PetName); } else { packet.AddString(""); } } if ((flag & 0x1000u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt16((ushort)objCharacter.Pet.Model); } else { packet.AddInt16(0); } } if ((flag & 0x2000u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt16((ushort)objCharacter.Pet.Life.Current); } else { packet.AddInt16(0); } } if ((flag & 0x4000u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt16((ushort)objCharacter.Pet.Life.Maximum); } else { packet.AddInt16(0); } } if ((flag & 0x8000u) != 0) { if (objCharacter.Pet != null) { packet.AddInt8(2); } else { packet.AddInt8(0); } } if ((flag & 0x10000u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt16((ushort)objCharacter.Pet.Mana.Current); } else { packet.AddInt16(0); } } if ((flag & 0x20000u) != 0) { if (objCharacter.Pet != null) { packet.AddUInt16((ushort)objCharacter.Pet.Mana.Maximum); } else { packet.AddInt16(0); } } if ((flag & 0x40000u) != 0) { if (objCharacter.Pet != null) { ulong auraMask = 0uL; int auraPos = packet.Data.Length; packet.AddUInt64(0uL); int num2 = WorldServiceLocator._Global_Constants.MAX_AURA_EFFECTs_VISIBLE - 1; for (int i = 0; i <= num2; i++) { if (objCharacter.Pet.ActiveSpells[i] != null) { unchecked { auraMask |= (ulong)(1L << checked ((int)(ulong)i)); } packet.AddUInt16((ushort)objCharacter.Pet.ActiveSpells[i].SpellID); packet.AddInt8(1); } } packet.AddUInt64(auraMask, auraPos); } else { packet.AddInt64(0L); } } return(packet); } }
public void On_CMSG_TEXT_EMOTE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { checked { if (packet.Data.Length - 1 < 21 && client.Character != null) { return; } packet.GetInt16(); int TextEmote = packet.GetInt32(); int Unk = packet.GetInt32(); ulong GUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TEXT_EMOTE [TextEmote={2} Unk={3}]", client.IP, client.Port, TextEmote, Unk); if (WorldServiceLocator._CommonGlobalFunctions.GuidIsCreature(GUID) && WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID)) { WS_Quests aLLQUESTS = WorldServiceLocator._WorldServer.ALLQUESTS; ref WS_PlayerData.CharacterObject character = ref client.Character; Dictionary <ulong, WS_Creatures.CreatureObject> wORLD_CREATUREs; ulong key; WS_Creatures.CreatureObject creature = (wORLD_CREATUREs = WorldServiceLocator._WorldServer.WORLD_CREATUREs)[key = GUID]; aLLQUESTS.OnQuestDoEmote(ref character, ref creature, TextEmote); wORLD_CREATUREs[key] = creature; if (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript != null && WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript is WS_Creatures_AI.GuardAI) { ((WS_Creatures_AI.GuardAI)WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript).OnEmote(TextEmote); } } if (WorldServiceLocator._WS_DBCDatabase.EmotesText.ContainsKey(TextEmote)) { if (WorldServiceLocator._WS_DBCDatabase.EmotesState[WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]] == 0) { client.Character.DoEmote(WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]); } else if (WorldServiceLocator._WS_DBCDatabase.EmotesState[WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]] == 2) { client.Character.cEmoteState = WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]; client.Character.SetUpdateFlag(148, client.Character.cEmoteState); client.Character.SendCharacterUpdate(); } } string secondName = ""; if (decimal.Compare(new decimal(GUID), 0m) > 0) { if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(GUID)) { secondName = WorldServiceLocator._WorldServer.CHARACTERs[GUID].Name; } else if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID)) { secondName = WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].Name; } } Packets.PacketClass SMSG_TEXT_EMOTE = new Packets.PacketClass(Opcodes.SMSG_TEXT_EMOTE); try { SMSG_TEXT_EMOTE.AddUInt64(client.Character.GUID); SMSG_TEXT_EMOTE.AddInt32(TextEmote); SMSG_TEXT_EMOTE.AddInt32(255); SMSG_TEXT_EMOTE.AddInt32(secondName.Length + 1); SMSG_TEXT_EMOTE.AddString(secondName); client.Character.SendToNearPlayers(ref SMSG_TEXT_EMOTE); } finally { SMSG_TEXT_EMOTE.Dispose(); } }
public void On_CMSG_NAME_QUERY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { try { if (checked (packet.Data.Length - 1) < 13) { return; } packet.GetInt16(); ulong GUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_NAME_QUERY [GUID={2:X}]", client.IP, client.Port, GUID); Packets.PacketClass SMSG_NAME_QUERY_RESPONSE = new Packets.PacketClass(Opcodes.SMSG_NAME_QUERY_RESPONSE); if (GUID == int.MaxValue) { try { SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID); SMSG_NAME_QUERY_RESPONSE.AddString("System"); SMSG_NAME_QUERY_RESPONSE.AddInt32(1); SMSG_NAME_QUERY_RESPONSE.AddInt32(1); SMSG_NAME_QUERY_RESPONSE.AddInt32(1); client.Send(ref SMSG_NAME_QUERY_RESPONSE); } finally { SMSG_NAME_QUERY_RESPONSE.Dispose(); } } else if (WorldServiceLocator._CommonGlobalFunctions.GuidIsPlayer(GUID)) { if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(GUID)) { try { SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID); SMSG_NAME_QUERY_RESPONSE.AddString(WorldServiceLocator._WorldServer.CHARACTERs[GUID].Name); SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Race); SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Gender); SMSG_NAME_QUERY_RESPONSE.AddInt32((int)WorldServiceLocator._WorldServer.CHARACTERs[GUID].Classe); client.Send(ref SMSG_NAME_QUERY_RESPONSE); } finally { SMSG_NAME_QUERY_RESPONSE.Dispose(); } return; } DataTable MySQLQuery = new DataTable(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name, char_race, char_class, char_gender FROM characters WHERE char_guid = \"{GUID}\";", ref MySQLQuery); if (MySQLQuery.Rows.Count > 0) { try { SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID); SMSG_NAME_QUERY_RESPONSE.AddString(MySQLQuery.Rows[0].As <string>("char_name")); SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_race")); SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_gender")); SMSG_NAME_QUERY_RESPONSE.AddInt32(MySQLQuery.Rows[0].As <int>("char_class")); client.Send(ref SMSG_NAME_QUERY_RESPONSE); } finally { SMSG_NAME_QUERY_RESPONSE.Dispose(); } } else { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_NAME_QUERY_RESPONSE [Character GUID={2:X} not found]", client.IP, client.Port, GUID); } MySQLQuery.Dispose(); } else { if (!WorldServiceLocator._CommonGlobalFunctions.GuidIsCreature(GUID)) { return; } if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID)) { try { SMSG_NAME_QUERY_RESPONSE.AddUInt64(GUID); SMSG_NAME_QUERY_RESPONSE.AddString(WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].Name); SMSG_NAME_QUERY_RESPONSE.AddInt32(0); SMSG_NAME_QUERY_RESPONSE.AddInt32(0); SMSG_NAME_QUERY_RESPONSE.AddInt32(0); client.Send(ref SMSG_NAME_QUERY_RESPONSE); } finally { SMSG_NAME_QUERY_RESPONSE.Dispose(); } } else { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_NAME_QUERY_RESPONSE [Creature GUID={2:X} not found]", client.IP, client.Port, GUID); } } } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception e = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error at name query.{0}", Environment.NewLine + e); ProjectData.ClearProjectError(); } }
public void On_CMSG_GET_MAIL_LIST(ref Packets.PacketClass packet, ref WS_Network.ClientClass client) { checked { if (packet.Data.Length - 1 < 13) { return; } packet.GetInt16(); ulong GameObjectGUID = packet.GetUInt64(); WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_GET_MAIL_LIST [GUID={2:X}]", client.IP, client.Port, GameObjectGUID); try { DataTable MySQLQuery = new DataTable(); WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT mail_id FROM characters_mail WHERE mail_time < {WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)};", ref MySQLQuery); if (MySQLQuery.Rows.Count > 0) { byte b = (byte)(MySQLQuery.Rows.Count - 1); byte j = 0; while (j <= (uint)b) { WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("DELETE FROM characters_mail WHERE mail_id = {0};", RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[j]["mail_id"]))); j = (byte)unchecked ((uint)(j + 1)); } } WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT * FROM characters_mail WHERE mail_receiver = {client.Character.GUID};", ref MySQLQuery); Packets.PacketClass response = new Packets.PacketClass(Opcodes.SMSG_MAIL_LIST_RESULT); response.AddInt8((byte)MySQLQuery.Rows.Count); if (MySQLQuery.Rows.Count > 0) { byte b2 = (byte)(MySQLQuery.Rows.Count - 1); byte i = 0; while (i <= (uint)b2) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id")); response.AddInt8(MySQLQuery.Rows[i].As <byte>("mail_type")); object left = MySQLQuery.Rows[i]["mail_type"]; if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.NORMAL, TextCompare: false)) { response.AddUInt64(MySQLQuery.Rows[i].As <ulong>("mail_sender")); } else if (Operators.ConditionalCompareObjectEqual(left, MailTypeInfo.AUCTION, TextCompare: false)) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_sender")); } response.AddString(MySQLQuery.Rows[i].As <string>("mail_subject")); if (Operators.ConditionalCompareObjectNotEqual(MySQLQuery.Rows[i]["mail_body"], "", TextCompare: false)) { response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_id")); } else { response.AddInt32(0); } response.AddInt32(0); response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_stationary")); if (decimal.Compare(new decimal(MySQLQuery.Rows[i].As <ulong>("item_guid")), 0m) > 0) { ItemObject tmpItem = WorldServiceLocator._WS_Items.LoadItemByGUID(MySQLQuery.Rows[i].As <ulong>("item_guid")); response.AddInt32(tmpItem.ItemEntry); if (tmpItem.Enchantments.ContainsKey(0)) { packet.AddInt32(tmpItem.Enchantments[0].ID); } else { packet.AddInt32(0); } response.AddInt32(tmpItem.RandomProperties); response.AddInt32(0); response.AddInt8((byte)tmpItem.StackCount); response.AddInt32(tmpItem.ChargesLeft); response.AddInt32(tmpItem.ItemInfo.Durability); response.AddInt32(tmpItem.Durability); } else { response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); response.AddInt8(0); response.AddInt32(0); response.AddInt32(0); response.AddInt32(0); } response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_money")); response.AddUInt32(MySQLQuery.Rows[i].As <uint>("mail_COD")); response.AddInt32(MySQLQuery.Rows[i].As <int>("mail_read")); response.AddSingle((float)((MySQLQuery.Rows[i].As <uint>("mail_time") - WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now)) / 86400.0)); response.AddInt32(0); i = (byte)unchecked ((uint)(i + 1)); } } client.Send(ref response); response.Dispose(); } catch (Exception ex) { ProjectData.SetProjectError(ex); Exception e = ex; WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error getting mail list: {0}{1}", Environment.NewLine, e.ToString()); ProjectData.ClearProjectError(); } } }