Beispiel #1
0
        public static void HandleRequestUITime(ref PacketReader packet, ref WorldClass session)
        {
            PacketWriter uiTime = new PacketWriter(LegacyMessage.UITime);

            uiTime.WriteUnixTime();
            session.Send(uiTime);
        }
Beispiel #2
0
        public static void HandleLogoutComplete(ref PacketReader packet, ref WorldClass session)
        {
            WorldMgr.DeleteSession(session.Character.Guid);

            PacketWriter logoutComplete = new PacketWriter(LegacyMessage.LogoutComplete);
            session.Send(logoutComplete);
        }
Beispiel #3
0
 public void BroadcastToAllPacket(ref PacketWriter packet)
 {
     foreach (WorldClass session in Globals.WorldMgr.Sessions.Values)
     {
         session.Send(ref packet);
     }
 }
Beispiel #4
0
        public static void HandleSendKnownSpells(ref WorldClass session)
        {
            Character pChar = session.Character;

            var specializationSpells = SpecializationMgr.GetSpecializationSpells(pChar);
            var specializationSpellCount = ((specializationSpells != null) ? specializationSpells.Count : 0);

            var talentSpells = SpecializationMgr.GetTalentSpells(pChar, pChar.ActiveSpecGroup);
            var talentSpellCount = ((talentSpells != null) ? talentSpells.Count : 0);

            int count = pChar.SpellList.Count + specializationSpellCount + talentSpellCount;

            PacketWriter writer = new PacketWriter(ServerMessage.SendKnownSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write(1);
            BitPack.Write(count, 22);
            BitPack.Flush();

            pChar.SpellList.ForEach(spell =>
                writer.WriteUInt32(spell.SpellId));

            if (specializationSpells != null)
                specializationSpells.ForEach(spell => writer.WriteUInt32(spell.Spell));

            if (talentSpells != null)
                talentSpells.ForEach(spell => writer.WriteUInt32(spell));

            session.Send(ref writer);
        }
Beispiel #5
0
        public void HandleAuthLogonChallenge(RealmClass session, PacketReader data)
        {
            Log.Message(LogType.NORMAL, "AuthLogonChallenge");

            data.Skip(10);
            ushort ClientBuild = data.ReadUInt16();
            data.Skip(8);
            account.Language = data.ReadStringFromBytes(4);
            data.Skip(4);

            account.IP = data.ReadIPAddress();
            account.Name = data.ReadAccountName();

            SQLResult result = DB.Realms.Select("SELECT id, name, password, expansion, gmlevel, securityFlags FROM accounts WHERE name = '{0}'", account.Name);

            PacketWriter logonChallenge = new PacketWriter();
            logonChallenge.WriteUInt8((byte)ClientLink.CMD_AUTH_LOGON_CHALLENGE);
            logonChallenge.WriteUInt8(0);

            if (result.Count != 0)
            {
                account.Id = result.Read<Int32>(0, "id");
                account.Expansion = result.Read<Byte>(0, "expansion");
                account.SecurityFlags = result.Read<Byte>(0, "securityFlags");

                DB.Realms.Execute("UPDATE accounts SET ip = '{0}', language = '{1}' WHERE id = {2}", account.IP, account.Language, account.Id);

                byte[] username = Encoding.ASCII.GetBytes(result.Read<String>(0, "name").ToUpper());
                byte[] password = Encoding.ASCII.GetBytes(result.Read<String>(0, "password").ToUpper());

                // WoW 5.1.0.16173 (5.1.0 PTR)
                if (ClientBuild == 16173)
                {
                    session.SecureRemotePassword.CalculateX(username, password);
                    byte[] buf = new byte[0x10];
                    SRP6.RAND_bytes(buf, 0x10);

                    logonChallenge.WriteUInt8((byte)AuthResults.WOW_SUCCESS);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.B);
                    logonChallenge.WriteUInt8(1);
                    logonChallenge.WriteUInt8(session.SecureRemotePassword.g[0]);
                    logonChallenge.WriteUInt8(0x20);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.N);
                    logonChallenge.WriteBytes(session.SecureRemotePassword.salt);
                    logonChallenge.WriteBytes(buf);

                    // Security flags
                    logonChallenge.WriteUInt8(account.SecurityFlags);

                    // Enable authenticator
                    if ((account.SecurityFlags & 4) != 0)
                        logonChallenge.WriteUInt8(1);
                }
            }
            else
                logonChallenge.WriteUInt8((byte)AuthResults.WOW_FAIL_UNKNOWN_ACCOUNT);

            session.Send(logonChallenge);
        }
