Beispiel #1
0
 public void On_MSG_TABARDVENDOR_ACTIVATE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 13)
     {
         packet.GetInt16();
         var GUID = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_TABARDVENDOR_ACTIVATE [GUID={2}]", client.IP, client.Port, GUID);
         SendTabardActivate(ref client.Character, GUID);
     }
 }
Beispiel #2
0
 public void On_CMSG_PETITION_SHOWLIST(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 13)
     {
         packet.GetInt16();
         ulong GUID = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_SHOWLIST [GUID={2:X}]", client.IP, client.Port, GUID);
         SendPetitionActivate(ref client.Character, GUID);
     }
 }
Beispiel #3
0
        public void On_CMSG_SET_ACTIONBAR_TOGGLES(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
        {
            packet.GetInt16();
            byte ActionBar = packet.GetInt8();

            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTIONBAR_TOGGLES [{2:X}]", client.IP, client.Port, ActionBar);
            client.Character.cPlayerFieldBytes = (client.Character.cPlayerFieldBytes & -983041) | (byte)(ActionBar << (0x10 & 7));
            client.Character.SetUpdateFlag(1222, client.Character.cPlayerFieldBytes);
            client.Character.SendCharacterUpdate();
        }
Beispiel #4
0
 public void On_CMSG_TURN_IN_PETITION(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 13)
     {
         packet.GetInt16();
         var itemGuid = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TURN_IN_PETITION [GUID={2:X}]", client.IP, client.Port, itemGuid);
         client.Character.ItemREMOVE(itemGuid, Destroy: true, Update: true);
     }
 }
Beispiel #5
0
 public void On_CMSG_PETITION_QUERY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 17)
         {
             return;
         }
         packet.GetInt16();
         int   PetitionGUID = packet.GetInt32();
         ulong itemGuid     = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_QUERY [pGUID={3} iGUID={2:X}]", client.IP, client.Port, itemGuid, PetitionGUID);
         DataTable MySQLQuery = new();
         WorldServiceLocator._WorldServer.CharacterDatabase.Query("SELECT * FROM petitions WHERE petition_itemGuid = " + Conversions.ToString(itemGuid - WorldServiceLocator._Global_Constants.GUID_ITEM) + ";", ref MySQLQuery);
         if (MySQLQuery.Rows.Count != 0)
         {
             Packets.PacketClass response = new(Opcodes.SMSG_PETITION_QUERY_RESPONSE);
             response.AddInt32(MySQLQuery.Rows[0].As <int>("petition_id"));
             response.AddUInt64(MySQLQuery.Rows[0].As <ulong>("petition_owner"));
             response.AddString(MySQLQuery.Rows[0].As <string>("petition_name"));
             response.AddInt8(0);
             if (MySQLQuery.Rows[0].As <byte>("petition_type") == 9)
             {
                 response.AddInt32(9);
                 response.AddInt32(9);
                 response.AddInt32(0);
             }
             else
             {
                 response.AddInt32(MySQLQuery.Rows[0].As <byte>("petition_type") - 1);
                 response.AddInt32(MySQLQuery.Rows[0].As <byte>("petition_type") - 1);
                 response.AddInt32(MySQLQuery.Rows[0].As <byte>("petition_type"));
             }
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt16(0);
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt32(0);
             response.AddInt32(0);
             if (MySQLQuery.Rows[0].As <byte>("petition_type") == 9)
             {
                 response.AddInt32(0);
             }
             else
             {
                 response.AddInt32(1);
             }
             client.Send(ref response);
             response.Dispose();
         }
     }
 }
 public void On_CMSG_TAXIQUERYAVAILABLENODES(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 13)
     {
         packet.GetInt16();
         var guid = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TAXIQUERYAVAILABLENODES [taxiGUID={2:X}]", client.IP, client.Port, guid);
         if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(guid) && ((uint)WorldServiceLocator._WorldServer.WORLD_CREATUREs[guid].CreatureInfo.cNpcFlags & 8u) != 0)
         {
             SendTaxiMenu(ref client.Character, guid);
         }
     }
 }
 public void On_CMSG_TAXINODE_STATUS_QUERY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 13)
     {
         packet.GetInt16();
         var guid = packet.GetUInt64();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TAXINODE_STATUS_QUERY [taxiGUID={2:X}]", client.IP, client.Port, guid);
         if (WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(guid))
         {
             SendTaxiStatus(ref client.Character, guid);
         }
     }
 }
 public void On_CMSG_TUTORIAL_FLAG(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 >= 9)
         {
             packet.GetInt16();
             var Flag = packet.GetInt32();
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_TUTORIAL_FLAG [flag={2}]", client.IP, client.Port, Flag);
             client.Character.TutorialFlags[Flag / 8] = (byte)(client.Character.TutorialFlags[Flag / 8] + (1 << (7 - (Flag % 8))));
             client.Character.SaveCharacter();
         }
     }
 }
 public void On_CMSG_WORLD_TELEPORT(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_WORLD_TELEPORT", client.IP, client.Port);
     if (client.Access >= AccessLevel.GameMaster)
     {
         packet.GetInt16();
         int   Time = packet.GetInt32();
         uint  Map  = packet.GetUInt32();
         float X    = packet.GetFloat();
         float Y    = packet.GetFloat();
         float Z    = packet.GetFloat();
         float O    = packet.GetFloat();
         client.Character.Teleport(X, Y, Z, O, checked ((int)Map));
     }
 }
