diff options
author | jackpoz <giacomopoz@gmail.com> | 2014-09-30 21:25:58 +0200 |
---|---|---|
committer | jackpoz <giacomopoz@gmail.com> | 2014-09-30 21:25:58 +0200 |
commit | 5150222f19c40958d364f7f1118f6f211176d114 (patch) | |
tree | 81c3200bcd0ac73076879f9d97e12aa8ec0783b6 /src | |
parent | 6daba66baf70d45e3b8ce681f588e4e9349d63ab (diff) |
Revert "Core/AuctionHouse: Delete expired auctions at startup."
This reverts commit a92038feaf440abe797ee4b0344612b6176e43a8 which caused items of expired auctions not being mailed back to the owner and leaving those items in item_instance table.
Please refer to the forum for steps to verify the integrity of your database and remove old unneeded rows in item_instance table.
Fixes #12699
Diffstat (limited to 'src')
5 files changed, 0 insertions, 131 deletions
diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 015109e70ee..3c27453fa7e 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -737,124 +737,6 @@ bool AuctionEntry::LoadFromDB(Field* fields) } return true; } - -void AuctionHouseMgr::DeleteExpiredAuctionsAtStartup() -{ - // Deletes expired auctions. Should be called at server start before loading auctions. - - // DO NOT USE after auctions are already loaded since this deletes from the DB - // and assumes the auctions HAVE NOT been loaded into a list or AuctionEntryMap yet - - uint32 oldMSTime = getMSTime(); - uint32 expirecount = 0; - time_t curTime = sWorld->GetGameTime(); - - // Query the DB to see if there are any expired auctions - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_EXPIRED_AUCTIONS); - stmt->setUInt32(0, (uint32)curTime+60); - PreparedQueryResult expAuctions = CharacterDatabase.Query(stmt); - - if (!expAuctions) - { - TC_LOG_INFO("server.loading", ">> No expired auctions to delete"); - - return; - } - - do - { - Field* fields = expAuctions->Fetch(); - - AuctionEntry* auction = new AuctionEntry(); - - // Can't use LoadFromDB() because it assumes the auction map is loaded - if (!auction->LoadFromFieldList(fields)) - { - // For some reason the record in the DB is broken (possibly corrupt - // faction info). Delete the object and move on. - delete auction; - continue; - } - - SQLTransaction trans = CharacterDatabase.BeginTransaction(); - - if (auction->bidder==0) - { - // Cancel the auction, there was no bidder - sAuctionMgr->SendAuctionExpiredMail(auction, trans); - } - else - { - // Send the item to the winner and money to seller - sAuctionMgr->SendAuctionSuccessfulMail(auction, trans); - sAuctionMgr->SendAuctionWonMail(auction, trans); - } - - // Call the appropriate AuctionHouseObject script - // ** Do we need to do this while core is still loading? ** - sScriptMgr->OnAuctionExpire(GetAuctionsMap(auction->factionTemplateId), auction); - - // Delete the auction from the DB - auction->DeleteFromDB(trans); - CharacterDatabase.CommitTransaction(trans); - - // Release memory - delete auction; - ++expirecount; - - } - while (expAuctions->NextRow()); - - TC_LOG_INFO("server.loading", ">> Deleted %u expired auctions in %u ms", expirecount, GetMSTimeDiffToNow(oldMSTime)); - - -} - -bool AuctionEntry::LoadFromFieldList(Field* fields) -{ - // Loads an AuctionEntry item from a field list. Unlike "LoadFromDB()", this one - // does not require the AuctionEntryMap to have been loaded with items. It simply - // acts as a wrapper to fill out an AuctionEntry struct from a field list - - Id = fields[0].GetUInt32(); - auctioneer = fields[1].GetUInt32(); - itemGUIDLow = fields[2].GetUInt32(); - itemEntry = fields[3].GetUInt32(); - itemCount = fields[4].GetUInt32(); - owner = fields[5].GetUInt32(); - buyout = fields[6].GetUInt32(); - expire_time = fields[7].GetUInt32(); - bidder = fields[8].GetUInt32(); - bid = fields[9].GetUInt32(); - startbid = fields[10].GetUInt32(); - deposit = fields[11].GetUInt32(); - - CreatureData const* auctioneerData = sObjectMgr->GetCreatureData(auctioneer); - if (!auctioneerData) - { - TC_LOG_ERROR("misc", "AuctionEntry::LoadFromFieldList() - Auction %u has not a existing auctioneer (GUID : %u)", Id, auctioneer); - return false; - } - - CreatureTemplate const* auctioneerInfo = sObjectMgr->GetCreatureTemplate(auctioneerData->id); - if (!auctioneerInfo) - { - TC_LOG_ERROR("misc", "AuctionEntry::LoadFromFieldList() - Auction %u has not a existing auctioneer (GUID : %u Entry: %u)", Id, auctioneer, auctioneerData->id); - return false; - } - - factionTemplateId = auctioneerInfo->faction; - auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntry(factionTemplateId); - - if (!auctionHouseEntry) - { - TC_LOG_ERROR("misc", "AuctionEntry::LoadFromFieldList() - Auction %u has auctioneer (GUID : %u Entry: %u) with wrong faction %u", Id, auctioneer, auctioneerData->id, factionTemplateId); - return false; - } - - return true; -} - std::string AuctionEntry::BuildAuctionMailSubject(MailAuctionAnswers response) const { std::ostringstream strm; diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.h b/src/server/game/AuctionHouse/AuctionHouseMgr.h index 0ef61be584a..fc70946d6c4 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.h +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.h @@ -87,7 +87,6 @@ struct AuctionEntry void DeleteFromDB(SQLTransaction& trans) const; void SaveToDB(SQLTransaction& trans) const; bool LoadFromDB(Field* fields); - bool LoadFromFieldList(Field* fields); std::string BuildAuctionMailSubject(MailAuctionAnswers response) const; static std::string BuildAuctionMailBody(uint32 lowGuid, uint32 bid, uint32 buyout, uint32 deposit, uint32 cut); @@ -173,9 +172,6 @@ class AuctionHouseMgr public: - // Used primarily at server start to avoid loading a list of expired auctions - void DeleteExpiredAuctionsAtStartup(); - //load first auction items, because of check if item exists, when loading void LoadAuctionItems(); void LoadAuctions(); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 0462148129a..a197ea7caa8 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1607,10 +1607,6 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading Completed Achievements..."); sAchievementMgr->LoadCompletedAchievements(); - // Delete expired auctions before loading - TC_LOG_INFO("server.loading", "Deleting expired auctions..."); - sAuctionMgr->DeleteExpiredAuctionsAtStartup(); - ///- Load dynamic data tables from the database TC_LOG_INFO("server.loading", "Loading Item Auctions..."); sAuctionMgr->LoadAuctionItems(); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.cpp b/src/server/shared/Database/Implementation/CharacterDatabase.cpp index 328a64dc5b3..e5e563071ec 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.cpp +++ b/src/server/shared/Database/Implementation/CharacterDatabase.cpp @@ -345,9 +345,6 @@ void CharacterDatabaseConnection::DoPrepareStatements() PrepareStatement(CHAR_INS_GM_SUBSURVEY, "INSERT INTO gm_subsurveys (surveyId, subsurveyId, rank, comment) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_INS_LAG_REPORT, "INSERT INTO lag_reports (guid, lagType, mapId, posX, posY, posZ, latency, createTime) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC); - // For loading and deleting expired auctions at startup - PrepareStatement(CHAR_SEL_EXPIRED_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 WHERE ah.time <= ?", CONNECTION_SYNCH); - // LFG Data PrepareStatement(CHAR_INS_LFG_DATA, "INSERT INTO lfg_data (guid, dungeon, state) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(CHAR_DEL_LFG_DATA, "DELETE FROM lfg_data WHERE guid = ?", CONNECTION_ASYNC); diff --git a/src/server/shared/Database/Implementation/CharacterDatabase.h b/src/server/shared/Database/Implementation/CharacterDatabase.h index 19b5fef82eb..9bc11e3f525 100644 --- a/src/server/shared/Database/Implementation/CharacterDatabase.h +++ b/src/server/shared/Database/Implementation/CharacterDatabase.h @@ -304,8 +304,6 @@ enum CharacterDatabaseStatements CHAR_INS_GM_SUBSURVEY, CHAR_INS_LAG_REPORT, - CHAR_SEL_EXPIRED_AUCTIONS, - CHAR_INS_CHARACTER, CHAR_UPD_CHARACTER, |