Beispiel #6
0
        public static void HandleTutorialFlags(ref WorldClass session)
        {
            PacketWriter tutorialFlags = new PacketWriter(LegacyMessage.TutorialFlags);
            for (int i = 0; i < 8; i++)
                tutorialFlags.WriteUInt32(0);

            session.Send(ref tutorialFlags);
        }
Beispiel #7
0
        public static void HandleCacheVersion(ref WorldClass session)
        {
            PacketWriter cacheVersion = new PacketWriter(ServerMessage.CacheVersion);

            cacheVersion.WriteUInt32(0);

            session.Send(ref cacheVersion);
        }
Beispiel #8
0
        public static void HandleUpdateClientCacheVersion(ref WorldClass session)
        {
            PacketWriter cacheVersion = new PacketWriter(LegacyMessage.UpdateClientCacheVersion);

            cacheVersion.WriteUInt32(0);

            session.Send(cacheVersion);
        }
Beispiel #9
0
        public static void HandleUITimeRequest(ref PacketReader packet, WorldClass session)
        {
            PacketWriter uiTime = new PacketWriter(ServerMessage.UITime);

            uiTime.WriteUnixTime();

            session.Send(ref uiTime);
        }
Beispiel #10
0
        public static void HandleObjectDestroy(ref WorldClass session)
        {
            PacketWriter objectDestroy = new PacketWriter(LegacyMessage.ObjectDestroy);

            objectDestroy.WriteUInt64(session.Character.Guid);
            objectDestroy.WriteUInt8(0);

            session.Send(objectDestroy);
        }
Beispiel #11
0
        public void OnConnect()
        {
            PacketWriter TransferInitiate = new PacketWriter(Message.TransferInitiate);
            TransferInitiate.WriteCString("RLD OF WARCRAFT CONNECTION - SERVER TO CLIENT");

            Send(TransferInitiate);

            clientSocket.BeginReceive(DataBuffer, 0, DataBuffer.Length, SocketFlags.None, Receive, null);
        }
Beispiel #12
0
        public static PacketWriter HandleObjectDestroy(ref WorldClass session, ulong guid)
        {
            PacketWriter objectDestroy = new PacketWriter(LegacyMessage.ObjectDestroy);

            objectDestroy.WriteUInt64(guid);
            objectDestroy.WriteUInt8(0);

            return objectDestroy;
        }
Beispiel #13
0
        public static void HandlePong(ref PacketReader packet, ref WorldClass session)
        {
            uint sequence = packet.ReadUInt32();
            uint latency = packet.ReadUInt32();

            PacketWriter pong = new PacketWriter(JAMCCMessage.Pong);
            pong.WriteUInt32(sequence);

            session.Send(pong);
        }
Beispiel #14
0
        public static void HandleMessageOfTheDay(ref WorldClass session)
        {
            PacketWriter motd = new PacketWriter(LegacyMessage.MessageOfTheDay);
            motd.WriteUInt32(3);

            motd.WriteCString("Arctium MoP test");
            motd.WriteCString("Welcome to our MoP server test.");
            motd.WriteCString("Your development team =)");
            session.Send(ref motd);
        }
