mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 16:37:00 +00:00
[11419] Resolve some problems with auction sorting.
This commit is contained in:
parent
df1376b14b
commit
dc1fd2b6cb
3 changed files with 71 additions and 80 deletions
|
|
@ -623,173 +623,162 @@ void AuctionHouseObject::BuildListOwnerItems(WorldPacket& data, Player* player,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const
|
int AuctionEntry::CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const
|
||||||
{
|
{
|
||||||
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
|
||||||
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
|
||||||
Player *pl1 = NULL;
|
|
||||||
Player *pl2 = NULL;
|
|
||||||
int res = 0;
|
|
||||||
time_t currentTime = time(NULL);
|
|
||||||
|
|
||||||
switch (column)
|
switch (column)
|
||||||
{
|
{
|
||||||
case 0: // level = 0
|
case 0: // level = 0
|
||||||
|
{
|
||||||
|
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
||||||
|
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
||||||
if (!item1 || !item2)
|
if (!item1 || !item2)
|
||||||
break;
|
return 0;
|
||||||
if (item1->GetProto()->RequiredLevel < item2->GetProto()->RequiredLevel)
|
if (item1->GetProto()->RequiredLevel < item2->GetProto()->RequiredLevel)
|
||||||
return true;
|
return -1;
|
||||||
else if (item1->GetProto()->RequiredLevel > item2->GetProto()->RequiredLevel)
|
else if (item1->GetProto()->RequiredLevel > item2->GetProto()->RequiredLevel)
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 1: // quality = 1
|
case 1: // quality = 1
|
||||||
|
{
|
||||||
|
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
||||||
|
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
||||||
if (!item1 || !item2)
|
if (!item1 || !item2)
|
||||||
break;
|
return 0;
|
||||||
if (item1->GetProto()->Quality < item2->GetProto()->Quality)
|
if (item1->GetProto()->Quality < item2->GetProto()->Quality)
|
||||||
return true;
|
return -1;
|
||||||
else if (item1->GetProto()->Quality > item2->GetProto()->Quality)
|
else if (item1->GetProto()->Quality > item2->GetProto()->Quality)
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 2: // buyoutthenbid = 2
|
case 2: // buyoutthenbid = 2
|
||||||
if (buyout)
|
if (buyout)
|
||||||
{
|
{
|
||||||
if (buyout < auc->buyout)
|
if (buyout < auc->buyout)
|
||||||
return true;
|
return -1;
|
||||||
else if (buyout > auc->buyout)
|
else if (buyout > auc->buyout)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (bid < auc->bid)
|
if (bid < auc->bid)
|
||||||
return true;
|
return -1;
|
||||||
else if (bid > auc->bid)
|
else if (bid > auc->bid)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 3: // duration = 3
|
case 3: // duration = 3
|
||||||
if ((expireTime - currentTime) < (auc->expireTime - currentTime))
|
if (expireTime < auc->expireTime)
|
||||||
return true;
|
return -1;
|
||||||
else if ((expireTime - currentTime) > (auc->expireTime - currentTime))
|
else if (expireTime > auc->expireTime)
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
case 4: // status = 4
|
case 4: // status = 4
|
||||||
if (bidder < auc->bidder)
|
if (bidder < auc->bidder)
|
||||||
return true;
|
return -1;
|
||||||
else if (bidder > auc->bidder)
|
else if (bidder > auc->bidder)
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
case 5: // name = 5
|
case 5: // name = 5
|
||||||
|
{
|
||||||
|
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
||||||
|
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
||||||
if (!item1 || !item2)
|
if (!item1 || !item2)
|
||||||
break;
|
return 0;
|
||||||
res = strcmp(item1->GetProto()->Name1, item2->GetProto()->Name1);
|
return strcmp(item1->GetProto()->Name1, item2->GetProto()->Name1);
|
||||||
if (res < 0)
|
}
|
||||||
return true;
|
|
||||||
else if (res > 0)
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case 6: // minbidbuyout = 6
|
case 6: // minbidbuyout = 6
|
||||||
if (bid)
|
if (bid)
|
||||||
{
|
{
|
||||||
if (bid < auc->bid)
|
if (bid < auc->bid)
|
||||||
return true;
|
return -1;
|
||||||
else if (bid > auc->bid)
|
else if (bid > auc->bid)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
else if (startbid)
|
else if (startbid)
|
||||||
{
|
{
|
||||||
if (startbid < auc->startbid)
|
if (startbid < auc->startbid)
|
||||||
return true;
|
return -1;
|
||||||
else if (startbid > auc->startbid)
|
else if (startbid > auc->startbid)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (buyout < auc->buyout)
|
if (buyout < auc->buyout)
|
||||||
return true;
|
return -1;
|
||||||
else if (buyout > auc->buyout)
|
else if (buyout > auc->buyout)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 7: // seller = 7
|
case 7: // seller = 7
|
||||||
pl1 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, owner));
|
{
|
||||||
pl2 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, auc->owner));
|
Player* pl1 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, owner));
|
||||||
|
Player* pl2 = sObjectMgr.GetPlayer(ObjectGuid(HIGHGUID_PLAYER, auc->owner));
|
||||||
if (!pl1 || !pl2)
|
if (!pl1 || !pl2)
|
||||||
break;
|
return 0;
|
||||||
res = strcmp(pl1->GetName(), pl2->GetName());
|
return strcmp(pl1->GetName(), pl2->GetName());
|
||||||
if (res < 0)
|
}
|
||||||
return true;
|
|
||||||
else if (res > 0)
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
case 8: // bid = 8
|
case 8: // bid = 8
|
||||||
if (bid)
|
if (bid)
|
||||||
{
|
{
|
||||||
if (bid < auc->bid)
|
if (bid < auc->bid)
|
||||||
return true;
|
return -1;
|
||||||
else if (bid > auc->bid)
|
else if (bid > auc->bid)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (startbid < auc->startbid)
|
if (startbid < auc->startbid)
|
||||||
return true;
|
return -1;
|
||||||
else if (startbid > auc->startbid)
|
else if (startbid > auc->startbid)
|
||||||
return false;
|
return +1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 9: // quantity = 9
|
case 9: // quantity = 9
|
||||||
|
{
|
||||||
|
Item *item1 = sAuctionMgr.GetAItem(itemGuidLow);
|
||||||
|
Item *item2 = sAuctionMgr.GetAItem(auc->itemGuidLow);
|
||||||
if (!item1 || !item2)
|
if (!item1 || !item2)
|
||||||
break;
|
return 0;
|
||||||
if (item1->GetCount() < item2->GetCount())
|
if (item1->GetCount() < item2->GetCount())
|
||||||
return true;
|
return -1;
|
||||||
else if (item1->GetCount() > item2->GetCount())
|
else if (item1->GetCount() > item2->GetCount())
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case 10: // buyout = 10
|
case 10: // buyout = 10
|
||||||
if (buyout < auc->buyout)
|
if (buyout < auc->buyout)
|
||||||
return true;
|
return -1;
|
||||||
else if (buyout > auc->buyout)
|
else if (buyout > auc->buyout)
|
||||||
return false;
|
return +1;
|
||||||
break;
|
break;
|
||||||
case 11: // unused = 11
|
case 11: // unused = 11
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Id < auc->Id)
|
return 0;
|
||||||
return true;
|
|
||||||
else if (Id > auc->Id)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AuctionSorter::operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const
|
bool AuctionSorter::operator()(const AuctionEntry *auc1, const AuctionEntry *auc2) const
|
||||||
{
|
{
|
||||||
bool result = false;
|
if (m_sort[0] == MAX_AUCTION_SORT) // not sorted
|
||||||
uint32 column = 0;
|
return false;
|
||||||
|
|
||||||
for (uint32 i = 0; i < MAX_AUCTION_SORT; ++i)
|
for (uint32 i = 0; i < MAX_AUCTION_SORT; ++i)
|
||||||
{
|
{
|
||||||
if (m_sort[i] == MAX_AUCTION_SORT) // end of sort
|
if (m_sort[i] == MAX_AUCTION_SORT) // end of sort
|
||||||
{
|
return false;
|
||||||
column = m_sort[0]; // use main column
|
|
||||||
break;
|
int res = auc1->CompareAuctionEntry(m_sort[i] & ~AUCTION_SORT_REVERSED, auc2);
|
||||||
|
// "equal" by used column
|
||||||
|
if (res == 0)
|
||||||
|
continue;
|
||||||
|
// less/greater and normal/reversed ordered
|
||||||
|
return (res < 0) == ((m_sort[i] & AUCTION_SORT_REVERSED) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
column = m_sort[i];
|
return false; // "equal" by all sorts
|
||||||
|
|
||||||
result = auc1->CompareAuctionEntry(column & ~AUCTION_SORT_REVERSED, auc2);
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (column & AUCTION_SORT_REVERSED) // reversed flag
|
|
||||||
result = !result;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
|
void WorldSession::BuildListAuctionItems(std::list<AuctionEntry*> &auctions, WorldPacket& data, std::wstring const& wsearchedname, uint32 listfrom, uint32 levelmin,
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,9 @@ struct AuctionEntry
|
||||||
bool BuildAuctionInfo(WorldPacket & data) const;
|
bool BuildAuctionInfo(WorldPacket & data) const;
|
||||||
void DeleteFromDB() const;
|
void DeleteFromDB() const;
|
||||||
void SaveToDB() const;
|
void SaveToDB() const;
|
||||||
bool CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const;
|
|
||||||
|
// -1,0,+1 order result
|
||||||
|
int CompareAuctionEntry(uint32 column, const AuctionEntry *auc) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
//this class is used as auctionhouse instance
|
//this class is used as auctionhouse instance
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11418"
|
#define REVISION_NR "11419"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue