Esempio n. 1
0
        public static void HandlePing(ref PacketReader packet, ref WorldManager manager)
        {
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_PONG);
            writer.WriteUInt32(packet.ReadUInt32());

            manager.Send(writer);
        }
Esempio n. 2
0
 public static void InitializeManager()
 {
     CharacterMgr = CharacterStore.GetInstance();
     ObjectMgr = ObjectManager.GetInstance();
     SkillMgr = SkillManager.GetInstance();
     SpellMgr = SpellManager.GetInstance();
     WorldMgr = WorldManager.GetInstance();
 }
Esempio n. 3
0
        public static void HandleLogoutRequest(ref PacketReader packet, ref WorldManager manager)
        {
            PacketWriter logoutComplete = new PacketWriter(Opcodes.SMSG_LOGOUT_COMPLETE);
            manager.Send(logoutComplete);

            var result = CharacterObject.GetOnlineCharacter(manager.account);
            result.IsOnline = false;
            DB.Characters.Save(result);
        }
Esempio n. 4
0
 public static void InitializeManager()
 {
     DataMgr = DataManager.GetInstance();
     ObjectMgr = ObjectManager.GetInstance();
     SkillMgr = SkillManager.GetInstance();
     SpawnMgr = SpawnManager.GetInstance();
     SpellMgr = SpellManager.GetInstance();
     WorldMgr = WorldManager.GetInstance();
 }
Esempio n. 5
0
 public static bool InvokeHandler(PacketReader reader, WorldManager manager, Opcodes opcode)
 {
     if (OpcodeHandlers.ContainsKey(opcode))
     {
         OpcodeHandlers[opcode].Invoke(ref reader, ref manager);
         return true;
     }
     else
         return false;
 }
Esempio n. 6
0
        public static void HandleMessageChat(ref PacketReader packet, ref WorldManager manager)
        {
            PacketWriter welcomeMessage = new PacketWriter(Opcodes.SMSG_MESSAGECHAT);
            welcomeMessage.WriteUInt8((byte)packet.ReadInt32());     // slashCmd, 9: SystemMessage
            welcomeMessage.WriteUInt32(packet.ReadUInt32());         // Language: General
            welcomeMessage.WriteUInt64(0);                           // Guid: 0 - ToAll???
            welcomeMessage.WriteString(packet.ReadString());
            welcomeMessage.WriteUInt8(0);                            // afkDND, 0: nothing

            manager.Send(welcomeMessage);
        }
Esempio n. 7
0
        public static void HandleNameCache(ref PacketReader packet, ref WorldManager manager)
        {
            UInt64 guid = packet.ReadUInt64();
            Character character = CharacterObject.GetCharacterByGuid(guid);

            PacketWriter nameCache = new PacketWriter(Opcodes.SMSG_NAME_QUERY_RESPONSE);
            nameCache.WriteUInt64(guid);
            nameCache.WriteString(character.Name);
            nameCache.WriteUInt32(character.Race);
            nameCache.WriteUInt32(character.Gender);
            nameCache.WriteUInt32(character.Class);
            nameCache.WriteUInt8(0);
            manager.Send(nameCache);
        }
Esempio n. 8
0
        protected void AcceptConnection()
        {
            while (listenWorldSocket)
            {
                Thread.Sleep(1);
                if (worldListener.Pending())
                {
                    WorldManager World = new WorldManager();
                    World.socket = worldListener.AcceptSocket();

                    Thread NewThread = new Thread(World.Recieve);
                    NewThread.Start();
                }
            }
        }
