public bool TryConnect(Client client) { if (Clients.Count >= MaxClient) return false; else return Clients.TryAdd(client.Account.AccountId, client); }
public Vault(bool isLimbo, Client client = null) { Id = VAULT_ID; Name = "Vault"; Background = 2; IsLimbo = isLimbo; this.client = client; }
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; }
public Vault(bool isLimbo, Client client = null) { Id = VAULT_ID; Name = "Vault"; Background = 2; Difficulty = 0; IsLimbo = isLimbo; SetMusic("world/Vault"); this.client = client; }
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); } }
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"; }
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, }; }
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); } }
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(); } }
public override World GetInstance(Client client) { return RealmManager.AddWorld(new WineCellarMap()); }
public override World GetInstance(Client client) { return RealmManager.AddWorld(new Vault(false, client)); }
public void Read(Client client, byte[] body, int offset, int len) { Crypt(client, body, offset, len); Read(client, new NReader(new MemoryStream(body))); }
public override World GetInstance(Client client) { return Manager.AddWorld(new SnakePit()); }
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()); }
protected abstract void Read(Client client, NReader rdr);
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)); }
protected override void Write(Client client, NWriter wtr) { }
protected override void Read(Client client, NReader rdr) { }
public override World GetInstance(Client psr) { return Manager.AddWorld(new PetYard(psr.Player)); }
public override World GetInstance(Client client) { return RealmManager.AddWorld(new SpriteWorld()); }
public override World GetInstance(Client client) { return Manager.AddWorld(new PVPArena()); }
public override World GetInstance(Client client) { return Manager.Monitor.GetRandomRealm(); }
public NetworkHandler(Client parent, Socket skt) { this.parent = parent; this.skt = skt; }
protected abstract void Write(Client client, NWriter wtr);
public override World GetInstance(Client psr) { return Manager.AddWorld(new UndeadLair()); }
public override World GetInstance(Client client) { return Manager.AddWorld(new Tutorial(false)); }