From 65ad442a3d8e370a590ec44b2c82f5af902f8d01 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Thu, 24 Oct 2013 11:32:43 -0700 Subject: Give better errors for too low GM level --- src/map/atcommand.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'src/map/atcommand.cpp') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 75c46a2..403520e 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -73,7 +73,7 @@ Map atcommand_info; static -AtCommandInfo *atcommand(const int level, XString cmd); +AtCommandInfo *atcommand(XString cmd); // These @commands are used within other @commands. static @@ -231,8 +231,17 @@ bool is_atcommand(const int fd, dumb_ptr sd, ZString arg; asplit(message, &command, &arg); - AtCommandInfo *info = atcommand(gmlvl > 0 ? gmlvl : pc_isGM(sd), command); + AtCommandInfo *info = atcommand(command); + if (!gmlvl) + gmlvl = pc_isGM(sd); + if (battle_config.atcommand_gm_only != 0 && !gmlvl) + { + FString output = STRPRINTF("GM command is level 0, but this server disables level 0 commands: %s", + FString(command)); + clif_displaymessage(fd, output); + return true; + } if (!info) { FString output = STRPRINTF("GM command not found: %s", @@ -241,6 +250,14 @@ bool is_atcommand(const int fd, dumb_ptr sd, return true; // don't show in chat } + if (info->level > gmlvl) + { + FString output = STRPRINTF("GM command is level %d, but you are level %d: %s", + info->level, gmlvl, + FString(command)); + clif_displaymessage(fd, output); + return true; + } { { @@ -274,18 +291,13 @@ bool is_atcommand(const int fd, dumb_ptr sd, } } -AtCommandInfo *atcommand(const int level, XString cmd) +AtCommandInfo *atcommand(XString cmd) { - if (battle_config.atcommand_gm_only != 0 && !level) - // level = pc_isGM(sd) - return nullptr; - if (cmd.startswith('@')) { XString command = cmd.xslice_t(1); AtCommandInfo *it = atcommand_info.search(command); - if (it && level >= it->level) - return it; + return it; } return nullptr; } -- cgit v1.2.3-70-g09d2