Beispiel #10
0
 public void On_CMSG_MAIL_MARK_AS_READ(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 >= 17)
         {
             packet.GetInt16();
             var GameObjectGUID = packet.GetUInt64();
             var MailID         = packet.GetInt32();
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_MARK_AS_READ [MailID={2}]", client.IP, client.Port, MailID);
             var MailTime = (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) + 259200L);
             WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("UPDATE characters_mail SET mail_read = 1, mail_time = {1} WHERE mail_id = {0} AND mail_read < 2;", MailID, MailTime));
         }
     }
 }
Beispiel #11
0
 public void On_CMSG_MAIL_DELETE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 17)
     {
         packet.GetInt16();
         var GameObjectGUID = packet.GetUInt64();
         var MailID         = packet.GetInt32();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_DELETE [MailID={2}]", client.IP, client.Port, MailID);
         WorldServiceLocator._WorldServer.CharacterDatabase.Update($"DELETE FROM characters_mail WHERE mail_id = {MailID};");
         Packets.PacketClass response = new(Opcodes.SMSG_SEND_MAIL_RESULT);
         response.AddInt32(MailID);
         response.AddInt32(4);
         response.AddInt32(0);
         client.Send(ref response);
         response.Dispose();
     }
 }
Beispiel #12
0
    public void On_CMSG_CLEAR_TRADE_ITEM(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        packet.GetInt16();
        var slot = packet.GetInt8();

        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_CLEAR_TRADE_ITEM [slot={2}]", client.IP, client.Port, slot);
        if (client.Character.tradeInfo.Trader == client.Character)
        {
            client.Character.tradeInfo.TraderSlots[slot] = -1;
            client.Character.tradeInfo.SendTradeUpdateToTarget();
        }
        else
        {
            client.Character.tradeInfo.TargetSlots[slot] = -1;
            client.Character.tradeInfo.SendTradeUpdateToTrader();
        }
    }
Beispiel #13
0
    public void On_CMSG_BATTLEMASTER_HELLO(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        if (checked (packet.Data.Length - 1) < 13)
        {
            return;
        }
        packet.GetInt16();
        var GUID = packet.GetUInt64();

        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_BATTLEMASTER_HELLO [{2:X}]", client.IP, client.Port, GUID);
        if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x800) == 0 || !WorldServiceLocator._WS_DBCDatabase.Battlemasters.ContainsKey(WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID))
        {
            return;
        }
        var BGType = WorldServiceLocator._WS_DBCDatabase.Battlemasters[WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].ID];

        if (!WorldServiceLocator._WS_DBCDatabase.Battlegrounds.ContainsKey(BGType))
        {
            return;
        }
        if (WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MinLevel > (uint)client.Character.Level || WorldServiceLocator._WS_DBCDatabase.Battlegrounds[BGType].MaxLevel < (uint)client.Character.Level)
        {
            WorldServiceLocator._Functions.SendMessageNotification(ref client, "You don't meet Battleground level requirements");
            return;
        }
        Packets.PacketClass response = new(Opcodes.SMSG_BATTLEFIELD_LIST);
        try
        {
            response.AddUInt64(client.Character.GUID);
            response.AddInt32(BGType);
            response.AddInt8(0);
            var Battlegrounds = WorldServiceLocator._WorldServer.ClsWorldServer.Cluster.BattlefieldList(BGType);
            response.AddInt32(Battlegrounds.Count);
            foreach (var Instance in Battlegrounds)
            {
                response.AddInt32(Instance);
            }
            client.Send(ref response);
        }
        finally
        {
            response.Dispose();
        }
    }
Beispiel #14
0
 public void On_CMSG_OFFER_PETITION(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 21)
     {
         packet.GetInt16();
         int   PetitionType = packet.GetInt32();
         ulong itemGuid     = packet.GetUInt64();
         ulong GUID         = packet.GetUInt64();
         if (WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(GUID) && WorldServiceLocator._WorldServer.CHARACTERs[GUID].IsHorde == client.Character.IsHorde)
         {
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_OFFER_PETITION [GUID={2:X} Petition={3}]", client.IP, client.Port, GUID, itemGuid);
             Dictionary <ulong, WS_PlayerData.CharacterObject> cHARACTERs;
             ulong key;
             WS_PlayerData.CharacterObject objCharacter = (cHARACTERs = WorldServiceLocator._WorldServer.CHARACTERs)[key = GUID];
             SendPetitionSignatures(ref objCharacter, itemGuid);
             cHARACTERs[key] = objCharacter;
         }
     }
 }
