Ejemplo n.º 1
0
 public bool TryConnect(Client client)
 {
     if (Clients.Count >= MaxClient)
         return false;
     else
         return Clients.TryAdd(client.Account.AccountId, client);
 }
Ejemplo n.º 2
0
        public Vault(bool isLimbo, Client client = null)
        {
            Id = VAULT_ID;
            Name = "Vault";
            Background = 2;
            IsLimbo = isLimbo;

            this.client = client;
        }
Ejemplo n.º 3
0
 void Listen(IAsyncResult ar)
 {
     var cliSkt = Socket.EndAccept(ar);
     Socket.BeginAccept(Listen, null);
     if (cliSkt != null)
     {
         var client = new Client(Manager, cliSkt);
         client.BeginProcess();
     }
 }
        public int Write(Client client, byte[] buff, int offset)
        {
            MemoryStream s = new MemoryStream(buff, offset + 5, buff.Length - offset - 5);
            Write(client, new NWriter(s));

            int len = (int)s.Position;
            Crypt(client, buff, offset + 5, len);
            Buffer.BlockCopy(BitConverter.GetBytes(IPAddress.HostToNetworkOrder(len + 5)), 0, buff, offset, 4);
            buff[offset + 4] = (byte)ID;
            return len + 5;
        }
Ejemplo n.º 5
0
        public Vault(bool isLimbo, Client client = null)
        {
            Id = VAULT_ID;
            Name = "Vault";
            Background = 2;
            Difficulty = 0;
            IsLimbo = isLimbo;
            SetMusic("world/Vault");

            this.client = client;
        }
Ejemplo n.º 6
0
 public Vault(bool isLimbo, Client client = null)
 {
     Id = VAULT_ID;
     Name = "Vault";
     Background = 2;
     if (!(IsLimbo = isLimbo))
     {
         base.FromWorldMap(typeof(RealmManager).Assembly.GetManifestResourceStream("wServer.realm.worlds.vault.wmap"));
         Init(client);
     }
 }
Ejemplo n.º 7
0
 public Vault(bool isLimbo, Client psr = null)
 {
     Id = VAULT_ID;
     Name = "Vault";
     ClientWorldName = "server.Vault";
     Background = 2;
     this.psr = psr;
     this.isLimbo = isLimbo;
     ShowDisplays = true;
     if (psr != null)
         AccountId = psr.Account != null ? psr.Account.AccountId : "-1";
     else
         AccountId = "-1";
 }
Ejemplo n.º 8
0
        public Player(Client client)
            : base(client.Manager, (ushort)client.Character.ObjectType, client.Random)
        {
            this.client = client;
            statsMgr = new StatsManager(this);
            Name = client.Account.Name;
            AccountId = client.Account.AccountId;

            Level = client.Character.Level;
            Experience = client.Character.Exp;
            ExperienceGoal = GetExpGoal(client.Character.Level);
            Stars = GetStars();
            Texture1 = client.Character.Tex1;
            Texture2 = client.Character.Tex2;
            Credits = client.Account.Credits;
            NameChosen = client.Account.NameChosen;
            CurrentFame = client.Account.Stats.Fame;
            Fame = client.Character.CurrentFame;
            var state = client.Account.Stats.ClassStates.SingleOrDefault(_ => _.ObjectType == ObjectType);
            if (state != null)
                FameGoal = GetFameGoal(state.BestFame);
            else
                FameGoal = GetFameGoal(0);
            Glowing = true;
            Guild = "";
            GuildRank = -1;
            HP = client.Character.HitPoints;
            MP = client.Character.MagicPoints;
            ConditionEffects = 0;

            Inventory = new Inventory(this,
                client.Character.Equipment
                    .Select(_ => _ == 0xffff ? null : client.Manager.GameData.Items[_])
                    .ToArray());
            Inventory.InventoryChanged += (sender, e) => CalculateBoost();
            SlotTypes = Utils.FromCommaSepString32(client.Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value);
            Stats = new int[]
            {
                client.Character.MaxHitPoints,
                client.Character.MaxMagicPoints,
                client.Character.Attack,
                client.Character.Defense,
                client.Character.Speed,
                client.Character.HpRegen,
                client.Character.MpRegen,
                client.Character.Dexterity,
            };
        }
