private void onAuctionList(AuctionlistPacket pkt) { debtClient = pkt.TraderDebt; if (pkt.IsFullUpdate) { activeAuctions.Clear(); ownAuctions.Clear(); auctions.Clear(); } if (pkt.NewAuctions != null) { foreach (var auction in pkt.NewAuctions) { auctions[auction.AuctionId] = auction; auction.ItemStack.ResolveBlockOrItem(capi.World); if (auction.State == EnumAuctionState.Active || (auction.State == EnumAuctionState.Sold && (auction.RetrievableTotalHours - capi.World.Calendar.TotalHours) > 0)) { insertOrUpdate(activeAuctions, auction); } else { remove(activeAuctions, auction); } if ( (auction.SellerUid == capi.World.Player.PlayerUID) || (auction.State == EnumAuctionState.Sold && auction.BuyerUid == capi.World.Player.PlayerUID) ) { insertOrUpdate(ownAuctions, auction); } else { remove(ownAuctions, auction); } } } if (pkt.RemovedAuctions != null) { foreach (var auctionId in pkt.RemovedAuctions) { auctions.Remove(auctionId); RemoveFromList(auctionId, activeAuctions); RemoveFromList(auctionId, ownAuctions); } } activeAuctions.Sort(); ownAuctions.Sort(); OnCellUpdateClient?.Invoke(); }
private void sendAuctions(IEnumerable <Auction> newauctions, long[] removedauctions, bool isFullUpdate = false, IServerPlayer toPlayer = null) { var newauctionsa = newauctions?.ToArray(); if ((newauctionsa?.Length ?? 0) == 0 && (removedauctions?.Length ?? 0) == 0 && !isFullUpdate) { return; } float debt = 0; if (toPlayer != null) { auctionsData.DebtToTraderByPlayer.TryGetValue(toPlayer.PlayerUID, out debt); } var pkt = new AuctionlistPacket() { NewAuctions = newauctionsa, RemovedAuctions = removedauctions, IsFullUpdate = isFullUpdate, TraderDebt = debt }; if (toPlayer != null) { sapi.Network.GetChannel("auctionHouse").SendPacket(pkt, toPlayer); } else { foreach (var playeruid in createAuctionSlotByPlayer.Keys) { IServerPlayer plr = sapi.World.PlayerByUid(playeruid) as IServerPlayer; if (plr != null) { sapi.Network.GetChannel("auctionHouse").SendPacket(pkt, plr); } } } }