From 1fd495484bb43a1e0b0d088874d7bc588d8d38c9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Nov 2012 02:59:26 +0300 Subject: Simplify command handlers. --- src/commands.h | 193 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 src/commands.h (limited to 'src/commands.h') diff --git a/src/commands.h b/src/commands.h new file mode 100644 index 000000000..33f86d76b --- /dev/null +++ b/src/commands.h @@ -0,0 +1,193 @@ +/* + * The ManaPlus Client + * Copyright (C) 2008-2009 The Mana World Development Team + * Copyright (C) 2009-2010 The Mana Developers + * Copyright (C) 2011-2012 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * 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 + * 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, see . + */ + +#ifndef COMMANDS_H +#define COMMANDS_H + +#include "playerrelations.h" + +#include + +class ChatTab; + +extern ChatTab *localChatTab; + +#define BOOLEAN_OPTIONS _("Options to /%s are \"yes\", \"no\", \"true\", "\ +"\"false\", \"1\", \"0\".") + +#define decHandler(name) void name(const std::string &args, ChatTab *const tab) + +typedef void (*CommandFuncPtr) (const std::string &args, ChatTab *const tab); + +struct CommandInfo +{ + const char *name; + CommandFuncPtr func; +}; + +namespace Commands +{ + decHandler(announce); + decHandler(help); + decHandler(where); + decHandler(who); + decHandler(msg); + decHandler(query); + decHandler(join); + decHandler(listChannels); + decHandler(clear); + decHandler(createParty); + decHandler(createGuild); + decHandler(party); + decHandler(me); + decHandler(toggle); + decHandler(present); + decHandler(ignore); + decHandler(unignore); + decHandler(beFriend); + decHandler(disregard); + decHandler(neutral); + decHandler(blackList); + decHandler(enemy); + decHandler(erase); + decHandler(quit); + decHandler(showAll); + decHandler(move); + decHandler(target); + decHandler(attackHuman); + decHandler(closeAll); + decHandler(ignoreAll); + decHandler(outfit); + decHandler(emote); + decHandler(away); + decHandler(pseudoAway); + decHandler(follow); + decHandler(imitation); + decHandler(heal); + decHandler(navigate); + decHandler(mail); + decHandler(hack); + decHandler(priceLoad); + decHandler(priceSave); + decHandler(trade); + decHandler(disconnect); + decHandler(undress); + decHandler(attack); + decHandler(dirs); + decHandler(info); + decHandler(wait); + decHandler(uptime); + decHandler(addAttack); + decHandler(addPriorityAttack); + decHandler(removeAttack); + decHandler(addIgnoreAttack); + decHandler(serverIgnoreAll); + decHandler(serverUnIgnoreAll); + decHandler(setDrop); + decHandler(error); + decHandler(url); + decHandler(open); + decHandler(dump); + decHandler(dumpGraphics); + decHandler(dumpTests); + decHandler(dumpOGL); + decHandler(cacheInfo); + + void replaceVars(std::string &str); +} + +static const CommandInfo commands[] = { + {"closeall", &Commands::closeAll}, + {"ignoreall", &Commands::ignoreAll}, + {"help", &Commands::help}, + {"announce", &Commands::announce}, + {"where", &Commands::where}, + {"who", &Commands::who}, + {"msg", Commands::msg}, + {"whisper", Commands::msg}, + {"w", &Commands::msg}, + {"query", Commands::query}, + {"q", &Commands::query}, + {"ignore", &Commands::ignore}, + {"unignore", &Commands::unignore}, + {"friend", Commands::beFriend}, + {"befriend", &Commands::beFriend}, + {"disregard", &Commands::disregard}, + {"neutral", &Commands::neutral}, + {"blacklist", &Commands::blackList}, + {"enemy", &Commands::enemy}, + {"erase", &Commands::erase}, + {"join", &Commands::join}, + {"list", &Commands::listChannels}, + {"clear", &Commands::clear}, + {"createparty", &Commands::createParty}, + {"createguild", &Commands::createGuild}, + {"party", &Commands::party}, + {"me", &Commands::me}, + {"toggle", &Commands::toggle}, + {"present", &Commands::present}, + {"quit", &Commands::quit}, + {"all", &Commands::showAll}, + {"move", &Commands::move}, + {"target", &Commands::target}, + {"atkhuman", &Commands::attackHuman}, + {"outfit", &Commands::outfit}, + {"emote", &Commands::emote}, + {"away", &Commands::away}, + {"pseudoaway", &Commands::pseudoAway}, + {"follow", &Commands::follow}, + {"heal", &Commands::heal}, + {"navigate", &Commands::navigate}, + {"imitation", &Commands::imitation}, + {"mail", &Commands::mail}, + {"trade", &Commands::trade}, + {"priceload", &Commands::priceLoad}, + {"pricesave", &Commands::priceSave}, + {"cacheinfo", &Commands::cacheInfo}, + {"disconnect", &Commands::disconnect}, + {"undress", &Commands::undress}, + {"attack", &Commands::attack}, + {"dirs", &Commands::dirs}, + {"info", &Commands::info}, + {"wait", &Commands::wait}, + {"uptime", &Commands::uptime}, + {"addpriorityattack", &Commands::addPriorityAttack}, + {"addattack", &Commands::addAttack}, + {"removeattack", Commands::removeAttack}, + {"removeignoreattack", &Commands::removeAttack}, + {"addignoreattack", &Commands::addIgnoreAttack}, + {"dump", &Commands::dump}, + {"serverignoreall", &Commands::serverIgnoreAll}, + {"serverunignoreall", &Commands::serverUnIgnoreAll}, + {"setdrop", &Commands::setDrop}, + {"error", &Commands::error}, + {"dumpg", &Commands::dumpGraphics}, + {"dumpt", &Commands::dumpTests}, + {"dumpogl", &Commands::dumpOGL}, + {"url", &Commands::url}, + {"open", &Commands::open}, + {"hack", &Commands::hack} +}; + +#undef decHandler + +#endif // COMMANDS_H -- cgit v1.2.3-70-g09d2