/////////////////////////////////////////////////////////////////////
// OpenTibia - an opensource roleplaying game
//////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////
// This program 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 (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software Foundation,
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//////////////////////////////////////////////////////////////////////
#include <string>
#include <sstream>
#include <fstream>
#include <utility>
#include "commands.h"
#include "player.h"
#include "npc.h"
#include "game.h"
#include "actions.h"
#include "map.h"
#include "status.h"
#include "monsters.h"
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
extern std::vector< std::pair<unsigned long, unsigned long> > bannedIPs;
extern Actions actions;
extern Monsters g_monsters;
extern bool readXMLInteger(xmlNodePtr p, const char *tag, int &value);
//table of commands
s_defcommands Commands::defined_commands[] = {
{"/s",&Commands::placeNpc},
{"/m",&Commands::placeMonster},
{"/summon",&Commands::placeSummon},
{"/B",&Commands::broadcastMessage},
{"/white",&Commands::broadcastMessageWhite},
{"/b",&Commands::banPlayer},
{"/t",&Commands::teleportMasterPos},
{"/c",&Commands::teleportHere},
{"/i",&Commands::createItems},
{"/q",&Commands::substract_contMoney},
{"/reload",&Commands::reloadInfo},
{"/z",&Commands::testCommand},
{"/goto",&Commands::teleportTo},
{"/info",&Commands::getInfo},
{"/closeserver",&Commands::closeServer},
{"/openserver",&Commands::openServer},
{"/getonline",&Commands::onlineList},
{"/a",&Commands::teleportNTiles},
{"/kick",&Commands::kickPlayer},
{"!rs",&Commands::showRs},
{"/checkmc",&Commands::mcCheck},
{"/makesay",&Commands::makePlayerSay},
#ifdef YUR_CMD_EXT
{"/ban",&Commands::banCharacter},
{"/up",&Commands::goUp},
{"/down",&Commands::goDown},
{"/pos",&Commands::showPos},
{"/pvp",&Commands::setWorldType},
{"/send",&Commands::teleportPlayerTo},
{"/max",&Commands::setMaxPlayers},
{"!exp",&Commands::showExpForLvl},
{"!mana",&Commands::showManaForLvl},
{"!report",&Commands::report},
{"!online",&Commands::whoIsOnline},
{"!uptime",&Commands::showUptime},
{"/outfit",&Commands::outfitChange},
{"/removeitem",&Commands::playerRemoveItem},
#endif //YUR_CMD_EXT
#ifdef TLM_HOUSE_SYSTEM
{"/owner",&Commands::setHouseOwner},
{"!house",&Commands::reloadRights},
#endif //TLM_HOUSE_SYSTEM
#ifdef TRS_GM_INVISIBLE
{"/invisible",&Commands::gmInvisible},
#endif //TRS_GM_INVISIBLE
#ifdef TLM_SKULLS_PARTY
{"!frags",&Commands::showFrags},
#endif //TLM_SKULLS_PARTY
#ifdef TLM_SERVER_SAVE
{"/save",&Commands::forceServerSave},
#endif //TLM_SERVER_SAVE
#ifdef YUR_SHUTDOWN
{"/shutdown",&Commands::shutdown},
#endif //YUR_SHUTDOWN
#ifdef YUR_CLEAN_MAP
{"/clean",&Commands::cleanMap},
#endif //YUR_CLEAN_MAP
#ifdef YUR_PREMIUM_PROMOTION
{"/promote",&Commands::promote},
{"/premmy",&Commands::premmy},
{"!premmy",&Commands::showPremmy},
#endif //YUR_PREMIUM_PROMOTION
{"/vote",&Commands::vote},
};
Commands::Commands(Game* igame):
game(igame),
loaded(false)
{
//setup command map
for(int i = 0;i< sizeof(defined_commands)/sizeof(defined_commands[0]); i++){
Command *tmp = new Command;
tmp->loaded = false;
tmp->accesslevel = 1;
tmp->f = defined_commands[i].f;
std::string key = defined_commands[i].name;
commandMap[key] = tmp;
}