private static void CacheBanners() { //T.Restart(); for (var i = 0; i < 10_000; i++) { // need to cache the banners before CEK adds background colours which // causes custom banners to crash for reasons unknown // have to use a seed because the game hasn't initialized the game's // inefficient but does it really matter for 38ms once at startup Banners.Add(Banner.CreateRandomBanner((int)DateTime.Now.Ticks)); } //Log(T.ElapsedMilliseconds); }
public Banner.Banner AddBanner(Banner.Banner banner) { if (Banners == null) { Banners = new List <Banner.Banner>(); } if (Banners.Any(p => p.Id == banner.Id)) { throw new Exception("Banner is exist."); } Banners.Add(banner); AddOrChangeEvent(); return(banner); }
public override void ParseFromNetworkMessage(NetworkMessage message) { CategoryName = message.ReadString(); DisplayOfferId = message.ReadUInt32(); WindowType = message.ReadByte(); Collections.Capacity = message.ReadByte(); for (var i = 0; i < Collections.Capacity; ++i) { Collections.Add(message.ReadString()); } if (Client.VersionNumber >= 11900000) { DisplaySubCategory = message.ReadString(); } Offers.Capacity = message.ReadUInt16(); for (var i = 0; i < Offers.Capacity; ++i) { var offer = new Offer { Name = message.ReadString(), IsFeatured = WindowType == 3 }; offer.Details.Capacity = message.ReadByte(); for (var j = 0; j < offer.Details.Capacity; ++j) { var details = new OfferDetails { Id = message.ReadUInt32(), Amount = message.ReadUInt16(), Price = message.ReadUInt32() }; if (Client.VersionNumber >= 11900000) { details.IsConfirmedPrice = message.ReadBool(); } details.IsDisabled = message.ReadBool(); if (details.IsDisabled) { details.DisabledReasons.Capacity = message.ReadByte(); for (var x = 0; x < details.DisabledReasons.Capacity; ++x) { var disabledReason = message.ReadString(); details.DisabledReasons.Add(disabledReason); } } details.HighlightState = message.ReadByte(); if (details.HighlightState == (int)StoreOfferHighlightState.Sale) { // This may actually be wrong, but since there aren't currently // any items on sale I can't confirm it. var saleValidUntilTimestamp = message.ReadUInt32(); var basePrice = message.ReadUInt32(); } offer.Details.Add(details); } offer.DisplayType = message.ReadByte(); if (offer.DisplayType == 0) // image (.png) { offer.DisplayImage = message.ReadString(); } else if (offer.DisplayType == 1) // mount id { offer.DisplayMountId = message.ReadUInt16(); } else if (offer.DisplayType == 2) // outfit { offer.DisplayLooktype = message.ReadUInt16(); offer.DisplayColorHead = message.ReadByte(); offer.DisplayColorTorso = message.ReadByte(); offer.DisplayColorLegs = message.ReadByte(); offer.DisplayColorDetail = message.ReadByte(); } else if (offer.DisplayType == 3) // item id { offer.DisplayItemId = message.ReadUInt16(); } else if (offer.DisplayType == 4) // male/female outfit { offer.GenderToShow = message.ReadByte(); offer.DisplayFemaleLooktype = message.ReadUInt16(); offer.DisplayMaleLooktype = message.ReadUInt16(); offer.DisplayColorHead = message.ReadByte(); offer.DisplayColorTorso = message.ReadByte(); offer.DisplayColorLegs = message.ReadByte(); offer.DisplayColorDetail = message.ReadByte(); } offer.TryType = message.ReadByte(); // 0 = disabled, 1 = mounts/outfits, 2 = hireling dresses offer.Collection = message.ReadString(); offer.PopularityScore = message.ReadUInt16(); offer.NewUntilTimestamp = message.ReadUInt32(); offer.NeedsUserConfigurationBeforeBuying = message.ReadBool(); offer.Products.Capacity = message.ReadUInt16(); for (var j = 0; j < offer.Products.Capacity; ++j) { var subOffer = new Offer { Name = message.ReadString(), DisplayType = message.ReadByte() }; if (subOffer.DisplayType == 0) // image (.png) { subOffer.DisplayImage = message.ReadString(); } else if (subOffer.DisplayType == 1) // mount id { subOffer.DisplayMountId = message.ReadUInt16(); } else if (subOffer.DisplayType == 2) // outfit { subOffer.DisplayLooktype = message.ReadUInt16(); subOffer.DisplayColorHead = message.ReadByte(); subOffer.DisplayColorTorso = message.ReadByte(); subOffer.DisplayColorLegs = message.ReadByte(); subOffer.DisplayColorDetail = message.ReadByte(); } else if (subOffer.DisplayType == 3) // item sprite { subOffer.DisplayItemId = message.ReadUInt16(); } else if (subOffer.DisplayType == 4) // male/female outfit { subOffer.GenderToShow = message.ReadByte(); subOffer.DisplayFemaleLooktype = message.ReadUInt16(); subOffer.DisplayMaleLooktype = message.ReadUInt16(); subOffer.DisplayColorHead = message.ReadByte(); subOffer.DisplayColorTorso = message.ReadByte(); subOffer.DisplayColorLegs = message.ReadByte(); subOffer.DisplayColorDetail = message.ReadByte(); } offer.Products.Add(subOffer); } Offers.Add(offer); } if (CategoryName.Equals("Search", StringComparison.CurrentCultureIgnoreCase)) { TooManySearchResults = message.ReadBool(); } if (WindowType == 3) // Home { Banners.Capacity = message.ReadByte(); for (var i = 0; i < Banners.Capacity; ++i) { var banner = new Banner { Image = message.ReadString(), Type = message.ReadByte() }; if (banner.Type == 2) { banner.Category = message.ReadString(); banner.Collection = message.ReadString(); } else if (banner.Type == 4) { banner.OfferId = message.ReadUInt32(); } banner.Unknown = message.ReadUInt16(); // Always 0x0200 (512)? Banners.Add(banner); } BannerSwitchDelay = message.ReadByte(); } }