@@ -0,0 +1,10 @@
|
||||
DELETE FROM `command` WHERE `name` = 'guild rename';
|
||||
INSERT INTO `command` (`name`, `security`, `help`) VALUES
|
||||
('guild rename', 3, 'Syntax: .guild rename "$GuildName" "$NewGuildName" \n\n Rename a guild named $GuildName with $NewGuildName. Guild name and new guild name must in quotes.');
|
||||
|
||||
SET @ENTRY1 := 96;
|
||||
SET @ENTRY2 := 97;
|
||||
DELETE FROM `trinity_string` WHERE `entry` IN (@ENTRY1, @ENTRY2);
|
||||
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES
|
||||
(@ENTRY1, 'The guild name \'%s\' is already taken'),
|
||||
(@ENTRY2, 'Changed guild name \'%s\' to \'%s\'');
|
||||
@@ -1285,6 +1285,19 @@ void Guild::OnPlayerStatusChange(Player* player, uint32 flag, bool state)
|
||||
}
|
||||
}
|
||||
|
||||
bool Guild::SetName(std::string const& name)
|
||||
{
|
||||
if (m_name == name || name.empty() || name.length() > 24 || sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
|
||||
return false;
|
||||
|
||||
m_name = name;
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_NAME);
|
||||
stmt->setString(0, m_name);
|
||||
stmt->setUInt32(1, GetId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Guild::HandleRoster(WorldSession* session /*= NULL*/)
|
||||
{
|
||||
// Guess size
|
||||
|
||||
@@ -657,6 +657,8 @@ public:
|
||||
std::string const& GetMOTD() const { return m_motd; }
|
||||
std::string const& GetInfo() const { return m_info; }
|
||||
|
||||
bool SetName(std::string const& name);
|
||||
|
||||
// Handle client commands
|
||||
void HandleRoster(WorldSession* session = NULL); // NULL = broadcast
|
||||
void HandleQuery(WorldSession* session);
|
||||
|
||||
@@ -119,7 +119,9 @@ enum TrinityStrings
|
||||
LANG_RBAC_LIST_GROUPS_HEADER = 93,
|
||||
LANG_RBAC_LIST_ROLES_HEADER = 94,
|
||||
LANG_RBAC_LIST_PERMISSIONS_HEADER = 95,
|
||||
// Room for more level 0 96-99 not used
|
||||
LANG_GUILD_RENAME_ALREADY_EXISTS = 96,
|
||||
LANG_GUILD_RENAME_DONE = 97,
|
||||
// Room for more level 0 98-99 not used
|
||||
|
||||
// level 1 chat
|
||||
LANG_GLOBAL_NOTIFY = 100,
|
||||
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
{ "invite", SEC_GAMEMASTER, true, &HandleGuildInviteCommand, "", NULL },
|
||||
{ "uninvite", SEC_GAMEMASTER, true, &HandleGuildUninviteCommand, "", NULL },
|
||||
{ "rank", SEC_GAMEMASTER, true, &HandleGuildRankCommand, "", NULL },
|
||||
{ "rename", SEC_GAMEMASTER, true, &HandleGuildRenameCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
static ChatCommand commandTable[] =
|
||||
@@ -192,6 +193,55 @@ public:
|
||||
uint8 newRank = uint8(atoi(rankStr));
|
||||
return targetGuild->ChangeMemberRank(targetGuid, newRank);
|
||||
}
|
||||
|
||||
static bool HandleGuildRenameCommand(ChatHandler* handler, char const* _args)
|
||||
{
|
||||
if (!*_args)
|
||||
return false;
|
||||
|
||||
char *args = (char *)_args;
|
||||
|
||||
char const* oldGuildStr = handler->extractQuotedArg(args);
|
||||
if (!oldGuildStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
char const* newGuildStr = handler->extractQuotedArg(strtok(NULL, ""));
|
||||
if (!newGuildStr)
|
||||
{
|
||||
handler->SendSysMessage(LANG_INSERT_GUILD_NAME);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
Guild* guild = sGuildMgr->GetGuildByName(oldGuildStr);
|
||||
if (!guild)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, oldGuildStr);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sGuildMgr->GetGuildByName(newGuildStr))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_GUILD_RENAME_ALREADY_EXISTS, newGuildStr);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!guild->SetName(newGuildStr))
|
||||
{
|
||||
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
handler->PSendSysMessage(LANG_GUILD_RENAME_DONE, oldGuildStr, newGuildStr);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_guild_commandscript()
|
||||
|
||||
@@ -171,6 +171,8 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
// 0: uint32, 1: string, 2: uint32, 3: string, 4: string, 5: uint64, 6-10: uint32, 11: uint64
|
||||
PrepareStatement(CHAR_INS_GUILD, "INSERT INTO guild (guildid, name, leaderguid, info, motd, createdate, EmblemStyle, EmblemColor, BorderStyle, BorderColor, BackgroundColor, BankMoney) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_GUILD, "DELETE FROM guild WHERE guildid = ?", CONNECTION_ASYNC); // 0: uint32
|
||||
// 0: string, 1: uint32
|
||||
PrepareStatement(CHAR_UPD_GUILD_NAME, "UPDATE guild SET name = ? WHERE guildid = ?", CONNECTION_ASYNC);
|
||||
// 0: uint32, 1: uint32, 2: uint8, 4: string, 5: string
|
||||
PrepareStatement(CHAR_INS_GUILD_MEMBER, "INSERT INTO guild_member (guildid, guid, rank, pnote, offnote) VALUES (?, ?, ?, ?, ?)", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_DEL_GUILD_MEMBER, "DELETE FROM guild_member WHERE guid = ?", CONNECTION_ASYNC); // 0: uint32
|
||||
|
||||
@@ -166,6 +166,7 @@ enum CharacterDatabaseStatements
|
||||
|
||||
CHAR_INS_GUILD,
|
||||
CHAR_DEL_GUILD,
|
||||
CHAR_UPD_GUILD_NAME,
|
||||
CHAR_INS_GUILD_MEMBER,
|
||||
CHAR_DEL_GUILD_MEMBER,
|
||||
CHAR_DEL_GUILD_MEMBERS,
|
||||
|
||||
Reference in New Issue
Block a user