Beispiel #15
0
 public void On_CMSG_EMOTE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     if (checked (packet.Data.Length - 1) >= 9)
     {
         packet.GetInt16();
         var emoteID = packet.GetInt32();
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_EMOTE [{2}]", client.IP, client.Port, emoteID);
         Packets.PacketClass response = new(Opcodes.SMSG_EMOTE);
         try
         {
             response.AddInt32(emoteID);
             response.AddUInt64(client.Character.GUID);
             client.Character.SendToNearPlayers(ref response);
         }
         finally
         {
             response.Dispose();
         }
     }
 }
Beispiel #16
0
    public void On_CMSG_SET_TRADE_GOLD(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        packet.GetInt16();
        var gold = packet.GetUInt32();

        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_TRADE_GOLD [gold={2}]", client.IP, client.Port, gold);
        if (client.Character.tradeInfo != null)
        {
            if (client.Character.tradeInfo.Trader == client.Character)
            {
                client.Character.tradeInfo.TraderGold = gold;
                client.Character.tradeInfo.SendTradeUpdateToTarget();
            }
            else
            {
                client.Character.tradeInfo.TargetGold = gold;
                client.Character.tradeInfo.SendTradeUpdateToTrader();
            }
        }
    }
Beispiel #17
0
 public void On_MSG_PETITION_RENAME(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 >= 14)
         {
             packet.GetInt16();
             ulong  itemGuid = packet.GetUInt64();
             string NewName  = packet.GetString();
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_PETITION_RENAME [NewName={3} GUID={2:X}]", client.IP, client.Port, itemGuid, NewName);
             WorldServiceLocator._WorldServer.CharacterDatabase.Update("UPDATE petitions SET petition_name = '" + NewName + "' WHERE petition_itemGuid = " + Conversions.ToString(itemGuid - WorldServiceLocator._Global_Constants.GUID_ITEM) + ";");
             Packets.PacketClass response = new(Opcodes.MSG_PETITION_RENAME);
             response.AddUInt64(itemGuid);
             response.AddString(NewName);
             response.AddInt32((int)(itemGuid - WorldServiceLocator._Global_Constants.GUID_ITEM));
             client.Send(ref response);
             response.Dispose();
         }
     }
 }
Beispiel #18
0
 public void On_MSG_PETITION_DECLINE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 >= 13)
         {
             packet.GetInt16();
             ulong itemGuid = packet.GetUInt64();
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_PETITION_DECLINE [GUID={2:X}]", client.IP, client.Port, itemGuid);
             DataTable q = new();
             WorldServiceLocator._WorldServer.CharacterDatabase.Query("SELECT petition_owner FROM petitions WHERE petition_itemGuid = " + Conversions.ToString(itemGuid - WorldServiceLocator._Global_Constants.GUID_ITEM) + " LIMIT 1;", ref q);
             Packets.PacketClass response = new(Opcodes.MSG_PETITION_DECLINE);
             response.AddUInt64(client.Character.GUID);
             if (q.Rows.Count > 0 && WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(q.Rows[0].As <ulong>("petition_owner")))
             {
                 WorldServiceLocator._WorldServer.CHARACTERs[q.Rows[0].As <ulong>("petition_owner")].client.SendMultiplyPackets(ref response);
             }
             response.Dispose();
         }
     }
 }
Beispiel #19
0
 public void On_CMSG_MAIL_RETURN_TO_SENDER(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 >= 17)
         {
             packet.GetInt16();
             var GameObjectGUID = packet.GetUInt64();
             var MailID         = packet.GetInt32();
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_RETURN_TO_SENDER [MailID={2}]", client.IP, client.Port, MailID);
             var MailTime = (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) + 2592000L);
             WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("UPDATE characters_mail SET mail_time = {1}, mail_read = 0, mail_receiver = (mail_receiver + mail_sender), mail_sender = (mail_receiver - mail_sender), mail_receiver = (mail_receiver - mail_sender) WHERE mail_id = {0};", MailID, MailTime));
             Packets.PacketClass response = new(Opcodes.SMSG_SEND_MAIL_RESULT);
             response.AddInt32(MailID);
             response.AddInt32(3);
             response.AddInt32(0);
             client.Send(ref response);
             response.Dispose();
         }
     }
 }
Beispiel #20
0
    public void On_CMSG_SET_ACTION_BUTTON(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        if (checked (packet.Data.Length - 1) < 10)
        {
            return;
        }
        packet.GetInt16();
        var button     = packet.GetInt8();
        var action     = packet.GetUInt16();
        var actionMisc = packet.GetInt8();
        var actionType = packet.GetInt8();

        if (action == 0)
        {
            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] MSG_SET_ACTION_BUTTON [Remove action from button {2}]", client.IP, client.Port, button);
            client.Character.ActionButtons.Remove(button);
        }
        else
        {
            switch (actionType)
            {
            case 64:
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Macro {2} into button {3}]", client.IP, client.Port, action, button);
                break;

            case 128:
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Item {2} into button {3}]", client.IP, client.Port, action, button);
                break;

            default:
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_SET_ACTION_BUTTON [Added Action {2}:{4}:{5} into button {3}]", client.IP, client.Port, action, button, actionType, actionMisc);
                break;
            }
        }
        client.Character.ActionButtons[button] = new WS_PlayerHelper.TActionButton(action, actionType, actionMisc);
    }
