mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[9339] Use group ids for indexing groups in DB
* Use group ids in DB * Pack used group ids at server startup * Finaly drop group search by leader guid.
This commit is contained in:
parent
b50c3a9355
commit
c9c578b5c3
11 changed files with 129 additions and 68 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
DROP TABLE IF EXISTS `character_db_version`;
|
||||
CREATE TABLE `character_db_version` (
|
||||
`required_9250_01_characters_character` bit(1) default NULL
|
||||
`required_9339_01_characters_group` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Last applied sql update to DB';
|
||||
|
||||
--
|
||||
|
|
@ -891,6 +891,7 @@ UNLOCK TABLES;
|
|||
|
||||
DROP TABLE IF EXISTS `groups`;
|
||||
CREATE TABLE `groups` (
|
||||
`groupId` int(11) unsigned NOT NULL,
|
||||
`leaderGuid` int(11) unsigned NOT NULL,
|
||||
`mainTank` int(11) unsigned NOT NULL,
|
||||
`mainAssistant` int(11) unsigned NOT NULL,
|
||||
|
|
@ -908,7 +909,8 @@ CREATE TABLE `groups` (
|
|||
`isRaid` tinyint(1) unsigned NOT NULL,
|
||||
`difficulty` tinyint(3) unsigned NOT NULL default '0',
|
||||
`raiddifficulty` int(11) UNSIGNED NOT NULL default '0',
|
||||
PRIMARY KEY (`leaderGuid`)
|
||||
PRIMARY KEY (`groupId`),
|
||||
UNIQUE KEY (`leaderGuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Groups';
|
||||
|
||||
--
|
||||
|
|
@ -947,11 +949,11 @@ UNLOCK TABLES;
|
|||
|
||||
DROP TABLE IF EXISTS `group_member`;
|
||||
CREATE TABLE `group_member` (
|
||||
`leaderGuid` int(11) unsigned NOT NULL,
|
||||
`groupId` int(11) unsigned NOT NULL,
|
||||
`memberGuid` int(11) unsigned NOT NULL,
|
||||
`assistant` tinyint(1) unsigned NOT NULL,
|
||||
`subgroup` smallint(6) unsigned NOT NULL,
|
||||
PRIMARY KEY (`leaderGuid`,`memberGuid`)
|
||||
PRIMARY KEY (`groupId`,`memberGuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Groups';
|
||||
|
||||
--
|
||||
|
|
|
|||
15
sql/updates/9339_01_characters_group.sql
Normal file
15
sql/updates/9339_01_characters_group.sql
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
ALTER TABLE character_db_version CHANGE COLUMN required_9250_01_characters_character required_9339_01_characters_group bit;
|
||||
|
||||
ALTER TABLE groups
|
||||
ADD COLUMN `groupId` int(11) unsigned NOT NULL FIRST;
|
||||
|
||||
UPDATE groups
|
||||
SET `groupId` = `leaderGuid`;
|
||||
|
||||
ALTER TABLE groups
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`groupId`),
|
||||
ADD UNIQUE KEY (`leaderGuid`);
|
||||
|
||||
ALTER TABLE group_member
|
||||
CHANGE COLUMN `leaderGuid` `groupId` int(11) unsigned NOT NULL;
|
||||
|
|
@ -265,6 +265,7 @@ pkgdata_DATA = \
|
|||
9312_01_mangos_quest_template.sql \
|
||||
9329_01_mangos_spell_chain.sql \
|
||||
9331_01_mangos_quest_template.sql \
|
||||
9339_01_characters_group.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -510,4 +511,5 @@ EXTRA_DIST = \
|
|||
9312_01_mangos_quest_template.sql \
|
||||
9329_01_mangos_spell_chain.sql \
|
||||
9331_01_mangos_quest_template.sql \
|
||||
9339_01_characters_group.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ bool LoginQueryHolder::Initialize()
|
|||
"resettalents_time, trans_x, trans_y, trans_z, trans_o, transguid, extra_flags, stable_slots, at_login, zone, online, death_expire_time, taxi_path, dungeon_difficulty,"
|
||||
"arenaPoints, totalHonorPoints, todayHonorPoints, yesterdayHonorPoints, totalKills, todayKills, yesterdayKills, chosenTitle, knownCurrencies, watchedFaction, drunk,"
|
||||
"health, power1, power2, power3, power4, power5, power6, power7 FROM characters WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT leaderGuid FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADGROUP, "SELECT groupId FROM group_member WHERE memberGuid ='%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES, "SELECT id, permanent, map, difficulty, resettime FROM character_instance LEFT JOIN instance ON instance = id WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADAURAS, "SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM character_aura WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
res &= SetPQuery(PLAYER_LOGIN_QUERY_LOADSPELLS, "SELECT spell,active,disabled FROM character_spell WHERE guid = '%u'", GUID_LOPART(m_guid));
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ bool Group::Create(const uint64 &guid, const char * name)
|
|||
|
||||
// store group in database
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM groups WHERE leaderGuid ='%u'", GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE leaderGuid ='%u'", GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("INSERT INTO groups (leaderGuid,mainTank,mainAssistant,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,isRaid,difficulty,raiddifficulty) "
|
||||
"VALUES ('%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u','%u')",
|
||||
GUID_LOPART(m_leaderGuid), GUID_LOPART(m_mainTank), GUID_LOPART(m_mainAssistant), uint32(m_lootMethod),
|
||||
CharacterDatabase.PExecute("DELETE FROM groups WHERE groupId ='%u'", m_Id);
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE groupId ='%u'", m_Id);
|
||||
CharacterDatabase.PExecute("INSERT INTO groups (groupId,leaderGuid,mainTank,mainAssistant,lootMethod,looterGuid,lootThreshold,icon1,icon2,icon3,icon4,icon5,icon6,icon7,icon8,isRaid,difficulty,raiddifficulty) "
|
||||
"VALUES ('%u','%u','%u','%u','%u','%u','%u','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','" UI64FMTD "','%u','%u','%u')",
|
||||
m_Id, GUID_LOPART(m_leaderGuid), GUID_LOPART(m_mainTank), GUID_LOPART(m_mainAssistant), 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], isRaidGroup(), uint32(m_dungeonDifficulty), m_raidDifficulty);
|
||||
}
|
||||
|
||||
|
|
@ -126,9 +126,10 @@ bool Group::Create(const uint64 &guid, const char * name)
|
|||
|
||||
bool Group::LoadGroupFromDB(Field* fields)
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid FROM groups");
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
// result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid, groupId FROM groups");
|
||||
|
||||
m_Id = fields[17].GetUInt32();
|
||||
m_leaderGuid = MAKE_NEW_GUID(fields[16].GetUInt32(),0,HIGHGUID_PLAYER);
|
||||
|
||||
// group leader not exist
|
||||
|
|
@ -159,7 +160,6 @@ bool Group::LoadGroupFromDB(Field* fields)
|
|||
for(int i = 0; i < TARGETICONCOUNT; ++i)
|
||||
m_targetIcons[i] = fields[5+i].GetUInt64();
|
||||
|
||||
m_Id = sObjectMgr.GenerateGroupId();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,7 @@ void Group::ConvertToRaid()
|
|||
_initRaidSubGroupsCounter();
|
||||
|
||||
if(!isBGGroup())
|
||||
CharacterDatabase.PExecute("UPDATE groups SET isRaid = 1 WHERE leaderGuid='%u'", GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET isRaid = 1 WHERE groupId='%u'", m_Id);
|
||||
SendUpdate();
|
||||
|
||||
// update quest related GO states (quest activity dependent from raid membership)
|
||||
|
|
@ -431,13 +431,14 @@ void Group::Disband(bool hideDestroy)
|
|||
if(!isBGGroup())
|
||||
{
|
||||
CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabase.PExecute("DELETE FROM groups WHERE leaderGuid='%u'", GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE leaderGuid='%u'", GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("DELETE FROM groups WHERE groupId='%u'", m_Id);
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE groupId='%u'", m_Id);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, false, NULL);
|
||||
ResetInstances(INSTANCE_RESET_GROUP_DISBAND, true, NULL);
|
||||
}
|
||||
|
||||
m_Id = 0;
|
||||
m_leaderGuid = 0;
|
||||
m_leaderName = "";
|
||||
}
|
||||
|
|
@ -1213,8 +1214,7 @@ void Group::_setLeader(const uint64 &guid)
|
|||
Player::ConvertInstancesToGroup(player, this, slot->guid);
|
||||
|
||||
// update the group leader
|
||||
CharacterDatabase.PExecute("UPDATE groups SET leaderGuid='%u' WHERE leaderGuid='%u'", GUID_LOPART(slot->guid), GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE group_member SET leaderGuid='%u' WHERE leaderGuid='%u'", GUID_LOPART(slot->guid), GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET leaderGuid='%u' WHERE groupId='%u'", GUID_LOPART(slot->guid), m_Id);
|
||||
CharacterDatabase.CommitTransaction();
|
||||
}
|
||||
|
||||
|
|
@ -1286,7 +1286,7 @@ bool Group::_setMainTank(const uint64 &guid)
|
|||
_setMainAssistant(0);
|
||||
m_mainTank = guid;
|
||||
if(!isBGGroup())
|
||||
CharacterDatabase.PExecute("UPDATE groups SET mainTank='%u' WHERE leaderGuid='%u'", GUID_LOPART(m_mainTank), GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET mainTank='%u' WHERE groupId='%u'", GUID_LOPART(m_mainTank), m_Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1300,7 +1300,7 @@ bool Group::_setMainAssistant(const uint64 &guid)
|
|||
_setMainTank(0);
|
||||
m_mainAssistant = guid;
|
||||
if(!isBGGroup())
|
||||
CharacterDatabase.PExecute("UPDATE groups SET mainAssistant='%u' WHERE leaderGuid='%u'", GUID_LOPART(m_mainAssistant), GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET mainAssistant='%u' WHERE groupId='%u'", GUID_LOPART(m_mainAssistant), m_Id);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1497,7 +1497,7 @@ void Group::SetDungeonDifficulty(Difficulty difficulty)
|
|||
{
|
||||
m_dungeonDifficulty = difficulty;
|
||||
if(!isBGGroup())
|
||||
CharacterDatabase.PExecute("UPDATE groups SET difficulty = %u WHERE leaderGuid ='%u'", m_dungeonDifficulty, GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET difficulty = %u WHERE groupId='%u'", m_dungeonDifficulty, m_Id);
|
||||
|
||||
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
|
|
@ -1513,7 +1513,7 @@ void Group::SetRaidDifficulty(Difficulty difficulty)
|
|||
{
|
||||
m_raidDifficulty = difficulty;
|
||||
if(!isBGGroup())
|
||||
CharacterDatabase.PExecute("UPDATE groups SET raiddifficulty = %u WHERE leaderGuid ='%u'", m_raidDifficulty, GUID_LOPART(m_leaderGuid));
|
||||
CharacterDatabase.PExecute("UPDATE groups SET raiddifficulty = %u WHERE groupId='%u'", m_raidDifficulty, m_Id);
|
||||
|
||||
for(GroupReference *itr = GetFirstMember(); itr != NULL; itr = itr->next())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -190,16 +190,6 @@ Group* ObjectMgr::GetGroupById(uint32 id) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Group* ObjectMgr::GetGroupByLeaderLowGUID(uint32 guid) const
|
||||
{
|
||||
for(GroupMap::const_iterator itr = mGroupMap.begin(); itr != mGroupMap.end(); ++itr)
|
||||
if (GUID_LOPART(itr->second->GetLeaderGUID())==guid)
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
Guild* ObjectMgr::GetGuildById(uint32 GuildId) const
|
||||
{
|
||||
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
|
||||
|
|
@ -3121,8 +3111,8 @@ void ObjectMgr::LoadGroups()
|
|||
{
|
||||
// -- loading groups --
|
||||
uint32 count = 0;
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid FROM groups");
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, raiddifficulty, leaderGuid, groupId FROM groups");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -3135,8 +3125,6 @@ void ObjectMgr::LoadGroups()
|
|||
return;
|
||||
}
|
||||
|
||||
std::map<uint32,uint32> leader2groupMap;
|
||||
|
||||
barGoLink bar( result->GetRowCount() );
|
||||
|
||||
do
|
||||
|
|
@ -3152,7 +3140,6 @@ void ObjectMgr::LoadGroups()
|
|||
continue;
|
||||
}
|
||||
AddGroup(group);
|
||||
leader2groupMap[GUID_LOPART(group->GetLeaderGUID())] = group->GetId();
|
||||
}while( result->NextRow() );
|
||||
|
||||
delete result;
|
||||
|
|
@ -3162,8 +3149,8 @@ void ObjectMgr::LoadGroups()
|
|||
|
||||
// -- loading members --
|
||||
count = 0;
|
||||
// 0 1 2 3
|
||||
result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, leaderGuid FROM group_member ORDER BY leaderGuid");
|
||||
// 0 1 2 3
|
||||
result = CharacterDatabase.Query("SELECT memberGuid, assistant, subgroup, groupId FROM group_member ORDER BY groupId");
|
||||
if (!result)
|
||||
{
|
||||
barGoLink bar2( 1 );
|
||||
|
|
@ -3183,17 +3170,13 @@ void ObjectMgr::LoadGroups()
|
|||
uint32 memberGuidlow = fields[0].GetUInt32();
|
||||
bool assistent = fields[1].GetBool();
|
||||
uint8 subgroup = fields[2].GetUInt8();
|
||||
uint32 leaderGuidLow = fields[3].GetUInt32();
|
||||
if (!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow)
|
||||
uint32 groupId = fields[3].GetUInt32();
|
||||
if (!group || group->GetId() != groupId)
|
||||
{
|
||||
// find group id in map by leader low guid
|
||||
std::map<uint32,uint32>::const_iterator l2g_itr = leader2groupMap.find(leaderGuidLow);
|
||||
if (l2g_itr != leader2groupMap.end())
|
||||
group = GetGroupById(l2g_itr->second);
|
||||
|
||||
group = GetGroupById(groupId);
|
||||
if (!group)
|
||||
{
|
||||
sLog.outErrorDb("Incorrect entry in group_member table : no group with leader %d for member %d!", leaderGuidLow, memberGuidlow);
|
||||
sLog.outErrorDb("Incorrect entry in group_member table : no group with Id %d for member %d!", groupId, memberGuidlow);
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", memberGuidlow);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -3201,7 +3184,7 @@ void ObjectMgr::LoadGroups()
|
|||
|
||||
if (!group->LoadMemberFromDB(memberGuidlow, subgroup, assistent))
|
||||
{
|
||||
sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group!", memberGuidlow, leaderGuidLow);
|
||||
sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group (Id: %u)!", memberGuidlow, GUID_LOPART(group->GetLeaderGUID()), groupId);
|
||||
CharacterDatabase.PExecute("DELETE FROM group_member WHERE memberGuid = '%d'", memberGuidlow);
|
||||
}
|
||||
}while( result->NextRow() );
|
||||
|
|
@ -3225,11 +3208,13 @@ void ObjectMgr::LoadGroups()
|
|||
// -- loading instances --
|
||||
count = 0;
|
||||
result = CharacterDatabase.Query(
|
||||
// 0 1 2 3 4 5
|
||||
"SELECT leaderGuid, map, instance, permanent, difficulty, resettime, "
|
||||
// 0 1 2 3 4 5
|
||||
"SELECT group_instance.leaderGuid, map, instance, permanent, instance.difficulty, resettime, "
|
||||
// 6
|
||||
"(SELECT COUNT(*) FROM character_instance WHERE guid = leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1) "
|
||||
"FROM group_instance LEFT JOIN instance ON instance = id ORDER BY leaderGuid"
|
||||
"(SELECT COUNT(*) FROM character_instance WHERE guid = group_instance.leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1), "
|
||||
// 7
|
||||
" groups.groupId "
|
||||
"FROM group_instance LEFT JOIN instance ON instance = id LEFT JOIN groups ON groups.leaderGUID = group_instance.leaderGUID ORDER BY leaderGuid"
|
||||
);
|
||||
|
||||
if (!result)
|
||||
|
|
@ -3251,14 +3236,12 @@ void ObjectMgr::LoadGroups()
|
|||
uint32 leaderGuidLow = fields[0].GetUInt32();
|
||||
uint32 mapId = fields[1].GetUInt32();
|
||||
Difficulty diff = (Difficulty)fields[4].GetUInt8();
|
||||
uint32 groupId = fields[7].GetUInt32();
|
||||
|
||||
if (!group || GUID_LOPART(group->GetLeaderGUID()) != leaderGuidLow)
|
||||
if (!group || group->GetId() != groupId)
|
||||
{
|
||||
// find group id in map by leader low guid
|
||||
std::map<uint32,uint32>::const_iterator l2g_itr = leader2groupMap.find(leaderGuidLow);
|
||||
if (l2g_itr != leader2groupMap.end())
|
||||
group = GetGroupById(l2g_itr->second);
|
||||
|
||||
group = GetGroupById(groupId);
|
||||
if (!group)
|
||||
{
|
||||
sLog.outErrorDb("Incorrect entry in group_instance table : no group with leader %d", leaderGuidLow);
|
||||
|
|
@ -5601,6 +5584,52 @@ AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void ObjectMgr::PackGroupIds()
|
||||
{
|
||||
// this routine renumbers groups in such a way so they start from 1 and go up
|
||||
|
||||
// obtain set of all groups
|
||||
std::set<uint32> groupIds;
|
||||
|
||||
// all valid ids are in the instance table
|
||||
// any associations to ids not in this table are assumed to be
|
||||
// cleaned already in CleanupInstances
|
||||
QueryResult *result = CharacterDatabase.Query("SELECT groupId FROM groups");
|
||||
if( result )
|
||||
{
|
||||
do
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
groupIds.insert(fields[0].GetUInt32());
|
||||
}
|
||||
while (result->NextRow());
|
||||
delete result;
|
||||
}
|
||||
|
||||
barGoLink bar( groupIds.size() + 1);
|
||||
bar.step();
|
||||
|
||||
uint32 groupId = 1;
|
||||
// we do assume std::set is sorted properly on integer value
|
||||
for (std::set<uint32>::iterator i = groupIds.begin(); i != groupIds.end(); ++i)
|
||||
{
|
||||
if (*i != groupId)
|
||||
{
|
||||
// remap group id
|
||||
CharacterDatabase.PExecute("UPDATE groups SET groupId = '%u' WHERE groupId = '%u'", groupId, *i);
|
||||
CharacterDatabase.PExecute("UPDATE group_member SET groupId = '%u' WHERE groupId = '%u'", groupId, *i);
|
||||
}
|
||||
|
||||
++groupId;
|
||||
bar.step();
|
||||
}
|
||||
|
||||
m_groupId = groupId;
|
||||
|
||||
sLog.outString( ">> Group Ids remapped, next group id is %u", groupId );
|
||||
sLog.outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::SetHighestGuids()
|
||||
{
|
||||
QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" );
|
||||
|
|
@ -5685,6 +5714,13 @@ void ObjectMgr::SetHighestGuids()
|
|||
m_guildId = (*result)[0].GetUInt32()+1;
|
||||
delete result;
|
||||
}
|
||||
|
||||
result = CharacterDatabase.Query( "SELECT MAX(groupId) FROM groups" );
|
||||
if (result)
|
||||
{
|
||||
m_groupId = (*result)[0].GetUInt32()+1;
|
||||
delete result;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GenerateArenaTeamId()
|
||||
|
|
|
|||
|
|
@ -408,8 +408,8 @@ class ObjectMgr
|
|||
void LoadGameobjectInfo();
|
||||
void AddGameobjectInfo(GameObjectInfo *goinfo);
|
||||
|
||||
void PackGroupIds();
|
||||
Group* GetGroupById(uint32 id) const;
|
||||
Group* GetGroupByLeaderLowGUID(uint32 guid) const; // slow way by leader guid
|
||||
void AddGroup(Group* group);
|
||||
void RemoveGroup(Group* group);
|
||||
|
||||
|
|
|
|||
|
|
@ -3975,12 +3975,12 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
|||
LeaveAllArenaTeams(playerguid);
|
||||
|
||||
// the player was uninvited already on logout so just remove from group
|
||||
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", guid);
|
||||
QueryResult *resultGroup = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", guid);
|
||||
if(resultGroup)
|
||||
{
|
||||
uint32 leaderGuidLow = (*resultGroup)[0].GetUInt32();
|
||||
uint32 groupId = (*resultGroup)[0].GetUInt32();
|
||||
delete resultGroup;
|
||||
if (Group* group = sObjectMgr.GetGroupByLeaderLowGUID(leaderGuidLow))
|
||||
if (Group* group = sObjectMgr.GetGroupById(groupId))
|
||||
RemoveFromGroup(group, playerguid);
|
||||
}
|
||||
|
||||
|
|
@ -15816,13 +15816,13 @@ void Player::_LoadSpells(QueryResult *result)
|
|||
|
||||
void Player::_LoadGroup(QueryResult *result)
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT leaderGuid FROM group_member WHERE memberGuid='%u'", GetGUIDLow());
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT groupId FROM group_member WHERE memberGuid='%u'", GetGUIDLow());
|
||||
if (result)
|
||||
{
|
||||
uint32 leaderGuidLow = (*result)[0].GetUInt32();
|
||||
uint32 groupId = (*result)[0].GetUInt32();
|
||||
delete result;
|
||||
|
||||
if (Group* group = sObjectMgr.GetGroupByLeaderLowGUID(leaderGuidLow))
|
||||
if (Group* group = sObjectMgr.GetGroupById(groupId))
|
||||
{
|
||||
uint8 subgroup = group->GetMemberGroup(GetGUID());
|
||||
SetGroup(group, subgroup);
|
||||
|
|
@ -16066,9 +16066,12 @@ void Player::ConvertInstancesToGroup(Player *player, Group *group, uint64 player
|
|||
}
|
||||
|
||||
// if the player's not online we don't know what binds it has
|
||||
if(!player || !group || has_binds) CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid));
|
||||
if(!player || !group || has_binds)
|
||||
CharacterDatabase.PExecute("INSERT INTO group_instance SELECT guid, instance, permanent FROM character_instance WHERE guid = '%u'", GUID_LOPART(player_guid));
|
||||
|
||||
// the following should not get executed when changing leaders
|
||||
if(!player || has_solo) CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid));
|
||||
if(!player || has_solo)
|
||||
CharacterDatabase.PExecute("DELETE FROM character_instance WHERE guid = '%d' AND permanent = 0", GUID_LOPART(player_guid));
|
||||
}
|
||||
|
||||
bool Player::_LoadHomeBind(QueryResult *result)
|
||||
|
|
|
|||
|
|
@ -1170,6 +1170,9 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Packing instances..." );
|
||||
sInstanceSaveMgr.PackInstances();
|
||||
|
||||
sLog.outString( "Packing groups..." );
|
||||
sObjectMgr.PackGroupIds();
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( "Loading Localization strings..." );
|
||||
sObjectMgr.LoadCreatureLocales();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "9338"
|
||||
#define REVISION_NR "9339"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef __REVISION_SQL_H__
|
||||
#define __REVISION_SQL_H__
|
||||
#define REVISION_DB_CHARACTERS "required_9250_01_characters_character"
|
||||
#define REVISION_DB_CHARACTERS "required_9339_01_characters_group"
|
||||
#define REVISION_DB_MANGOS "required_9331_01_mangos_quest_template"
|
||||
#define REVISION_DB_REALMD "required_9010_01_realmd_realmlist"
|
||||
#endif // __REVISION_SQL_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue