Ejemplo n.º 1
0
    public static void On_SMSG_CHAR_ENUM(ref Packets.PacketClass Packet)
    {
        Console.WriteLine("[{0}][World] Received Character List.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
        var NumChars = Packet.GetInt8();

        if (NumChars > 0)
        {
            for (byte i = 1, loopTo = NumChars; i <= loopTo; i++)
            {
                var GUID        = Packet.GetUInt64();
                var Name        = Packet.GetString();
                var Race        = Packet.GetInt8();
                var Classe      = Packet.GetInt8();
                var Gender      = Packet.GetInt8();
                var Skin        = Packet.GetInt8();
                var Face        = Packet.GetInt8();
                var HairStyle   = Packet.GetInt8();
                var HairColor   = Packet.GetInt8();
                var FacialHair  = Packet.GetInt8();
                var Level       = Packet.GetInt8();
                var Zone        = Packet.GetInt32();
                var Map         = Packet.GetInt32();
                var PosX        = Packet.GetFloat();
                var PosY        = Packet.GetFloat();
                var PosZ        = Packet.GetFloat();
                var GuildID     = Packet.GetUInt32();
                var PlayerState = Packet.GetUInt32();
                var RestState   = Packet.GetInt8();
                var PetInfoID   = Packet.GetUInt32();
                var PetLevel    = Packet.GetUInt32();
                var PetFamilyID = Packet.GetUInt32();
                Console.WriteLine("[{0}][World] Logging in with character [{1}].", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"), Name);
                Worldserver.CharacterGUID = GUID;
                Packets.PacketClass Response = new(OPCODES.CMSG_PLAYER_LOGIN);
                Response.AddUInt64(GUID);
                Worldserver.Send(Response);
                Response.Dispose();
                break;

                // Skip the equipment
                Packet.Offset += 20 * 9;
            }
        }
        else
        {
            Console.WriteLine("[{0}][World] No characters found.", Strings.Format(DateAndTime.TimeOfDay, "HH:mm:ss"));
        }
    }
Ejemplo n.º 2
0
    public static void On_SMSG_MESSAGECHAT(ref Packets.PacketClass Packet)
    {
        ChatMsg   msgType     = (ChatMsg)Packet.GetInt8();
        LANGUAGES msgLanguage = (LANGUAGES)Packet.GetInt32();

        switch (msgType)
        {
        case ChatMsg.CHAT_MSG_WHISPER:
        {
            var SenderGuid = (ulong)Packet.GetInt64();
            var ByteCount  = Packet.GetInt32();
            var Message    = Packet.GetString();
            var ChatFlag   = Packet.GetInt8();
            Console.WriteLine("Answer: " + Message);
            break;
        }
        }
    }
Ejemplo n.º 3
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();
         }
     }
 }
Ejemplo n.º 4
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;
            }
        }
Ejemplo n.º 5
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();
         }
     }
 }