Beispiel #21
0
    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();
            var 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(Opcodes.SMSG_NAME_QUERY_RESPONSE);
            switch (GUID)
            {
            case 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();
                }
                break;

            default:
                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();
                    WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT char_name, char_race, char_class, char_gender FROM characters WHERE char_guid = \"{GUID}\";", ref MySQLQuery);
                    switch (MySQLQuery.Rows.Count)
                    {
                    case > 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();
                        }
                        break;

                    default:
                        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] SMSG_NAME_QUERY_RESPONSE [Character GUID={2:X} not found]", client.IP, client.Port, GUID);
                        break;
                    }
                    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);
                    }
                }

                break;
            }
        }
        catch (Exception e)
        {
            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "Error at name query.{0}", Environment.NewLine + e);
        }
    }
Beispiel #22
0
    public void On_CMSG_ACTIVATETAXI(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        if (checked (packet.Data.Length - 1) < 21)
        {
            return;
        }
        packet.GetInt16();
        var guid    = packet.GetUInt64();
        var srcNode = packet.GetInt32();
        var dstNode = packet.GetInt32();

        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_ACTIVATETAXI [taxiGUID={2:X} srcNode={3} dstNode={4}]", client.IP, client.Port, guid, srcNode, dstNode);
        if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(guid) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[guid].CreatureInfo.cNpcFlags & 8) == 0)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXINOVENDORNEARBY);
            return;
        }
        if (client.Character.LogoutTimer != null)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXIPLAYERBUSY);
            return;
        }
        if (((uint)client.Character.cUnitFlags & 4u) != 0)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXINOTSTANDING);
            return;
        }
        if ((int)client.Character.ShapeshiftForm > 0 && client.Character.ShapeshiftForm != ShapeshiftForm.FORM_BERSERKERSTANCE && client.Character.ShapeshiftForm != ShapeshiftForm.FORM_BATTLESTANCE && client.Character.ShapeshiftForm != ShapeshiftForm.FORM_DEFENSIVESTANCE && client.Character.ShapeshiftForm != ShapeshiftForm.FORM_SHADOW)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXIPLAYERSHAPESHIFTED);
            return;
        }
        if (client.Character.Mount != 0)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXIPLAYERALREADYMOUNTED);
            return;
        }
        if (!WorldServiceLocator._WS_DBCDatabase.TaxiNodes.ContainsKey(srcNode) || !WorldServiceLocator._WS_DBCDatabase.TaxiNodes.ContainsKey(dstNode))
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXINOSUCHPATH);
            return;
        }
        int mount;

        if (client.Character.IsHorde)
        {
            if (!WorldServiceLocator._WorldServer.CREATURESDatabase.ContainsKey(WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].HordeMount))
            {
                mount = new CreatureInfo(WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].HordeMount).GetFirstModel;
            }
            else
            {
                mount = WorldServiceLocator._WorldServer.CREATURESDatabase[WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].HordeMount].ModelA1;
            }
        }
        else if (!WorldServiceLocator._WorldServer.CREATURESDatabase.ContainsKey(WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].AllianceMount))
        {
            mount = new CreatureInfo(WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].AllianceMount).GetFirstModel;
        }
        else
        {
            mount = WorldServiceLocator._WorldServer.CREATURESDatabase[WorldServiceLocator._WS_DBCDatabase.TaxiNodes[srcNode].AllianceMount].ModelA2;
        }
        if (mount == 0)
        {
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXIUNSPECIFIEDSERVERERROR);
            return;
        }
        checked
        {
            int totalCost   = default;
            var discountMod = client.Character.GetDiscountMod(WorldServiceLocator._WorldServer.WORLD_CREATUREs[guid].Faction);
            foreach (var taxiPath in WorldServiceLocator._WS_DBCDatabase.TaxiPaths)
            {
                if (taxiPath.Value.TFrom == srcNode && taxiPath.Value.TTo == dstNode)
                {
                    totalCost = (int)Math.Round(totalCost + (taxiPath.Value.Price * discountMod));
                    break;
                }
            }
            if (client.Character.Copper < totalCost)
            {
                SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXINOTENOUGHMONEY);
                return;
            }
            ref var copper = ref client.Character.Copper;
            copper = (uint)(copper - totalCost);
            client.Character.TaxiNodes.Clear();
            client.Character.TaxiNodes.Enqueue(srcNode);
            client.Character.TaxiNodes.Enqueue(dstNode);
            SendActivateTaxiReply(ref client, ActivateTaxiReplies.ERR_TAXIOK);
            TaxiTake(client.Character, mount);
            TaxiMove(client.Character, discountMod);
        }
