DB Layer:
- Make SQL Transactions actual objects used in code. (Thanks to Derex for the idea) * Uncommitted transactions will be automatically rolled back and cleaned up using ACE_Refcounted_Auto_Ptr, so no need to call Rollback() in the code. * Prevents recursive transactions and makes developers aware of transactions going on. * Gets rid of unneccesary overhead iterating over a concurrent map. - Some cleanups in affected code, including better usage of transaction control in AH / mail related code to prevent data loss. *** Experimental, use at own risk, recommended to backup your DBs. *** --HG-- branch : trunk
This commit is contained in:
@@ -113,53 +113,6 @@ void WorldSession::SendAuctionOwnerNotification(AuctionEntry* auction)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
//this function sends mail to old bidder
|
||||
void WorldSession::SendAuctionOutbiddedMail(AuctionEntry *auction, uint32 newPrice)
|
||||
{
|
||||
uint64 oldBidder_guid = MAKE_NEW_GUID(auction->bidder,0, HIGHGUID_PLAYER);
|
||||
Player *oldBidder = sObjectMgr.GetPlayer(oldBidder_guid);
|
||||
|
||||
uint32 oldBidder_accId = 0;
|
||||
if (!oldBidder)
|
||||
oldBidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(oldBidder_guid);
|
||||
|
||||
// old bidder exist
|
||||
if (oldBidder || oldBidder_accId)
|
||||
{
|
||||
std::ostringstream msgAuctionOutbiddedSubject;
|
||||
msgAuctionOutbiddedSubject << auction->item_template << ":0:" << AUCTION_OUTBIDDED << ":0:0";
|
||||
|
||||
if (oldBidder && _player)
|
||||
oldBidder->GetSession()->SendAuctionBidderNotification(auction->GetHouseId(), auction->Id, _player->GetGUID(), newPrice, auction->GetAuctionOutBid(), auction->item_template);
|
||||
|
||||
MailDraft(msgAuctionOutbiddedSubject.str(), "") // TODO: fix body
|
||||
.AddMoney(auction->bid)
|
||||
.SendMailTo(MailReceiver(oldBidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED);
|
||||
}
|
||||
}
|
||||
|
||||
//this function sends mail, when auction is cancelled to old bidder
|
||||
void WorldSession::SendAuctionCancelledToBidderMail(AuctionEntry* auction)
|
||||
{
|
||||
uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER);
|
||||
Player *bidder = sObjectMgr.GetPlayer(bidder_guid);
|
||||
|
||||
uint32 bidder_accId = 0;
|
||||
if (!bidder)
|
||||
bidder_accId = sObjectMgr.GetPlayerAccountIdByGUID(bidder_guid);
|
||||
|
||||
// bidder exist
|
||||
if (bidder || bidder_accId)
|
||||
{
|
||||
std::ostringstream msgAuctionCancelledSubject;
|
||||
msgAuctionCancelledSubject << auction->item_template << ":0:" << AUCTION_CANCELLED_TO_BIDDER << ":0:0";
|
||||
|
||||
MailDraft(msgAuctionCancelledSubject.str(), "") // TODO: fix body
|
||||
.AddMoney(auction->bid)
|
||||
.SendMailTo(MailReceiver(bidder, auction->bidder), auction, MAIL_CHECK_MASK_COPIED);
|
||||
}
|
||||
}
|
||||
|
||||
//this void creates new auction and adds auction to some auctionhouse
|
||||
void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
||||
{
|
||||
@@ -284,12 +237,12 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
||||
|
||||
pl->MoveItemFromInventory(it->GetBagSlot(), it->GetSlot(), true);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
it->DeleteFromInventoryDB();
|
||||
it->SaveToDB(); // recursive and not have transaction guard into self, not in inventiory and can be save standalone
|
||||
AH->SaveToDB();
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
it->DeleteFromInventoryDB(trans);
|
||||
it->SaveToDB(trans); // recursive and not have transaction guard into self, not in inventiory and can be save standalone
|
||||
AH->SaveToDB(trans);
|
||||
pl->SaveInventoryAndGoldToDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
SendAuctionCommandResult(AH->Id, AUCTION_SELL_ITEM, AUCTION_OK);
|
||||
|
||||
@@ -359,6 +312,8 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
if (price < auction->buyout || auction->buyout == 0)
|
||||
{
|
||||
if (auction->bidder > 0)
|
||||
@@ -368,7 +323,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
else
|
||||
{
|
||||
// mail to last bidder and return money
|
||||
SendAuctionOutbiddedMail(auction, price);
|
||||
sAuctionMgr.SendAuctionOutbiddedMail(auction, price, GetPlayer(), trans);
|
||||
pl->ModifyMoney(-int32(price));
|
||||
}
|
||||
}
|
||||
@@ -379,9 +334,7 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
auction->bid = price;
|
||||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
||||
|
||||
// after this update we should save player's money ...
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
trans->PAppend("UPDATE auctionhouse SET buyguid = '%u',lastbid = '%u' WHERE id = '%u'", auction->bidder, auction->bid, auction->Id);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK, 0);
|
||||
}
|
||||
@@ -394,26 +347,27 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket & recv_data)
|
||||
{
|
||||
pl->ModifyMoney(-int32(auction->buyout));
|
||||
if (auction->bidder) //buyout for bidded auction ..
|
||||
SendAuctionOutbiddedMail(auction, auction->buyout);
|
||||
sAuctionMgr.SendAuctionOutbiddedMail(auction, auction->buyout, GetPlayer(), trans);
|
||||
}
|
||||
auction->bidder = pl->GetGUIDLow();
|
||||
auction->bid = auction->buyout;
|
||||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, auction->buyout);
|
||||
|
||||
sAuctionMgr.SendAuctionSalePendingMail(auction);
|
||||
sAuctionMgr.SendAuctionSuccessfulMail(auction);
|
||||
sAuctionMgr.SendAuctionWonMail(auction);
|
||||
//- Mails must be under transaction control too to prevent data loss
|
||||
sAuctionMgr.SendAuctionSalePendingMail(auction, trans);
|
||||
sAuctionMgr.SendAuctionSuccessfulMail(auction, trans);
|
||||
sAuctionMgr.SendAuctionWonMail(auction, trans);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, AUCTION_OK);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
auction->DeleteFromDB();
|
||||
auction->DeleteFromDB(trans);
|
||||
|
||||
uint32 item_template = auction->item_template;
|
||||
sAuctionMgr.RemoveAItem(auction->item_guidlow);
|
||||
auctionHouse->RemoveAuction(auction, item_template);
|
||||
}
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
pl->SaveInventoryAndGoldToDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
//this void is called when auction_owner cancels his auction
|
||||
@@ -441,6 +395,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||
AuctionEntry *auction = auctionHouse->GetAuction(auctionId);
|
||||
Player *pl = GetPlayer();
|
||||
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
if (auction && auction->owner == pl->GetGUIDLow())
|
||||
{
|
||||
Item *pItem = sAuctionMgr.GetAItem(auction->item_guidlow);
|
||||
@@ -452,7 +407,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||
if (pl->GetMoney() < auctionCut) //player doesn't have enough money, maybe message needed
|
||||
return;
|
||||
//some auctionBidderNotification would be needed, but don't know that parts..
|
||||
SendAuctionCancelledToBidderMail(auction);
|
||||
sAuctionMgr.SendAuctionCancelledToBidderMail(auction, trans);
|
||||
pl->ModifyMoney(-int32(auctionCut));
|
||||
}
|
||||
// Return the item by mail
|
||||
@@ -462,7 +417,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||
// item will deleted or added to received mail list
|
||||
MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body
|
||||
.AddItem(pItem)
|
||||
.SendMailTo(pl, auction, MAIL_CHECK_MASK_COPIED);
|
||||
.SendMailTo(trans, pl, auction, MAIL_CHECK_MASK_COPIED);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -483,13 +438,14 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_CANCEL, AUCTION_OK);
|
||||
|
||||
// Now remove the auction
|
||||
CharacterDatabase.BeginTransaction();
|
||||
pl->SaveInventoryAndGoldToDB();
|
||||
auction->DeleteFromDB();
|
||||
|
||||
pl->SaveInventoryAndGoldToDB(trans);
|
||||
auction->DeleteFromDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
uint32 item_template = auction->item_template;
|
||||
sAuctionMgr.RemoveAItem(auction->item_guidlow);
|
||||
auctionHouse->RemoveAuction(auction, item_template);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
//called when player lists his bids
|
||||
|
||||
@@ -1041,11 +1041,11 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recv_data)
|
||||
for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
CharacterDatabase.escape_string(declinedname.name[i]);
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
CharacterDatabase.PExecute("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')",
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM character_declinedname WHERE guid = '%u'", GUID_LOPART(guid));
|
||||
trans->PAppend("INSERT INTO character_declinedname (guid, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%s','%s','%s','%s','%s')",
|
||||
GUID_LOPART(guid), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
WorldPacket data(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT, 4+8);
|
||||
data << uint32(0); // OK
|
||||
|
||||
@@ -887,13 +887,11 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket & recv_data)
|
||||
if (!pGuild->GetPurchasedTabs())
|
||||
return;
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
pGuild->SetBankMoney(pGuild->GetGuildBankMoney()+money);
|
||||
pGuild->SetBankMoney(pGuild->GetGuildBankMoney()+money, trans);
|
||||
GetPlayer()->ModifyMoney(-int(money));
|
||||
GetPlayer()->SaveGoldToDB();
|
||||
|
||||
CharacterDatabase.CommitTransaction();
|
||||
GetPlayer()->SaveGoldToDB(trans);
|
||||
|
||||
// logging money
|
||||
if (_player->GetSession()->GetSecurity() > SEC_PLAYER && sWorld.getConfig(CONFIG_GM_LOG_TRADE))
|
||||
@@ -903,7 +901,9 @@ void WorldSession::HandleGuildBankDepositMoney(WorldPacket & recv_data)
|
||||
}
|
||||
|
||||
// log
|
||||
pGuild->LogBankEvent(GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money);
|
||||
pGuild->LogBankEvent(trans, GUILD_BANK_LOG_DEPOSIT_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
pGuild->DisplayGuildBankTabsInfo(this);
|
||||
pGuild->DisplayGuildBankContent(this, 0);
|
||||
@@ -941,21 +941,18 @@ void WorldSession::HandleGuildBankWithdrawMoney(WorldPacket & recv_data)
|
||||
if (!pGuild->HasRankRight(GetPlayer()->GetRank(), GR_RIGHT_WITHDRAW_GOLD))
|
||||
return;
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
if (!pGuild->MemberMoneyWithdraw(money, GetPlayer()->GetGUIDLow()))
|
||||
{
|
||||
CharacterDatabase.RollbackTransaction();
|
||||
if (!pGuild->MemberMoneyWithdraw(money, GetPlayer()->GetGUIDLow(), trans))
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlayer()->ModifyMoney(money);
|
||||
GetPlayer()->SaveGoldToDB();
|
||||
|
||||
CharacterDatabase.CommitTransaction();
|
||||
GetPlayer()->SaveGoldToDB(trans);
|
||||
|
||||
// Log
|
||||
pGuild->LogBankEvent(GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money);
|
||||
pGuild->LogBankEvent(trans, GUILD_BANK_LOG_WITHDRAW_MONEY, uint8(0), GetPlayer()->GetGUIDLow(), money);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
pGuild->SendMoneyInfo(this, GetPlayer()->GetGUIDLow());
|
||||
pGuild->DisplayGuildBankTabsInfo(this);
|
||||
|
||||
@@ -1120,8 +1120,8 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("INSERT INTO character_gifts VALUES ('%u', '%u', '%u', '%u')", GUID_LOPART(item->GetOwnerGUID()), item->GetGUIDLow(), item->GetEntry(), item->GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
item->SetEntry(gift->GetEntry());
|
||||
|
||||
switch (item->GetEntry())
|
||||
@@ -1141,9 +1141,9 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
// after save it will be impossible to remove the item from the queue
|
||||
item->RemoveFromUpdateQueueOf(_player);
|
||||
item->SaveToDB(); // item gave inventory record unchanged and can be save standalone
|
||||
item->SaveToDB(trans); // item gave inventory record unchanged and can be save standalone
|
||||
}
|
||||
CharacterDatabase.CommitTransaction();
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
uint32 count = 1;
|
||||
_player->DestroyItemCount(gift, count, true);
|
||||
|
||||
@@ -863,7 +863,12 @@ void WorldSession::HandleRepairItemOpcode(WorldPacket & recv_data)
|
||||
Guild *pGuild = sObjectMgr.GetGuildById(GuildId);
|
||||
if (!pGuild)
|
||||
return;
|
||||
pGuild->LogBankEvent(GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost);
|
||||
|
||||
//- TODO: Fix poor function call design
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
pGuild->LogBankEvent(trans, GUILD_BANK_LOG_REPAIR_MONEY, 0, _player->GetGUIDLow(), TotalCost);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
pGuild->SendMoneyInfo(this, _player->GetGUIDLow());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,19 +601,19 @@ void WorldSession::HandlePetRename(WorldPacket & recv_data)
|
||||
}
|
||||
}
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
if (isdeclined)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
CharacterDatabase.escape_string(declinedname.name[i]);
|
||||
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
||||
CharacterDatabase.PExecute("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
|
||||
trans->PAppend("DELETE FROM character_pet_declinedname WHERE owner = '%u' AND id = '%u'", _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
||||
trans->PAppend("INSERT INTO character_pet_declinedname (id, owner, genitive, dative, accusative, instrumental, prepositional) VALUES ('%u','%u','%s','%s','%s','%s','%s')",
|
||||
pet->GetCharmInfo()->GetPetNumber(), _player->GetGUIDLow(), declinedname.name[0].c_str(), declinedname.name[1].c_str(), declinedname.name[2].c_str(), declinedname.name[3].c_str(), declinedname.name[4].c_str());
|
||||
}
|
||||
|
||||
CharacterDatabase.escape_string(name);
|
||||
CharacterDatabase.PExecute("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
||||
CharacterDatabase.CommitTransaction();
|
||||
trans->PAppend("UPDATE character_pet SET name = '%s', renamed = '1' WHERE owner = '%u' AND id = '%u'", name.c_str(), _player->GetGUIDLow(), pet->GetCharmInfo()->GetPetNumber());
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
pet->SetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP, time(NULL));
|
||||
}
|
||||
|
||||
@@ -225,12 +225,12 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||
|
||||
sLog.outDebug("Invalid petition GUIDs: %s", ssInvalidPetitionGUIDs.str().c_str());
|
||||
CharacterDatabase.escape_string(name);
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM petition WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
|
||||
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
|
||||
CharacterDatabase.PExecute("INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES ('%u', '%u', '%s', '%u')",
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM petition WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
|
||||
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid IN (%s)", ssInvalidPetitionGUIDs.str().c_str());
|
||||
trans->PAppend("INSERT INTO petition (ownerguid, petitionguid, name, type) VALUES ('%u', '%u', '%s', '%u')",
|
||||
_player->GetGUIDLow(), charter->GetGUIDLow(), name.c_str(), type);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
void WorldSession::HandlePetitionShowSignOpcode(WorldPacket & recv_data)
|
||||
@@ -845,10 +845,10 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
}
|
||||
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
|
||||
CharacterDatabase.PExecute("DELETE FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
|
||||
CharacterDatabase.CommitTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM petition WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
|
||||
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = '%u'", GUID_LOPART(petitionguid));
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
// created
|
||||
sLog.outDebug("TURN IN PETITION GUID %u", GUID_LOPART(petitionguid));
|
||||
|
||||
@@ -480,10 +480,10 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
|
||||
trader->m_trade = NULL;
|
||||
|
||||
// desynchronized with the other saves here (SaveInventoryAndGoldToDB() not have own transaction guards)
|
||||
CharacterDatabase.BeginTransaction();
|
||||
_player->SaveInventoryAndGoldToDB();
|
||||
trader->SaveInventoryAndGoldToDB();
|
||||
CharacterDatabase.CommitTransaction();
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
_player->SaveInventoryAndGoldToDB(trans);
|
||||
trader->SaveInventoryAndGoldToDB(trans);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
trader->GetSession()->SendTradeStatus(TRADE_STATUS_TRADE_COMPLETE);
|
||||
SendTradeStatus(TRADE_STATUS_TRADE_COMPLETE);
|
||||
|
||||
@@ -625,11 +625,11 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
|
||||
{
|
||||
uint32 acc = GetAccountId();
|
||||
|
||||
CharacterDatabase.BeginTransaction ();
|
||||
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
|
||||
CharacterDatabase.escape_string(data);
|
||||
CharacterDatabase.PExecute("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction ();
|
||||
trans->PAppend("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -637,11 +637,11 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
|
||||
if (!m_GUIDLow)
|
||||
return;
|
||||
|
||||
CharacterDatabase.BeginTransaction ();
|
||||
CharacterDatabase.PExecute("DELETE FROM character_account_data WHERE guid='%u' AND type='%u'", m_GUIDLow, type);
|
||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
trans->PAppend("DELETE FROM character_account_data WHERE guid='%u' AND type='%u'", m_GUIDLow, type);
|
||||
CharacterDatabase.escape_string(data);
|
||||
CharacterDatabase.PExecute("INSERT INTO character_account_data VALUES ('%u','%u','%u','%s')", m_GUIDLow, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction ();
|
||||
trans->PAppend("INSERT INTO character_account_data VALUES ('%u','%u','%u','%s')", m_GUIDLow, type, (uint32)time_, data.c_str());
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
||||
m_accountData[type].Time = time_;
|
||||
@@ -689,7 +689,7 @@ void WorldSession::SendTutorialsData()
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::SaveTutorialsData()
|
||||
void WorldSession::SaveTutorialsData(SQLTransaction& trans)
|
||||
{
|
||||
if (!m_TutorialsChanged)
|
||||
return;
|
||||
@@ -701,14 +701,10 @@ void WorldSession::SaveTutorialsData()
|
||||
Rows = result->Fetch()[0].GetUInt32();
|
||||
|
||||
if (Rows)
|
||||
{
|
||||
CharacterDatabase.PExecute("UPDATE character_tutorial SET tut0='%u', tut1='%u', tut2='%u', tut3='%u', tut4='%u', tut5='%u', tut6='%u', tut7='%u' WHERE account = '%u'",
|
||||
trans->PAppend("UPDATE character_tutorial SET tut0='%u', tut1='%u', tut2='%u', tut3='%u', tut4='%u', tut5='%u', tut6='%u', tut7='%u' WHERE account = '%u'",
|
||||
m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7], GetAccountId());
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", GetAccountId(), m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7]);
|
||||
}
|
||||
trans->PAppend("INSERT INTO character_tutorial (account,tut0,tut1,tut2,tut3,tut4,tut5,tut6,tut7) VALUES ('%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u', '%u')", GetAccountId(), m_Tutorials[0], m_Tutorials[1], m_Tutorials[2], m_Tutorials[3], m_Tutorials[4], m_Tutorials[5], m_Tutorials[6], m_Tutorials[7]);
|
||||
|
||||
m_TutorialsChanged = false;
|
||||
}
|
||||
@@ -994,7 +990,7 @@ void WorldSession::ProcessQueryCallbacks()
|
||||
//! HandleAddFriendOpcode
|
||||
if (m_addFriendCallback.IsReady())
|
||||
{
|
||||
const std::string& param = m_addFriendCallback.GetParam();
|
||||
std::string param = m_addFriendCallback.GetParam();
|
||||
m_addFriendCallback.GetResult(result);
|
||||
HandleAddFriendOpcodeCallBack(result, param);
|
||||
m_addFriendCallback.FreeResult();
|
||||
@@ -1003,7 +999,7 @@ void WorldSession::ProcessQueryCallbacks()
|
||||
//- HandleCharRenameOpcode
|
||||
if (m_charRenameCallback.IsReady())
|
||||
{
|
||||
const std::string& param = m_charRenameCallback.GetParam();
|
||||
std::string param = m_charRenameCallback.GetParam();
|
||||
m_charRenameCallback.GetResult(result);
|
||||
HandleChangePlayerNameOpcodeCallBack(result, param);
|
||||
m_charRenameCallback.FreeResult();
|
||||
|
||||
@@ -229,7 +229,7 @@ class WorldSession
|
||||
void LoadAccountData(QueryResult_AutoPtr result, uint32 mask);
|
||||
void LoadTutorialsData();
|
||||
void SendTutorialsData();
|
||||
void SaveTutorialsData();
|
||||
void SaveTutorialsData(SQLTransaction& trans);
|
||||
uint32 GetTutorialInt(uint32 intId)
|
||||
{
|
||||
return m_Tutorials[intId];
|
||||
@@ -250,8 +250,6 @@ class WorldSession
|
||||
void SendAuctionCommandResult(uint32 auctionId, uint32 Action, uint32 ErrorCode, uint32 bidError = 0);
|
||||
void SendAuctionBidderNotification(uint32 location, uint32 auctionId, uint64 bidder, uint32 bidSum, uint32 diff, uint32 item_template);
|
||||
void SendAuctionOwnerNotification(AuctionEntry * auction);
|
||||
void SendAuctionOutbiddedMail(AuctionEntry * auction, uint32 newPrice);
|
||||
void SendAuctionCancelledToBidderMail(AuctionEntry* auction);
|
||||
|
||||
//Item Enchantment
|
||||
void SendEnchantmentLog(uint64 Target, uint64 Caster,uint32 ItemID,uint32 SpellID);
|
||||
|
||||
Reference in New Issue
Block a user