aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Groups/Group.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Groups/Group.cpp')
-rw-r--r--src/server/game/Groups/Group.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 837f7d3ad77..7a8ffb061b5 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -116,20 +116,19 @@ bool Group::Create(const uint64 &guid, const char * name)
Player::ConvertInstancesToGroup(leader, this, guid);
+ if (!AddMember(guid, name))
+ return false;
+
// store group in database
- CharacterDatabase.BeginTransaction();
- CharacterDatabase.PExecute("DELETE FROM groups WHERE guid ='%u'", lowguid);
- CharacterDatabase.PExecute("DELETE FROM group_member WHERE guid ='%u'", lowguid);
- CharacterDatabase.PExecute("INSERT INTO groups (guid,leaderGuid,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,groupType,difficulty,raiddifficulty) "
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
+ trans->PAppend("DELETE FROM groups WHERE guid ='%u'", lowguid);
+ trans->PAppend("DELETE FROM group_member WHERE guid ='%u'", lowguid);
+ trans->PAppend("INSERT INTO groups (guid,leaderGuid,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,groupType,difficulty,raiddifficulty) "
"VALUES ('%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u','%u')",
lowguid, GUID_LOPART(m_leaderGuid), uint32(m_lootMethod),
GUID_LOPART(m_looterGuid), uint32(m_lootThreshold), m_targetIcons[0], m_targetIcons[1], m_targetIcons[2], m_targetIcons[3], m_targetIcons[4], m_targetIcons[5], m_targetIcons[6], m_targetIcons[7], uint8(m_groupType), uint32(m_dungeonDifficulty), m_raidDifficulty);
- if (!AddMember(guid, name))
- {
- CharacterDatabase.RollbackTransaction();
- return false;
- }
- CharacterDatabase.CommitTransaction();
+
+ CharacterDatabase.CommitTransaction(trans);
}
else if (!AddMember(guid, name))
return false;
@@ -497,10 +496,10 @@ void Group::Disband(bool hideDestroy)
if (!isBGGroup())
{
uint32 lowguid = GUID_LOPART(m_guid);
- CharacterDatabase.BeginTransaction();
- CharacterDatabase.PExecute("DELETE FROM groups WHERE guid=%u", lowguid);
- CharacterDatabase.PExecute("DELETE FROM group_member WHERE guid=%u", lowguid);
- CharacterDatabase.CommitTransaction();
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
+ trans->PAppend("DELETE FROM groups WHERE guid=%u", lowguid);
+ trans->PAppend("DELETE FROM group_member WHERE guid=%u", lowguid);
+ CharacterDatabase.CommitTransaction(trans);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
}
@@ -1334,14 +1333,14 @@ void Group::_setLeader(const uint64 &guid)
if (!isBGGroup())
{
// TODO: set a time limit to have this function run rarely cause it can be slow
- CharacterDatabase.BeginTransaction();
+ SQLTransaction trans = CharacterDatabase.BeginTransaction();
// update the group's bound instances when changing leaders
// remove all permanent binds from the group
// in the DB also remove solo binds that will be replaced with permbinds
// from the new leader
- CharacterDatabase.PExecute(
+ trans->PAppend(
"DELETE FROM group_instance WHERE guid=%u AND (permanent = 1 OR "
"instance IN (SELECT instance FROM character_instance WHERE guid = '%u')"
")", GUID_LOPART(m_guid), GUID_LOPART(slot->guid)
@@ -1371,8 +1370,8 @@ void Group::_setLeader(const uint64 &guid)
Player::ConvertInstancesToGroup(player, this, slot->guid);
// update the group leader
- CharacterDatabase.PExecute("UPDATE groups SET leaderGuid='%u' WHERE guid='%u'", GUID_LOPART(slot->guid), GUID_LOPART(m_guid));
- CharacterDatabase.CommitTransaction();
+ trans->PAppend("UPDATE groups SET leaderGuid='%u' WHERE guid='%u'", GUID_LOPART(slot->guid), GUID_LOPART(m_guid));
+ CharacterDatabase.CommitTransaction(trans);
}
m_leaderGuid = slot->guid;