Пример #1
0
        private void OnPacket(byte[] data)
        {
            try
            {
                for (int index = 0; index < data.Length; index++)
                {
                    byte[] headerData = new byte[6];
                    Array.Copy(data, index, headerData, 0, 6);

                    ushort length;
                    short  opcode;

                    Decode(headerData, out length, out opcode);
                    Log.Print(LogType.RealmServer, $"[{ConnectionSocket.RemoteEndPoint}] [CLIENT] [{((RealmCMD)opcode).ToString().PadRight(25, ' ')}] = {length}");
                    RealmCMD code = (RealmCMD)opcode;

                    byte[] packetDate = new byte[length];
                    Array.Copy(data, index + 6, packetDate, 0, length - 4);
                    RealmServerRouter.CallHandler(this, code, packetDate);

                    index += 2 + (length - 1);
                }
            }
            catch (Exception e)
            {
                var trace = new StackTrace(e, true);
                Log.Print(LogType.Error, $"{e.Message}: {e.Source}\n{trace.GetFrame(trace.FrameCount - 1).GetFileName()}:{trace.GetFrame(trace.FrameCount - 1).GetFileLineNumber()}");
                DumpPacket(data, this);
            }
        }
Пример #2
0
 internal static void AddHandler <T>(RealmCMD opcode, ProcessLoginPacketCallbackTypes <T> callback)
 {
     AddHandler(opcode, (session, data) =>
     {
         T generatedHandler = (T)Activator.CreateInstance(typeof(T), data);
         callback(session, generatedHandler);
     });
 }
Пример #3
0
 internal static void CallHandler(RealmServerSession authServerSession, RealmCMD opcode, byte[] data)
 {
     if (MCallbacks.ContainsKey(opcode))
     {
         MCallbacks[opcode](authServerSession, data);
     }
     else
     {
         Log.Print(LogType.RealmServer, $"Missing handler: {opcode}");
         RealmServerSession.DumpPacket(data, authServerSession);
     }
 }
Пример #4
0
        public PsMovement(RealmServerSession session, MsgMoveInfo handler, RealmCMD opcode) : base(opcode)
        {
            if (session.Entity.Caindo)
            {
                return;
            }

            byte[] packedGuid = UpdateObject.GenerateGuidBytes((ulong)session.Character.Id);
            UpdateObject.WriteBytes(this, packedGuid);
            UpdateObject.WriteBytes(this, (handler.BaseStream as MemoryStream)?.ToArray());

            // We then overwrite the original moveTime (sent from the client) with ours
            ((MemoryStream)BaseStream).Position = 4 + packedGuid.Length;
            UpdateObject.WriteBytes(this, BitConverter.GetBytes((uint)Environment.TickCount));
        }
Пример #5
0
        private static async Task TransmitMovement(RealmServerSession session, MsgMoveInfo handler, RealmCMD code)
        {
            session.Character.MapX = handler.MapX;
            session.Character.MapY = handler.MapY;
            session.Character.MapZ = handler.MapZ;
            session.Character.MapO = handler.MapR;

            await MainForm.Database.UpdateMovement(session.Character);

            // If character is falling below the world

            // Boarding transport

            // Unmount when boarding

            // Unboarding transport

            // Checking Explore System

            // Fire quest event to check for if this area is used in explore area quest

            // If character is moving
            // - Stop emotes if moving
            session.Entity.SetUpdateField((int)UnitFields.UNIT_NPC_EMOTESTATE, 0);
            // - Stop casting

            // If character is turning

            // Movement time calculation

            // Send to nearby players

            // They may slow the movement down so let's do them after the packet is sent

            // Remove auras that requires you to not move

            // Remove auras that requires you to not turn

            //MSG_MOVE_HEARTBEAT
            //Check for out of continent - coordinates from WorldMapContinent.dbc
            //Duel check
            //Aggro range
            //Creatures that are following you will have a more smooth movement

            session.Entity.KnownPlayers.ForEach(s => s.Session.SendPacket(new PsMovement(session, handler, code)));

            // Gambi para nao mostrar o char andando sozinho para os demais
            if (code == RealmCMD.MSG_MOVE_JUMP)
            {
                session.Entity.Caindo = true;
            }
        }
Пример #6
0
 internal static RealmServerRouter.ProcessLoginPacketCallbackTypes <MsgMoveInfo> GenerateResponse(RealmCMD code)
 {
     return(async delegate(RealmServerSession session, MsgMoveInfo handler) { await TransmitMovement(session, handler, code); });
 }
Пример #7
0
 internal static void AddHandler(RealmCMD opcode, ProcessLoginPacketCallback handler)
 {
     MCallbacks.Add(opcode, handler);
 }
Пример #8
0
 public PacketServer(RealmCMD realmOpcode) : this((int)realmOpcode)
 {
 }