• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] [Wotlk] Guild vs Guild battlegrounds

Status
Not open for further replies.

S0SUM3

Enthusiast
I stumbled across an ancient script and am interested in updating it. I got so far and gave up after my vs spat out a silly amount of errors.. I am not sure if requests are possible here, but would anyone be interested in helping with this?

Script found here: http://pastebin.com/ug1SFvcH
 

S0SUM3

Enthusiast
If anyone is interested in assisting with this please add my skype: Bigwill600

Just some errors in BattlegroundQueue.cpp left
 

S0SUM3

Enthusiast
23 IntelliSense: return value type does not match the function type c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 514 16 game

This error corresponds to:

bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 side)

This returns false..




16 IntelliSense: member function "BattlegroundQueue::IsPlayerInvited" may not be redeclared outside its class c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 435 25 game

This error corresponds to:

bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
{
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid);
return (qItr != m_QueuedPlayers.end()
&& qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == bgInstanceGuid
&& qItr->second.GroupInfo->RemoveInviteTime == removeTime);
}

This is TC code, not custom. Obviously this doesnt error with clean TC..




27 IntelliSense: identifier "m_SelectionPools" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 581 41 game
and
28 IntelliSense: identifier "hordeFree" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 582 23 game
and
26 IntelliSense: identifier "aliFree" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 581 23 game

These errors correspond to:


int32 diffAli = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
int32 diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
 

Tommy

Founder
23 IntelliSense: return value type does not match the function type c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 514 16 game

This error corresponds to:

bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, uint32 side)

This returns false..




16 IntelliSense: member function "BattlegroundQueue::IsPlayerInvited" may not be redeclared outside its class c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 435 25 game

This error corresponds to:

bool BattlegroundQueue::IsPlayerInvited(uint64 pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime)
{
QueuedPlayersMap::const_iterator qItr = m_QueuedPlayers.find(pl_guid);
return (qItr != m_QueuedPlayers.end()
&& qItr->second.GroupInfo->IsInvitedToBGInstanceGUID == bgInstanceGuid
&& qItr->second.GroupInfo->RemoveInviteTime == removeTime);
}

This is TC code, not custom. Obviously this doesnt error with clean TC..




27 IntelliSense: identifier "m_SelectionPools" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 581 41 game
and
28 IntelliSense: identifier "hordeFree" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 582 23 game
and
26 IntelliSense: identifier "aliFree" is undefined c:\Users\Will\Desktop\TrinityCore\src\server\game\Battlegrounds\BattlegroundQueue.cpp 581 23 game

These errors correspond to:


int32 diffAli = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
int32 diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());

I put this system in a 4.3.4 emulator and it worked fine, so I'm going to copy some stuff over for you. Everything is pretty straight forward. I have an if statement 'If (GuildvsGuild)' on each portion that the system edited.

In LIME is GuildvsGuild:

(BattlegroundQueue.h):

Add this under '#define BG_QUEUE_GROUP_TYPES_COUNT':
Code:
enum BattlegroundQueueGuildTypes
{
	BG_QUEUE_GUILD              = 0,
	BG_QUEUE_NOT_GUILD          = 1
};
#define BG_QUEUE_GROUP_TYPES_GUILD 2

Change "void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id);" to:

Code:
void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id, bool GuildvsGuild);

Change "bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);" to:

Code:
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, bool GuildvsGuild = false);

Change "bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);" to:

Code:
bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers, bool GuildvsGuild = false);

Change "GroupQueueInfo* AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0);" to:

Code:
GroupQueueInfo* AddGroup(Player* leader, Group* group, BattlegroundTypeId bgTypeId, PvPDifficultyEntry const*  bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 ArenaTeamId = 0, uint32 guildId = 0);

Change "GroupsQueueType m_QueuedGroups[MAX_BATTLEGROUND_BRACKETS][BG_QUEUE_GROUP_TYPES_COUNT];" to:

Code:
GroupsQueueType m_QueuedGroups[MAX_BATTLEGROUND_BRACKETS][BG_QUEUE_GROUP_TYPES_COUNT][BG_QUEUE_GROUP_TYPES_GUILD];

This is the part some of your errors are from: (BattlegroundQueue.cpp)

"void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id, bool GuildvsGuild)"

