summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-18 21:00:21 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-05-18 21:00:21 +0000
commit4b4b6d0865f5f04f73e04926fb9e6b610f0a71a7 (patch)
tree791472ee9d5696fe07949558a0d8addd535cf9de /src
parentebe0c66a036ff159cf4bdbdcaf7a755c95aef83c (diff)
downloadmanaserv-4b4b6d0865f5f04f73e04926fb9e6b610f0a71a7.tar.gz
manaserv-4b4b6d0865f5f04f73e04926fb9e6b610f0a71a7.tar.bz2
manaserv-4b4b6d0865f5f04f73e04926fb9e6b610f0a71a7.tar.xz
manaserv-4b4b6d0865f5f04f73e04926fb9e6b610f0a71a7.zip
Provide feedback when admin commands fail (patch by rodge)
Diffstat (limited to 'src')
-rw-r--r--src/game-server/command.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp
index cced1318..836be6ad 100644
--- a/src/game-server/command.cpp
+++ b/src/game-server/command.cpp
@@ -279,6 +279,15 @@ static Command const commands[] =
};
/**
+ * Send a message to the given character from the server.
+ */
+static void say(Character * ch, std::string const &message)
+{
+ GameState::sayTo(ch, NULL, message);
+}
+
+
+/**
* Parses a command and executes its associated handler.
*/
void runCommand(Character *ch, std::string const &text)
@@ -297,12 +306,17 @@ void runCommand(Character *ch, std::string const &text)
}
}
- if (!c || c->level > ch->getAccountLevel())
+ if (!c)
{
- // No such command or no sufficient rights.
+ say(ch, "The command " + s + " was not found");
return;
}
+ if (c->level > ch->getAccountLevel())
+ {
+ say(ch, "You have insufficient rights to perform the " + s + " command");
+ }
+
intptr_t args[4];
for (int i = 0; i < 4 && c->type[i]; ++i)
@@ -310,6 +324,8 @@ void runCommand(Character *ch, std::string const &text)
if (pos == npos || pos + 1 >= text.length())
{
// Not enough parameters.
+ say(ch, "Not enough parameters for the " + s +
+ " command. See the command documentation for details");
return;
}
@@ -318,6 +334,7 @@ void runCommand(Character *ch, std::string const &text)
if (arg.empty())
{
// Empty parameter.
+ say(ch, "One of your parameters was empty");
return;
}
@@ -336,11 +353,13 @@ void runCommand(Character *ch, std::string const &text)
{
/* TODO: forward command to other game servers through
account server, in case the player is elsewhere. */
+ say(ch, "Player " + arg + " was not found");
return;
}
if (c->status != CLIENT_CONNECTED)
{
// No suitable character.
+ say(ch, "Player " + arg + " is offline");
return;
}
args[i] = (intptr_t)c->character;
@@ -355,6 +374,7 @@ void runCommand(Character *ch, std::string const &text)
else
{
// No such item.
+ say(ch, "No item was found with id " + arg);
return;
}
break;
@@ -372,6 +392,7 @@ void runCommand(Character *ch, std::string const &text)
else
{
// No such map.
+ say(ch, "Map " + arg + " was not found");
return;
}
break;
@@ -388,6 +409,7 @@ void runCommand(Character *ch, std::string const &text)
else
{
// No such item.
+ say(ch, "No monster with id " + arg + " was found");
return;
}
break;