Core/DBLayer: Remove a problematic and unneeded transaction in _LoadMails
This commit is contained in:
@@ -308,6 +308,10 @@ void Item::UpdateDuration(Player* owner, uint32 diff)
|
|||||||
|
|
||||||
void Item::SaveToDB(SQLTransaction& trans)
|
void Item::SaveToDB(SQLTransaction& trans)
|
||||||
{
|
{
|
||||||
|
bool isInTransaction = !(trans.null());
|
||||||
|
if (!isInTransaction)
|
||||||
|
trans = CharacterDatabase.BeginTransaction();
|
||||||
|
|
||||||
uint32 guid = GetGUIDLow();
|
uint32 guid = GetGUIDLow();
|
||||||
switch (uState)
|
switch (uState)
|
||||||
{
|
{
|
||||||
@@ -368,13 +372,21 @@ void Item::SaveToDB(SQLTransaction& trans)
|
|||||||
stmt->setUInt32(0, guid);
|
stmt->setUInt32(0, guid);
|
||||||
trans->Append(stmt);
|
trans->Append(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isInTransaction)
|
||||||
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case ITEM_UNCHANGED:
|
case ITEM_UNCHANGED:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetState(ITEM_UNCHANGED);
|
SetState(ITEM_UNCHANGED);
|
||||||
|
|
||||||
|
if (!isInTransaction)
|
||||||
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
|
bool Item::LoadFromDB(uint32 guid, uint64 owner_guid, Field* fields, uint32 entry)
|
||||||
|
|||||||
@@ -17413,7 +17413,6 @@ void Player::_LoadMailedItems(Mail *mail)
|
|||||||
if (!result)
|
if (!result)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Field* fields = result->Fetch();
|
Field* fields = result->Fetch();
|
||||||
@@ -17428,10 +17427,10 @@ void Player::_LoadMailedItems(Mail *mail)
|
|||||||
if (!proto)
|
if (!proto)
|
||||||
{
|
{
|
||||||
sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID);
|
sLog->outError("Player %u has unknown item_template (ProtoType) in mailed items(GUID: %u template: %u) in mail (%u), deleted.", GetGUIDLow(), item_guid_low, item_template, mail->messageID);
|
||||||
trans->PAppend("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||||
stmt->setUInt32(0, item_guid_low);
|
stmt->setUInt32(0, item_guid_low);
|
||||||
trans->Append(stmt);
|
CharacterDatabase.Execute(stmt);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17442,15 +17441,13 @@ void Player::_LoadMailedItems(Mail *mail)
|
|||||||
sLog->outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
|
sLog->outError("Player::_LoadMailedItems - Item in mail (%u) doesn't exist !!!! - item guid: %u, deleted from mail", mail->messageID, item_guid_low);
|
||||||
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid = '%u'", item_guid_low);
|
||||||
item->FSetState(ITEM_REMOVED);
|
item->FSetState(ITEM_REMOVED);
|
||||||
item->SaveToDB(trans); // it also deletes item object !
|
item->SaveToDB(SQLTransaction(NULL)); // it also deletes item object !
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddMItem(item);
|
AddMItem(item);
|
||||||
}
|
}
|
||||||
while (result->NextRow());
|
while (result->NextRow());
|
||||||
|
|
||||||
CharacterDatabase.CommitTransaction(trans);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::_LoadMailInit(PreparedQueryResult resultUnread, PreparedQueryResult resultDelivery)
|
void Player::_LoadMailInit(PreparedQueryResult resultUnread, PreparedQueryResult resultDelivery)
|
||||||
@@ -17504,7 +17501,8 @@ void Player::_LoadMail()
|
|||||||
_LoadMailedItems(m);
|
_LoadMailedItems(m);
|
||||||
|
|
||||||
m_mail.push_back(m);
|
m_mail.push_back(m);
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
}
|
}
|
||||||
m_mailsLoaded = true;
|
m_mailsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user