示例#1
0
        public void ChangeLocation(Player player, int prevLocation, int newLocation)
        {
            PacketStream stream = new PacketStream(0x0385);

            stream.WriteInt32(prevLocation);
            stream.WriteInt32(newLocation);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#2
0
        /// <summary>
        /// Called whenever a packet is received from a game client
        /// </summary>
        /// <param name="client"></param>
        /// <param name="stream"></param>
        public void PacketReceived(AuthServer server, PacketStream packet)
        {
            byte[] data = packet.ToArray();
            ConsoleUtils.HexDump(data, "Received from AuthServer");

            // Is it a known packet ID
            if (!PacketsDb.ContainsKey(packet.GetId()))
            {
                ConsoleUtils.ShowWarning("Unknown packet Id: {0}", packet.GetId());
                return;
            }

            // Calls this packet parsing function
            Task.Factory.StartNew(() => { PacketsDb[packet.GetId()].Invoke(server, data); });
        }
示例#3
0
        /// <summary>
        /// Sends a packet to clients
        /// </summary>
        /// <param name="target">the target from which area will be calculated</param>
        /// <param name="packet">packet data</param>
        /// <param name="area">the target area</param>
        public void Send(GameObject target, PacketStream packet, BroadcastArea area)
        {
            byte[] data = packet.GetPacket().ToArray();

            ConsoleUtils.HexDump(data, "Sent to Client");

            List<Player> players = new List<Player>();
            // Gets the list of players who will receive this packet
            switch (area)
            {
                case BroadcastArea.Self:
                    if (target.ObjType != ObjectType.Player)
                    {
                        ConsoleUtils.ShowError("Trying to send packet to a non-player object.");
                        return;
                    }
                    players.Add((Player)target);
                    break;
                case BroadcastArea.Region:
                    // TODO : Get players in region
                    if (target.ObjType == ObjectType.Player)
                        players.Add((Player)target);
                    break;
                case BroadcastArea.World:
                    // TODO : Get all players in the server
                    if (target.ObjType == ObjectType.Player)
                        players.Add((Player)target);
                    break;
                default:
                    ConsoleUtils.ShowError("Unknown Broadcast Area.");
                    return;
            }

            // Sends data to every client in the list
            foreach (Player client in players)
            {
                client.NetData.ClSocket.BeginSend(
                    client.NetData.OutCipher.DoCipher(ref data),
                    0,
                    data.Length,
                    0,
                    new AsyncCallback(SendCallback),
                    client
                );
            }
        }
示例#4
0
        internal void LoginResult(Player player)
        {
            PacketStream stream = new PacketStream(0x0004);

            stream.WriteByte(1);
            stream.WriteUInt32(player.Handle);
            stream.WriteSingle(168344f);//player.Position.X);
            stream.WriteSingle(55400f);//player.Position.Y);
            stream.WriteSingle(player.Position.Z);
            stream.WriteByte(1);//player.Position.Layer);
            stream.WriteSingle(0f); // TODO : face_direction
            stream.WriteInt32(Globals.RegionSize);
            stream.WriteInt32(100);//player.Hp);
            stream.WriteInt16(100);//player.Mp);
            stream.WriteInt32(100);//player.MaxHp);
            stream.WriteInt16(100);// player.MaxMp);
            stream.WriteInt32(player.Havoc);
            stream.WriteInt32(Globals.MaxHavoc); // TODO : Is this constant?
            stream.WriteInt32(player.Sex);
            stream.WriteInt32(player.Race);
            stream.WriteUInt32(player.SkinColor);
            stream.WriteInt32(player.FaceId);
            stream.WriteInt32(player.HairId);
            stream.WriteString(player.Name, 19);
            stream.WriteInt32(Globals.CellSize);
            stream.WriteInt32(player.GuildId);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#5
0
        internal void LevelUpdate(Player player, int level, int jobLevel)
        {
            PacketStream stream = new PacketStream(0x03EA);

            stream.WriteUInt32(player.Handle);
            stream.WriteInt32(level);
            stream.WriteInt32(jobLevel);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#6
0
        /// <summary>
        /// Informs about changes in what target is wearing
        /// </summary>
        /// <param name="itemHandle"></param>
        /// <param name="position"></param>
        /// <param name="targetHandle"></param>
        /// <param name="enhance"></param>
        /// <param name="elementalEffectType"></param>
        internal void ItemWearInfo(Player player, uint itemHandle, short position, uint targetHandle, int enhance, short elementalEffectType)
        {
            PacketStream stream = new PacketStream(0x011f);

            stream.WriteUInt32(itemHandle);
            stream.WriteInt16(position);
            stream.WriteUInt32(targetHandle);
            stream.WriteInt32(enhance);
            stream.WriteByte((byte)elementalEffectType);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#7
0
        internal void InventoryList(Player player, List<uint> inventory)
        {
            PacketStream stream = new PacketStream(0x00CF);

            stream.WriteUInt16((ushort)inventory.Count);
            for (int i = 0; i < inventory.Count; i++)
            {
                Item item = (Item) GObjectManager.Instance.Get(ObjectType.Item, inventory[i]);

                // TS_ITEM_BASE_INFO
                stream.WriteUInt32(item.Handle);
                stream.WriteInt32(item.Code);
                stream.WriteInt64(item.UId);
                stream.WriteInt64(item.Count);
                stream.WriteInt32(item.Durability);
                stream.WriteUInt32(item.Endurance);
                stream.WriteByte((byte)item.Enhance);
                stream.WriteByte((byte)item.Level);
                stream.WriteInt32(item.Flag);
                stream.WriteInt32(item.Socket[0]);
                stream.WriteInt32(item.Socket[1]);
                stream.WriteInt32(item.Socket[2]);
                stream.WriteInt32(item.Socket[3]);
                stream.WriteInt32(item.RemainTime);
                stream.WriteByte((byte)item.ElementalEffectType);
                stream.WriteInt32(0); // TODO : elemental_effect_remain_time
                stream.WriteInt32(item.ElementalEffectAttackPoint);
                stream.WriteInt32(item.ElementalEffectMagicPoint);

                // TS_ITEM_INFO
                stream.WriteInt16((short)item.WearInfo);
                stream.WriteUInt32(0); // TODO : own_summon_handle
                stream.WriteInt32(i); // TODO : index
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#8
0
 /// <summary>
 /// Called when an entire packet is received
 /// </summary>
 /// <param name="gs"></param>
 /// <param name="packetStream"></param>
 private void PacketReceived(AuthServer server, PacketStream packetStream)
 {
     AuthPackets.Instance.PacketReceived(server, packetStream);
 }
示例#9
0
        internal void WearInfo(Player player, uint[] wearInfo)
        {
            PacketStream stream = new PacketStream(0x00CA);

            int maxWear = (int)Wear.Max;
            List<int> enhance = new List<int>(maxWear);
            List<int> level = new List<int>(maxWear);
            List<byte> type = new List<byte>(maxWear);

            stream.WriteUInt32(player.Handle);

            for (int i = 0; i < maxWear; i++)
            {
                Item item = (Item)GObjectManager.Instance.Get(ObjectType.Item, wearInfo[i]);

                if (item != null)
                {
                    // If there's an item equipped in this slot
                    enhance.Add(item.Enhance);
                    level.Add(item.Level);
                    type.Add((byte)item.ElementalEffectType);
                    stream.WriteInt32(item.Code);
                }
                else
                {
                    enhance.Add(0);
                    level.Add(0);
                    type.Add(0);
                    // If nothing is equipped in the slot, and slot is armor,
                    // hands or feet, sends body part id
                    switch (i)
                    {
                        case 2: stream.WriteInt32(player.BodyId); break;
                        case 3: stream.WriteInt32(player.HandsId); break;
                        case 4: stream.WriteInt32(player.FeetId); break;
                        default: stream.WriteInt32(0); break;
                    }
                }
            }

            for (int i = 0; i < maxWear; i++)
                stream.WriteInt32(enhance[i]);
            for (int i = 0; i < maxWear; i++)
                stream.WriteInt32(level[i]);
            for (int i = 0; i < maxWear; i++)
                stream.WriteByte(type[i]);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#10
0
        /// <summary>
        /// Updates game object stats and attributes
        /// </summary>
        /// <param name="player">the target</param>
        /// <param name="stat">stats</param>
        /// <param name="attribute">attributes</param>
        /// <param name="isBonus">are these bonus stats (green)</param>
        internal void StatInfo(Player player, CreatureStat stat, CreatureAttribute attribute, bool isBonus)
        {
            PacketStream stream = new PacketStream(0x03E8);

            stream.WriteUInt32(player.Handle);

            // Creature Stat
            stream.WriteInt16(stat.StatId);
            stream.WriteInt16(stat.STR);
            stream.WriteInt16(stat.VIT);
            stream.WriteInt16(stat.DEX);
            stream.WriteInt16(stat.AGI);
            stream.WriteInt16(stat.INT);
            stream.WriteInt16(stat.MEN);
            stream.WriteInt16(stat.LUK);

            // Creature Attributes
            stream.WriteInt16(attribute.Critical);
            stream.WriteInt16(attribute.CriticalPower);
            stream.WriteInt16(attribute.PAttackRight);
            stream.WriteInt16(attribute.PAttackLeft);
            stream.WriteInt16(attribute.Defense);
            stream.WriteInt16(attribute.BlockDefense);
            stream.WriteInt16(attribute.MAttack);
            stream.WriteInt16(attribute.MDefense);
            stream.WriteInt16(attribute.AccuracyRight);
            stream.WriteInt16(attribute.AccuracyLeft);
            stream.WriteInt16(attribute.MagicAccuracy);
            stream.WriteInt16(attribute.Evasion);
            stream.WriteInt16(attribute.MagicEvasion);
            stream.WriteInt16(attribute.BlockChance);
            stream.WriteInt16(attribute.MoveSpeed);
            stream.WriteInt16(attribute.AttackSpeed);
            stream.WriteInt16(attribute.AttackRange);
            stream.WriteInt16(attribute.MaxWeight);
            stream.WriteInt16(attribute.CastingSpeed);
            stream.WriteInt16(attribute.CoolTimeSpeed);
            stream.WriteInt16(attribute.ItemChance);
            stream.WriteInt16(attribute.HPRegenPercentage);
            stream.WriteInt16(attribute.HPRegenPoint);
            stream.WriteInt16(attribute.MPRegenPercentage);
            stream.WriteInt16(attribute.MPRegenPoint);

            stream.WriteBool(isBonus);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#11
0
        /* TODO : add struct
        // 0x0258
        struct TS_SC_QUEST_LIST
        {
        TS_MESSAGE baseclass_0;
        unsigned __int16 count_active;
        unsigned __int16 count_pending;
        //TS_SC_QUEST_LIST::TS_QUEST_INFO actives[count_active];
        //TS_SC_QUEST_LIST::TS_PENDING_QUEST_INFO pendings[count_pending];
        };

        struct TS_SC_QUEST_LIST::TS_QUEST_INFO
        {
        int code;
        int nStartID;
        int nRandomValue[6];
        int nStatus[6];
        char nProgress;
        unsigned int nTimeLimit;
        };

        struct TS_SC_QUEST_LIST::TS_PENDING_QUEST_INFO
        {
        int code;
        int nStartID;
        };*/
        internal void Chat(Player player, string sender, byte type, string message)
        {
            PacketStream stream = new PacketStream(0x0016);

            stream.WriteString(sender, 21);
            stream.WriteUInt16((ushort)message.Length);
            stream.WriteByte(type);
            stream.WriteString(message, message.Length+1);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#12
0
        internal void BeltSlotInfo(Player player, BeltSlotData[] belt)
        {
            PacketStream stream = new PacketStream(0x00D8);

            for (int i = 0; i < 6; i++)
            {
                stream.WriteUInt32(belt[i].Handle);
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#13
0
        public void WeatherInfo(Player player, uint regionId, ushort weatherId)
        {
            PacketStream stream = new PacketStream(0x0386);

            stream.WriteUInt32(regionId);
            stream.WriteUInt16(weatherId);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#14
0
        /// <summary>
        /// Sends a list of URLs
        /// </summary>
        /// <param name="client"></param>
        public void UrlList(Player player)
        {
            PacketStream stream = new PacketStream(0x2329);

            stream.WriteUInt16((ushort)Server.UrlList.Length);
            stream.WriteString(Server.UrlList);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#15
0
        /// <summary>
        /// Sends the result of a packet
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packetId"></param>
        /// <param name="response"></param>
        /// <param name="value"></param>
        public void Result(Player client, ushort packetId, ushort response = 0, int value = 0)
        {
            PacketStream stream = new PacketStream(0x0000);

            stream.WriteUInt16(packetId);
            stream.WriteUInt16(response);
            stream.WriteInt32(value);

            ClientManager.Instance.Send(client, stream, BroadcastArea.Self);
        }
示例#16
0
        public void QuestList(Player player)
        {
            // TODO  : Quest List
            PacketStream stream = new PacketStream(0x0258);

            stream.WriteUInt16(0); // count_active
            stream.WriteUInt16(0); // count_pending

            for (int i = 0; i < 1; i++) // count_active
            {
                stream.WriteInt32(0); // code
                for (int j = 0; i < 6; i++) // nRandomValue
                {
                    stream.WriteInt32(0);
                }
                for (int j = 0; i < 6; i++) // nStatus
                {
                    stream.WriteInt32(0);
                }
                stream.WriteByte(0); // nProgress
                stream.WriteUInt32(0); // nTimeLimit
            }

            for (int i = 0; i < 1; i++) // count_pending
            {
                stream.WriteInt32(0); // code
                stream.WriteInt32(0); // nStartID
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#17
0
        internal void Move(Player player)
        {
            PacketStream stream = new PacketStream(0x0008);

            stream.WriteUInt32(Globals.GetTime());
            stream.WriteUInt32(player.Handle);
            stream.WriteByte(player.Position.Layer);
            stream.WriteByte(11); // speed
            stream.WriteUInt16((ushort)player.PositionsToMove.Count);
            for (int i = 0; i < player.PositionsToMove.Count; ++i)
            {
                stream.WriteSingle(player.PositionsToMove[i].X);
                stream.WriteSingle(player.PositionsToMove[i].Y);
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#18
0
        /// <summary>
        /// Sets a property
        /// </summary>
        /// <param name="player">target player</param>
        /// <param name="name">property name</param>
        /// <param name="value">value</param>
        /// <param name="isInt">send as int?</param>
        internal void Property(Player player, string name, object value, bool isInt)
        {
            PacketStream stream = new PacketStream(0x01FB);

            stream.WriteUInt32(player.Handle);
            stream.WriteBool(isInt);
            stream.WriteString(name, 16);
            if (isInt)
            {
                stream.WriteInt64(Convert.ToInt64(value));
            }
            else
            {
                stream.WriteInt64(0);
                string val = (string)value;
                stream.WriteString(val, val.Length + 1);
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#19
0
        internal void EquipSummon(Player player, SummonData[] summon, bool openDialog)
        {
            PacketStream stream = new PacketStream(0x012F);

            stream.WriteBool(openDialog);
            for (int i = 0; i < 6; i++)
            {
                stream.WriteUInt32(summon[i].CardHandle);
            }

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#20
0
        internal void StatusChange(Player player, uint handle, uint status)
        {
            PacketStream stream = new PacketStream(0x01F4);

            stream.WriteUInt32(handle);
            stream.WriteUInt32(status);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#21
0
        /// <summary>
        /// Sends the list of characters
        /// </summary>
        /// <param name="client"></param>
        /// <param name="charList"></param>
        public void CharacterList(Player client, LobbyCharacterInfo[] charList, ushort lastLoginIndex)
        {
            PacketStream stream = new PacketStream(0x07D4);

            stream.WriteUInt32(0); // currentSvTime
            stream.WriteUInt16(lastLoginIndex);
            stream.WriteUInt16((ushort)charList.Length);
            for (int i = 0; i < charList.Length; i++)
            {
                stream.WriteInt32(charList[i].ModelInfo.Sex);
                stream.WriteInt32(charList[i].ModelInfo.Race);
                for (int j = 0; j < 5; j++)
                    stream.WriteInt32(charList[i].ModelInfo.ModelId[j]);
                stream.WriteInt32(charList[i].ModelInfo.TextureId);
                for (int j = 0; j < 24; j++)
                    stream.WriteInt32(charList[i].ModelInfo.WearInfo[j]);
                stream.WriteInt32(charList[i].Level);
                stream.WriteInt32(charList[i].Job);
                stream.WriteInt32(charList[i].JobLevel);
                stream.WriteInt32(charList[i].ExpPercentage);
                stream.WriteInt32(charList[i].Hp);
                stream.WriteInt32(charList[i].Mp);
                stream.WriteInt32(charList[i].Permission);
                stream.WriteBool(charList[i].IsBanned);
                stream.WriteString(charList[i].Name, 19);
                stream.WriteUInt32(charList[i].SkinColor);
                stream.WriteString(charList[i].CreateTime, 30);
                stream.WriteString(charList[i].DeleteTime, 30);
                for (int j = 0; j < 24; j++)
                    stream.WriteInt32(charList[i].WearItemEnhanceInfo[j]);
                for (int j = 0; j < 24; j++)
                    stream.WriteInt32(charList[i].WearItemLevelInfo[j]);
                for (int j = 0; j < 24; j++)
                    stream.WriteByte(charList[i].WearItemElementalType[j]);
            }

            ClientManager.Instance.Send(client, stream, BroadcastArea.Self);
        }
示例#22
0
        internal void ExpUpdate(Player player, long exp, int jp)
        {
            PacketStream stream = new PacketStream(0x03EB);

            stream.WriteUInt32(player.Handle);
            stream.WriteInt64(exp);
            stream.WriteInt32(jp);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#23
0
 /// <summary>
 /// Called when an entire packet is received
 /// </summary>
 /// <param name="gs"></param>
 /// <param name="packetStream"></param>
 private void PacketReceived(Player gameClient, PacketStream packetStream)
 {
     ClientPackets.Instance.PacketReceived(gameClient, packetStream);
 }
示例#24
0
        internal void GoldUpdate(Player player, long gold, int chaos)
        {
            PacketStream stream = new PacketStream(0x03E9);

            stream.WriteInt64(gold);
            stream.WriteInt32(chaos);

            ClientManager.Instance.Send(player, stream, BroadcastArea.Self);
        }
示例#25
0
 /// <summary>
 /// Called when an entire packet is received
 /// </summary>
 /// <param name="gs"></param>
 /// <param name="packetStream"></param>
 private void PacketReceived(GameServer gameServer, PacketStream packetStream)
 {
     GamePackets.Instance.PacketReceived(gameServer, packetStream);
 }