Beispiel #15
0
        public static void HandleLogoutComplete(ref PacketReader packet, ref WorldClass session)
        {
            var pChar = session.Character;

            ObjectMgr.SavePositionToDB(pChar);
            WorldMgr.DeleteSession(pChar.Guid);

            PacketWriter logoutComplete = new PacketWriter(LegacyMessage.LogoutComplete);
            session.Send(logoutComplete);
        }
        public static void HandleCreateCharacter(ref PacketReader packet, WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            var hairStyle = packet.ReadByte();
            var gender = packet.ReadByte();
            var race = packet.ReadByte();
            var hairColor = packet.ReadByte();
            var pClass = packet.ReadByte();
            var facialHair = packet.ReadByte();
            packet.ReadByte();                      // Always 0
            var skin = packet.ReadByte();
            var face       = packet.ReadByte();

            var nameLength = BitUnpack.GetBits<uint>(7);
            var name = Character.NormalizeName(packet.ReadString(nameLength));

            var result = DB.Characters.Select("SELECT * from characters WHERE name = ?", name);
            var createChar = new PacketWriter(ServerMessage.CreateChar);

            if (result.Count != 0)
            {
                // Name already in use
                createChar.WriteUInt8(0x32);
                session.Send(ref createChar);
                return;
            }

            result = DB.Characters.Select("SELECT map, zone, posX, posY, posZ, posO FROM character_creation_data WHERE race = ? AND class = ?", race, pClass);
            if (result.Count == 0)
            {
                createChar.WriteUInt8(0x31);
                session.Send(ref createChar);
                return;
            }

            var map  = result.Read<uint>(0, "map");
            var zone = result.Read<uint>(0, "zone");
            var posX = result.Read<float>(0, "posX");
            var posY = result.Read<float>(0, "posY");
            var posZ = result.Read<float>(0, "posZ");
            var posO = result.Read<float>(0, "posO");

            // Allow declined names for now
            var characterFlags = CharacterFlag.Decline;

            DB.Characters.Execute("INSERT INTO characters (name, accountid, realmId, race, class, gender, skin, zone, map, x, y, z, o, face, hairstyle, haircolor, facialhair, characterFlags) VALUES (" +
                                  "?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
                                  name, session.Account.Id, WorldConfig.RealmId, race, pClass, gender, skin, zone, map, posX, posY, posZ, posO, face, hairStyle, hairColor, facialHair, characterFlags);

            // Success
            createChar.WriteUInt8(0x2F);
            session.Send(ref createChar);
        }
Beispiel #17
0
        public static void HandleLogoutCancel(ref PacketReader packet, WorldClass session)
        {
            cts.Cancel();

            MoveHandler.HandleMoveUnroot(session);

            PacketWriter LogoutCancelAck = new PacketWriter(ServerMessage.LogoutCancelAck);
            session.Send(ref LogoutCancelAck);

            session.Character.setStandState(0);
        }
Beispiel #18
0
        public static void HandleTalkToGossip(ref PacketReader packet, ref WorldClass session)
        {
            BitUnpack BitUnpack = new BitUnpack(packet);

            byte[] guidMask = { 3, 1, 7, 4, 6, 0, 2, 5 };
            byte[] guidBytes = { 0, 1, 7, 6, 5, 2, 4, 3 };

            var guid = BitUnpack.GetPackedValue(guidMask, guidBytes);
            var gossipData = GossipMgr.GetGossip<Creature>(SmartGuid.GetGuid(guid));

            if (gossipData != null)
            {
                PacketWriter gossipMessage = new PacketWriter(ServerMessage.GossipMessage);
                BitPack BitPack = new BitPack(gossipMessage, guid);

                BitPack.WriteGuidMask(0, 1);
                BitPack.Write(0, 19);           // gossipData.QuestsCount
                BitPack.WriteGuidMask(2);
                BitPack.Write(0, 20);           // gossipData.OptionsCount

                // QuestsCount not supported.
                // for (int i = 0; i < gossipData.QuestsCount; i++)

                BitPack.WriteGuidMask(3);

                // OptionsCount not supported.
                // for (int i = 0; i < gossipData.OptionsCount; i++)

                BitPack.WriteGuidMask(5, 4, 6, 7);

                BitPack.Flush();

                BitPack.WriteGuidBytes(6);

                // OptionsCount not supported.
                // for (int i = 0; i < gossipData.OptionsCount; i++)

                BitPack.WriteGuidBytes(0);

                // QuestsCount not supported.
                // for (int i = 0; i < gossipData.QuestsCount; i++)

                gossipMessage.WriteInt32(gossipData.Id);

                BitPack.WriteGuidBytes(4, 3);

                gossipMessage.WriteInt32(gossipData.FriendshipFactionID);
                gossipMessage.WriteInt32(gossipData.TextID);

                BitPack.WriteGuidBytes(7, 1, 5, 1);

                session.Send(ref gossipMessage);
            }
        }
