mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Commands] Cleanup #guild Command (#2693)
# Commands - Adds `#guild search [Search Criteria]` sub command. # Notes - Allows operators to search for a guild instead of listing all guilds at once. - Adds a method for sending guild sub commands to make code drier.
This commit is contained in:
parent
b15e73e1b2
commit
d9f437d90f
@ -33,6 +33,7 @@ std::map<std::string, std::string> GetModifyNPCStatMap();
|
|||||||
std::string GetModifyNPCStatDescription(std::string stat);
|
std::string GetModifyNPCStatDescription(std::string stat);
|
||||||
void SendNPCEditSubCommands(Client *c);
|
void SendNPCEditSubCommands(Client *c);
|
||||||
void SendRuleSubCommands(Client *c);
|
void SendRuleSubCommands(Client *c);
|
||||||
|
void SendGuildSubCommands(Client *c);
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
void command_acceptrules(Client *c, const Seperator *sep);
|
void command_acceptrules(Client *c, const Seperator *sep);
|
||||||
|
|||||||
@ -8,24 +8,15 @@ extern WorldServer worldserver;
|
|||||||
|
|
||||||
void command_guild(Client *c, const Seperator *sep)
|
void command_guild(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
int arguments = sep->argnum;
|
const auto arguments = sep->argnum;
|
||||||
if (!arguments) {
|
if (!arguments) {
|
||||||
c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]");
|
SendGuildSubCommands(c);
|
||||||
c->Message(Chat::White, "#guild delete [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild help");
|
|
||||||
c->Message(Chat::White, "#guild info [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild list");
|
|
||||||
c->Message(Chat::White, "#guild rename [Guild ID] [New Name]");
|
|
||||||
c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)");
|
|
||||||
c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]");
|
|
||||||
c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]");
|
|
||||||
c->Message(Chat::White, "#guild status [Character ID|Character Name]");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto target = c;
|
auto t = c;
|
||||||
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||||
target = c->GetTarget()->CastToClient();
|
t = c->GetTarget()->CastToClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_create = !strcasecmp(sep->arg[1], "create");
|
bool is_create = !strcasecmp(sep->arg[1], "create");
|
||||||
@ -34,6 +25,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
bool is_info = !strcasecmp(sep->arg[1], "info");
|
bool is_info = !strcasecmp(sep->arg[1], "info");
|
||||||
bool is_list = !strcasecmp(sep->arg[1], "list");
|
bool is_list = !strcasecmp(sep->arg[1], "list");
|
||||||
bool is_rename = !strcasecmp(sep->arg[1], "rename");
|
bool is_rename = !strcasecmp(sep->arg[1], "rename");
|
||||||
|
bool is_search = !strcasecmp(sep->arg[1], "search");
|
||||||
bool is_set = !strcasecmp(sep->arg[1], "set");
|
bool is_set = !strcasecmp(sep->arg[1], "set");
|
||||||
bool is_set_leader = !strcasecmp(sep->arg[1], "setleader");
|
bool is_set_leader = !strcasecmp(sep->arg[1], "setleader");
|
||||||
bool is_set_rank = !strcasecmp(sep->arg[1], "setrank");
|
bool is_set_rank = !strcasecmp(sep->arg[1], "setrank");
|
||||||
@ -45,21 +37,13 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
!is_info &&
|
!is_info &&
|
||||||
!is_list &&
|
!is_list &&
|
||||||
!is_rename &&
|
!is_rename &&
|
||||||
|
!is_search &&
|
||||||
!is_set &&
|
!is_set &&
|
||||||
!is_set_leader &&
|
!is_set_leader &&
|
||||||
!is_set_rank &&
|
!is_set_rank &&
|
||||||
!is_status
|
!is_status
|
||||||
) {
|
) {
|
||||||
c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]");
|
SendGuildSubCommands(c);
|
||||||
c->Message(Chat::White, "#guild delete [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild help");
|
|
||||||
c->Message(Chat::White, "#guild info [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild list");
|
|
||||||
c->Message(Chat::White, "#guild rename [Guild ID] [New Name]");
|
|
||||||
c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)");
|
|
||||||
c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]");
|
|
||||||
c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]");
|
|
||||||
c->Message(Chat::White, "#guild status [Character ID|Character Name]");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,16 +172,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (is_help) {
|
} else if (is_help) {
|
||||||
c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]");
|
SendGuildSubCommands(c);
|
||||||
c->Message(Chat::White, "#guild delete [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild help");
|
|
||||||
c->Message(Chat::White, "#guild info [Guild ID]");
|
|
||||||
c->Message(Chat::White, "#guild list");
|
|
||||||
c->Message(Chat::White, "#guild rename [Guild ID] [New Name]");
|
|
||||||
c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)");
|
|
||||||
c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]");
|
|
||||||
c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]");
|
|
||||||
c->Message(Chat::White, "#guild status [Character ID|Character Name]");
|
|
||||||
} else if (is_info) {
|
} else if (is_info) {
|
||||||
if (arguments != 2 && c->IsInAGuild()) {
|
if (arguments != 2 && c->IsInAGuild()) {
|
||||||
if (c->Admin() >= minStatusToEditOtherGuilds) {
|
if (c->Admin() >= minStatusToEditOtherGuilds) {
|
||||||
@ -223,7 +198,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
guild_mgr.ListGuilds(c);
|
guild_mgr.ListGuilds(c, std::string());
|
||||||
} else if (is_rename) {
|
} else if (is_rename) {
|
||||||
if (!sep->IsNumber(2)) {
|
if (!sep->IsNumber(2)) {
|
||||||
c->Message(Chat::White, "Usage: #guild rename [Guild ID] [New Guild Name]");
|
c->Message(Chat::White, "Usage: #guild rename [Guild ID] [New Guild Name]");
|
||||||
@ -269,6 +244,16 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if (is_search) {
|
||||||
|
if (Strings::IsNumber(sep->arg[2])) {
|
||||||
|
const auto guild_id = std::stoul(sep->arg[2]);
|
||||||
|
|
||||||
|
guild_mgr.ListGuilds(c, guild_id);
|
||||||
|
} else {
|
||||||
|
const std::string search_criteria = sep->argplus[2];
|
||||||
|
|
||||||
|
guild_mgr.ListGuilds(c, search_criteria);
|
||||||
|
}
|
||||||
} else if (is_set) {
|
} else if (is_set) {
|
||||||
if (
|
if (
|
||||||
arguments != 3 ||
|
arguments != 3 ||
|
||||||
@ -502,8 +487,8 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
} else if (is_status) {
|
} else if (is_status) {
|
||||||
auto client = (
|
auto client = (
|
||||||
target ?
|
t ?
|
||||||
target :
|
t :
|
||||||
(
|
(
|
||||||
arguments == 2 ?
|
arguments == 2 ?
|
||||||
entity_list.GetClientByName(sep->arg[2]) :
|
entity_list.GetClientByName(sep->arg[2]) :
|
||||||
@ -521,7 +506,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} not in a guild.",
|
"{} {} not in a guild.",
|
||||||
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
||||||
c == target ? "are" : "is"
|
c == t ? "are" : "is"
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
} else if (guild_mgr.IsGuildLeader(client->GuildID(), client->CharacterID())) {
|
} else if (guild_mgr.IsGuildLeader(client->GuildID(), client->CharacterID())) {
|
||||||
@ -530,7 +515,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} the leader of {}.",
|
"{} {} the leader of {}.",
|
||||||
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
||||||
c == target ? "are" : "is",
|
c == t ? "are" : "is",
|
||||||
guild_mgr.GetGuildNameByID(client->GuildID())
|
guild_mgr.GetGuildNameByID(client->GuildID())
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
@ -540,7 +525,7 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
fmt::format(
|
fmt::format(
|
||||||
"{} {} a(n) {} of {}.",
|
"{} {} a(n) {} of {}.",
|
||||||
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
c->GetTargetDescription(client, TargetDescriptionType::UCYou),
|
||||||
c == target ? "are" : "is",
|
c == t ? "are" : "is",
|
||||||
guild_mgr.GetRankName(client->GuildID(), client->GuildRank()),
|
guild_mgr.GetRankName(client->GuildID(), client->GuildRank()),
|
||||||
guild_mgr.GetGuildNameByID(client->GuildID())
|
guild_mgr.GetGuildNameByID(client->GuildID())
|
||||||
).c_str()
|
).c_str()
|
||||||
@ -549,3 +534,18 @@ void command_guild(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendGuildSubCommands(Client *c)
|
||||||
|
{
|
||||||
|
c->Message(Chat::White, "#guild create [Character ID|Character Name] [Guild Name]");
|
||||||
|
c->Message(Chat::White, "#guild delete [Guild ID]");
|
||||||
|
c->Message(Chat::White, "#guild help");
|
||||||
|
c->Message(Chat::White, "#guild info [Guild ID]");
|
||||||
|
c->Message(Chat::White, "#guild list");
|
||||||
|
c->Message(Chat::White, "#guild rename [Guild ID] [New Name]");
|
||||||
|
c->Message(Chat::White, "#guild search [Search Criteria]");
|
||||||
|
c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)");
|
||||||
|
c->Message(Chat::White, "#guild setleader [Guild ID] [Character ID|Character Name]");
|
||||||
|
c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]");
|
||||||
|
c->Message(Chat::White, "#guild status [Character ID|Character Name]");
|
||||||
|
}
|
||||||
|
|||||||
@ -189,19 +189,70 @@ uint8 *ZoneGuildManager::MakeGuildMembers(uint32 guild_id, const char *prefix_na
|
|||||||
return(retbuffer);
|
return(retbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneGuildManager::ListGuilds(Client *c) const {
|
void ZoneGuildManager::ListGuilds(Client *c, uint32 guild_id) const {
|
||||||
if (m_guilds.size()) {
|
if (m_guilds.size()) {
|
||||||
|
const auto& g = m_guilds.find(guild_id);
|
||||||
|
if (g == m_guilds.end()) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Guild ID {} does not exist or is invalid.",
|
||||||
|
guild_id
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto leader_name = database.GetCharNameByID(g->second->leader_char_id);
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Listing {} Guild{}.",
|
"Guild {} | {}Name: {}",
|
||||||
m_guilds.size(),
|
g->first,
|
||||||
m_guilds.size() != 1 ? "s" : ""
|
(
|
||||||
|
!leader_name.empty() ?
|
||||||
|
fmt::format(
|
||||||
|
"Leader: {} ({}) ",
|
||||||
|
leader_name,
|
||||||
|
g->second->leader_char_id
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
),
|
||||||
|
g->second->name
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
c->Message(Chat::White, "There are no Guilds to list.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneGuildManager::ListGuilds(Client *c, std::string search_criteria) const {
|
||||||
|
if (m_guilds.size()) {
|
||||||
|
if (search_criteria.empty()) {
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Listing {} Guild{}.",
|
||||||
|
m_guilds.size(),
|
||||||
|
m_guilds.size() != 1 ? "s" : ""
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto found_count = 0;
|
||||||
|
|
||||||
for (const auto& guild : m_guilds) {
|
for (const auto& guild : m_guilds) {
|
||||||
auto leader_name = database.GetCharNameByID(guild.second->leader_char_id);
|
if (
|
||||||
|
!search_criteria.empty() &&
|
||||||
|
!Strings::Contains(
|
||||||
|
Strings::ToLower(guild.second->name),
|
||||||
|
Strings::ToLower(search_criteria)
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto leader_name = database.GetCharNameByID(guild.second->leader_char_id);
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -219,7 +270,26 @@ void ZoneGuildManager::ListGuilds(Client *c) const {
|
|||||||
guild.second->name
|
guild.second->name
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
found_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Found {} Guild{}{}.",
|
||||||
|
found_count,
|
||||||
|
found_count != 1 ? "s" : "",
|
||||||
|
(
|
||||||
|
!search_criteria.empty() ?
|
||||||
|
fmt::format(
|
||||||
|
" matching '{}'",
|
||||||
|
search_criteria
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
c->Message(Chat::White, "There are no Guilds to list.");
|
c->Message(Chat::White, "There are no Guilds to list.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,7 +80,8 @@ public:
|
|||||||
//called by worldserver when it receives a message from world.
|
//called by worldserver when it receives a message from world.
|
||||||
void ProcessWorldPacket(ServerPacket *pack);
|
void ProcessWorldPacket(ServerPacket *pack);
|
||||||
|
|
||||||
void ListGuilds(Client *c) const;
|
void ListGuilds(Client *c, std::string search_criteria = std::string()) const;
|
||||||
|
void ListGuilds(Client *c, uint32 guild_id = 0) const;
|
||||||
void DescribeGuild(Client *c, uint32 guild_id) const;
|
void DescribeGuild(Client *c, uint32 guild_id) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user