check if GuildName is already taken by other guild
fixed NPE `if (!player) ...  player->GetName()`
This commit is contained in:
Bogir[rus]
2022-04-08 17:47:01 +05:00
committed by GitHub
parent 0b83523a2c
commit ac36231adc

View File

@@ -497,6 +497,12 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
if (guildName.empty())
continue;
if (sGuildMgr->GetGuildByName(guildName))
{
LOG_WARN("playerbots", "GuildName %s is busy. Skipped...", guildName.c_str());
continue;
}
if (availableLeaders.empty())
{
LOG_ERROR("playerbots", "No leaders for random guilds available");
@@ -508,14 +514,16 @@ void RandomPlayerbotFactory::CreateRandomGuilds()
Player* player = ObjectAccessor::FindPlayer(leader);
if (!player)
{
LOG_ERROR("playerbots", "Cannot find player for leader {}", player->GetName().c_str());
LOG_ERROR("playerbots", "ObjectAccessor Cannot find player to set leader for guild {} . Skipped...", guildName.c_str());
continue;
}
Guild* guild = new Guild();
if (!guild->Create(player, guildName))
{
LOG_ERROR("playerbots", "Error creating guild {}", guildName.c_str());
// it very strange, but sometimes Guild can't be created by unknown reason
// We already checked that player is exists and guildName are correct
LOG_ERROR("playerbots", "Error creating guild [ {} ] with leader [ {} ]", guildName.c_str(), player->GetName().c_str());
delete guild;
continue;
}