mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Commands] Command Status Reload and Helper Method (#2377)
* [Commands] Command Status Reloading
Currently command status changes require a server restart to take effect, this will allow them to be changed and use `#reload commands` without needing a restart.
Added a helper method called GetCommandStatus() for future reference when sending command saylinks to people and making sure if they're high enough status for the command before sending the link.
* Update client.cpp
* Update command.h
* Saylink cleanup.
* Remove unnecessary packet sending.
* Revert "Remove unnecessary packet sending."
This reverts commit e7e77b83af.
This commit is contained in:
+16
-18
@@ -53,6 +53,7 @@ int (*command_dispatch)(Client *,std::string) = command_notavail;
|
||||
std::map<std::string, CommandRecord *> commandlist;
|
||||
std::map<std::string, std::string> commandaliases;
|
||||
std::vector<CommandRecord *> command_delete_list;
|
||||
std::map<std::string, uint8> commands_map;
|
||||
|
||||
/*
|
||||
* command_notavail
|
||||
@@ -82,7 +83,9 @@ int command_notavail(Client *c, std::string message)
|
||||
|
||||
int command_init(void)
|
||||
{
|
||||
commandaliases.clear();
|
||||
if (!commandaliases.empty()) {
|
||||
command_deinit();
|
||||
}
|
||||
|
||||
if (
|
||||
command_add("acceptrules", "[acceptrules] - Accept the EQEmu Agreement", AccountStatus::Player, command_acceptrules) ||
|
||||
@@ -469,8 +472,10 @@ int command_init(void)
|
||||
*/
|
||||
void command_deinit(void)
|
||||
{
|
||||
for (auto &c : command_delete_list)
|
||||
for (auto &c : command_delete_list) {
|
||||
delete c;
|
||||
}
|
||||
|
||||
command_delete_list.clear();
|
||||
commandlist.clear();
|
||||
commandaliases.clear();
|
||||
@@ -521,6 +526,8 @@ int command_add(std::string command_name, std::string description, uint8 admin,
|
||||
c->description = description;
|
||||
c->function = function;
|
||||
|
||||
commands_map[command_name] = admin;
|
||||
|
||||
commandlist[command_name] = c;
|
||||
commandaliases[command_name] = command_name;
|
||||
command_delete_list.push_back(c);
|
||||
@@ -529,6 +536,11 @@ int command_add(std::string command_name, std::string description, uint8 admin,
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8 GetCommandStatus(Client *c, std::string command_name) {
|
||||
auto command_status = commands_map[command_name];
|
||||
return command_status;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* command_realdispatch
|
||||
@@ -608,11 +620,6 @@ void command_help(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
command_link = Saylink::Silent(
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
cur.first
|
||||
),
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
@@ -623,8 +630,9 @@ void command_help(Client *c, const Seperator *sep)
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} | {}",
|
||||
"{} | Status: {} | {}",
|
||||
command_link,
|
||||
cur.second->admin,
|
||||
!cur.second->description.empty() ? cur.second->description : ""
|
||||
).c_str()
|
||||
);
|
||||
@@ -689,11 +697,6 @@ void command_findaliases(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
auto current_commmand_link = Saylink::Silent(
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
command_iter->first
|
||||
),
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
@@ -713,11 +716,6 @@ void command_findaliases(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
alias_link = Saylink::Silent(
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
a.first
|
||||
),
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
|
||||
Reference in New Issue
Block a user