Ejemplo n.º 1
0
 public static Channel Find(Muid uid)
 {
     lock (ObjectLock)
         return
             Channels.Find(
                 c => c.GetTraits().ChannelId == uid && c.GetTraits().MaxUsers != c.GetTraits().Playerlist.Count);
 }
Ejemplo n.º 2
0
        public static void ResponseAllPlayerList(Client client, List<Client> clients, Muid channelId)
        {
            using (var packet = new PacketWriter(Operation.ChannelResponseAllPlayerList, CryptFlags.Encrypt))
            {
                packet.Write(channelId);
                packet.Write(clients.Count, 73);

                foreach (var c in clients)
                {
                    packet.Write(c.GetMuid());
                    packet.Write(c.GetCharacter().Name, 32);
                    packet.Write(c.GetCharacter().ClanName, 16);
                    packet.Write((byte)c.GetCharacter().Level);
                    packet.Write((byte)c.GetCharacter().DuelRank);//dagger for duel tourney.
                    packet.Write((Int32)c.ClientPlayer.PlayerLocation);
                    packet.Write((byte)c.ClientPlayer.PlayerAccount.Access);
                    packet.Write((byte)2);
                    packet.Write(c.GetCharacter().ClanId);
                    packet.Write(0);//unknown.
                    packet.Write((byte)3);//unknown
                }

                client.Send(packet);
            }
        }
Ejemplo n.º 3
0
 public static void ReserveStageToAgent(Client client, Muid stageId)
 {
     using (var packet = new PacketWriter(Operation.AgentStageReserve, CryptFlags.Encrypt))
     {
         packet.Write(stageId);
         client.Send(packet);
     }
 }
Ejemplo n.º 4
0
 public static void ResponsePeerRelay(Client client, Muid playerId)
 {
     using (var packet = new PacketWriter(Operation.MatchResponsePeerRelay, CryptFlags.Encrypt))
     {
         packet.Write(playerId);
         client.Send(packet);
     }
 }