Code:
void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id, bool GuildvsGuild)
{
    int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
    int32 aliFree   = bg->GetFreeSlotsForTeam(ALLIANCE);

[COLOR="#00FF00"]	uint32 aliCount = 0;
	uint32 aliIndex = 0;
	uint32 hordeCount = 0;
	uint32 hordeIndex = 0;[/COLOR]

	if (!bg->isArena())
		if (CanFillPlayersToBGForCrossFaction(bg, bracket_id, false))
			return;

    GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE][COLOR="#00FF00"][BG_QUEUE_GUILD][/COLOR].begin();
    GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE][COLOR="#00FF00"][BG_QUEUE_GUILD][/COLOR].begin();
    //iterator for iterating through bg queue
[COLOR="#00FF00"]    if (GuildvsGuild)
    {
        for (; Ali_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE][BG_QUEUE_GUILD].end(); ++Ali_itr)
        {
            if ((*Ali_itr)->guildId == bg->getGuildIdFirst())
            {
                if (!m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree))
                    break;
            }
        }

        for (; Horde_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE][BG_QUEUE_GUILD].end(); ++Horde_itr)
        {
            if ((*Horde_itr)->guildId == bg->getGuildIdSecond())
            {
                if (!m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree))
                    break;
            }
        }
    }[/COLOR]
	else
	{
        Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].begin();
        Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].begin();

		aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].size();
		for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
			++Ali_itr;

		hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].size();
		for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
			++Horde_itr;
	}

    //if ofc like BG queue invitation is set in config, then we are happy
    if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == 0)
        return;

    /*
    if we reached this code, then we have to solve NP - complete problem called Subset sum problem
    So one solution is to check all possible invitation subgroups, or we can use these conditions:
    1. Last time when BattlegroundQueue::Update was executed we invited all possible players - so there is only small possibility
        that we will invite now whole queue, because only 1 change has been made to queues from the last BattlegroundQueue::Update call
    2. Other thing we should consider is group order in queue
    */

    // At first we need to compare free space in bg and our selection pool
    int32 diffAli   = aliFree   - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
    int32 diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
    while (abs(diffAli - diffHorde) > 1 && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
    {
        //each cycle execution we need to kick at least 1 group
        if (diffAli < diffHorde)
        {
            //kick alliance group, add to pool new group if needed
            if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(diffHorde - diffAli))
            {
[COLOR="#00FF00"]                if (GuildvsGuild)
                {
                    for (; Ali_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE][BG_QUEUE_GUILD].end(); ++Ali_itr)
                    {
                        if ((*Ali_itr)->guildId == bg->getGuildIdFirst())
                            if (!m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0))
                                break;
                    }
                }[/COLOR]
				else
				{
                    if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(diffHorde - diffAli))
                    {
                        for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0); aliIndex++)
                            ++Ali_itr;
                    }
				}
            }
            //if ali selection is already empty, then kick horde group, but if there are less horde than ali in bg - break;
            if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
            {
                if (aliFree <= diffHorde + 1)
                    break;
                m_SelectionPools[TEAM_HORDE].KickGroup(diffHorde - diffAli);
            }
        }
        else
        {
            //kick horde group, add to pool new group if needed
            if (m_SelectionPools[TEAM_HORDE].KickGroup(diffAli - diffHorde))
            {
[COLOR="#00FF00"]                if (GuildvsGuild)
                {
                    for (; Horde_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE][BG_QUEUE_GUILD].end(); ++Horde_itr)
                    {
                        if ((*Horde_itr)->guildId == bg->getGuildIdSecond())
                            if (!m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0))
                                break;
                   }
                }[/COLOR]
				else
				{
                    if (m_SelectionPools[TEAM_HORDE].KickGroup(diffAli - diffHorde))
                    {
                        for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0); hordeIndex++)
                            ++Horde_itr;
                    }
				}
            }
            if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
            {
                if (hordeFree <= diffAli + 1)
                    break;
                 m_SelectionPools[TEAM_ALLIANCE].KickGroup(diffAli - diffHorde);
            }
        }
        //count diffs after small update
        diffAli   = aliFree   - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
        diffHorde = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
    }
}

Manually go through "bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam)" with the GuildvsGuild edits:

