aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp61
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.cpp1
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.h1
3 files changed, 33 insertions, 30 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 8a96a571c00..23e8891e15f 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -457,23 +457,20 @@ void AuctionHouseObject::Update()
if (AuctionsMap.empty())
return;
- PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTION_BY_TIME);
- stmt->setUInt32(0, (uint32)curTime+60);
- PreparedQueryResult result = CharacterDatabase.Query(stmt);
- if (!result)
- return;
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
- 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 AuctionEntry deletion
+ ++it;
- if (!auction)
+ ///- filter auctions expired 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)
{
@@ -491,16 +488,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)
@@ -595,22 +591,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
+ // These are found in ItemRandomSuffix.dbc and ItemRandomProperties.dbc
// even though the DBC names seem misleading
- const ItemRandomPropertiesEntry* itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
- if (itemRandProp)
+ char* const* suffix = nullptr;
+
+ if (propRefID < 0)
+ {
+ const ItemRandomSuffixEntry* itemRandSuffix = sItemRandomSuffixStore.LookupEntry(-propRefID);
+ if (itemRandSuffix)
+ suffix = itemRandSuffix->nameSuffix;
+ }
+ else
+ {
+ const ItemRandomPropertiesEntry* itemRandProp = sItemRandomPropertiesStore.LookupEntry(propRefID);
+ if (itemRandProp)
+ suffix = itemRandProp->nameSuffix;
+ }
+
+ // dbc local name
+ if (suffix)
{
- char* temp = itemRandProp->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];
- }
+ // 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];
}
}
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 803d456b9c6..8abf6571af2 100644
--- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
@@ -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);
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h
index 7ee523786b9..1a1b2f56669 100644
--- a/src/server/shared/Database/Implementation/CharacterDatabase.h
+++ b/src/server/shared/Database/Implementation/CharacterDatabase.h
@@ -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,