summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-10-24 11:32:43 -0700
committerBen Longbons <b.r.longbons@gmail.com>2013-10-24 11:32:43 -0700
commit65ad442a3d8e370a590ec44b2c82f5af902f8d01 (patch)
tree3122f6953b56e8c2ee631249365c4c4e3cdad6eb
parent23aa8816357a24e480f133e7138e8ac78af757e5 (diff)
downloadtmwa-65ad442a3d8e370a590ec44b2c82f5af902f8d01.tar.gz
tmwa-65ad442a3d8e370a590ec44b2c82f5af902f8d01.tar.bz2
tmwa-65ad442a3d8e370a590ec44b2c82f5af902f8d01.tar.xz
tmwa-65ad442a3d8e370a590ec44b2c82f5af902f8d01.zip
Give better errors for too low GM level
-rw-r--r--src/map/atcommand.cpp30
1 files changed, 21 insertions, 9 deletions
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<XString, AtCommandInfo> 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<map_session_data> 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<map_session_data> 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<map_session_data> 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;
}