public void LoadAccounts() { lock (LoadLock) { if (!File.Exists(AccountPath)) SaveAccounts(); using (FileStream stream = File.OpenRead(AccountPath)) using (BinaryReader reader = new BinaryReader(stream)) { LoadVersion = reader.ReadInt32(); if (LoadVersion > 57) LoadCustomVersion = reader.ReadInt32(); NextAccountID = reader.ReadInt32(); NextCharacterID = reader.ReadInt32(); NextUserItemID = reader.ReadUInt64(); if (LoadVersion > 27) { GuildCount = reader.ReadInt32(); NextGuildID = reader.ReadInt32(); } int count = reader.ReadInt32(); AccountList.Clear(); CharacterList.Clear(); for (int i = 0; i < count; i++) { AccountList.Add(new AccountInfo(reader)); CharacterList.AddRange(AccountList[i].Characters); } if (LoadVersion < 7) return; foreach (AuctionInfo auction in Auctions) auction.CharacterInfo.AccountInfo.Auctions.Remove(auction); Auctions.Clear(); if (LoadVersion >= 8) NextAuctionID = reader.ReadUInt64(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AuctionInfo auction = new AuctionInfo(reader, LoadVersion, LoadCustomVersion); if (!BindItem(auction.Item) || !BindCharacter(auction)) continue; Auctions.AddLast(auction); auction.CharacterInfo.AccountInfo.Auctions.AddLast(auction); } if (LoadVersion == 7) { foreach (AuctionInfo auction in Auctions) { if (auction.Sold && auction.Expired) auction.Expired = false; auction.AuctionID = ++NextAuctionID; } } if(LoadVersion > 43) { NextMailID = reader.ReadUInt64(); Mail.Clear(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader, LoadVersion, LoadCustomVersion)); } } } } }
private bool BindCharacter(AuctionInfo auction) { for (int i = 0; i < CharacterList.Count; i++) { if (CharacterList[i].Index != auction.CharacterIndex) continue; auction.CharacterInfo = CharacterList[i]; return true; } return false; }
public void ConsignItem(ulong uniqueID, uint price) { S.ConsignItem p = new S.ConsignItem { UniqueID = uniqueID }; if (price < Globals.MinConsignment || price > Globals.MaxConsignment || Dead) { Enqueue(p); return; } if (NPCPage == null || !String.Equals(NPCPage.Key, NPCObject.ConsignKey, StringComparison.CurrentCultureIgnoreCase)) { Enqueue(p); return; } if (Account.Gold < Globals.ConsignmentCost) { Enqueue(p); return; } for (int n = 0; n < CurrentMap.NPCs.Count; n++) { NPCObject ob = CurrentMap.NPCs[n]; if (ob.ObjectID != NPCID) continue; UserItem temp = null; int index = -1; for (int i = 0; i < Info.Inventory.Length; i++) { temp = Info.Inventory[i]; if (temp == null || temp.UniqueID != uniqueID) continue; index = i; break; } if (temp == null || index == -1) { Enqueue(p); return; } if (temp.Info.Bind.HasFlag(BindMode.DontSell)) { Enqueue(p); return; } //Check Max Consignment. AuctionInfo auction = new AuctionInfo { AuctionID = ++Envir.NextAuctionID, CharacterIndex = Info.Index, CharacterInfo = Info, ConsignmentDate = Envir.Now, Item = temp, Price = price }; Account.Auctions.AddLast(auction); Envir.Auctions.AddFirst(auction); p.Success = true; Enqueue(p); Report.ItemChanged("ConsignItem", temp, temp.Count, 1); Info.Inventory[index] = null; Account.Gold -= Globals.ConsignmentCost; Enqueue(new S.LoseGold { Gold = Globals.ConsignmentCost }); RefreshBagWeight(); } Enqueue(p); }
public bool Match(AuctionInfo info) { if (Envir.Now >= info.ConsignmentDate.AddDays(Globals.ConsignmentLength) && !info.Sold) info.Expired = true; return (UserMatch || !info.Expired && !info.Sold) && ((MatchType == ItemType.Nothing || info.Item.Info.Type == MatchType) && (string.IsNullOrWhiteSpace(MatchName) || info.Item.Info.Name.Replace(" ", "").IndexOf(MatchName, StringComparison.OrdinalIgnoreCase) >= 0)); }
public void LoadAccounts() { lock (LoadLock) { if (!File.Exists(AccountPath)) SaveAccounts(); using (FileStream stream = File.OpenRead(AccountPath)) using (BinaryReader reader = new BinaryReader(stream)) { LoadVersion = reader.ReadInt32(); if (LoadVersion > 57) LoadCustomVersion = reader.ReadInt32(); NextAccountID = reader.ReadInt32(); NextCharacterID = reader.ReadInt32(); NextUserItemID = reader.ReadUInt64(); if (LoadVersion > 27) { GuildCount = reader.ReadInt32(); NextGuildID = reader.ReadInt32(); } int count = reader.ReadInt32(); AccountList.Clear(); CharacterList.Clear(); for (int i = 0; i < count; i++) { AccountList.Add(new AccountInfo(reader)); CharacterList.AddRange(AccountList[i].Characters); } if (LoadVersion < 7) return; foreach (AuctionInfo auction in Auctions) auction.CharacterInfo.AccountInfo.Auctions.Remove(auction); Auctions.Clear(); if (LoadVersion >= 8) NextAuctionID = reader.ReadUInt64(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { AuctionInfo auction = new AuctionInfo(reader, LoadVersion, LoadCustomVersion); if (!BindItem(auction.Item) || !BindCharacter(auction)) continue; Auctions.AddLast(auction); auction.CharacterInfo.AccountInfo.Auctions.AddLast(auction); } if (LoadVersion == 7) { foreach (AuctionInfo auction in Auctions) { if (auction.Sold && auction.Expired) auction.Expired = false; auction.AuctionID = ++NextAuctionID; } } if(LoadVersion > 43) { NextMailID = reader.ReadUInt64(); Mail.Clear(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { Mail.Add(new MailInfo(reader, LoadVersion, LoadCustomVersion)); } } if(LoadVersion >= 63) { int logCount = reader.ReadInt32(); for (int i = 0; i < logCount; i++) { GameshopLog.Add(reader.ReadInt32(), reader.ReadInt32()); } if (ResetGS) ClearGameshopLog(); } if (LoadVersion >= 68) { int SaveCount = reader.ReadInt32(); for (int i = 0; i < SaveCount; i++) { RespawnSave Saved = new RespawnSave(reader); foreach (MapRespawn Respawn in SavedSpawns) { if (Respawn.Info.RespawnIndex == Saved.RespawnIndex) { Respawn.NextSpawnTick = Saved.NextSpawnTick; if ((Saved.Spawned) && ((Respawn.Info.Count * spawnmultiplyer) > Respawn.Count)) { int mobcount = (Respawn.Info.Count * spawnmultiplyer) - Respawn.Count; for (int j = 0; j < mobcount; j++) { Respawn.Spawn(); } } } } } } } } }