Core/PacketIO: Add new auction house packet structures (not used yet)

Port From (https://github.com/TrinityCore/TrinityCore/commit/569f1c9f2a4806948521f4c6eab36d406ba45593)
This commit is contained in:
hondacrx
2020-04-25 00:02:23 -04:00
parent 25feacd08e
commit aa7fe7a3a1
5 changed files with 959 additions and 473 deletions
+27 -34
View File
@@ -363,7 +363,7 @@ namespace Game
public AuctionHouseRecord GetAuctionHouseEntry(uint factionTemplateId, ref uint houseId) public AuctionHouseRecord GetAuctionHouseEntry(uint factionTemplateId, ref uint houseId)
{ {
uint houseid = 7; // goblin auction house uint houseid = 1; // Auction House
if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionAuction)) if (!WorldConfig.GetBoolValue(WorldCfg.AllowTwoSideInteractionAuction))
{ {
@@ -372,27 +372,26 @@ namespace Game
// but no easy way convert creature faction to player race faction for specific city // but no easy way convert creature faction to player race faction for specific city
switch (factionTemplateId) switch (factionTemplateId)
{ {
case 12: houseid = 1; break; // human case 120:
case 29: houseid = 6; break; // orc, and generic for horde houseid = 7;
case 55: houseid = 2; break; // dwarf, and generic for alliance break; // booty bay, Blackwater Auction House
case 68: houseid = 4; break; // undead case 474:
case 80: houseid = 3; break; // n-elf houseid = 7;
case 104: houseid = 5; break; // trolls break; // gadgetzan, Blackwater Auction House
case 120: houseid = 7; break; // booty bay, neutral case 855:
case 474: houseid = 7; break; // gadgetzan, neutral houseid = 7;
case 855: houseid = 7; break; // everlook, neutral break; // everlook, Blackwater Auction House
case 1604: houseid = 6; break; // b-elfs, default: // default
default: // for unknown case
{ {
FactionTemplateRecord u_entry = CliDB.FactionTemplateStorage.LookupByKey(factionTemplateId); FactionTemplateRecord u_entry = CliDB.FactionTemplateStorage.LookupByKey(factionTemplateId);
if (u_entry == null) if (u_entry == null)
houseid = 7; // goblin auction house houseid = 1; // Auction House
else if ((u_entry.FactionGroup & (int)FactionMasks.Alliance) != 0) else if ((u_entry.FactionGroup & (int)FactionMasks.Alliance) != 0)
houseid = 1; // human auction house houseid = 2; // Alliance Auction House
else if ((u_entry.FactionGroup & (int)FactionMasks.Horde) != 0) else if ((u_entry.FactionGroup & (int)FactionMasks.Horde) != 0)
houseid = 6; // orc auction house houseid = 6; // Horde Auction House
else else
houseid = 7; // goblin auction house houseid = 1; // Auction House
break; break;
} }
} }
@@ -476,31 +475,25 @@ namespace Game
DB.Characters.CommitTransaction(trans); DB.Characters.CommitTransaction(trans);
} }
public void BuildListBidderItems(AuctionListBidderItemsResult packet, Player player, ref uint totalcount) public void BuildListBidderItems(AuctionListBidderItemsResult packet, Player player)
{ {
foreach (var Aentry in AuctionsMap.Values) foreach (var Aentry in AuctionsMap.Values)
{ {
if (Aentry != null && Aentry.bidder == player.GetGUID().GetCounter()) if (Aentry != null && Aentry.bidder == player.GetGUID().GetCounter())
{
Aentry.BuildAuctionInfo(packet.Items, false); Aentry.BuildAuctionInfo(packet.Items, false);
++totalcount;
}
} }
} }
public void BuildListOwnerItems(AuctionListOwnerItemsResult packet, Player player, ref uint totalcount) public void BuildListOwnerItems(AuctionListOwnerItemsResult packet, Player player)
{ {
foreach (var Aentry in AuctionsMap.Values) foreach (var Aentry in AuctionsMap.Values)
{ {
if (Aentry != null && Aentry.owner == player.GetGUID().GetCounter()) if (Aentry != null && Aentry.owner == player.GetGUID().GetCounter())
{
Aentry.BuildAuctionInfo(packet.Items, false); Aentry.BuildAuctionInfo(packet.Items, false);
++totalcount;
}
} }
} }
public void BuildListAuctionItems(AuctionListItemsResult packet, Player player, string searchedname, uint listfrom, byte levelmin, byte levelmax, bool usable, Optional<AuctionSearchFilters> filters, uint quality) public void BuildListAuctionItems(AuctionListItemsResult packet, Player player, string searchedname, uint listfrom, byte levelmin, byte levelmax, AuctionHouseFilterMask filters, Optional<AuctionSearchClassFilters> classFilters)
{ {
long curTime = GameTime.GetGameTime(); long curTime = GameTime.GetGameTime();
@@ -515,32 +508,32 @@ namespace Game
continue; continue;
ItemTemplate proto = item.GetTemplate(); ItemTemplate proto = item.GetTemplate();
if (filters.HasValue) if (classFilters.HasValue)
{ {
// if we dont want any class filters, Optional is not initialized // if we dont want any class filters, Optional is not initialized
// if we dont want this class included, SubclassMask is set to FILTER_SKIP_CLASS // if we dont want this class included, SubclassMask is set to FILTER_SKIP_CLASS
// if we want this class and did not specify and subclasses, its set to FILTER_SKIP_SUBCLASS // if we want this class and did not specify and subclasses, its set to FILTER_SKIP_SUBCLASS
// otherwise full restrictions apply // otherwise full restrictions apply
if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask == AuctionSearchFilters.FilterType.SkipClass) if (classFilters.Value.Classes[(int)proto.GetClass()].SubclassMask == AuctionSearchClassFilters.FilterType.SkipClass)
continue; continue;
if (filters.Value.Classes[(int)proto.GetClass()].SubclassMask != AuctionSearchFilters.FilterType.SkipSubclass) if (classFilters.Value.Classes[(int)proto.GetClass()].SubclassMask != AuctionSearchClassFilters.FilterType.SkipSubclass)
{ {
if (!Convert.ToBoolean((int)filters.Value.Classes[(int)proto.GetClass()].SubclassMask & (1u << (int)proto.GetSubClass()))) if (!Convert.ToBoolean((int)classFilters.Value.Classes[(int)proto.GetClass()].SubclassMask & (1u << (int)proto.GetSubClass())))
continue; continue;
if (!Convert.ToBoolean(filters.Value.Classes[(int)proto.GetClass()].InvTypes[(int)proto.GetSubClass()] & (1u << (int)proto.GetInventoryType()))) if (!Convert.ToBoolean(classFilters.Value.Classes[(int)proto.GetClass()].InvTypes[(int)proto.GetSubClass()] & (1u << (int)proto.GetInventoryType())))
continue; continue;
} }
} }
if (quality != 0xffffffff && (uint)proto.GetQuality() != quality) if (!filters.HasFlag((AuctionHouseFilterMask)(1 << ((int)proto.GetQuality() + 4))))
continue; continue;
if (levelmin != 0 && (item.GetRequiredLevel() < levelmin || (levelmax != 0 && item.GetRequiredLevel() > levelmax))) if (levelmin != 0 && (item.GetRequiredLevel() < levelmin || (levelmax != 0 && item.GetRequiredLevel() > levelmax)))
continue; continue;
if (usable && player.CanUseItem(item) != InventoryResult.Ok) if (filters.HasFlag(AuctionHouseFilterMask.UsableOnly) && player.CanUseItem(item) != InventoryResult.Ok)
continue; continue;
// Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey) // Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey)
@@ -580,7 +573,7 @@ namespace Game
} }
AuctionItem auctionItem = new AuctionItem(); AuctionItem auctionItem = new AuctionItem();
auctionItem.AuctionItemID = (int)Id; auctionItem.AuctionID = (int)Id;
auctionItem.Item = new ItemInstance(item); auctionItem.Item = new ItemInstance(item);
auctionItem.BuyoutPrice = buyout; auctionItem.BuyoutPrice = buyout;
auctionItem.CensorBidInfo = false; auctionItem.CensorBidInfo = false;
@@ -786,7 +779,7 @@ namespace Game
public uint factionTemplateId; public uint factionTemplateId;
} }
public class AuctionSearchFilters public class AuctionSearchClassFilters
{ {
public enum FilterType : uint public enum FilterType : uint
{ {
+24 -33
View File
@@ -69,14 +69,14 @@ namespace Game
{ {
AuctionCommandResult auctionCommandResult = new AuctionCommandResult(); AuctionCommandResult auctionCommandResult = new AuctionCommandResult();
auctionCommandResult.InitializeAuction(auction); auctionCommandResult.InitializeAuction(auction);
auctionCommandResult.Command = action; auctionCommandResult.Command = (int)action;
auctionCommandResult.ErrorCode = errorCode; auctionCommandResult.ErrorCode = (int)errorCode;
SendPacket(auctionCommandResult); SendPacket(auctionCommandResult);
} }
public void SendAuctionOutBidNotification(AuctionEntry auction, Item item) public void SendAuctionOutBidNotification(AuctionEntry auction, Item item)
{ {
AuctionOutBidNotification packet = new AuctionOutBidNotification(); AuctionOutbidNotification packet = new AuctionOutbidNotification();
packet.BidAmount = auction.bid; packet.BidAmount = auction.bid;
packet.MinIncrement = auction.GetAuctionOutBid(); packet.MinIncrement = auction.GetAuctionOutBid();
packet.Info.Initialize(auction, item); packet.Info.Initialize(auction, item);
@@ -223,7 +223,7 @@ namespace Game
ulong deposit = Global.AuctionMgr.GetAuctionDeposit(auctionHouseEntry, packet.RunTime, item, finalCount); ulong deposit = Global.AuctionMgr.GetAuctionDeposit(auctionHouseEntry, packet.RunTime, item, finalCount);
if (!GetPlayer().HasEnoughMoney(deposit)) if (!GetPlayer().HasEnoughMoney(deposit))
{ {
SendAuctionCommandResult(null, AuctionAction.SellItem, AuctionError.NotEnoughtMoney); SendAuctionCommandResult(null, AuctionAction.SellItem, AuctionError.NotEnoughMoney);
return; return;
} }
@@ -355,7 +355,7 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.AuctionPlaceBid)] [WorldPacketHandler(ClientOpcodes.AuctionPlaceBid)]
void HandleAuctionPlaceBid(AuctionPlaceBid packet) void HandleAuctionPlaceBid(AuctionPlaceBid packet)
{ {
if (packet.AuctionItemID == 0 || packet.BidAmount == 0) if (packet.AuctionID == 0 || packet.BidAmount == 0)
return; // check for cheaters return; // check for cheaters
Creature creature = GetPlayer().GetNPCIfCanInteractWith(packet.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None); Creature creature = GetPlayer().GetNPCIfCanInteractWith(packet.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None);
@@ -371,7 +371,7 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction()); AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
AuctionEntry auction = auctionHouse.GetAuction(packet.AuctionItemID); AuctionEntry auction = auctionHouse.GetAuction(packet.AuctionID);
Player player = GetPlayer(); Player player = GetPlayer();
if (auction == null || auction.owner == player.GetGUID().GetCounter()) if (auction == null || auction.owner == player.GetGUID().GetCounter())
@@ -406,7 +406,7 @@ namespace Game
if (!player.HasEnoughMoney(packet.BidAmount)) if (!player.HasEnoughMoney(packet.BidAmount))
{ {
// client already test it but just in case ... // client already test it but just in case ...
SendAuctionCommandResult(auction, AuctionAction.PlaceBid, AuctionError.NotEnoughtMoney); SendAuctionCommandResult(auction, AuctionAction.PlaceBid, AuctionError.NotEnoughMoney);
return; return;
} }
@@ -493,7 +493,7 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction()); AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
AuctionEntry auction = auctionHouse.GetAuction((uint)packet.AuctionItemID); AuctionEntry auction = auctionHouse.GetAuction((uint)packet.AuctionID);
Player player = GetPlayer(); Player player = GetPlayer();
SQLTransaction trans = new SQLTransaction(); SQLTransaction trans = new SQLTransaction();
@@ -527,7 +527,7 @@ namespace Game
{ {
SendAuctionCommandResult(null, AuctionAction.Cancel, AuctionError.DatabaseError); SendAuctionCommandResult(null, AuctionAction.Cancel, AuctionError.DatabaseError);
//this code isn't possible ... maybe there should be assert //this code isn't possible ... maybe there should be assert
Log.outError(LogFilter.Network, "CHEATER: {0} tried to cancel auction (id: {1}) of another player or auction is null", player.GetGUID().ToString(), packet.AuctionItemID); Log.outError(LogFilter.Network, "CHEATER: {0} tried to cancel auction (id: {1}) of another player or auction is null", player.GetGUID().ToString(), packet.AuctionID);
return; return;
} }
@@ -562,7 +562,7 @@ namespace Game
AuctionListBidderItemsResult result = new AuctionListBidderItemsResult(); AuctionListBidderItemsResult result = new AuctionListBidderItemsResult();
Player player = GetPlayer(); Player player = GetPlayer();
auctionHouse.BuildListBidderItems(result, player, ref result.TotalCount); auctionHouse.BuildListBidderItems(result, player);
result.DesiredDelay = 300; result.DesiredDelay = 300;
SendPacket(result); SendPacket(result);
} }
@@ -585,18 +585,18 @@ namespace Game
AuctionListOwnerItemsResult result = new AuctionListOwnerItemsResult(); AuctionListOwnerItemsResult result = new AuctionListOwnerItemsResult();
auctionHouse.BuildListOwnerItems(result, GetPlayer(), ref result.TotalCount); auctionHouse.BuildListOwnerItems(result, GetPlayer());
result.DesiredDelay = 300; result.DesiredDelay = 300;
SendPacket(result); SendPacket(result);
} }
//[WorldPacketHandler(ClientOpcodes.AuctionListItems)] [WorldPacketHandler(ClientOpcodes.AuctionBrowseQuery)]
void HandleAuctionListItems(AuctionListItems packet) void HandleAuctionListItems(AuctionBrowseQuery browseQuery)
{ {
Creature creature = GetPlayer().GetNPCIfCanInteractWith(packet.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None); Creature creature = GetPlayer().GetNPCIfCanInteractWith(browseQuery.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None);
if (!creature) if (!creature)
{ {
Log.outDebug(LogFilter.Network, "WORLD: HandleAuctionListItems - {0} not found or you can't interact with him.", packet.Auctioneer.ToString()); Log.outDebug(LogFilter.Network, "WORLD: HandleAuctionListItems - {0} not found or you can't interact with him.", browseQuery.Auctioneer.ToString());
return; return;
} }
@@ -606,41 +606,32 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction()); AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
Optional<AuctionSearchClassFilters> classFilters = new Optional<AuctionSearchClassFilters>();
Optional<AuctionSearchFilters> filters = new Optional<AuctionSearchFilters>();
AuctionListItemsResult result = new AuctionListItemsResult(); AuctionListItemsResult result = new AuctionListItemsResult();
if (!packet.ClassFilters.Empty()) if (!browseQuery.ItemClassFilters.Empty())
{ {
filters.HasValue = true; classFilters.HasValue = true;
foreach (var classFilter in packet.ClassFilters) foreach (var classFilter in browseQuery.ItemClassFilters)
{ {
if (!classFilter.SubClassFilters.Empty()) if (!classFilter.SubClassFilters.Empty())
{ {
foreach (var subClassFilter in classFilter.SubClassFilters) foreach (var subClassFilter in classFilter.SubClassFilters)
{ {
filters.Value.Classes[classFilter.ItemClass].SubclassMask |= (AuctionSearchFilters.FilterType)(1 << subClassFilter.ItemSubclass); classFilters.Value.Classes[classFilter.ItemClass].SubclassMask |= (AuctionSearchClassFilters.FilterType)(1 << subClassFilter.ItemSubclass);
filters.Value.Classes[classFilter.ItemClass].InvTypes[subClassFilter.ItemSubclass] = subClassFilter.InvTypeMask; if (subClassFilter.ItemSubclass < ItemConst.MaxItemSubclassTotal)
classFilters.Value.Classes[classFilter.ItemClass].InvTypes[subClassFilter.ItemSubclass] = subClassFilter.InvTypeMask;
} }
} }
else else
filters.Value.Classes[classFilter.ItemClass].SubclassMask = AuctionSearchFilters.FilterType.SkipSubclass; classFilters.Value.Classes[classFilter.ItemClass].SubclassMask = AuctionSearchClassFilters.FilterType.SkipSubclass;
} }
} }
auctionHouse.BuildListAuctionItems(result, GetPlayer(), packet.Name.ToLower(), packet.Offset, packet.MinLevel, packet.MaxLevel, packet.OnlyUsable, filters, packet.Quality); auctionHouse.BuildListAuctionItems(result, GetPlayer(), browseQuery.Name.ToLower(), browseQuery.Offset, browseQuery.MinLevel, browseQuery.MaxLevel, browseQuery.Filters, classFilters);
result.DesiredDelay = WorldConfig.GetUIntValue(WorldCfg.AuctionSearchDelay); result.DesiredDelay = WorldConfig.GetUIntValue(WorldCfg.AuctionSearchDelay);
result.OnlyUsable = packet.OnlyUsable;
SendPacket(result);
}
//[WorldPacketHandler(ClientOpcodes.AuctionListPendingSales)]
void HandleAuctionListPendingSales(AuctionListPendingSales packet)
{
AuctionListPendingSalesResult result = new AuctionListPendingSalesResult();
result.TotalNumRecords = 0;
SendPacket(result); SendPacket(result);
} }
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2012-2020 CypherCore <http://github.com/CypherCore>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Framework.Constants;
using Game.Entities;
using System;
using System.Collections.Generic;
using Framework.Dynamic;
namespace Game.Network.Packets
{
public struct AddOnInfo
{
public string Name;
public string Version;
public bool Loaded;
public bool Enabled;
public void Read(WorldPacket data)
{
uint nameLength = data.ReadBits<uint>(10);
uint versionLength = data.ReadBits<uint>(10);
Loaded = data.HasBit();
Enabled = data.HasBit();
if (nameLength > 1)
{
Name = data.ReadString(nameLength - 1);
data.ReadUInt8(); // null terminator
}
if (versionLength > 1)
{
Version = data.ReadString(versionLength - 1);
data.ReadUInt8(); // null terminator
}
}
}
}
File diff suppressed because it is too large Load Diff
-1
View File
@@ -431,7 +431,6 @@ namespace Game.Network
return; return;
} }
Sha256 keyData = new Sha256(); Sha256 keyData = new Sha256();
keyData.Finish(account.game.SessionKey); keyData.Finish(account.game.SessionKey);