Ejemplo n.º 5
0
        public static void AssignBerserker(List<Client> clients, Muid berserkerId)
        {
            using (var packet = new PacketWriter(Operation.MatchAssignBerserker, CryptFlags.Encrypt))
            {
                packet.Write(berserkerId);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 6
0
        public static void AssignVips(List<Client> clients, Muid red, Muid blue)
        {
            using (var packet = new PacketWriter(Operation.MatchAssignCommander, CryptFlags.Encrypt))
            {
                packet.Write(red);
                packet.Write(blue);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 7
0
        public Client(Socket pSocket, Muid pUid)
        {
            ClientIp = ((IPEndPoint)pSocket.RemoteEndPoint).Address.ToString();
            _socket = pSocket;
            ClientPlayer =  new Player(pUid);
            Log.Write("{0} Client connected", ClientIp);

            Handshake();
            _socket.BeginReceive(_buffer, 0, 4096, SocketFlags.None, new AsyncCallback(HandleReceive), null);
        }
Ejemplo n.º 8
0
        public static void QuestError(List<Client> clients, int error, Muid stageId)
        {
            using (var packet = new PacketWriter(Operation.QuestFail, CryptFlags.Encrypt))
            {
                packet.Write(error);
                packet.Write(stageId);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 9
0
        public Muid ReadMuid()
        {
            Muid uid = new Muid();
            var first = ReadInt32();
            var second = ReadInt32();

            uid.LowId = first;
            uid.HighId = second;

            return uid;
        }
Ejemplo n.º 10
0
        public static void AskAgreement(List<Client> members, int request, string name, Muid master, string masterName)
        {
            using (var packet = new PacketWriter(Operation.MatchClanAskSponsorAgreement, CryptFlags.Encrypt))
            {
                packet.Write(request);
                packet.Write(name);
                packet.Write(master);
                packet.Write(masterName);

                members.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 11
0
        public static void ResponseChat(List<Client> clients, Muid channelId, string charName, string message, UGradeId access)
        {
            using (var packet = new PacketWriter(Operation.ChannelChat, CryptFlags.Encrypt))
            {
                packet.Write(channelId);
                packet.Write(charName);
                packet.Write(message);
                packet.Write((Int32)access);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 12
0
        public static void AgentLocateToClient(Client client, Muid agentId)
        {
            using (var packet = new PacketWriter(Operation.AgentLocateToClient, CryptFlags.Encrypt))
            {
                packet.Write(agentId);
                packet.Write(Globals.Config.Agent.RemoteIp);
                packet.Write((Int32)Globals.Config.Agent.TcpPort);
                packet.Write((Int32)Globals.Config.Agent.UdpPort);

                Log.Write("Telling client to locate to: {0}:{1}:{2}", Globals.Config.Agent.RemoteIp,
                          Globals.Config.Agent.TcpPort, Globals.Config.Agent.UdpPort);
                client.Send(packet);
            }
        }
Ejemplo n.º 13
0
        public static void ResponseStageTeam(List<Client> clients, Muid playerId, Muid stageId, Team team)
        {
            using (var packet = new PacketWriter(Operation.StageTeam, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write(stageId);
                packet.Write((Int32)team);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 14
0
        public static void StageRoundUpdate(Client client, Muid stageId, Int32 curRound, RoundState roundState, Int32 winner = 0)
        {
            using (var packet = new PacketWriter(Operation.StageRoundState, CryptFlags.Encrypt))
            {
                packet.Write(stageId);
                packet.Write(curRound);
                packet.Write((Int32)roundState);
                packet.Write(winner);

                client.Send(packet);
            }
        }
Ejemplo n.º 15
0
        public static void SetObserver(List<Client> clients, Muid playerId)
        {
            using (var packet = new PacketWriter(Operation.MatchSetObserver, CryptFlags.Encrypt))
            {
                packet.Write(playerId);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 16
0
        public static void LoadingComplete(List<Client> clients, Muid playerId)
        {
            using (var packet = new PacketWriter(Operation.LoadingComplete, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write(100);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 17
0
        public static void GameSpawn(List<Client> clients, Muid playerId, Position position, Direction direction)
        {
            using (var packet = new PacketWriter(Operation.GameResponseSpawn, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write((UInt16)position.X);
                packet.Write((UInt16)position.Y);
                packet.Write((UInt16)position.Z);
                packet.Write((UInt16)(direction.X * 32000.0));
                packet.Write((UInt16)(direction.Y * 32000.0));
                packet.Write((UInt16)(direction.Z * 32000.0));

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 18
0
 public ChannelTraits(Muid uid)
 {
     ChannelId = uid;
 }
Ejemplo n.º 19
0
 public static void ResponseRecommendedChannel(Client client, Muid channelId)
 {
     using (var packet = new PacketWriter(Operation.MatchResponseRecommendedChannel, CryptFlags.Encrypt))
     {
         packet.Write(channelId);
         client.Send(packet);
     }
 }
Ejemplo n.º 20
0
        public static void ResponseLogin(Client client, Results results,  string user, UGradeId ugrade, PGradeId pgrade, Muid playerId)
        {
            using (var packetWriter = new PacketWriter(Operation.MatchLoginResponse, CryptFlags.Encrypt))
            {
                packetWriter.Write((Int32)results);
                packetWriter.Write(Globals.Config.Server.Name);

                switch (Globals.Config.Server.Mode.ToLower())
                {
                    case "match":
                        packetWriter.Write((byte)0);
                        break;

                    case "clan":
                        packetWriter.Write((byte)1);
                        break;

                    case "quest":
                        packetWriter.Write((byte)4);
                        break;;

                    case "test":
                        packetWriter.Write((byte)4);
                        break;

                    case "develop":
                        packetWriter.Write((byte)3);
                        break;
                    default:
                        packetWriter.Write((byte)1);
                        break;
                }

                packetWriter.Write(user);
                packetWriter.Write((byte)ugrade);
                packetWriter.Write((byte)pgrade);
                packetWriter.Write(playerId);
                packetWriter.Write(Globals.Config.Server.Survival);
                packetWriter.Write(Globals.Config.Server.DuelTourney);
                packetWriter.Write(1, 20);
                packetWriter.WriteSkip(20);

                client.Send(packetWriter);
            }
        }
Ejemplo n.º 21
0
        public static void GameLevelUp(List<Client> clients, Muid uid, Int32 level)
        {
            using (var packet = new PacketWriter(Operation.GameLevelUp, CryptFlags.Encrypt))
            {
                packet.Write(uid);
                packet.Write(level);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 22
0
 public static void UnbindPeer(Client client, Muid playerId)
 {
     using (var packet = new PacketWriter(Operation.AgentPeerUnbind, CryptFlags.Encrypt))
     {
         packet.Write(playerId);
         client.Send(packet);
     }
 }
Ejemplo n.º 23
0
        public static void LeaveBattle(List<Client> clients, Muid playerId, bool relayMap = false)
        {
            using (var packet = new PacketWriter(Operation.StageResponseLeaveBattle, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write(relayMap);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 24
0
 public Player(Muid uid)
 {
     PlayerId = uid;
 }
Ejemplo n.º 25
0
        public static void ObtainWorldItem(List<Client> clients, Muid player, int item)
        {
            using (var packet = new PacketWriter(Operation.MatchWorldItemObtain, CryptFlags.Encrypt))
            {
                packet.Write(player);
                packet.Write(item);

                clients.ForEach(c=> c.Send(packet));
            }
        }
Ejemplo n.º 26
0
        public static void ResponsePlayerState(List<Client> clients, Muid playerId, Muid stageId, ObjectStageState state)
        {
            using (var packet = new PacketWriter(Operation.StageState, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write(stageId);
                packet.Write((Int32)state);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 27
0
        public static void StageFinish(List<Client> clients, Muid stageId, bool relayFinished = true)
        {
            using (var packet = new PacketWriter(Operation.StageFinish, CryptFlags.Encrypt))
            {
                packet.Write(stageId);
                packet.Write(relayFinished);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 28
0
        public static void ResponseStageChat(List<Client> clients, Muid playerId, Muid stageId, string message)
        {
            using (var packet = new PacketWriter(Operation.StageChat, CryptFlags.Encrypt))
            {
                packet.Write(playerId);
                packet.Write(stageId);
                packet.Write(message);

                clients.ForEach(c => c.Send(packet));
            }
        }
Ejemplo n.º 29
0
 public static Client GetClientFromUid(Muid uidClient)
 {
     lock (Clients)
         return Clients.Find(c => c.GetMuid() == uidClient);
 }
Ejemplo n.º 30
0
        public static void ResponseStageLeave(List<Client> clients, Muid player)
        {
            using (var packet = new PacketWriter(Operation.StageLeave, CryptFlags.Encrypt))
            {
                packet.Write(player);

                clients.ForEach(c => c.Send(packet));
            }
        }