Beispiel #23
0
    public void On_CMSG_MAIL_TAKE_ITEM(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        checked
        {
            if (packet.Data.Length - 1 < 17)
            {
                return;
            }
            packet.GetInt16();
            var GameObjectGUID = packet.GetUInt64();
            var MailID         = packet.GetInt32();
            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MAIL_TAKE_ITEM [MailID={2}]", client.IP, client.Port, MailID);
            try
            {
                DataTable MySQLQuery = new();
                WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT mail_cod, mail_sender, item_guid FROM characters_mail WHERE mail_id = {MailID} AND mail_receiver = {client.Character.GUID};", ref MySQLQuery);
                if (MySQLQuery.Rows.Count == 0)
                {
                    Packets.PacketClass response4 = new(Opcodes.SMSG_SEND_MAIL_RESULT);
                    response4.AddInt32(MailID);
                    response4.AddInt32(2);
                    response4.AddInt32(6);
                    client.Send(ref response4);
                    response4.Dispose();
                    return;
                }
                if (!Operators.ConditionalCompareObjectNotEqual(MySQLQuery.Rows[0]["mail_cod"], 0, TextCompare: false))
                {
                    goto IL_02b9;
                }
                if (Operators.ConditionalCompareObjectLess(client.Character.Copper, MySQLQuery.Rows[0]["mail_cod"], TextCompare: false))
                {
                    Packets.PacketClass noMoney = new(Opcodes.SMSG_SEND_MAIL_RESULT);
                    noMoney.AddInt32(MailID);
                    noMoney.AddInt32(0);
                    noMoney.AddInt32(3);
                    client.Send(ref noMoney);
                    noMoney.Dispose();
                    return;
                }
                ref var copper = ref client.Character.Copper;
                copper = Conversions.ToUInteger(Operators.SubtractObject(copper, MySQLQuery.Rows[0]["mail_cod"]));
                WorldServiceLocator._WorldServer.CharacterDatabase.Update($"UPDATE characters_mail SET mail_cod = 0 WHERE mail_id = {MailID};");
                var MailTime = (int)(WorldServiceLocator._Functions.GetTimestamp(DateAndTime.Now) + 2592000L);
                WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("INSERT INTO characters_mail (mail_sender, mail_receiver, mail_subject, mail_body, mail_item_guid, mail_money, mail_COD, mail_time, mail_read, mail_type) VALUES \r\n                        ({0},{1},'{2}','{3}',{4},{5},{6},{7},{8},{9});", client.Character.GUID, MySQLQuery.Rows[0]["mail_sender"], "", "", 0, MySQLQuery.Rows[0]["mail_cod"], 0, MailTime, MailReadInfo.COD, 0));
IL_02b9:
                if (Operators.ConditionalCompareObjectEqual(MySQLQuery.Rows[0]["item_guid"], 0, TextCompare: false))
                {
                    Packets.PacketClass response3 = new(Opcodes.SMSG_SEND_MAIL_RESULT);
                    response3.AddInt32(MailID);
                    response3.AddInt32(2);
                    response3.AddInt32(6);
                    client.Send(ref response3);
                    response3.Dispose();
                    return;
                }
                var tmpItem = WorldServiceLocator._WS_Items.LoadItemByGUID(MySQLQuery.Rows[0].As <ulong>("item_guid"));
                tmpItem.OwnerGUID = client.Character.GUID;
                tmpItem.Save();
                if (client.Character.ItemADD(ref tmpItem))
                {
                    WorldServiceLocator._WorldServer.CharacterDatabase.Update($"UPDATE characters_mail SET item_guid = 0 WHERE mail_id = {MailID};");
                    WorldServiceLocator._WorldServer.CharacterDatabase.Update($"DELETE FROM mail_items WHERE mail_id = {MailID};");
                    Packets.PacketClass response2 = new(Opcodes.SMSG_SEND_MAIL_RESULT);
                    response2.AddInt32(MailID);
                    response2.AddInt32(2);
                    response2.AddInt32(0);
                    client.Send(ref response2);
                    response2.Dispose();
                }
                else
                {
                    tmpItem.Dispose();
                    Packets.PacketClass response = new(Opcodes.SMSG_SEND_MAIL_RESULT);
                    response.AddInt32(MailID);
                    response.AddInt32(2);
                    response.AddInt32(1);
                    client.Send(ref response);
                    response.Dispose();
                }
                client.Character.Save();
            }
Beispiel #24
0
 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();
         var 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();
             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)
             {
                 var  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(Opcodes.SMSG_MAIL_LIST_RESULT);
             response.AddInt8((byte)MySQLQuery.Rows.Count);
             if (MySQLQuery.Rows.Count > 0)
             {
                 var  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"));
                     var 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)
                     {
                         var 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);
             var e = ex;
             WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "Error getting mail list: {0}{1}", Environment.NewLine, e.ToString());
             ProjectData.ClearProjectError();
         }
     }
 }