Beispiel #19
0
        public static void HandleLoginSetTimeSpeed(ref WorldClass session)
        {
            PacketWriter loginSetTimeSpeed = new PacketWriter(ServerMessage.LoginSetTimeSpeed);

            loginSetTimeSpeed.WriteInt32(1);
            loginSetTimeSpeed.WriteInt32(1);
            loginSetTimeSpeed.WriteFloat(0.01666667f);
            loginSetTimeSpeed.WritePackedTime();
            loginSetTimeSpeed.WritePackedTime();

            session.Send(ref loginSetTimeSpeed);
        }
Beispiel #20
0
        public static void HandleRealmSplitStateResponse(ref PacketReader packet, ref WorldClass session)
        {
            uint realmSplitState = 0;

            PacketWriter realmSplitStateResp = new PacketWriter(LegacyMessage.RealmSplitStateResponse);

            realmSplitStateResp.WriteUInt32(packet.ReadUInt32());
            realmSplitStateResp.WriteUInt32(realmSplitState);
            realmSplitStateResp.WriteCString("01/01/01");

            session.Send(ref realmSplitStateResp);
        }
        public static void HandleAuthChallenge(ref PacketReader packet, ref WorldClass session)
        {
            PacketWriter authChallenge = new PacketWriter(ServerMessage.AuthChallenge, true);

            for (int i = 0; i < 8; i++)
                authChallenge.WriteUInt32(0);

            authChallenge.WriteUInt32((uint)new Random(DateTime.Now.Second).Next(1, 0xFFFFFFF));
            authChallenge.WriteUInt8(1);

            session.Send(ref authChallenge);
        }
Beispiel #22
0
        public static void HandleSendNewTimeSpeed(ref WorldClass session)
        {
            PacketWriter newTimeSpeed = new PacketWriter(LegacyMessage.SendNewTimeSpeed);

            newTimeSpeed.WritePackedTime();
            newTimeSpeed.WritePackedTime();
            newTimeSpeed.WriteFloat(0.01666667f);
            newTimeSpeed.WriteInt32(0);
            newTimeSpeed.WriteInt32(0);

            session.Send(ref newTimeSpeed);
        }
Beispiel #23
0
        public static void HandleLogoutComplete(WorldClass session)
        {
            var pChar = session.Character;

            ObjectMgr.SavePositionToDB(pChar);

            PacketWriter logoutComplete = new PacketWriter(ServerMessage.LogoutComplete);
            session.Send(ref logoutComplete);

            WorldMgr.SendToInRangeCharacter(pChar, Packets.PacketHandler.ObjectHandler.HandleDestroyObject(ref session, pChar.Guid));
            WorldMgr.DeleteSession(pChar.Guid);
        }
Beispiel #24
0
        public static void HandleUnlearnedSpells(ref WorldClass session, List<uint> oldSpells)
        {
            PacketWriter writer = new PacketWriter(ServerMessage.UnlearnedSpells);
            BitPack BitPack = new BitPack(writer);

            BitPack.Write<int>(oldSpells.Count, 22);
            BitPack.Flush();

            for (int i = 0; i < oldSpells.Count; i++)
                writer.WriteUInt32(oldSpells[i]);

            session.Send(ref writer);
        }
        public static void HandleStartCinematic(ref WorldClass session)
        {
            Character pChar = session.Character;

            PacketWriter startCinematic = new PacketWriter(ServerMessage.StartCinematic);

            startCinematic.WriteUInt32(CliDB.ChrRaces.Single(race => race.Id == pChar.Race).CinematicSequence);

            session.Send(ref startCinematic);

            if (pChar.LoginCinematic)
                DB.Characters.Execute("UPDATE characters SET loginCinematic = 0 WHERE guid = ?", pChar.Guid);
        }
