AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
AuctionHouseMgr.cpp File Reference
#include "AuctionHouseMgr.h"
#include "Common.h"
#include "DBCStores.h"
#include "DatabaseEnv.h"
#include "GameTime.h"
#include "Item.h"
#include "Logging/Log.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "UpdateTime.h"
#include "World.h"
#include "WorldPacket.h"
#include <vector>

Go to the source code of this file.

Functions

static bool SortAuction (AuctionEntry *left, AuctionEntry *right, AuctionSortOrderVector &sortOrder, Player *player, bool checkMinBidBuyout)
 

Variables

constexpr auto AH_MINIMUM_DEPOSIT = 100
 

Function Documentation

◆ SortAuction()

static bool SortAuction ( AuctionEntry left,
AuctionEntry right,
AuctionSortOrderVector sortOrder,
Player player,
bool  checkMinBidBuyout 
)
static
37{
38 for (auto& thisOrder : sortOrder)
39 {
40 switch (thisOrder.sortOrder)
41 {
43 {
44 if (left->bid == right->bid)
45 {
46 if (checkMinBidBuyout)
47 {
48 if (left->buyout == right->buyout)
49 {
50 if (left->startbid == right->startbid)
51 {
52 continue;
53 }
54
55 return thisOrder.isDesc ? left->startbid > right->startbid : left->startbid < right->startbid;
56 }
57
58 return thisOrder.isDesc ? left->buyout > right->buyout : left->buyout < right->buyout;
59 }
60
61 continue;
62 }
63
64 return thisOrder.isDesc ? left->bid > right->bid : left->bid < right->bid;
65 }
68 {
69 if (left->buyout == right->buyout)
70 {
71 continue;
72 }
73
74 return thisOrder.isDesc ? left->buyout > right->buyout : left->buyout < right->buyout;
75 }
77 {
78 ItemTemplate const* protoLeft = sObjectMgr->GetItemTemplate(left->item_template);
79 ItemTemplate const* protoRight = sObjectMgr->GetItemTemplate(right->item_template);
80 if (!protoLeft || !protoRight)
81 {
82 continue;
83 }
84
85 std::string leftName = protoLeft->Name1;
86 std::string rightName = protoRight->Name1;
87 if (leftName.empty() || rightName.empty())
88 {
89 continue;
90 }
91
93 if (player && player->GetSession())
94 {
95 locale = player->GetSession()->GetSessionDbLocaleIndex();
96 }
97
98 if (locale > LOCALE_enUS)
99 {
100 if (ItemLocale const* leftIl = sObjectMgr->GetItemLocale(protoLeft->ItemId))
101 {
102 ObjectMgr::GetLocaleString(leftIl->Name, locale, leftName);
103 }
104
105 if (ItemLocale const* rightIl = sObjectMgr->GetItemLocale(protoRight->ItemId))
106 {
107 ObjectMgr::GetLocaleString(rightIl->Name, locale, rightName);
108 }
109 }
110
111 int result = leftName.compare(rightName);
112 if (result == 0)
113 {
114 continue;
115 }
116
117 return thisOrder.isDesc ? result > 0 : result < 0;
118 }
120 {
121 ItemTemplate const* protoLeft = sObjectMgr->GetItemTemplate(left->item_template);
122 ItemTemplate const* protoRight = sObjectMgr->GetItemTemplate(right->item_template);
123 if (!protoLeft || !protoRight)
124 {
125 continue;
126 }
127
128 if (protoLeft->RequiredLevel == protoRight->RequiredLevel)
129 {
130 continue;
131 }
132
133 return thisOrder.isDesc ? protoLeft->RequiredLevel > protoRight->RequiredLevel : protoLeft->RequiredLevel < protoRight->RequiredLevel;
134 }
136 {
137 std::string leftName;
138 sCharacterCache->GetCharacterNameByGuid(left->owner, leftName);
139
140 std::string rightName;
141 sCharacterCache->GetCharacterNameByGuid(right->owner, rightName);
142
143 int result = leftName.compare(rightName);
144 if (result == 0)
145 {
146 continue;
147 }
148
149 return thisOrder.isDesc ? result > 0 : result < 0;
150 }
152 {
153 ItemTemplate const* protoLeft = sObjectMgr->GetItemTemplate(left->item_template);
154 ItemTemplate const* protoRight = sObjectMgr->GetItemTemplate(right->item_template);
155 if (!protoLeft || !protoRight)
156 {
157 continue;
158 }
159
160 if (protoLeft->Quality == protoRight->Quality)
161 {
162 continue;
163 }
164
165 return thisOrder.isDesc ? protoLeft->Quality > protoRight->Quality : protoLeft->Quality < protoRight->Quality;
166 }
168 {
169 if (left->itemCount == right->itemCount)
170 {
171 continue;
172 }
173
174 if (!thisOrder.isDesc)
175 {
176 return (left->itemCount < right->itemCount);
177 }
178
179 return (left->itemCount > right->itemCount);
180 }
182 {
183 if (left->expire_time == right->expire_time)
184 {
185 continue;
186 }
187
188 return thisOrder.isDesc ? left->expire_time > right->expire_time : left->expire_time < right->expire_time;
189 }
191 {
192 if (left->buyout == right->buyout)
193 {
194 if (left->startbid == right->startbid)
195 {
196 continue;
197 }
198
199 return thisOrder.isDesc ? left->startbid > right->startbid : left->startbid < right->startbid;
200 }
201
202 return thisOrder.isDesc ? left->buyout > right->buyout : left->buyout < right->buyout;
203 }
204 case AUCTION_SORT_MAX:
205 // Such sad travis appeasement
207 default:
208 break;
209 }
210 }
211
212 return false;
213}
LocaleConstant
Definition: Common.h:65
@ LOCALE_enUS
Definition: Common.h:66
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ AUCTION_SORT_TIMELEFT
Definition: AuctionHouseMgr.h:78
@ AUCTION_SORT_BID
Definition: AuctionHouseMgr.h:83
@ AUCTION_SORT_BUYOUT
Definition: AuctionHouseMgr.h:77
@ AUCTION_SORT_MINLEVEL
Definition: AuctionHouseMgr.h:75
@ AUCTION_SORT_UNK4
Definition: AuctionHouseMgr.h:79
@ AUCTION_SORT_MAX
Definition: AuctionHouseMgr.h:87
@ AUCTION_SORT_MINBIDBUY
Definition: AuctionHouseMgr.h:81
@ AUCTION_SORT_OWNER
Definition: AuctionHouseMgr.h:82
@ AUCTION_SORT_ITEM
Definition: AuctionHouseMgr.h:80
@ AUCTION_SORT_STACK
Definition: AuctionHouseMgr.h:84
@ AUCTION_SORT_RARITY
Definition: AuctionHouseMgr.h:76
@ AUCTION_SORT_BUYOUT_2
Definition: AuctionHouseMgr.h:85
#define sCharacterCache
Definition: CharacterCache.h:83
uint32 bid
Definition: AuctionHouseMgr.h:109
time_t expire_time
Definition: AuctionHouseMgr.h:111
uint32 startbid
Definition: AuctionHouseMgr.h:108
uint32 itemCount
Definition: AuctionHouseMgr.h:106
uint32 buyout
Definition: AuctionHouseMgr.h:110
uint32 item_template
Definition: AuctionHouseMgr.h:105
ObjectGuid owner
Definition: AuctionHouseMgr.h:107
Definition: ItemTemplate.h:619
uint32 Quality
Definition: ItemTemplate.h:626
uint32 RequiredLevel
Definition: ItemTemplate.h:636
std::string Name1
Definition: ItemTemplate.h:624
uint32 ItemId
Definition: ItemTemplate.h:620
Definition: ItemTemplate.h:838
WorldSession * GetSession() const
Definition: Player.h:1998
static std::string_view GetLocaleString(std::vector< std::string > const &data, std::size_t locale)
Definition: ObjectMgr.h:1407
LocaleConstant GetSessionDbLocaleIndex() const
Definition: WorldSession.h:498

References AUCTION_SORT_BID, AUCTION_SORT_BUYOUT, AUCTION_SORT_BUYOUT_2, AUCTION_SORT_ITEM, AUCTION_SORT_MAX, AUCTION_SORT_MINBIDBUY, AUCTION_SORT_MINLEVEL, AUCTION_SORT_OWNER, AUCTION_SORT_RARITY, AUCTION_SORT_STACK, AUCTION_SORT_TIMELEFT, AUCTION_SORT_UNK4, AuctionEntry::bid, AuctionEntry::buyout, AuctionEntry::expire_time, ObjectMgr::GetLocaleString(), Player::GetSession(), WorldSession::GetSessionDbLocaleIndex(), AuctionEntry::item_template, AuctionEntry::itemCount, ItemTemplate::ItemId, LOCALE_enUS, ItemTemplate::Name1, AuctionEntry::owner, ItemTemplate::Quality, ItemTemplate::RequiredLevel, sCharacterCache, sObjectMgr, and AuctionEntry::startbid.

Referenced by AuctionHouseObject::BuildListAuctionItems().

Variable Documentation

◆ AH_MINIMUM_DEPOSIT

constexpr auto AH_MINIMUM_DEPOSIT = 100
constexpr