Beispiel #25
0
        public void On_CMSG_WARDEN_DATA(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
        {
            byte[] b = new byte[checked (packet.Data.Length - 6 - 1 + 1)];
            Buffer.BlockCopy(packet.Data, 6, b, 0, b.Length);
            RC4.Crypt(ref b, client.Character.WardenData.KeyOut);
            Buffer.BlockCopy(b, 0, packet.Data, 6, b.Length);
            packet.GetInt16();
            MaievResponse Response = (MaievResponse)packet.GetInt8();

            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_WARDEN_DATA [{2}]", client.IP, client.Port, Response);
            if (!client.Character.WardenData.Ready)
            {
                return;
            }
            switch (Response)
            {
            case MaievResponse.MAIEV_RESPONSE_FAILED_OR_MISSING:
                MaievSendTransfer(ref client.Character);
                break;

            case MaievResponse.MAIEV_RESPONSE_SUCCESS:
                MaievSendSeed(ref client.Character);
                break;

            case MaievResponse.MAIEV_RESPONSE_RESULT:
                MaievResult(ref client.Character, ref packet);
                break;

            case MaievResponse.MAIEV_RESPONSE_HASH:
            {
                byte[] hash = new byte[20];
                Buffer.BlockCopy(packet.Data, packet.Offset, hash, 0, 20);
                WorldServiceLocator._WS_Warden.Maiev.GenerateNewRC4Keys(client.Character.WardenData.K);
                byte[] PacketData = new byte[17]
                {
                    5,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0
                };
                Buffer.BlockCopy(client.Character.WardenData.Seed, 0, PacketData, 1, 16);
                int HandledBytes = WorldServiceLocator._WS_Warden.Maiev.HandlePacket(PacketData);
                if (HandledBytes <= 0)
                {
                    WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "[WARDEN] Failed to handle 0x05 packet.");
                    break;
                }
                byte[] thePacket = WorldServiceLocator._WS_Warden.Maiev.ReadPacket();
                byte[] ourHash   = new byte[20];
                Array.Copy(thePacket, 1, ourHash, 0, ourHash.Length);
                WorldServiceLocator._WS_Warden.Maiev.ReadXorByte(ref client.Character);
                WorldServiceLocator._WS_Warden.Maiev.ReadKeys(ref client.Character);
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[WARDEN] XorByte: {0}", client.Character.WardenData.xorByte);
                bool HashCorrect = true;
                int  i           = 0;
                do
                {
                    if (hash[i] != ourHash[i])
                    {
                        HashCorrect = false;
                        break;
                    }
                    i = checked (i + 1);
                }while (i <= 19);
                if (!HashCorrect)
                {
                    WorldServiceLocator._WorldServer.Log.WriteLine(LogType.CRITICAL, "[WARDEN] Hashes in packet 0x05 didn't match. Cheater?");
                }
                break;
            }

            case (MaievResponse)3:
                break;

            default:
                break;
            }
        }
Beispiel #26
0
        public void On_CMSG_MESSAGECHAT(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
        {
            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MESSAGECHAT", client.IP, client.Port);
            if (checked (packet.Data.Length - 1) < 14 && client.Character != null)
            {
                return;
            }
            packet.GetInt16();
            ChatMsg   msgType     = (ChatMsg)packet.GetInt32();
            LANGUAGES msgLanguage = (LANGUAGES)packet.GetInt32();

            WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_MESSAGECHAT [{2}:{3}]", client.IP, client.Port, msgType, msgLanguage);
            if (client.Character.Spell_Language != (LANGUAGES)(-1))
            {
                msgLanguage = client.Character.Spell_Language;
            }
            switch (msgType)
            {
            case ChatMsg.CHAT_MSG_SAY:
            case ChatMsg.CHAT_MSG_YELL:
            case ChatMsg.CHAT_MSG_WHISPER:
            case ChatMsg.CHAT_MSG_EMOTE:
            {
                string Message3 = packet.GetString();
                if (Message3.StartsWith(WorldServiceLocator._ConfigurationProvider.GetConfiguration().CommandCharacter) && client.Character.Access > AccessLevel.Player)
                {
                    Message3 = Message3.Remove(0, 1);
                    Packets.PacketClass toCommand = WorldServiceLocator._Functions.BuildChatMessage(2147483647uL, Message3, ChatMsg.CHAT_MSG_SYSTEM, LANGUAGES.LANG_GLOBAL);
                    try
                    {
                        client.Send(ref toCommand);
                    }
                    finally
                    {
                        toCommand.Dispose();
                    }
                    WorldServiceLocator._WS_Commands.OnCommand(ref client, Message3);
                }
                else
                {
                    client.Character.SendChatMessage(ref client.Character, Message3, msgType, (int)msgLanguage, "", SendToMe: true);
                }
                break;
            }

            case ChatMsg.CHAT_MSG_AFK:
            {
                string Message = packet.GetString();
                if ((Operators.CompareString(Message, "", TextCompare: false) == 0 || !client.Character.AFK) && !client.Character.IsInCombat)
                {
                    client.Character.AFK = !client.Character.AFK;
                    if (client.Character.AFK && client.Character.DND)
                    {
                        client.Character.DND = false;
                    }
                    client.Character.SetUpdateFlag(190, (int)client.Character.cPlayerFlags);
                    client.Character.SendCharacterUpdate();
                }
                break;
            }

            case ChatMsg.CHAT_MSG_DND:
            {
                string Message2 = packet.GetString();
                if (Operators.CompareString(Message2, "", TextCompare: false) == 0 || !client.Character.DND)
                {
                    client.Character.DND = !client.Character.DND;
                    if (client.Character.DND && client.Character.AFK)
                    {
                        client.Character.AFK = false;
                    }
                    client.Character.SetUpdateFlag(190, (int)client.Character.cPlayerFlags);
                    client.Character.SendCharacterUpdate();
                }
                break;
            }

            case ChatMsg.CHAT_MSG_PARTY:
            case ChatMsg.CHAT_MSG_RAID:
            case ChatMsg.CHAT_MSG_CHANNEL:
            case ChatMsg.CHAT_MSG_RAID_LEADER:
            case ChatMsg.CHAT_MSG_RAID_WARNING:
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.WARNING, "This chat message type should not be here!");
                break;

            default:
                WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "[{0}:{1}] Unknown chat message [msgType={2}, msgLanguage={3}]", client.IP, client.Port, msgType, msgLanguage);
                WorldServiceLocator._Packets.DumpPacket(packet.Data, client);
                break;
            }
        }
