Exemplo n.º 1
0
        private static void HandleDestroy(ClientTCP client, byte[] data)
        {
            using (PacketBuffer buffer = new PacketBuffer())
            {
                buffer.WriteBytes(data);
                buffer.ReadInteger();
                ObjectType type  = (ObjectType)buffer.ReadInteger();
                int        index = buffer.ReadInteger();
                switch (type)
                {
                case ObjectType.player:
                    client.room.roomPlayers[index].Destroy(client.room);
                    break;

                case ObjectType.spell:
                    if (client.room.dynamicObjectsList[index] != null)     // Kostil
                    {
                        client.room.dynamicObjectsList[index].Destroy(client.room);
                    }
                    break;

                case ObjectType.staticObjects:
                    client.room.staticObjectsList[index].Destroy(client.room);
                    break;
                }
            }
        }
Exemplo n.º 2
0
 public static void SendDataToRoomPlayers(BaseGameRoom room, ClientTCP exceptClient, byte[] data)
 {
     try
     {
         for (int i = 0; i < room.PlayersCount; i++)
         {
             try
             {
                 if (room.playersTCP[i] != null && !exceptClient.Equals(room.playersTCP[i]))
                 {
                     room.playersTCP[i].socket.Send(data);
                 }
             }
             catch (Exception ex)
             {
                 room.playersTCP[i].Close();
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         Global.serverForm.Debug(ex + "");
     }
 }
Exemplo n.º 3
0
        private static void HandleDamage(ClientTCP client, byte[] data)
        {
            using (PacketBuffer buffer = new PacketBuffer())
            {
                buffer.WriteBytes(data);
                buffer.ReadInteger();
                ObjectType type          = (ObjectType)buffer.ReadInteger();
                int        _index        = buffer.ReadInteger();
                int        _physicDamage = buffer.ReadInteger();
                int        _ignisDamage  = buffer.ReadInteger();
                int        _terraDamage  = buffer.ReadInteger();
                int        _aquaDamage   = buffer.ReadInteger();
                int        _caeliDamage  = buffer.ReadInteger();
                int        _pureDamage   = buffer.ReadInteger();
                bool       _heal         = buffer.ReadBool();
                switch (type)
                {
                case ObjectType.player:
                    client.room.roomPlayers[_index].TakeDamage(client, _index, _physicDamage, _ignisDamage, _terraDamage, _aquaDamage, _caeliDamage, _pureDamage, _heal);
                    break;

                case ObjectType.spell:
                    client.room.dynamicObjectsList[_index].TakeDamage(client, _index, _physicDamage, _ignisDamage, _terraDamage, _aquaDamage, _caeliDamage, _pureDamage, _heal);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     int treeCount;
        ///                     for(treeCount)
        ///                     {
        ///                         int Index;
        ///                         int Health;
        ///                         float[3] pos;
        ///                         float[4] rot;
        ///                     }
        ///
        /// </summary>
        public static void SendTreeSpawned(ClientTCP client, int[] ranges)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.STreeSpawned);
            int start = ranges[0];
            int end   = ranges[1];

            buffer.WriteInteger(end - start + 1);
            while (start <= end)
            {
                var k = client.room.staticObjectsList.Get(start).GetInfo();
                buffer.WriteInteger(start);
                buffer.WriteInteger(k.Item1);
                buffer.WriteFloat(k.Item2[0]);
                buffer.WriteFloat(k.Item2[1]);
                buffer.WriteFloat(k.Item2[2]);
                buffer.WriteFloat(k.Item3[0]);
                buffer.WriteFloat(k.Item3[1]);
                buffer.WriteFloat(k.Item3[2]);
                buffer.WriteFloat(k.Item3[3]);
                start++;
            }
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 5
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string race;
        ///                     int spellCount;
        ///                     short[spellCount] spellIndex
        /// </summary>
        private static void HandleSaveSkillBuild(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            string race       = buffer.ReadString();
            int    spellCount = buffer.ReadInteger();

            string[] spellBuild = new string[spellCount];
            for (int i = 0; i < spellCount; i++)
            {
                string spellIndex = "" + buffer.ReadShort();
                while (spellIndex.Length != 4)
                {
                    spellIndex = "0" + spellIndex;
                }
                string spellType = "" + buffer.ReadShort();
                while (spellType.Length != 4)
                {
                    spellType = "0" + spellType;
                }
                spellBuild[i] = spellIndex + "" + spellType;
            }
            buffer.Dispose();
            //Global.data.SetSkillBuildData(client.nickname, race, spellBuild);
            SendDataTCP.SendBuildSaved(client);
        }
Exemplo n.º 6
0
 /// <summary>
 ///             Buffer:
 ///                     int PacketNum;
 ///                     int SpellIndex; (index in client's spell array)
 ///                     int ParentIndex;
 ///                     float[3] position;
 ///                     float[4] rotation;
 ///                     int hp;
 /// </summary>
 private static void HandleInstantiate(ClientTCP client, byte[] data)
 {
     using (PacketBuffer buffer = new PacketBuffer())
     {
         buffer.WriteBytes(data);
         buffer.ReadInteger();
         client.room.dynamicObjectsList.Add(
             client.room,
             buffer.ReadInteger(),
             buffer.ReadInteger(),
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             new float[] {
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat(),
             buffer.ReadFloat()
         },
             buffer.ReadInteger(),
             client.nickname
             );
     }
 }
Exemplo n.º 7
0
 /// <summary>
 ///             Buffer:
 ///                     int PacketNum;
 /// </summary>
 private static void HandleQueueStop(ClientTCP client, byte[] data)
 {
     Queue.StopSearch(client);
     foreach (ClientTCP friend in client.friends)
     {
         SendDataTCP.SendFriendChange(client, friend);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendRoomLogOut(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SPlayerLogOut);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 9
0
 public static void StopSearch(ClientTCP client)
 {
     if (client.room != null)
     {
         client.room.DeletePlayer(client);
     }
     client.playerState = NetPlayerState.InMainLobby;
 }
Exemplo n.º 10
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendRegisterOk(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SRegisterOK);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 11
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendBuildSaved(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SBuildSaved);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 12
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        /// </summary>
        public static void SendClientConnetionOK(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SConnectionOK);
            ServerTCP.SendClientConnection(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 13
0
 public void LoadSpells(ClientTCP client)
 {
     short[][] spellBuilds = new short[PlayersCount][];
     for (int i = 0; i < PlayersCount; i++)
     {
         spellBuilds[i] = playersTCP[i].accountData.AccountSkillBuilds.IgnisBuild.ToArray();
     }
     SendDataTCP.SendLoadSpells(client, spellBuilds);
 }
Exemplo n.º 14
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     float loadProgress;
        /// </summary>
        public static void SendEnemyProgress(BaseGameRoom room, ClientTCP client, float loadProgress)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SEnemyLoadProgress);
            buffer.WriteFloat(loadProgress);
            ServerTCP.SendDataToRoomPlayers(room, client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 15
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        public static void SendClientAlert(ClientTCP client, string message)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SAlert);
            buffer.WriteString(message);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 16
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     int mapIndex;
        /// </summary>
        public static void SendMapData(int mapIndex, ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SMapLoad);
            buffer.WriteInteger(mapIndex);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 17
0
        public static void SendFriendLeave(ClientTCP player, ClientTCP friend)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SFriendLeave);
            buffer.WriteString(player.accountData.GuideKey);
            ServerTCP.SendDataToClient(friend, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 18
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        public static void SendPlayerConnectionOK(ClientTCP player)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SConnectionOK);
            buffer.WriteString("Hello sexy guy...We've been waiting for you =*");
            ServerTCP.SendDataToClient(player, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 19
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string message;
        /// </summary>
        private static void HandleGlChatMsg(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            SendDataTCP.SendGlChatMsg(client.nickname, buffer.ReadString() /* message */);
            buffer.Dispose();
        }
Exemplo n.º 20
0
        /// <summary>
        ///             Buffer:
        ///                     int PacketNum;
        ///                     string winnerNickname;
        /// </summary>
        public static void SendMatchEnded(ClientTCP client)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SMatchResult);
            buffer.WriteString(client.nickname);
            ServerTCP.SendDataToClient(client, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 21
0
        private static void HandleTreesSpawn(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            client.room.SetLoadProgress(client, buffer.ReadFloat());
            client.room.SpawnTree(client, buffer.ReadInteger(), buffer.ReadBool(), buffer.ReadBool(), buffer.ReadBool());
            buffer.Dispose();
        }
Exemplo n.º 22
0
        private static void HandleGetSpells(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            client.room.SetLoadProgress(client, buffer.ReadFloat());
            buffer.Dispose();
            client.room.LoadSpells(client);
        }
Exemplo n.º 23
0
 private static void HandleTestRoom(ClientTCP client, byte[] data)
 {
     using (PacketBuffer buffer = new PacketBuffer())
     {
         buffer.WriteBytes(data);
         buffer.ReadInteger();
         int mapIndex = buffer.ReadInteger();
         client.race = buffer.ReadString();
         Global.roomsList.Add(new TestRoom(client, mapIndex));
     }
 }
Exemplo n.º 24
0
 public void Surrended(ClientTCP client)
 {
     CloseUpdateTimer();
     Status = RoomState.MatchEnded;
     foreach (ClientTCP player in playersTCP)
     {
         player.playerState = NetPlayerState.EndPlaying;
     }
     _closeTimer = new Timer(EndGameSession, null, 300000, Timeout.Infinite);
     SendDataTCP.SendMatchEnded(client.nickname, this);
 }
Exemplo n.º 25
0
        private static void HandleAddFriend(ClientTCP client, byte[] data)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteBytes(data);
            buffer.ReadInteger();
            string guideTag = buffer.ReadString();

            buffer.Dispose();
            client.AddFriend(guideTag);
        }
Exemplo n.º 26
0
 public static void SendDataToClient(ClientTCP client, byte[] data)
 {
     try
     {
         client.socket.Send(data);
     }
     catch
     {
         client.Close();
     }
 }
Exemplo n.º 27
0
        public static void SendFriendInfo(ClientTCP player, ClientTCP friend)
        {
            PacketBuffer buffer = new PacketBuffer();

            buffer.WriteInteger((int)ServerPackets.SFriendInfo);
            buffer.WriteString(friend.nickname);
            buffer.WriteString(friend.accountData.GuideKey);
            buffer.WriteInteger((int)friend.playerState);
            ServerTCP.SendDataToClient(player, buffer.ToArray());
            buffer.Dispose();
        }
Exemplo n.º 28
0
 private static void AcceptCallback(IAsyncResult ar)
 {
     if (!Closed)
     {
         Socket socket = _serverSocket.EndAccept(ar);
         _serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);
         ClientTCP client = new ClientTCP(socket, socket.RemoteEndPoint as IPEndPoint);
         Global.clientList.Add(client);
         SendDataTCP.SendClientConnetionOK(client);
     }
 }
Exemplo n.º 29
0
 public void SpawnTree(ClientTCP client, int treeCount, bool bigTree, bool mediumTree, bool smallTree)
 {
     int[] ranges;
     lock (expectant)
     {
         if (!staticObjectsList.GetRange(StaticTypes.tree, out ranges))
         {
             ranges = staticObjectsList.Add(StaticTypes.tree, ObjectType.staticObjects, this, treeCount, bigTree, mediumTree, smallTree);
         }
     }
     SendDataTCP.SendTreeSpawned(client, ranges);
 }
Exemplo n.º 30
0
 public void AddClient(ClientTCP client)
 {
     if (listClients.InvokeRequired)
     {
         StringArgReturningVoidDelegate <ClientTCP> d = new StringArgReturningVoidDelegate <ClientTCP>(AddClient);
         Invoke(d, new object[] { client });
     }
     else
     {
         listClients.Items.Add(client);
     }
 }