Ejemplo n.º 9
0
        private void Init(Client client)
        {
            this.Client = client;
            this.acc = client.Account;
            List<IntPoint> vaultChestPosition = new List<IntPoint>();
            IntPoint spawn = new IntPoint(0, 0);

            int w = Map.Width;
            int h = Map.Height;
            for (int y = 0; y < h; y++)
                for (int x = 0; x < w; x++)
                {
                    var tile = Map[x, y];
                    if (tile.Region == TileRegion.Spawn)
                        spawn = new IntPoint(x, y);
                    else if (tile.Region == TileRegion.Vault)
                        vaultChestPosition.Add(new IntPoint(x, y));
                }
            vaultChestPosition.Sort((x, y) => Comparer<int>.Default.Compare(
                (x.X - spawn.X) * (x.X - spawn.X) + (x.Y - spawn.Y) * (x.Y - spawn.Y),
                (y.X - spawn.X) * (y.X - spawn.X) + (y.Y - spawn.Y) * (y.Y - spawn.Y)));

            var chests = client.Account.Vault.Chests;
            for (int i = 0; i < chests.Count; i++)
            {
                Container con = new Container(0x0504, null, false);
                var inv = chests[i].Items.Select(_ => _ == -1 ? null : (XmlDatas.ItemDescs.ContainsKey((short)_) ? XmlDatas.ItemDescs[(short)_] : null)).ToArray();
                for (int j = 0; j < 8; j++)
                    con.Inventory[j] = inv[j];
                con.Move(vaultChestPosition[0].X + 0.5f, vaultChestPosition[0].Y + 0.5f);
                EnterWorld(con);
                vaultChestPosition.RemoveAt(0);

                vaultChests[new Tuple<Container, VaultChest>(con, chests[i])] = con.UpdateCount;
            }
            foreach (var i in vaultChestPosition)
            {
                SellableObject x = new SellableObject(0x0505);
                x.Move(i.X + 0.5f, i.Y + 0.5f);
                EnterWorld(x);
            }
        }
Ejemplo n.º 10
0
 private static void Listen(IAsyncResult ar)
 {
     Socket skt = null;
     try
     {
         skt = svrSkt.EndAccept(ar);
     }
     catch (ObjectDisposedException)
     {
     }
     try
     {
         svrSkt.BeginAccept(Listen, null);
     }
     catch (ObjectDisposedException)
     {
     }
     if (skt != null)
     {
         var psr = new Client(skt);
         psr.BeginProcess();
     }
 }
Ejemplo n.º 11
0
 public override World GetInstance(Client client)
 {
     return RealmManager.AddWorld(new WineCellarMap());
 }
Ejemplo n.º 12
0
 public override World GetInstance(Client client)
 {
     return RealmManager.AddWorld(new Vault(false, client));
 }
Ejemplo n.º 13
0
 public void Read(Client client, byte[] body, int offset, int len)
 {
     Crypt(client, body, offset, len);
     Read(client, new NReader(new MemoryStream(body)));
 }
Ejemplo n.º 14
0
 public override World GetInstance(Client client)
 {
     return Manager.AddWorld(new SnakePit());
 }
Ejemplo n.º 15
0
 public override void Crypt(Client client, byte[] dat, int offset, int len)
 {
 }
 public override World GetInstance(Client psr)
 {
     return Manager.AddWorld(new LairofShaitan());
 }
 public override World GetInstance(Client psr)
 {
     return Manager.AddWorld(new WineCellar());
 }
Ejemplo n.º 18
0
 protected abstract void Read(Client client, NReader rdr);
Ejemplo n.º 19
0
 public void AddPendingPacket(Client client, PacketID id, byte[] packet)
 {
     pendings.Enqueue(new Work(client, id, packet));
 }
 public void AddPendingPacket(Client parrent, Packet pkt)
 {
     pendings.Enqueue(new Work(parrent, pkt));
 }
Ejemplo n.º 21
0
 protected override void Write(Client client, NWriter wtr)
 {
 }
Ejemplo n.º 22
0
 protected override void Read(Client client, NReader rdr)
 {
 }
Ejemplo n.º 23
0
 public override World GetInstance(Client psr)
 {
     return Manager.AddWorld(new PetYard(psr.Player));
 }
Ejemplo n.º 24
0
 public override World GetInstance(Client client)
 {
     return RealmManager.AddWorld(new SpriteWorld());
 }
Ejemplo n.º 25
0
 public override World GetInstance(Client client)
 {
     return Manager.AddWorld(new PVPArena());
 }
Ejemplo n.º 26
0
 public override World GetInstance(Client client)
 {
     return Manager.Monitor.GetRandomRealm();
 }
 public NetworkHandler(Client parent, Socket skt)
 {
     this.parent = parent;
     this.skt = skt;
 }
Ejemplo n.º 28
0
 protected abstract void Write(Client client, NWriter wtr);
 public override World GetInstance(Client psr)
 {
     return Manager.AddWorld(new UndeadLair());
 }
Ejemplo n.º 30
0
 public override World GetInstance(Client client)
 {
     return Manager.AddWorld(new Tutorial(false));
 }