Beispiel #27
0
    public void On_CMSG_INITIATE_TRADE(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
    {
        packet.GetInt16();
        var targetGUID = packet.GetUInt64();

        WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_INITIATE_TRADE [Trader={2} Target={3}]", client.IP, client.Port, client.Character.GUID, targetGUID);
        if (client.Character.DEAD)
        {
            Packets.PacketClass response6 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response6.AddInt32(17);
                client.Send(ref response6);
            }
            finally
            {
                response6.Dispose();
            }
            return;
        }
        if (client.Character.LogoutTimer != null)
        {
            Packets.PacketClass response8 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response8.AddInt32(19);
                client.Send(ref response8);
            }
            finally
            {
                response8.Dispose();
            }
            return;
        }
        if (((uint)client.Character.cUnitFlags & 0x40000u) != 0)
        {
            Packets.PacketClass response10 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response10.AddInt32(15);
                client.Send(ref response10);
            }
            finally
            {
                response10.Dispose();
            }
            return;
        }
        if (!WorldServiceLocator._WorldServer.CHARACTERs.ContainsKey(targetGUID))
        {
            Packets.PacketClass response12 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response12.AddInt32(6);
                client.Send(ref response12);
            }
            finally
            {
                response12.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].DEAD)
        {
            Packets.PacketClass response13 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response13.AddInt32(18);
                client.Send(ref response13);
            }
            finally
            {
                response13.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].LogoutTimer != null)
        {
            Packets.PacketClass response11 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response11.AddInt32(20);
                client.Send(ref response11);
            }
            finally
            {
                response11.Dispose();
            }
            return;
        }
        if (((uint)WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].cUnitFlags & 0x40000u) != 0)
        {
            Packets.PacketClass response9 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response9.AddInt32(15);
                client.Send(ref response9);
            }
            finally
            {
                response9.Dispose();
            }
            return;
        }
        if (client.Character.tradeInfo != null)
        {
            Packets.PacketClass response7 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response7.AddInt32(0);
                client.Send(ref response7);
            }
            finally
            {
                response7.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].tradeInfo != null)
        {
            Packets.PacketClass response5 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response5.AddInt32(5);
                client.Send(ref response5);
            }
            finally
            {
                response5.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].IsHorde != client.Character.IsHorde)
        {
            Packets.PacketClass response4 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response4.AddInt32(11);
                client.Send(ref response4);
            }
            finally
            {
                response4.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WS_Combat.GetDistance(client.Character, WorldServiceLocator._WorldServer.CHARACTERs[targetGUID]) > 30f)
        {
            Packets.PacketClass response3 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response3.AddInt32(10);
                client.Send(ref response3);
            }
            finally
            {
                response3.Dispose();
            }
            return;
        }
        if (client.Character.Access == AccessLevel.Trial)
        {
            Packets.PacketClass response2 = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response2.AddInt32(21);
                client.Send(ref response2);
            }
            finally
            {
                response2.Dispose();
            }
            return;
        }
        if (WorldServiceLocator._WorldServer.CHARACTERs[targetGUID].Access == AccessLevel.Trial)
        {
            Packets.PacketClass response = new(Opcodes.SMSG_TRADE_STATUS);
            try
            {
                response.AddInt32(21);
                client.Send(ref response);
            }
            finally
            {
                response.Dispose();
            }
            return;
        }
        ref var character = ref client.Character;