Beispiel #26
0
        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter setCanFly = new PacketWriter(JAMCMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(setCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(7, 3, 1, 5, 0, 6, 2, 4);
            BitPack.Flush();

            setCanFly.WriteUInt32(0);

            BitPack.WriteGuidBytes(2, 6, 7, 1, 3, 4, 6, 0);
            session.Send(setCanFly);
        }
        public static void HandleStartCinematic(ref WorldClass session)
        {
            Character pChar = session.Character;

            PacketWriter startCinematic = new PacketWriter(LegacyMessage.StartCinematic);

            startCinematic.WriteUInt32(DBCStorage.RaceStorage[pChar.Race].CinematicSequence);

            session.Send(ref startCinematic);

            if (pChar.LoginCinematic)
                DB.Characters.Execute("UPDATE characters SET loginCinematic = 0 WHERE guid = ?", pChar.Guid);
        }
Beispiel #28
0
        public static void HandleCreatureStats(ref PacketReader packet, ref WorldClass session)
        {
            int id = packet.ReadInt32();
            ulong guid = packet.ReadUInt64();

            Creature creature = DataMgr.FindCreature(id);
            if (creature != null)
            {
                CreatureStats stats = creature.Stats;

                PacketWriter creatureStats = new PacketWriter(LegacyMessage.CreatureStats);

                creatureStats.WriteInt32(stats.Id);
                creatureStats.WriteCString(stats.Name);

                for (int i = 0; i < 7; i++)
                    creatureStats.WriteCString("");

                creatureStats.WriteCString(stats.SubName);
                creatureStats.WriteCString("");
                creatureStats.WriteCString(stats.IconName);

                foreach (var v in stats.Flag)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteInt32(stats.Type);
                creatureStats.WriteInt32(stats.Family);
                creatureStats.WriteInt32(stats.Rank);

                foreach (var v in stats.QuestKillNpcId)
                    creatureStats.WriteInt32(v);

                foreach (var v in stats.DisplayInfoId)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteFloat(stats.HealthModifier);
                creatureStats.WriteFloat(stats.PowerModifier);

                creatureStats.WriteUInt8(stats.RacialLeader);

                foreach (var v in stats.QuestItemId)
                    creatureStats.WriteInt32(v);

                creatureStats.WriteInt32(stats.MovementInfoId);
                creatureStats.WriteInt32(stats.ExpansionRequired);

                session.Send(ref creatureStats);
            }
            else
                Log.Message(LogType.DEBUG, "Creature (Id: {0}) not found.", id);
        }
Beispiel #29
0
        public static PacketWriter HandleDestroyObject(ref WorldClass session, ulong guid)
        {
            PacketWriter destroyObject = new PacketWriter(ServerMessage.DestroyObject);
            BitPack BitPack = new BitPack(destroyObject, guid);

            BitPack.WriteGuidMask(1, 6, 5, 7, 4, 2, 0, 3);
            BitPack.Write(0);

            BitPack.Flush();

            BitPack.WriteGuidBytes(7, 2, 6, 1, 3, 7, 5, 0);

            return destroyObject;
        }
Beispiel #30
0
        public static void HandleMoveSetCanFly(ref WorldClass session)
        {
            PacketWriter moveSetCanFly = new PacketWriter(ServerMessage.MoveSetCanFly);
            BitPack BitPack = new BitPack(moveSetCanFly, session.Character.Guid);

            BitPack.WriteGuidMask(5, 3, 0, 2, 4, 1, 6, 7);
            BitPack.Flush();

            BitPack.WriteGuidBytes(1, 3, 5, 0, 7, 2, 4, 6);

            moveSetCanFly.WriteUInt32(0);

            session.Send(ref moveSetCanFly);
        }