public static void Init() { foreach (Asda2ItemAuctionCategory key1 in Enum.GetValues(typeof(Asda2ItemAuctionCategory)) .Cast <Asda2ItemAuctionCategory>()) { Dictionary <AuctionLevelCriterion, SortedSet <Asda2ItemRecord> > dictionary = new Dictionary <AuctionLevelCriterion, SortedSet <Asda2ItemRecord> >(); foreach (AuctionLevelCriterion key2 in Enum.GetValues(typeof(AuctionLevelCriterion)) .Cast <AuctionLevelCriterion>()) { dictionary.Add(key2, new SortedSet <Asda2ItemRecord>((IComparer <Asda2ItemRecord>)Asda2AuctionMgr.ItemsComparer)); } Asda2AuctionMgr.CategorizedItemsById.Add(key1, dictionary); } foreach (Asda2ItemRecord loadAuctionedItem in Asda2ItemRecord.LoadAuctionedItems()) { Asda2AuctionMgr.RegisterItem(loadAuctionedItem); } foreach (AuctionSelledRecord auctionSelledRecord in ActiveRecordBase <AuctionSelledRecord> .FindAll()) { if (!Asda2AuctionMgr.SelledRecords.ContainsKey(auctionSelledRecord.ReciverCharacterId)) { Asda2AuctionMgr.SelledRecords.Add(auctionSelledRecord.ReciverCharacterId, new List <AuctionSelledRecord>()); } Asda2AuctionMgr.SelledRecords[auctionSelledRecord.ReciverCharacterId].Add(auctionSelledRecord); } }
private static void SendMoneyToSeller(Asda2ItemRecord item) { Character character = World.GetCharacter(item.OwnerId); if (character != null) { Asda2AuctionMgr.SendMoneyToSeller(item.Template.Name, item.AuctionPrice, item.Amount, character); } else { new AuctionSelledRecord(item.OwnerId, item.AuctionPrice, item.Amount, item.ItemId).Create(); } }
public static void ShowMyAukItemsRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 15; if (packet.ReadByte() == (byte)1) { Asda2AuctionHandler.SendMyAukItemsInfoResponse(client, Asda2AuctionMgr.GetCharacterRegularItems((uint)client.ActiveCharacter.Record.Guid)); } else { Asda2AuctionHandler.SendMyAukItemsInfoResponse(client, Asda2AuctionMgr.GetCharacterShopItems((uint)client.ActiveCharacter.Record.Guid)); } }
[PacketHandler(RealmServerOpCode.BuyFromAuk)] //9905 public static void BuyFromAukRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 11; //tab35 default : stab35Len : 11 var aucIds = new List <int>(); for (int i = 0; i < 7; i += 1) { packet.Position += 4; if (packet.RemainingLength <= 0) { break; } var aukId = packet.ReadInt32(); //default : 924Len : 4 aucIds.Add(aukId); packet.Position += 41; //default : stub8Len : 41 } RealmServer.IOQueue.AddMessage(() => Asda2AuctionMgr.TryBuy(aucIds, client.ActiveCharacter)); }
[PacketHandler(RealmServerOpCode.ShowMyAukItems)] //9907 public static void ShowMyAukItemsRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 15; //tab35 default : stab35Len : 1 if (packet.ReadByte() == 1) { //regualr items SendMyAukItemsInfoResponse(client, Asda2AuctionMgr.GetCharacterRegularItems( (uint)client.ActiveCharacter.Record.Guid)); } else { //equip items SendMyAukItemsInfoResponse(client, Asda2AuctionMgr.GetCharacterShopItems( (uint)client.ActiveCharacter.Record.Guid)); } }
[PacketHandler(RealmServerOpCode.RemoveFromAuk)] //9909 public static void RemoveFromAukRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 4; var items = new List <int>(); for (int i = 0; i < 8; i += 1) { packet.Position += 19; //nk7 default : unk7Len : 19 if (packet.RemainingLength <= 4) { break; } var aukId = packet.ReadInt32(); //default : 1179Len : 4 packet.Position += 26; items.Add(aukId); } RealmServer.IOQueue.AddMessage(() => Asda2AuctionMgr.TryRemoveItems(client.ActiveCharacter, items)); }
public static void OnLogin(Character chr) { uint guid = (uint)chr.Record.Guid; if (!Asda2AuctionMgr.SelledRecords.ContainsKey(guid)) { return; } List <AuctionSelledRecord> selledRecord = Asda2AuctionMgr.SelledRecords[guid]; foreach (AuctionSelledRecord record in selledRecord) { Asda2AuctionMgr.SendMoneyToSeller(Asda2ItemMgr.GetTemplate(record.ItemId).Name, record.GoldAmount, record.ItemAmount, chr); record.DeleteLater(); } selledRecord.Clear(); Asda2AuctionMgr.SelledRecords.Remove(guid); }
public static void RemoveFromAukRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 4; List <int> items = new List <int>(); for (int index = 0; index < 8; ++index) { packet.Position += 19; if (packet.RemainingLength > 4) { int num = packet.ReadInt32(); packet.Position += 26; items.Add(num); } else { break; } } ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => Asda2AuctionMgr.TryRemoveItems(client.ActiveCharacter, items))); }
public static void BuyFromAukRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 11; List <int> aucIds = new List <int>(); for (int index = 0; index < 7; ++index) { packet.Position += 4; if (packet.RemainingLength > 0) { int num = packet.ReadInt32(); aucIds.Add(num); packet.Position += 41; } else { break; } } ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() => Asda2AuctionMgr.TryBuy(aucIds, client.ActiveCharacter))); }
public static void TryRemoveItems(Character activeCharacter, List <int> itemIds) { uint entityLowId = activeCharacter.Record.EntityLowId; if (!Asda2AuctionMgr.ItemsByOwner.ContainsKey(entityLowId)) { activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded."); } else { bool?nullable1 = new bool?(); List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>(); foreach (int itemId in itemIds) { if (!Asda2AuctionMgr.ItemsByOwner[entityLowId].ContainsKey(itemId)) { asda2ItemRecordList.Clear(); activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded."); return; } Asda2ItemRecord asda2ItemRecord = Asda2AuctionMgr.ItemsByOwner[entityLowId][itemId]; if (!nullable1.HasValue) { nullable1 = new bool?(asda2ItemRecord.Template.IsShopInventoryItem); } bool?nullable2 = nullable1; bool shopInventoryItem = asda2ItemRecord.Template.IsShopInventoryItem; if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0) { activeCharacter.YouAreFuckingCheater( "Trying to remove shop\not shop item in one auction buy request.", 1); activeCharacter.SendAuctionMsg( "Removing from auction failed cause founded shop\not shop items in one request."); } asda2ItemRecordList.Add(asda2ItemRecord); } if (nullable1.Value) { if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } } else if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count) { activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space."); return; } List <Asda2ItemTradeRef> asda2Items = new List <Asda2ItemTradeRef>(); foreach (Asda2ItemRecord record in asda2ItemRecordList) { Asda2AuctionMgr.UnRegisterItem(record); int amount = record.Amount; int auctionId = record.AuctionId; Asda2Item asda2Item = (Asda2Item)null; Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null); int num = (int)activeCharacter.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true, ref asda2Item, new Asda2InventoryType?(), itemToCopyStats); record.DeleteLater(); asda2Items.Add(new Asda2ItemTradeRef() { Amount = amount, Item = asda2Item, Price = auctionId }); Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId) .AddAttribute("source", 0.0, "removed_from_auction").AddItemAttributes(asda2Item, "").Write(); } Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, asda2Items); } }
public static void TryBuy(List <int> aucIds, Character chr) { if (aucIds.Count == 0) { return; } List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>(); uint amount1 = 0; bool?nullable1 = new bool?(); foreach (int aucId in aucIds) { if (!Asda2AuctionMgr.AllAuctionItems.ContainsKey(aucId)) { chr.SendAuctionMsg("Can't found item you want to buy, may be some one already buy it."); return; } Asda2ItemRecord allAuctionItem = Asda2AuctionMgr.AllAuctionItems[aucId]; if (!nullable1.HasValue) { nullable1 = new bool?(allAuctionItem.Template.IsShopInventoryItem); } bool?nullable2 = nullable1; bool shopInventoryItem = allAuctionItem.Template.IsShopInventoryItem; if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0) { chr.YouAreFuckingCheater("Trying to buy shop\not shop item in one auction buy request.", 1); chr.SendAuctionMsg("Buying from auction failed cause founded shop\not shop items in one request."); } asda2ItemRecordList.Add(allAuctionItem); amount1 += (uint)allAuctionItem.AuctionPrice; } if (chr.Money <= amount1) { chr.SendAuctionMsg("Failed to buy items. Not enoght money."); } else { if (nullable1.HasValue && nullable1.Value) { if (chr.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count) { chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space."); return; } } else if (chr.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count) { chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space."); return; } chr.SubtractMoney(amount1); List <Asda2ItemTradeRef> items = new List <Asda2ItemTradeRef>(); foreach (Asda2ItemRecord record in asda2ItemRecordList) { Asda2AuctionMgr.SendMoneyToSeller(record); Asda2AuctionMgr.UnRegisterItem(record); int amount2 = record.Amount; int auctionId = record.AuctionId; Asda2Item asda2Item = (Asda2Item)null; Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null); int num = (int)chr.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true, ref asda2Item, new Asda2InventoryType?(), itemToCopyStats); items.Add(new Asda2ItemTradeRef() { Amount = amount2, Item = asda2Item, Price = auctionId }); record.DeleteLater(); } Asda2AuctionHandler.SendItemsBuyedFromAukResponse(chr.Client, items); chr.SendMoneyUpdate(); } }