Beispiel #28
0
 public void On_CMSG_PETITION_BUY(ref Packets.PacketClass packet, ref WS_Network.ClientClass client)
 {
     checked
     {
         if (packet.Data.Length - 1 < 26)
         {
             return;
         }
         packet.GetInt16();
         ulong GUID = packet.GetUInt64();
         packet.GetInt64();
         packet.GetInt32();
         string Name = packet.GetString();
         if (packet.Data.Length - 1 < 26 + Name.Length + 40 + 2 + 1 + 4 + 4)
         {
             return;
         }
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt64();
         packet.GetInt16();
         packet.GetInt8();
         int Index = packet.GetInt32();
         packet.GetInt32();
         if (!WorldServiceLocator._WorldServer.WORLD_CREATUREs.ContainsKey(GUID) || (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].CreatureInfo.cNpcFlags & 0x200) == 0)
         {
             return;
         }
         WorldServiceLocator._WorldServer.Log.WriteLine(LogType.DEBUG, "[{0}:{1}] CMSG_PETITION_BUY [GuildName={2}]", client.IP, client.Port, Name);
         if ((ulong)client.Character.GuildID != 0)
         {
             return;
         }
         int       CharterID    = WorldServiceLocator._Global_Constants.PETITION_GUILD;
         int       CharterPrice = WorldServiceLocator._Global_Constants.PETITION_GUILD_PRICE;
         DataTable q            = new();
         WorldServiceLocator._WorldServer.CharacterDatabase.Query($"SELECT guild_id FROM guilds WHERE guild_name = '{Name}'", ref q);
         if (q.Rows.Count > 0)
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_EXISTS, Name);
         }
         q.Clear();
         if (!WorldServiceLocator._Functions.ValidateGuildName(Name))
         {
             SendGuildResult(ref client, GuildCommand.GUILD_CREATE_S, GuildError.GUILD_NAME_INVALID, Name);
         }
         if (!WorldServiceLocator._WorldServer.ITEMDatabase.ContainsKey(CharterID))
         {
             Packets.PacketClass response2 = new(Opcodes.SMSG_BUY_FAILED);
             response2.AddUInt64(GUID);
             response2.AddInt32(CharterID);
             response2.AddInt8(0);
             client.Send(ref response2);
             response2.Dispose();
             return;
         }
         if (client.Character.Copper < CharterPrice)
         {
             Packets.PacketClass response = new(Opcodes.SMSG_BUY_FAILED);
             response.AddUInt64(GUID);
             response.AddInt32(CharterID);
             response.AddInt8(2);
             client.Send(ref response);
             response.Dispose();
             return;
         }
         ref uint copper = ref client.Character.Copper;
         copper = (uint)(copper - CharterPrice);
         client.Character.SetUpdateFlag(1176, client.Character.Copper);
         client.Character.SendCharacterUpdate(toNear: false);
         ItemObject tmpItem = new(CharterID, client.Character.GUID)
         {
             StackCount = 1
         };
         tmpItem.AddEnchantment((int)(tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM), 0);
         if (client.Character.ItemADD(ref tmpItem))
         {
             WorldServiceLocator._WorldServer.CharacterDatabase.Update(string.Format("INSERT INTO petitions (petition_id, petition_itemGuid, petition_owner, petition_name, petition_type, petition_signedMembers) VALUES ({0}, {0}, {1}, '{2}', {3}, 0);", tmpItem.GUID - WorldServiceLocator._Global_Constants.GUID_ITEM, client.Character.GUID - WorldServiceLocator._Global_Constants.GUID_PLAYER, Name, 9));
         }
         else
         {
             tmpItem.Delete();
         }
     }
 }
Beispiel #29
0
    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();
            var TextEmote = packet.GetInt32();
            var Unk       = packet.GetInt32();
            var 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))
            {
                ref var character = ref client.Character;
                ulong   key;
                Dictionary <ulong, WS_Creatures.CreatureObject> WORLD_CREATUREs;
                var creature = (WORLD_CREATUREs = WorldServiceLocator._WorldServer.WORLD_CREATUREs)[key = GUID];
                WorldServiceLocator._WorldServer.ALLQUESTS.OnQuestDoEmote(ref character, ref creature, TextEmote);
                WORLD_CREATUREs[key] = creature;
                if (WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript is not null and WS_Creatures_AI.GuardAI)
                {
                    ((WS_Creatures_AI.GuardAI)WorldServiceLocator._WorldServer.WORLD_CREATUREs[GUID].aiScript).OnEmote(TextEmote);
                }
            }
            if (WorldServiceLocator._WS_DBCDatabase.EmotesText.ContainsKey(TextEmote))
            {
                switch (WorldServiceLocator._WS_DBCDatabase.EmotesState[WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]])
                {
                case 0:
                    client.Character.DoEmote(WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote]);
                    break;

                case 2:
                    client.Character.cEmoteState = WorldServiceLocator._WS_DBCDatabase.EmotesText[TextEmote];
                    client.Character.SetUpdateFlag(148, client.Character.cEmoteState);
                    client.Character.SendCharacterUpdate();
                    break;

                default:
                    break;
                }
            }
            var 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(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();
            }
        }