summaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorAndrew <47818697+Nyeriah@users.noreply.github.com>2023-11-26 12:59:58 -0300
committerGitHub <noreply@github.com>2023-11-26 16:59:58 +0100
commit76a2bbfef057303894b6f0100b2df182c764d109 (patch)
tree8e84b34894b950ce924a5697cbc2c6dd2d229af2 /src/server/scripts/Commands
parente68bd9060abf26ce39e6ea000157ffca28648388 (diff)
fix(Scripts/Commands): Use the argument parser to parse guild names (#17863)
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_guild.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp
index d6966092b9..91d0f73fa1 100644
--- a/src/server/scripts/Commands/cs_guild.cpp
+++ b/src/server/scripts/Commands/cs_guild.cpp
@@ -53,7 +53,7 @@ public:
return commandTable;
}
- static bool HandleGuildCreateCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, std::string_view guildName)
+ static bool HandleGuildCreateCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, QuotedString guildName)
{
if (!target)
{
@@ -67,8 +67,6 @@ public:
return false;
}
- guildName = guild_commandscript::_RemoveQuotes(guildName);
-
if (guildName.empty())
{
return false;
@@ -111,10 +109,8 @@ public:
return true;
}
- static bool HandleGuildDeleteCommand(ChatHandler*, std::string_view guildName)
+ static bool HandleGuildDeleteCommand(ChatHandler*, QuotedString guildName)
{
- guildName = guild_commandscript::_RemoveQuotes(guildName);
-
if (guildName.empty())
{
return false;
@@ -130,7 +126,7 @@ public:
return true;
}
- static bool HandleGuildInviteCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, std::string_view guildName)
+ static bool HandleGuildInviteCommand(ChatHandler* handler, Optional<PlayerIdentifier> target, QuotedString guildName)
{
if (!target)
{
@@ -142,8 +138,6 @@ public:
return false;
}
- guildName = guild_commandscript::_RemoveQuotes(guildName);
-
if (guildName.empty())
{
return false;
@@ -202,11 +196,8 @@ public:
return targetGuild->ChangeMemberRank(player->GetGUID(), rank);
}
- static bool HandleGuildRenameCommand(ChatHandler* handler, std::string_view oldGuildStr, std::string_view newGuildStr)
+ static bool HandleGuildRenameCommand(ChatHandler* handler, QuotedString oldGuildStr, QuotedString newGuildStr)
{
- oldGuildStr = guild_commandscript::_RemoveQuotes(oldGuildStr);
- newGuildStr = guild_commandscript::_RemoveQuotes(newGuildStr);
-
if (oldGuildStr.empty() || newGuildStr.empty())
{
return false;
@@ -238,7 +229,7 @@ public:
return true;
}
- static bool HandleGuildInfoCommand(ChatHandler* handler, Optional<Variant<ObjectGuid::LowType, std::string_view>> const& guildIdentifier)
+ static bool HandleGuildInfoCommand(ChatHandler* handler, Optional<Variant<ObjectGuid::LowType, QuotedString>> const& guildIdentifier)
{
Guild* guild = nullptr;
@@ -247,7 +238,7 @@ public:
if (ObjectGuid::LowType const* guid = std::get_if<ObjectGuid::LowType>(&*guildIdentifier))
guild = sGuildMgr->GetGuildById(*guid);
else
- guild = sGuildMgr->GetGuildByName(guildIdentifier->get<std::string_view>());
+ guild = sGuildMgr->GetGuildByName(guildIdentifier->get<QuotedString>());
}
else if (Optional<PlayerIdentifier> target = PlayerIdentifier::FromTargetOrSelf(handler); target && target->IsConnected())
guild = target->GetConnectedPlayer()->GetGuild();
@@ -275,20 +266,6 @@ public:
handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information
return true;
}
-private:
- static std::string_view _RemoveQuotes(std::string_view inputString)
- {
- if (inputString.starts_with('"') && inputString.ends_with('"'))
- {
- inputString.remove_prefix(1);
- inputString.remove_suffix(1);
- return inputString;
- }
- else
- {
- return "";
- }
- }
};
void AddSC_guild_commandscript()