mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
fix
check if GuildName is already taken by other guild fixed NPE `if (!player) ... player->GetName()`
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user