** Fix for groups with multiple players and bots.

*  Fixes non-group leaders zoning with their bots.
*  Fixes non-bot owners attempting to load bots they don't own.
*  Sets bots that zone to follow owner not group leader.
*  Updates database call only load bots in group you own.
*  Tested on server 2 clients, 4 bots, all permutations of zoning.
This commit is contained in:
Allen 2017-04-12 00:54:37 -07:00
parent 478a9d115b
commit f88a6774a9
3 changed files with 17 additions and 21 deletions

View File

@ -2995,7 +2995,8 @@ void Bot::LoadAndSpawnAllZonedBots(Client* botOwner) {
if(g) {
uint32 TempGroupId = g->GetID();
std::list<uint32> ActiveBots;
if (!botdb.LoadGroupedBotsByGroupID(TempGroupId, ActiveBots)) {
// Modified LoadGroupedBotsByGroupID to require a CharacterID
if (!botdb.LoadGroupedBotsByGroupID(botOwner->CharacterID(), TempGroupId, ActiveBots)) {
botOwner->Message(13, "%s", BotDatabase::fail::LoadGroupedBotsByGroupID());
return;
}
@ -3007,8 +3008,9 @@ void Bot::LoadAndSpawnAllZonedBots(Client* botOwner) {
if(activeBot) {
activeBot->Spawn(botOwner);
g->UpdatePlayer(activeBot);
if(g->GetLeader())
activeBot->SetFollowID(g->GetLeader()->GetID());
// follow the bot owner, not the group leader we just zoned with our owner.
if(g->IsGroupMember(botOwner) && g->IsGroupMember(activeBot))
activeBot->SetFollowID(botOwner->GetID());
}
if(activeBot && !botOwner->HasGroup())
@ -7297,10 +7299,11 @@ void Bot::ProcessClientZoneChange(Client* botOwner) {
if(tempBot) {
if(tempBot->HasGroup()) {
Group* g = tempBot->GetGroup();
if(g && g->GetLeader()) {
Mob* tempGroupLeader = tempBot->GetGroup()->GetLeader();
if(tempGroupLeader && tempGroupLeader->IsClient()) {
if(tempBot->GetBotOwnerCharacterID() == tempGroupLeader->CastToClient()->CharacterID())
if(g && g->IsGroupMember(botOwner)) {
if(botOwner && botOwner->IsClient()) {
// Modified to not only zone bots if you're the leader.
// Also zone bots of the non-leader when they change zone.
if(tempBot->GetBotOwnerCharacterID() == botOwner->CharacterID() && g->IsGroupMember(botOwner))
tempBot->Zone();
else
tempBot->Camp();

View File

@ -2459,9 +2459,10 @@ bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<st
/* Bot owner group functions */
bool BotDatabase::LoadGroupedBotsByGroupID(const uint32 group_id, std::list<uint32>& group_list)
// added owner ID to this function to fix groups with mulitple players grouped with bots.
bool BotDatabase::LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list)
{
if (!group_id)
if (!group_id || !owner_id)
return false;
query = StringFormat(
@ -2471,18 +2472,10 @@ bool BotDatabase::LoadGroupedBotsByGroupID(const uint32 group_id, std::list<uint
" AND `charid` IN ("
" SELECT `bot_id`"
" FROM `bot_data`"
" WHERE `owner_id` IN ("
" SELECT `charid`"
" FROM `group_id`"
" WHERE `groupid` = '%u'"
" AND `name` IN ("
" SELECT `name`"
" FROM `character_data`"
" )"
" )"
" )",
" WHERE `owner_id` = '%u'"
" )",
group_id,
group_id
owner_id
);
auto results = QueryDatabase(query);

View File

@ -169,7 +169,7 @@ public:
/* Bot group functions */
bool LoadGroupedBotsByGroupID(const uint32 group_id, std::list<uint32>& group_list);
bool LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list);
/* Bot heal rotation functions */