summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-07 00:58:46 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2010-07-08 23:18:55 +0200
commit2627acefebc688d9d9733abe23ba5aae79f66ea0 (patch)
tree8601ab2c65b5c1db8cfd32f620c518dd8af5a5ee /src
parent983ea271e82a92c20caad1bb6e25b620b6702844 (diff)
downloadmanaserv-2627acefebc688d9d9733abe23ba5aae79f66ea0.tar.gz
manaserv-2627acefebc688d9d9733abe23ba5aae79f66ea0.tar.bz2
manaserv-2627acefebc688d9d9733abe23ba5aae79f66ea0.tar.xz
manaserv-2627acefebc688d9d9733abe23ba5aae79f66ea0.zip
Made Manaserv accept parameters enclosed with double-quotes.
Reviewed-by: Jaxad0127. Resolves: Manasource-Mantis #22
Diffstat (limited to 'src')
-rw-r--r--src/game-server/commandhandler.cpp37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp
index 1f3c3913..0f3bc85b 100644
--- a/src/game-server/commandhandler.cpp
+++ b/src/game-server/commandhandler.cpp
@@ -124,14 +124,45 @@ static bool checkPermission(Character *player, unsigned int permissions)
return false;
}*/
+/**
+ * Returns the next argument, and remove it from the given string.
+ */
static std::string getArgument(std::string &args)
{
std::string argument = "";
- std::string::size_type pos = args.find(' ');
+ std::string::size_type pos = std::string::npos;
+ bool doubleQuotes = false;
+
+ // Finds out if the next argument is between double-quotes
+ if (args.substr(0, 1).compare("\""))
+ {
+ // No double-quotes, we then search an ending space.
+ pos = args.find(' ');
+ doubleQuotes = false;
+ }
+ else
+ {
+ // Exclude the first double-quote from search.
+ pos = args.find('"', 1);
+ doubleQuotes = true;
+ }
+
if (pos != std::string::npos)
{
argument = args.substr(0, pos);
- args = args.substr(pos+1);
+ if (doubleQuotes)
+ {
+ // Jumps to the next parameter,
+ // after the ending double-quote and space,
+ // and remove the two double-quotes before returning.
+ args = args.substr(pos + 2);
+ argument = argument.substr(1, pos - 1);
+ }
+ else
+ {
+ // Jumps to the next parameter, after the ending space.
+ args = args.substr(pos + 1);
+ }
}
else
{
@@ -229,7 +260,7 @@ static void handleWarp(Character *player, std::string &args)
other = getPlayer(character);
if (!other)
{
- say("Invalid character, or they are offline", player);
+ say("Invalid or offline character <" + character + ">.", player);
return;
}
}