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)
{
uint houseid = 7; // goblin auction house
uint houseid = 1; // Auction House
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
switch (factionTemplateId)
{
case 12: houseid = 1; break; // human
case 29: houseid = 6; break; // orc, and generic for horde
case 55: houseid = 2; break; // dwarf, and generic for alliance
case 68: houseid = 4; break; // undead
case 80: houseid = 3; break; // n-elf
case 104: houseid = 5; break; // trolls
case 120: houseid = 7; break; // booty bay, neutral
case 474: houseid = 7; break; // gadgetzan, neutral
case 855: houseid = 7; break; // everlook, neutral
case 1604: houseid = 6; break; // b-elfs,
default: // for unknown case
case 120:
houseid = 7;
break; // booty bay, Blackwater Auction House
case 474:
houseid = 7;
break; // gadgetzan, Blackwater Auction House
case 855:
houseid = 7;
break; // everlook, Blackwater Auction House
default: // default
{
FactionTemplateRecord u_entry = CliDB.FactionTemplateStorage.LookupByKey(factionTemplateId);
if (u_entry == null)
houseid = 7; // goblin auction house
houseid = 1; // Auction House
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)
houseid = 6; // orc auction house
houseid = 6; // Horde Auction House
else
houseid = 7; // goblin auction house
houseid = 1; // Auction House
break;
}
}
@@ -476,31 +475,25 @@ namespace Game
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)
{
if (Aentry != null && Aentry.bidder == player.GetGUID().GetCounter())
{
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)
{
if (Aentry != null && Aentry.owner == player.GetGUID().GetCounter())
{
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();
@@ -515,32 +508,32 @@ namespace Game
continue;
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 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
// 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;
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;
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;
}
}
if (quality != 0xffffffff && (uint)proto.GetQuality() != quality)
if (!filters.HasFlag((AuctionHouseFilterMask)(1 << ((int)proto.GetQuality() + 4))))
continue;
if (levelmin != 0 && (item.GetRequiredLevel() < levelmin || (levelmax != 0 && item.GetRequiredLevel() > levelmax)))
continue;
if (usable && player.CanUseItem(item) != InventoryResult.Ok)
if (filters.HasFlag(AuctionHouseFilterMask.UsableOnly) && player.CanUseItem(item) != InventoryResult.Ok)
continue;
// Allow search by suffix (ie: of the Monkey) or partial name (ie: Monkey)
@@ -580,7 +573,7 @@ namespace Game
}
AuctionItem auctionItem = new AuctionItem();
auctionItem.AuctionItemID = (int)Id;
auctionItem.AuctionID = (int)Id;
auctionItem.Item = new ItemInstance(item);
auctionItem.BuyoutPrice = buyout;
auctionItem.CensorBidInfo = false;
@@ -786,7 +779,7 @@ namespace Game
public uint factionTemplateId;
}
public class AuctionSearchFilters
public class AuctionSearchClassFilters
{
public enum FilterType : uint
{
+24 -33
View File
@@ -69,14 +69,14 @@ namespace Game
{
AuctionCommandResult auctionCommandResult = new AuctionCommandResult();
auctionCommandResult.InitializeAuction(auction);
auctionCommandResult.Command = action;
auctionCommandResult.ErrorCode = errorCode;
auctionCommandResult.Command = (int)action;
auctionCommandResult.ErrorCode = (int)errorCode;
SendPacket(auctionCommandResult);
}
public void SendAuctionOutBidNotification(AuctionEntry auction, Item item)
{
AuctionOutBidNotification packet = new AuctionOutBidNotification();
AuctionOutbidNotification packet = new AuctionOutbidNotification();
packet.BidAmount = auction.bid;
packet.MinIncrement = auction.GetAuctionOutBid();
packet.Info.Initialize(auction, item);
@@ -223,7 +223,7 @@ namespace Game
ulong deposit = Global.AuctionMgr.GetAuctionDeposit(auctionHouseEntry, packet.RunTime, item, finalCount);
if (!GetPlayer().HasEnoughMoney(deposit))
{
SendAuctionCommandResult(null, AuctionAction.SellItem, AuctionError.NotEnoughtMoney);
SendAuctionCommandResult(null, AuctionAction.SellItem, AuctionError.NotEnoughMoney);
return;
}
@@ -355,7 +355,7 @@ namespace Game
[WorldPacketHandler(ClientOpcodes.AuctionPlaceBid)]
void HandleAuctionPlaceBid(AuctionPlaceBid packet)
{
if (packet.AuctionItemID == 0 || packet.BidAmount == 0)
if (packet.AuctionID == 0 || packet.BidAmount == 0)
return; // check for cheaters
Creature creature = GetPlayer().GetNPCIfCanInteractWith(packet.Auctioneer, NPCFlags.Auctioneer, NPCFlags2.None);
@@ -371,7 +371,7 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
AuctionEntry auction = auctionHouse.GetAuction(packet.AuctionItemID);
AuctionEntry auction = auctionHouse.GetAuction(packet.AuctionID);
Player player = GetPlayer();
if (auction == null || auction.owner == player.GetGUID().GetCounter())
@@ -406,7 +406,7 @@ namespace Game
if (!player.HasEnoughMoney(packet.BidAmount))
{
// client already test it but just in case ...
SendAuctionCommandResult(auction, AuctionAction.PlaceBid, AuctionError.NotEnoughtMoney);
SendAuctionCommandResult(auction, AuctionAction.PlaceBid, AuctionError.NotEnoughMoney);
return;
}
@@ -493,7 +493,7 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
AuctionEntry auction = auctionHouse.GetAuction((uint)packet.AuctionItemID);
AuctionEntry auction = auctionHouse.GetAuction((uint)packet.AuctionID);
Player player = GetPlayer();
SQLTransaction trans = new SQLTransaction();
@@ -527,7 +527,7 @@ namespace Game
{
SendAuctionCommandResult(null, AuctionAction.Cancel, AuctionError.DatabaseError);
//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;
}
@@ -562,7 +562,7 @@ namespace Game
AuctionListBidderItemsResult result = new AuctionListBidderItemsResult();
Player player = GetPlayer();
auctionHouse.BuildListBidderItems(result, player, ref result.TotalCount);
auctionHouse.BuildListBidderItems(result, player);
result.DesiredDelay = 300;
SendPacket(result);
}
@@ -585,18 +585,18 @@ namespace Game
AuctionListOwnerItemsResult result = new AuctionListOwnerItemsResult();
auctionHouse.BuildListOwnerItems(result, GetPlayer(), ref result.TotalCount);
auctionHouse.BuildListOwnerItems(result, GetPlayer());
result.DesiredDelay = 300;
SendPacket(result);
}
//[WorldPacketHandler(ClientOpcodes.AuctionListItems)]
void HandleAuctionListItems(AuctionListItems packet)
[WorldPacketHandler(ClientOpcodes.AuctionBrowseQuery)]
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)
{
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;
}
@@ -606,41 +606,32 @@ namespace Game
AuctionHouseObject auctionHouse = Global.AuctionMgr.GetAuctionsMap(creature.GetFaction());
Optional<AuctionSearchFilters> filters = new Optional<AuctionSearchFilters>();
Optional<AuctionSearchClassFilters> classFilters = new Optional<AuctionSearchClassFilters>();
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())
{
foreach (var subClassFilter in classFilter.SubClassFilters)
{
filters.Value.Classes[classFilter.ItemClass].SubclassMask |= (AuctionSearchFilters.FilterType)(1 << subClassFilter.ItemSubclass);
filters.Value.Classes[classFilter.ItemClass].InvTypes[subClassFilter.ItemSubclass] = subClassFilter.InvTypeMask;
classFilters.Value.Classes[classFilter.ItemClass].SubclassMask |= (AuctionSearchClassFilters.FilterType)(1 << subClassFilter.ItemSubclass);
if (subClassFilter.ItemSubclass < ItemConst.MaxItemSubclassTotal)
classFilters.Value.Classes[classFilter.ItemClass].InvTypes[subClassFilter.ItemSubclass] = subClassFilter.InvTypeMask;
}
}
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.OnlyUsable = packet.OnlyUsable;
SendPacket(result);
}
//[WorldPacketHandler(ClientOpcodes.AuctionListPendingSales)]
void HandleAuctionListPendingSales(AuctionListPendingSales packet)
{
AuctionListPendingSalesResult result = new AuctionListPendingSalesResult();
result.TotalNumRecords = 0;
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;
}
Sha256 keyData = new Sha256();
keyData.Finish(account.game.SessionKey);