Wrap guild_bank_item save queries in transactions.
Fixes a potential dataloss issue --HG-- branch : trunk
This commit is contained in:
@@ -1594,10 +1594,10 @@ void Guild::LogBankEvent(SQLTransaction& trans, uint8 EventType, uint8 TabId, ui
|
|||||||
m_Id, currentLogGuid, currentTabId, uint32(NewEvent.EventType), NewEvent.PlayerGuid, NewEvent.ItemOrMoney, uint32(NewEvent.ItemStackCount), uint32(NewEvent.DestTabId), NewEvent.TimeStamp);
|
m_Id, currentLogGuid, currentTabId, uint32(NewEvent.EventType), NewEvent.PlayerGuid, NewEvent.ItemOrMoney, uint32(NewEvent.ItemStackCount), uint32(NewEvent.DestTabId), NewEvent.TimeStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Guild::AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry)
|
bool Guild::AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry, SQLTransaction& trans)
|
||||||
{
|
{
|
||||||
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE guildid = '%u' AND TabId = '%u'AND SlotId = '%u'", GuildId, BankTab, BankTabSlot);
|
trans->PAppend("DELETE FROM guild_bank_item WHERE guildid = '%u' AND TabId = '%u'AND SlotId = '%u'", GuildId, BankTab, BankTabSlot);
|
||||||
CharacterDatabase.PExecute("INSERT INTO guild_bank_item (guildid,TabId,SlotId,item_guid,item_entry) "
|
trans->PAppend("INSERT INTO guild_bank_item (guildid,TabId,SlotId,item_guid,item_entry) "
|
||||||
"VALUES ('%u', '%u', '%u', '%u', '%u')", GuildId, BankTab, BankTabSlot, GUIDLow, Entry);
|
"VALUES ('%u', '%u', '%u', '%u', '%u')", GuildId, BankTab, BankTabSlot, GUIDLow, Entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1688,7 +1688,7 @@ Item* Guild::_StoreItem(uint8 tab, uint8 slot, Item *pItem, uint32 count, bool c
|
|||||||
|
|
||||||
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0);
|
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0);
|
||||||
pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
|
pItem->SetUInt64Value(ITEM_FIELD_OWNER, 0);
|
||||||
AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry());
|
AddGBankItemToDB(GetId(), tab, slot, pItem->GetGUIDLow(), pItem->GetEntry(), trans);
|
||||||
pItem->FSetState(ITEM_NEW);
|
pItem->FSetState(ITEM_NEW);
|
||||||
pItem->SaveToDB(trans); // not in inventory and can be save standalone
|
pItem->SaveToDB(trans); // not in inventory and can be save standalone
|
||||||
|
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ class Guild
|
|||||||
void LoadGuildBankEventLogFromDB();
|
void LoadGuildBankEventLogFromDB();
|
||||||
void DisplayGuildBankLogs(WorldSession *session, uint8 TabId);
|
void DisplayGuildBankLogs(WorldSession *session, uint8 TabId);
|
||||||
void LogBankEvent(SQLTransaction& trans, uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0);
|
void LogBankEvent(SQLTransaction& trans, uint8 EventType, uint8 TabId, uint32 PlayerGuidLow, uint32 ItemOrMoney, uint8 ItemStackCount=0, uint8 DestTabId=0);
|
||||||
bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry);
|
bool AddGBankItemToDB(uint32 GuildId, uint32 BankTab , uint32 BankTabSlot , uint32 GUIDLow, uint32 Entry, SQLTransaction& trans);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void AddRank(const std::string& name,uint32 rights,uint32 money);
|
void AddRank(const std::string& name,uint32 rights,uint32 money);
|
||||||
|
|||||||
Reference in New Issue
Block a user