Esempio n. 9
0
        public static void HandleCharEnum(ref PacketReader packet, ref WorldManager manager)
        {
            var account = manager.account;
            var result = CharacterObject.GetCharactersByAccount(account);

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CHAR_ENUM);
            writer.WriteUInt8((byte)result.Length);

            foreach (Character c in result)
            {
                writer.WriteUInt64(c.Guid);
                Console.WriteLine("GUID: {0}", c.Guid);

                writer.WriteString(c.Name);

                writer.WriteUInt8(c.Race);
                writer.WriteUInt8(c.Class);
                writer.WriteUInt8(c.Gender);
                writer.WriteUInt8(c.Skin);
                writer.WriteUInt8(c.Face);
                writer.WriteUInt8(c.HairStyle);
                writer.WriteUInt8(c.HairStyle);
                writer.WriteUInt8(c.FacialHair);
                writer.WriteUInt8(c.Level);

                writer.WriteUInt32(c.Zone);
                writer.WriteUInt32(c.Map);

                writer.WriteFloat(c.X);
                writer.WriteFloat(c.Y);
                writer.WriteFloat(c.Z);

                writer.WriteUInt32(c.GuildGuid);
                writer.WriteUInt32(c.PetDisplayInfo);
                writer.WriteUInt32(c.PetLevel);
                writer.WriteUInt32(c.PetFamily);

                // Not implented
                for (int j = 0; j < 20; j++)
                {
                    writer.WriteUInt32(0);    // DisplayId
                    writer.WriteUInt8(0);     // InventoryType
                }
            }

            manager.Send(writer);
        }
Esempio n. 10
0
        public static void HandleAuthSession(ref PacketReader packet, ref WorldManager manager)
        {
            packet.ReadUInt32();
            packet.ReadUInt32();

            string name = packet.ReadAccountName(); // Error!!! - use UTF-8
            Account account = Account.GetAccountByName(name);

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_AUTH_RESPONSE);

            if (account == null)
                writer.WriteUInt8((byte)AuthCodes.AUTH_UNKNOWN_ACCOUNT);
            else
            {
                manager.account = account;
                writer.WriteUInt8((byte)AuthCodes.AUTH_OK);
            }

            manager.Send(writer);
        }
Esempio n. 11
0
        public static void HandleWorldTeleport(ref PacketReader packet, ref WorldManager manager)
        {
            packet.ReadUInt32();
            byte zone = packet.ReadUInt8();
            float x = packet.ReadFloat();
            float y = packet.ReadFloat();
            float z = packet.ReadFloat();
            float o = packet.ReadFloat();

            PacketWriter movementStatus = new PacketWriter(Opcodes.SMSG_MOVE_WORLDPORT_ACK);
            movementStatus.WriteUInt64(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(0);
            movementStatus.WriteFloat(x);
            movementStatus.WriteFloat(y);
            movementStatus.WriteFloat(z);
            movementStatus.WriteFloat(o);
            movementStatus.WriteFloat(0);
            movementStatus.WriteUInt32(0x08000000);
            manager.Send(movementStatus);
        }
Esempio n. 12
0
        public static void HandleMovementStatus(ref PacketReader packet, ref WorldManager manager)
        {
            Opcodes MoveMessage = packet.Opcode;
            UInt64 TransportGuid = packet.ReadUInt64();
            Single TransportX = packet.ReadFloat();
            Single TransportY = packet.ReadFloat();
            Single TransportZ = packet.ReadFloat();
            Single TransportO = packet.ReadFloat();
            Single X = packet.ReadFloat();
            Single Y = packet.ReadFloat();
            Single Z = packet.ReadFloat();
            Single O = packet.ReadFloat();
            Single Pitch = packet.ReadFloat();
            UInt32 Flags = packet.ReadUInt32();

            PacketWriter movementStatus = new PacketWriter(MoveMessage);
            movementStatus.WriteUInt64(TransportGuid);
            movementStatus.WriteFloat(TransportX);
            movementStatus.WriteFloat(TransportY);
            movementStatus.WriteFloat(TransportZ);
            movementStatus.WriteFloat(TransportO);
            movementStatus.WriteFloat(X);
            movementStatus.WriteFloat(Y);
            movementStatus.WriteFloat(Z);
            movementStatus.WriteFloat(O);
            movementStatus.WriteFloat(Pitch);
            movementStatus.WriteUInt32(Flags);

            manager.Send(movementStatus);

            var result = CharacterObject.GetOnlineCharacter(manager.account);
            result.X = X;
            result.Y = Y;
            result.Z = Z;
            result.O = O;
            DB.Characters.Save(result);
        }
Esempio n. 13
0
        public static void HandleCharCreate(ref PacketReader packet, ref WorldManager manager)
        {
            Character cha = new Character();
            cha.Name = packet.ReadString();
            cha.Race = packet.ReadByte();
            cha.Class = packet.ReadByte();
            cha.Gender = packet.ReadByte();
            cha.Skin = packet.ReadByte();
            cha.Face = packet.ReadByte();
            cha.HairStyle = packet.ReadByte();
            cha.HairColor = packet.ReadByte();
            cha.FacialHair = packet.ReadByte();
            packet.ReadByte();

            var result = DB.Characters.Select<Character>();
            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CHAR_CREATE);

            foreach (Character c in result)
            {
                if (c.Name == cha.Name)
                {
                    // Name already in use
                    writer.WriteUInt8(0x2B);
                    manager.Send(writer);
                    return;
                }
            }

            cha.AccountId = manager.account.Id;
            cha.Guid = (ulong)(DB.Characters.RowCount + 1);
            DB.Characters.Save(cha);

            // Success
            writer.WriteUInt8(0x28);
            manager.Send(writer);
        }