Code:
bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, bool GuildvsGuild)
{
[COLOR="#00FF00"]    //check match
    GroupsQueueType::const_iterator ali_group, horde_group;
    bool empty = true;
    bool end = true;
    uint32 guildId[BG_QUEUE_GROUP_TYPES_GUILD];
    guildId[TEAM_ALLIANCE] = 0;
    guildId[TEAM_HORDE] = 0;[/COLOR]

[COLOR="#00FF00"]    if (GuildvsGuild)
    {
        if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_GUILD].empty() && !m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_GUILD].empty())
        {
            empty = false;
            //start premade match
            //if groups aren't invited
            for (ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_GUILD].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_GUILD].end(); ++ali_group)
                if (!(*ali_group)->IsInvitedToBGInstanceGUID)
                {
                    guildId[0] = (*ali_group)->guildId;
                    break;
                }

            for (horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_GUILD].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_GUILD].end(); ++horde_group)
                if (!(*horde_group)->IsInvitedToBGInstanceGUID)
                {
                    guildId[1] = (*horde_group)->guildId;
                    break;
                }
        }
    }[/COLOR]
    else
    {
        if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_NOT_GUILD].empty() && !m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_NOT_GUILD].empty())
        {
            empty = false;
            //start premade match
            //if groups aren't invited
            for (ali_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_NOT_GUILD].begin(); ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_NOT_GUILD].end(); ++ali_group)
                if (!(*ali_group)->IsInvitedToBGInstanceGUID)
                    break;

            for (horde_group = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_NOT_GUILD].begin(); horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_NOT_GUILD].end(); ++horde_group)
                if (!(*horde_group)->IsInvitedToBGInstanceGUID)
                    break;
        }
    }

    if (!empty)
    {
[COLOR="#00FF00"]        if (GuildvsGuild)
        {
            if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][BG_QUEUE_GUILD].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][BG_QUEUE_GUILD].end())
                end = false;
            else
                if (ali_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].end() && horde_group != m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].end())
                    end = false;
        }[/COLOR]

        if (!end)
        {
            m_SelectionPools[TEAM_ALLIANCE].AddGroup((*ali_group), MaxPlayersPerTeam);
            m_SelectionPools[TEAM_HORDE].AddGroup((*horde_group), MaxPlayersPerTeam);
            uint32 maxPlayers = std::min(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount(), m_SelectionPools[TEAM_HORDE].GetPlayerCount());
            GroupsQueueType::const_iterator itr;
[COLOR="#00FF00"]            if (GuildvsGuild)
            {
                for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
                {
                    for (itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][BG_QUEUE_GUILD].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][BG_QUEUE_GUILD].end(); ++itr)
                    {
                        if ((*itr)->guildId == guildId[i])
                            if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers))
                                break;
                    }
                }
            }[/COLOR]
            else
            {
                for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
                {
                    for (itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].end(); ++itr)
                        if (!(*itr)->IsInvitedToBGInstanceGUID && !m_SelectionPools[i].AddGroup((*itr), maxPlayers))
                            break;
                }
            }
       }

        // now check if we can move group from Premade queue to normal queue (timer has expired) or group size lowered!!
        // this could be 2 cycles but i'm checking only first team in queue - it can cause problem -
        // if first is invited to BG and seconds timer expired, but we can ignore it, because players have only 80 seconds to click to enter bg
        // and when they click or after 80 seconds the queue info is removed from queue
        uint32 time_before = getMSTime() - sWorld->getIntConfig(CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH);
[COLOR="#00FF00"]        for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
        {
            for (uint32 j = 0; j < BG_QUEUE_GROUP_TYPES_GUILD; j++)
            {
                if (!m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i][j].empty())
                {
                    GroupsQueueType::iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i][j].begin();
                    if (!(*itr)->IsInvitedToBGInstanceGUID && ((*itr)->JoinTime < time_before || (*itr)->Players.size() < MinPlayersPerTeam))
                    {
                        //we must insert group to normal queue and erase pointer from premade queue
                        m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][j].push_front((*itr));
                       m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE + i][j].erase(itr);
                    }
                }
            }
        }
    }[/COLOR]
    //selection pools are not set
    return false;
}

"bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers)":

