Hlkz
1
Hi, I want to redirect player to a custom queue when he tag on a specific battleground id. (alterac for exemple) I will use this queue in outdoor.
So I duplicated BattlegroundQueue.h/cpp, I am stuck here :
In my customqueue.h : (copy from BattlegroundQueue.h)
struct BAOGroupQueueInfo;
struct BAOPlayerQueueInfo // players in queue
{
uint32 LastOnlineTime;
BAOGroupQueueInfo* GroupInfo;
};
struct BAOGroupQueueInfo // groups (even player alone) in queue
{
std::map<uint64, BAOPlayerQueueInfo*> Players;
uint32 Team;
uint32 JoinTime;
uint32 RemoveInviteTime;
bool IsInvitedToBAO;
};
And my function in the .cpp file : (copy from BattlegroundQueue.cpp)
BAOGroupQueueInfo* BattleAOQueue::AddGroup(Player* leader, Group* grp, bool isPremade)
{
BAOGroupQueueInfo* ginfo = new BAOGroupQueueInfo;
ginfo->IsInvitedToBAO = 0;
ginfo->JoinTime = getMSTime();
ginfo->RemoveInviteTime = 0;
ginfo->Team = leader->GetTeam();
ginfo->Players.clear();
sLog->outError(LOG_FILTER_BAO, “player guid in AddGroup : %u”, leader->GetGUID());
BAOPlayerQueueInfo& pl_info = m_QueuedPlayers[leader->GetGUID()]; //////// <= crash here
…
The guid is good, I can’t find what I did wrong.
Thanks in advance !
Jasa
2
Well, let’s say leader’s GUID is 10000, then you would be retrieving pl_info like this:
BAOPlayerQueueInfo& pl_info = m_QueuedPlayers[10000];
which would result in crash (sigsegv, accessing to memory to which you don’t have any access)
Hlkz
3
I didn’t get that… That function has no access ?
Why there is no access ? How do I solve this ?
In BattlegroundQueue I didn’t seen any thing more.
Hlkz
4
bump, still stuck.
tell me if I have to send more code
Paint me dumb or unknowing, but I am pretty sure that calling for the leader GUID for the m_Queuedplayers is wrong.
Hlkz
6
I believe you, but I don’t know how I can replace that. What would you do ?
It’s the same here : https://github.com/TrinityCore/TrinityCore/blob/master/src/server/game/Battlegrounds/BattlegroundQueue.cpp and it works.
[SPOILER]
[CODE]
GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, BattlegroundTypeId BgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 ArenaType, bool isRated, bool isPremade, uint32 ArenaRating, uint32 MatchmakerRating, uint32 arenateamid)
{
BattlegroundBracketId bracketId = bracketEntry->GetBracketId();
// create new ginfo
GroupQueueInfo* ginfo = new GroupQueueInfo;
ginfo->BgTypeId = BgTypeId;
ginfo->ArenaType = ArenaType;
ginfo->ArenaTeamId = arenateamid;
ginfo->IsRated = isRated;
ginfo->IsInvitedToBGInstanceGUID = 0;
ginfo->JoinTime = getMSTime();
ginfo->RemoveInviteTime = 0;
ginfo->Team = leader->GetTeam();
ginfo->ArenaTeamRating = ArenaRating;
ginfo->ArenaMatchmakerRating = MatchmakerRating;
ginfo->OpponentsTeamRating = 0;
ginfo->OpponentsMatchmakerRating = 0;
ginfo->Players.clear();
//compute index (if group is premade or joined a rated match) to queues
uint32 index = 0;
if (!isRated && !isPremade)
index += BG_TEAMS_COUNT;
if (ginfo->Team == HORDE)
index++;
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
uint32 lastOnlineTime = getMSTime();
//announce world (this don't need mutex)
if (isRated && sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_ENABLE))
{
ArenaTeam* Team = sArenaTeamMgr->GetArenaTeamById(arenateamid);
if (Team)
sWorld->SendWorldText(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, Team->GetName().c_str(), ginfo->ArenaType, ginfo->ArenaType, ginfo->ArenaTeamRating);
}
//add players from group to ginfo
if (grp)
{
for (GroupReference* itr = grp->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* member = itr->getSource();
if (!member)
continue; // this should never happen
PlayerQueueInfo& pl_info = m_QueuedPlayers[member->GetGUID()];
pl_info.LastOnlineTime = lastOnlineTime;
pl_info.GroupInfo = ginfo;
// add the pinfo to ginfo's list
ginfo->Players[member->GetGUID()] = &pl_info;[/CODE]
[/SPOILER](with console logs I checked that player guid, it was the good one, so I don’t know…)