/*
* The Mana Server
* Copyright (C) 2008 The Mana World Development Team
*
* This file is part of The Mana Server.
*
* The Mana Server is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* any later version.
*
* The Mana Server is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with The Mana Server. If not, see .
*/
#include
#include "game-server/commandhandler.hpp"
#include "game-server/accountconnection.hpp"
#include "game-server/character.hpp"
#include "game-server/gamehandler.hpp"
#include "game-server/inventory.hpp"
#include "game-server/item.hpp"
#include "game-server/itemmanager.hpp"
#include "game-server/mapmanager.hpp"
#include "game-server/monster.hpp"
#include "game-server/monstermanager.hpp"
#include "game-server/state.hpp"
#include "common/permissionmanager.hpp"
#include "common/transaction.hpp"
#include "utils/string.hpp"
static void say(const std::string error, Character *player)
{
GameState::sayTo(player, NULL, error);
}
/*
static bool checkPermission(Character *player, unsigned int permissions)
{
if (player->getAccountLevel() & permissions)
{
return true;
}
say("Invalid permissions", player);
return false;
}*/
static std::string getArgument(std::string &args)
{
std::string argument = "";
std::string::size_type pos = args.find(' ');
if (pos != std::string::npos)
{
argument = args.substr(0, pos);
args = args.substr(pos+1);
}
else
{
argument = args.substr(0);
args = "";
}
return argument;
}
static Character* getPlayer(const std::string &player)
{
// get character, via the client, as they may be
// on a different game server
GameClient *client = gameHandler->getClientByNameSlow(player);
if (!client)
{
return NULL;
}
if (client->status != CLIENT_CONNECTED)
{
return NULL;
}
return client->character;
}
static void handleHelp(Character *player, std::string &args)
{
if (args == "")
{
if (player->getAccountLevel() & AL_PLAYER)
{
say("=General Commands=", player);
say("@help [command]", player);
say("@report ", player);
say("@where", player);
say("@rights", player);
}
if (player->getAccountLevel() & AL_TESTER)
{
say("=Tester Commands=", player);
say("@warp