Esempio n. 14
0
        public static void HandleUpdateObject(ref PacketReader packet, ref WorldManager manager)
        {
            UInt64 guid = packet.ReadUInt64();
            Character character = CharacterObject.GetCharacterByGuid(guid);
            character.IsOnline = true;
            DB.Characters.Save(character);

            PacketWriter welcomeMessage = new PacketWriter(Opcodes.SMSG_MESSAGECHAT);
            welcomeMessage.WriteUInt8(9);     // slashCmd, 9: SystemMessage
            welcomeMessage.WriteUInt32(0);    // Language: General
            welcomeMessage.WriteUInt64(0);    // Guid: 0 - ToAll???
            welcomeMessage.WriteString("Welcome to Flame-WoW Server!");
            welcomeMessage.WriteUInt8(0);     // afkDND, 0: nothing

            manager.Send(welcomeMessage);

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_UPDATE_OBJECT);
            writer.WriteUInt32(1);           // ObjectCount
            writer.WriteUInt8(2);            // UpdateType, UPDATE_FULL/CreateObject) + PartialUpdateFromFullUpdate
            writer.WriteUInt64(guid);        // ObjectGuid
            writer.WriteUInt8(4);            // ObjectType, 4 = Player

            writer.WriteUInt64(0);           // TransportGuid
            writer.WriteFloat(0);            // TransportX
            writer.WriteFloat(0);            // TransportY
            writer.WriteFloat(0);            // TransportZ
            writer.WriteFloat(0);            // TransportW (TransportO)

            writer.WriteFloat(character.X);  // x
            writer.WriteFloat(character.Y);  // y
            writer.WriteFloat(character.Z);  // z
            writer.WriteFloat(character.O);  // w (o)

            writer.WriteFloat(0);            // Pitch

            writer.WriteUInt32(0x08000000);  // MovementFlagMask
            writer.WriteUInt32(0);           // FallTime

            writer.WriteFloat(2.5f);         // WalkSpeed
            writer.WriteFloat(7.0f);         // RunSpeed
            writer.WriteFloat(4.7222f);      // SwimSpeed
            writer.WriteFloat(3.14f);        // TurnSpeed

            writer.WriteUInt32(1);           // Flags, 1 - Player
            writer.WriteUInt32(1);           // AttackCycle
            writer.WriteUInt32(0);           // TimerId
            writer.WriteUInt64(0);           // VictimGuid

            // FillInPartialObjectData
            writer.WriteUInt8(0x14);         // UpdateMaskBlocks, 20

            for (int i = 0; i < 0x14; i++)
                writer.WriteUInt32(0xFFFFFFFF);

            // ObjectFields
            writer.WriteUInt64(guid);
            writer.WriteUInt32(0x19);         // UpdateType, 0x19 - Player (Player + Unit + Object)
            writer.WriteUInt32(0);
            writer.WriteFloat(1);
            writer.WriteUInt32(0);

            // UnitFields
            for (int i = 0; i < 16; i++)
                writer.WriteUInt32(0);

            writer.WriteUInt32(character.Health);
            writer.WriteUInt32(character.Mana);
            writer.WriteUInt32(character.Rage);
            writer.WriteUInt32(character.Focus);
            writer.WriteUInt32(character.Energy);
            // Max values...
            writer.WriteUInt32(character.Health);
            writer.WriteUInt32(character.Mana);
            writer.WriteUInt32(character.Rage);
            writer.WriteUInt32(character.Focus);
            writer.WriteUInt32(character.Energy);
            writer.WriteUInt32(character.Level);
            writer.WriteUInt32(5);
            writer.WriteUInt8(character.Race);
            writer.WriteUInt8(character.Class);
            writer.WriteUInt8(character.Gender);
            writer.WriteUInt8(1);

            writer.WriteUInt32(character.Strength);
            writer.WriteUInt32(character.Agility);
            writer.WriteUInt32(character.Stamina);
            writer.WriteUInt32(character.Intellect);
            writer.WriteUInt32(character.Spirit);
            // BastStats, copy ...
            writer.WriteUInt32(character.Strength);
            writer.WriteUInt32(character.Agility);
            writer.WriteUInt32(character.Stamina);
            writer.WriteUInt32(character.Intellect);
            writer.WriteUInt32(character.Spirit);

            for (int i = 0; i < 10; i++)
                writer.WriteUInt32(0);

            // Money
            writer.WriteUInt32(character.Money);

            for (int i = 0; i < 56; i++)
                writer.WriteUInt32(0);

            for (int i = 0; i < 39; i++)
                writer.WriteUInt32(0);

            // DisplayId
            switch (character.Race)
            {
                case 1:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x31 : 0x32));
                    break;
                case 2:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x33 : 0x34));
                    break;
                case 3:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x35 : 0x36));
                    break;
                case 4:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x37 : 0x38));
                    break;
                case 5:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x39 : 0x40));
                    break;
                case 6:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x3B : 0x3C));
                    break;
                case 7:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x61B : 0x61C));
                    break;
                case 8:
                    writer.WriteUInt32((uint)(character.Gender == 0 ? 0x5C6 : 0x5C7));
                    break;
            }

            for (int i = 0; i < 32; i++)
                writer.WriteUInt32(0);

            // PlayerFields
            for (int i = 0; i < 46; i++)
                writer.WriteUInt32(0);

            for (int i = 0; i < 32; i++)
                writer.WriteUInt32(0);

            for (int i = 0; i < 48; i++)
                writer.WriteUInt32(0);

            for (int i = 0; i < 12; i++)
                writer.WriteUInt32(0);

            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            // InventarSlots
            writer.WriteUInt32(14);

            writer.WriteUInt32(0);
            writer.WriteUInt32(0);

            // PLAYER_BYTES (Skin, Face, HairStyle, HairColor)
            writer.WriteUInt8(character.Skin);
            writer.WriteUInt8(character.Face);
            writer.WriteUInt8(character.HairStyle);
            writer.WriteUInt8(character.HairColor);

            // XP
            writer.WriteUInt32(0);
            // NextLevel
            writer.WriteUInt32(200);

            // SkillInfo
            for (int i = 0; i < 192; i++)
                writer.WriteUInt32(0);

            // PLAYER_BYTES_2 (FacialHair, Unknown, BankBagSlotCount, RestState)
            writer.WriteUInt8(character.FacialHair);
            writer.WriteUInt8(0);
            writer.WriteUInt8(0);
            writer.WriteUInt8(1);

            // QuestInfo
            for (int i = 0; i < 96; i++)
                writer.WriteUInt32(0);

            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            writer.WriteUInt32(0);
            // BaseMana
            writer.WriteUInt32(20);
            writer.WriteUInt32(0);

            // Hmm xD?
            writer.WriteUInt8(0);
            writer.WriteUInt8(0);
            writer.WriteUInt8(0);
            manager.Send(writer);
        }
Esempio n. 15
0
 public static void HandleWorldTeleportAck(ref PacketReader packet, ref WorldManager manager)
 {
 }
Esempio n. 16
0
        public static void HandleCharDelete(ref PacketReader packet, ref WorldManager manager)
        {
            UInt64 guid = packet.ReadUInt64();
            Character character = CharacterObject.GetCharacterByGuid(guid);

            PacketWriter writer = new PacketWriter(Opcodes.SMSG_CHAR_DELETE);
            writer.WriteUInt8(0x2C);
            manager.Send(writer);

            DB.Characters.Delete(character);
        }