aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AuctionHouse/AuctionHouseMgr.cpp66
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBot.cpp2
-rw-r--r--src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp10
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.cpp1
-rw-r--r--src/server/shared/Database/Implementation/CharacterDatabase.h1
5 files changed, 43 insertions, 37 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
index 53267a6e565..0661c7ae2ea 100644
--- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -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);
-
- if (!result)
- return;
+ time_t curTime = sWorld->GetGameTime();
+ 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 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
+
+ char* const* suffix = nullptr;
+
+ if (propRefID < 0)
+ {
+ 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;
+ }
- if (itemRandProp)
+ // dbc local name
+ if (suffix)
{
- char* const* 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/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
index 6bf5fa0aaa5..804a1508d3e 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBot.cpp
@@ -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();
}
}
diff --git a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
index 513b23afd70..f7eac1a40dc 100644
--- a/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
+++ b/src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
@@ -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];
}
}
diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp
index 010ceb12d78..ac9e17fb872 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 7305568d9ab..b04a484b248 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,