mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
AH related fixes
Load items from memory instead of DB (may break 3rd party programs) Fix item suffix search Closes #9196 For AHBot set expired auctions ignored from update process
This commit is contained in:
@@ -447,30 +447,26 @@ bool AuctionHouseObject::RemoveAuction(AuctionEntry* auction, uint32 /*itemEntry
|
||||
|
||||
void AuctionHouseObject::Update()
|
||||
{
|
||||
time_t curTime = sWorld->GetGameTime();
|
||||
///- Handle expired auctions
|
||||
|
||||
// If storage is empty, no need to update. next == NULL in this case.
|
||||
if (AuctionsMap.empty())
|
||||
return;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTION_BY_TIME);
|
||||
stmt->setUInt32(0, (uint32)curTime+60);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
time_t curTime = sWorld->GetGameTime();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
if (!result)
|
||||
return;
|
||||
|
||||
do
|
||||
for (AuctionEntryMap::iterator it = AuctionsMap.begin(); it != AuctionsMap.end();)
|
||||
{
|
||||
// from auctionhousehandler.cpp, creates auction pointer & player pointer
|
||||
AuctionEntry* auction = GetAuction(result->Fetch()->GetUInt32());
|
||||
AuctionEntry* auction = it->second;
|
||||
// Increment iterator due to deletion
|
||||
++it;
|
||||
|
||||
if (!auction)
|
||||
///- filter auctions exipred on next update
|
||||
if (auction->expire_time > curTime + 60)
|
||||
continue;
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
///- Either cancel the auction if there was no bidder
|
||||
if (auction->bidder == 0)
|
||||
{
|
||||
@@ -488,16 +484,15 @@ void AuctionHouseObject::Update()
|
||||
sScriptMgr->OnAuctionSuccessful(this, auction);
|
||||
}
|
||||
|
||||
uint32 itemEntry = auction->itemEntry;
|
||||
|
||||
///- In any case clear the auction
|
||||
auction->DeleteFromDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
sAuctionMgr->RemoveAItem(auction->itemGUIDLow);
|
||||
RemoveAuction(auction, itemEntry);
|
||||
RemoveAuction(auction, auction->itemEntry);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
// Run DB changes
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void AuctionHouseObject::BuildListBidderItems(WorldPacket& data, Player* player, uint32& count, uint32& totalcount)
|
||||
@@ -592,22 +587,31 @@ void AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
|
||||
if (propRefID)
|
||||
{
|
||||
// Append the suffix to the name (ie: of the Monkey) if one exists
|
||||
// These are found in ItemRandomProperties.dbc, not ItemRandomSuffix.dbc
|
||||
// even though the DBC names seem misleading
|
||||
const ItemRandomPropertiesEntry* itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
|
||||
// These are found in ItemRandomSuffix.dbc and ItemRandomProperties.dbc
|
||||
// even though the DBC name seems misleading
|
||||
|
||||
if (itemRandProp)
|
||||
char* const* suffix = nullptr;
|
||||
|
||||
if (propRefID < 0)
|
||||
{
|
||||
char* const* temp = itemRandProp->nameSuffix;
|
||||
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
}
|
||||
else
|
||||
{
|
||||
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
}
|
||||
|
||||
// dbc local name
|
||||
if (temp)
|
||||
{
|
||||
// Append the suffix (ie: of the Monkey) to the name using localization
|
||||
// or default enUS if localization is invalid
|
||||
name += ' ';
|
||||
name += temp[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
|
||||
}
|
||||
// dbc local name
|
||||
if (suffix)
|
||||
{
|
||||
// Append the suffix (ie: of the Monkey) to the name using localization
|
||||
// or default enUS if localization is invalid
|
||||
name += ' ';
|
||||
name += suffix[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -388,7 +388,7 @@ void AuctionHouseBot::Rebuild(bool all)
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(AuctionHouseType(i));
|
||||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
|
||||
if (!itr->second->owner) // ahbot auction
|
||||
if (all || itr->second->bid == 0) // expire now auction if no bid or forced
|
||||
if (all || itr->second->bidder == 0) // expire auction if forced or no bids
|
||||
itr->second->expire_time = sWorld->GetGameTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Log.h"
|
||||
#include "DBCStores.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "World.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "AuctionHouseBotSeller.h"
|
||||
|
||||
@@ -614,17 +615,20 @@ uint32 AuctionBotSeller::SetStat(SellerConfiguration& config)
|
||||
{
|
||||
AllItemsArray itemsSaved(MAX_AUCTION_QUALITY, std::vector<uint32>(MAX_ITEM_CLASS));
|
||||
|
||||
time_t curTime = sWorld->GetGameTime();
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(config.GetHouseType());
|
||||
for (AuctionHouseObject::AuctionEntryMap::const_iterator itr = auctionHouse->GetAuctionsBegin(); itr != auctionHouse->GetAuctionsEnd(); ++itr)
|
||||
{
|
||||
AuctionEntry* auctionEntry = itr->second;
|
||||
if (auctionEntry->owner != 0) // Add only ahbot items
|
||||
continue;
|
||||
if (auctionEntry->expire_time > curTime) // Add only nonexpired items
|
||||
continue;
|
||||
Item* item = sAuctionMgr->GetAItem(auctionEntry->itemGUIDLow);
|
||||
if (item)
|
||||
{
|
||||
ItemTemplate const* prototype = item->GetTemplate();
|
||||
if (prototype)
|
||||
if (!auctionEntry->owner) // Add only ahbot items
|
||||
++itemsSaved[prototype->Quality][prototype->Class];
|
||||
++itemsSaved[prototype->Quality][prototype->Class];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,6 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PrepareStatement(CHAR_SEL_AUCTIONS, "SELECT id, auctioneerguid, itemguid, itemEntry, count, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit FROM auctionhouse ah INNER JOIN item_instance ii ON ii.guid = ah.itemguid", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_INS_AUCTION, "INSERT INTO auctionhouse (id, auctioneerguid, itemguid, itemowner, buyoutprice, time, buyguid, lastbid, startbid, deposit) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_AUCTION, "DELETE FROM auctionhouse WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_SEL_AUCTION_BY_TIME, "SELECT id FROM auctionhouse WHERE time <= ? ORDER BY TIME ASC", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_UPD_AUCTION_BID, "UPDATE auctionhouse SET buyguid = ?, lastbid = ? WHERE id = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_INS_MAIL, "INSERT INTO mail(id, messageType, stationery, mailTemplateId, sender, receiver, subject, body, has_items, expire_time, deliver_time, money, cod, checked) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_MAIL_BY_ID, "DELETE FROM mail WHERE id = ?", CONNECTION_ASYNC);
|
||||
|
||||
@@ -128,7 +128,6 @@ enum CharacterDatabaseStatements
|
||||
CHAR_SEL_AUCTION_ITEMS,
|
||||
CHAR_INS_AUCTION,
|
||||
CHAR_DEL_AUCTION,
|
||||
CHAR_SEL_AUCTION_BY_TIME,
|
||||
CHAR_UPD_AUCTION_BID,
|
||||
CHAR_SEL_AUCTIONS,
|
||||
CHAR_INS_MAIL,
|
||||
|
||||
Reference in New Issue
Block a user