Core/Guild: avoid data integrity problems wrapping delete+insert statements in a transaction

This commit is contained in:
ariel-
2016-11-19 23:28:52 -03:00
parent d2bf7237a3
commit 25281ecb31
6 changed files with 184 additions and 157 deletions

View File

@@ -1843,13 +1843,10 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
{
// Reset guild
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER);
stmt->setUInt32(0, lowGuid);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32()))
guild->DeleteMember(factionChangeInfo.Guid, false, false, true);
guild->DeleteMember(trans, factionChangeInfo.Guid, false, false, true);
Player::LeaveAllArenaTeams(factionChangeInfo.Guid);
}