mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-19 08:38:20 +00:00
[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.
This commit is contained in:
@@ -11301,6 +11301,16 @@ void Client::SendReloadCommandMessages() {
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto commands_link = Saylink::Silent("#reload commands");
|
||||
|
||||
Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Usage: {} - Reloads Commands globally",
|
||||
commands_link
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto content_flags_link = Saylink::Silent("#reload content_flags");
|
||||
|
||||
Message(
|
||||
|
||||
+16
-8
@@ -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) ||
|
||||
@@ -468,8 +471,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();
|
||||
@@ -520,6 +525,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);
|
||||
@@ -528,6 +535,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
|
||||
@@ -607,11 +619,6 @@ void command_help(Client *c, const Seperator *sep)
|
||||
}
|
||||
|
||||
command_link = Saylink::Silent(
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
cur.first
|
||||
),
|
||||
fmt::format(
|
||||
"{}{}",
|
||||
COMMAND_CHAR,
|
||||
@@ -622,8 +629,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()
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ class Client;
|
||||
class Seperator;
|
||||
|
||||
#include "../common/types.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#define COMMAND_CHAR '#'
|
||||
@@ -27,6 +28,7 @@ int command_add(std::string command_name, std::string description, uint8 admin,
|
||||
int command_notavail(Client *c, std::string message);
|
||||
int command_realdispatch(Client *c, std::string message);
|
||||
void command_logcommand(Client *c, std::string message);
|
||||
uint8 GetCommandStatus(Client *c, std::string command_name);
|
||||
|
||||
// Commands
|
||||
void command_acceptrules(Client *c, const Seperator *sep);
|
||||
|
||||
@@ -11,6 +11,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
bool is_aa = !strcasecmp(sep->arg[1], "aa");
|
||||
bool is_alternate_currencies = !strcasecmp(sep->arg[1], "alternate_currencies");
|
||||
bool is_blocked_spells = !strcasecmp(sep->arg[1], "blocked_spells");
|
||||
bool is_commands = !strcasecmp(sep->arg[1], "commands");
|
||||
bool is_content_flags = !strcasecmp(sep->arg[1], "content_flags");
|
||||
bool is_doors = !strcasecmp(sep->arg[1], "doors");
|
||||
bool is_dztemplates = !strcasecmp(sep->arg[1], "dztemplates");
|
||||
@@ -37,6 +38,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
!is_aa &&
|
||||
!is_alternate_currencies &&
|
||||
!is_blocked_spells &&
|
||||
!is_commands &&
|
||||
!is_content_flags &&
|
||||
!is_doors &&
|
||||
!is_dztemplates &&
|
||||
@@ -74,7 +76,10 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
} else if (is_blocked_spells) {
|
||||
c->Message(Chat::White, "Attempting to reload Blocked Spells globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadBlockedSpells, 0);
|
||||
} else if (is_content_flags) {
|
||||
} else if (is_commands) {
|
||||
c->Message(Chat::White, "Attempting to reload Commands globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadCommands, 0);
|
||||
} else if (is_content_flags) {
|
||||
c->Message(Chat::White, "Attempting to reload Content Flags globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadContentFlags, 0);
|
||||
} else if (is_doors) {
|
||||
|
||||
@@ -40,6 +40,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "../common/profanity_manager.h"
|
||||
|
||||
#include "client.h"
|
||||
#include "command.h"
|
||||
#include "corpse.h"
|
||||
#include "entity.h"
|
||||
#include "expedition.h"
|
||||
@@ -1915,6 +1916,12 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
zone->LoadZoneBlockedSpells();
|
||||
break;
|
||||
}
|
||||
case ServerOP_ReloadCommands:
|
||||
{
|
||||
zone->SendReloadMessage("Commands");
|
||||
command_init();
|
||||
break;
|
||||
}
|
||||
case ServerOP_ReloadContentFlags:
|
||||
{
|
||||
zone->SendReloadMessage("Content Flags");
|
||||
|
||||
Reference in New Issue
Block a user