scripts/Commands: Sync with 4.3.4 branch (meh nayd)

This commit is contained in:
Vincent-Michael
2014-08-29 21:40:07 +02:00
parent 730136ab4f
commit 1dc8a219a3

View File

@@ -249,41 +249,29 @@ public:
{
Guild* guild = nullptr;
if (!*args)
if (args && strlen(args) > 0)
{
// Look for the guild of the selected player or ourselves
if (Player* target = handler->getSelectedPlayerOrSelf())
guild = target->GetGuild();
if (isNumeric(args))
{
uint32 guildId = uint32(atoi(args));
guild = sGuildMgr->GetGuildById(guildId);
}
else
// getSelectedPlayerOrSelf will return null if there is no session
// so target becomes nullptr if the command is ran through console
// without specifying args.
return false;
}
else if (uint32 guildId = atoi(args)) // Try searching by Id
guild = sGuildMgr->GetGuildById(guildId);
else
{
// Try to extract a guild name
char* tailStr = *args != '"' ? strtok(NULL, "") : (char*)args;
if (!tailStr)
return false;
char* guildStr = handler->extractQuotedArg((char*)args);
if (!guildStr)
return false;
std::string guildName = guildStr;
guild = sGuildMgr->GetGuildByName(guildName);
{
std::string guildName = args;
guild = sGuildMgr->GetGuildByName(guildName);
}
}
else if (Player* target = handler->getSelectedPlayerOrSelf())
guild = target->GetGuild();
if (!guild)
return false;
std::string guildMasterName;
// Display Guild Information
handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name
std::string guildMasterName;
if (sObjectMgr->GetPlayerNameByGUID(guild->GetLeaderGUID(), guildMasterName))
handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID()); // Guild Master