GuildvsGuild edit:
Code:
bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers, [COLOR="#00FF00"]bool GuildvsGuild[/COLOR])
{
    GroupsQueueType::const_iterator itr_team[BG_TEAMS_COUNT];
    [COLOR="#00FF00"]uint32 guildId[BG_QUEUE_GROUP_TYPES_GUILD];[/COLOR]

[COLOR="#00FF00"]	if (GuildvsGuild)
	{
        for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
        {
            guildId[i] = 0;
            itr_team[i] = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][BG_QUEUE_GUILD].begin();
            for (; itr_team[i] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][BG_QUEUE_GUILD].end(); ++(itr_team[i]))
            {
                if (!(*(itr_team[i]))->IsInvitedToBGInstanceGUID)
                {
					if (guildId[i] > 0 && guildId[i] != (*(itr_team[i]))->guildId)
						continue;
					guildId[i] = (*(itr_team[i]))->guildId;
                    m_SelectionPools[i].AddGroup(*(itr_team[i]), maxPlayers);
                    if (m_SelectionPools[i].GetPlayerCount() >= minPlayers)
                        break;
                }
            }
        }
    }[/COLOR]
	else
	{
        for (uint32 i = 0; i < BG_TEAMS_COUNT; i++)
        {
            itr_team[i] = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].begin();
            for (; itr_team[i] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + i][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].end(); ++(itr_team[i]))
            {
                if (!(*(itr_team[i]))->IsInvitedToBGInstanceGUID)
                {
                    m_SelectionPools[i].AddGroup(*(itr_team[i]), maxPlayers);
                    if (m_SelectionPools[i].GetPlayerCount() >= minPlayers)
                        break;
                }
            }
        }
	}
    //try to invite same number of players - this cycle may cause longer wait time even if there are enough players in queue, but we want ballanced bg
    uint32 j = TEAM_ALLIANCE;
    if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
        j = TEAM_HORDE;
    if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != 0
        && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers)
    {
[COLOR="#00FF00"]        if (GuildvsGuild)
		{
            //we will try to invite more groups to team with less players indexed by j
            ++(itr_team[j]);                                         //this will not cause a crash, because for cycle above reached break;
            for (; itr_team[j] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + j][BG_QUEUE_GUILD].end(); ++(itr_team[j]))
            {
                if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID)
					if (guildId[j] == (*(itr_team[j]))->guildId)
                        if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % BG_TEAMS_COUNT].GetPlayerCount()))
                            break;
            }
		}[/COLOR]
		else
		{
            //we will try to invite more groups to team with less players indexed by j
            ++(itr_team[j]);                                         //this will not cause a crash, because for cycle above reached break;
            for (; itr_team[j] != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE + j][COLOR="#00FF00"][BG_QUEUE_NOT_GUILD][/COLOR].end(); ++(itr_team[j]))
            {
                if (!(*(itr_team[j]))->IsInvitedToBGInstanceGUID)
                    if (!m_SelectionPools[j].AddGroup(*(itr_team[j]), m_SelectionPools[(j + 1) % BG_TEAMS_COUNT].GetPlayerCount()))
                        break;
            }
		}
        // do not allow to start bg with more than 2 players more on 1 faction
        if (abs((int32)(m_SelectionPools[TEAM_HORDE].GetPlayerCount() - m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())) > 2)
            return false;
    }
    //allow 1v0 if debug bg
[COLOR="#00FF00"]	if (sBattlegroundMgr->isTesting() && bg_template->isBattleground() && [COLOR="#00FF00"]GuildvsGuild[/COLOR])
	{
		uint32 i;
		if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
			i = TEAM_ALLIANCE;
		else if (m_SelectionPools[TEAM_HORDE].GetPlayerCount())
			i = TEAM_HORDE;[/COLOR]
		
		GroupsQueueType::const_iterator itr = m_SelectionPools[i].SelectedGroups.begin();
[COLOR="#00FF00"]		if (GuildvsGuild && (*itr)->guildId > 0)
			return true;
		else if (!GuildvsGuild && (*itr)->guildId == 0)[/COLOR]
            return true;
	}

[COLOR="#00FF00"]	if (sBattlegroundMgr->isTesting() && !GuildvsGuild && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
		return true;[/COLOR]
    //return true if there are enough players in selection pools - enable to work .debug bg command correctly
	if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && GuildvsGuild)
	{
		GroupsQueueType::const_iterator alliance = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups.begin();
		GroupsQueueType::const_iterator horde = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups.begin();
[COLOR="#00FF00"]		if (GuildvsGuild && (*alliance)->guildId > 0 && (*horde)->guildId > 0)
			return true;[/COLOR]
		return false;
	}
	return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers;
}

Where are you using "BattlegroundQueue::IsPlayerInvited" exactly? It is being used in BattlegroundQueue and it isn't throwing an error like that.

If you need more information, tell me. I don't want to write all of this and you might already have it done. However, if you think you can handle it without my help like this, here is the BattlegroundQueue sources:

Guild vs Guild : BattlegroundQueue.cpp
Guild vs Guild : BattlegroundQueue.h
 
Last edited:

S0SUM3

Enthusiast
Thank you so much for such a detailed response, i really appreciate it..

Unfortunately though, I'm on the verge of giving up on this after spending considerably more time than i anticipated it would need. Frankly, I've made a mess of it and would want to start over but can't find it in me to do so. For those who were hoping this would fabricate, i apologise for my lack of persistence. I have a lot on my plate at the moment.
 
Status
Not open for further replies.
Top