On my tournament 1v1 script custom when I start the matches , I have this error on my console :
Battleground::%s: player (GUID: %u) not found for BG (map: %u, instance id: %u)!
Here is the part of my script tournament 1v1 where there is the bug :
void EventTournament::OnUpdate(uint32 diff)
{
if (_winnerGuid)
{
if (Player* winner = ObjectAccessor::FindPlayer(_winnerGuid))
{
sLog->outString(“[EventTournament] Winner %s recoit titre %u (%u sec)”, winner->GetName().c_str(), GetData()->GetRewardTitle(), GetData()->GetRewardTitleTime());
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(GetData()->GetRewardTitle());
if (titleEntry)
{
winner->AddTemporaryTitle(titleEntry, GetData()->GetRewardTitleTime());
winner->SetUInt32Value(PLAYER_CHOSEN_TITLE, titleEntry->bit_index);
}
else if (GetData()->GetRewardTitle())
sLog->outError(LOG_FILTER_EVENTAUTO, “Titre %u introuvable.”, GetData()->GetRewardTitle());
_winnerGuid = 0;
}
}
if (!_started)
return;
ASSERT(_tournamentMgr);
// A-t-on un gagnant ?
if (_tournamentMgr->GetTree()->HasWinner())
{
sLog->outString(“[EventTournament] Gagnant : %s”, _tournamentMgr->GetTree()->GetPlayer()->GetName().c_str());
std::stringstream oss;
oss << “Fin du tournoi. Le grand gagnant est “” << _tournamentMgr->GetTree()->GetPlayer()->GetName().c_str() << “””;
_winnerGuid = _tournamentMgr->GetTree()->GetPlayer()->GetGUID();
Announce(oss);
StopEvent();
return;
}
// Lancer les nouveaux matchs
TournamentPlayer *pl1, *pl2;
if (_tournamentMgr->GetTree()->FindMatch(pl1, pl2))
{
ASSERT(pl1 && pl2);
Player *player1 = ObjectAccessor::FindPlayer(pl1->GetGUID()), *player2 = ObjectAccessor::FindPlayer(pl2->GetGUID());
// On peut attendre un peu, mais pas trop (fin de teleportation par exemple)
if (CheckReady(player1, pl1->NotFoundTimes) && CheckReady(player2, pl2->NotFoundTimes))
{
// Ca y est ! Les joueurs sont la !
sLog->outString("[EventTournament] MATCH %s VS %s.", pl1->GetName().c_str(), pl2->GetName().c_str());
Match m;
m.bg = CreateBattleground();
if (!m.bg)
{
sLog->outString("[EventTournament] Impossible de creer un BG.");
return;
}
m.bg->StartBattleground();
if (!PlayerJoinBG(m.bg, player1, ALLIANCE) || !PlayerJoinBG(m.bg, player2, HORDE))
{
sLog->outString("[EventTournament] Impossible rejoindre un BG.");
return;
}
m.pl1 = pl1;
m.pl2 = pl2;
pl1->SetInCombat(pl2);
pl2->SetInCombat(pl1);
sLog->outError(LOG_FILTER_EVENTAUTO, "mARCHE 2.");
_matchs.push_back(m);
std::stringstream oss;
oss << "Le match opposant " << player1->GetName() << " et " << player2->GetName() << " commence.";
Announce(oss);
}
else
{
if (pl1->NotFoundTimes > MAX_NOT_FOUND_TIMES)
{
_tournamentMgr->GetTree()->MatchFinished(pl2, pl1);
if (player1)
ChatHandler(player1->GetSession()).SendSysMessage("Vous perdez le match, car nous n'avons pu vous teleporter.");
}
else if (pl2->NotFoundTimes > MAX_NOT_FOUND_TIMES)
{
_tournamentMgr->GetTree()->MatchFinished(pl1, pl2);
if (player2)
ChatHandler(player2->GetSession()).SendSysMessage("Vous perdez le match, car nous n'avons pu vous teleporter.");
}
sLog->outString("[EventTournament] Un des joueurs est introuvable.");
}
}
}
and here is the part of Battleground.cpp which is used
inline Player* Battleground::_GetPlayer(uint64 guid, bool offlineRemove, char const* context) const
{
Player* player = NULL;
if (!offlineRemove)
{
player = ObjectAccessor::FindPlayer(guid);
if (!player)
sLog->outError(LOG_FILTER_BATTLEGROUND, “Battleground::%s: player (GUID: %u) not found for BG (map: %u, instance id: %u)!”,
context, GUID_LOPART(guid), m_MapId, m_InstanceID);
}
return player;
}