void Chat::sendHelp(User* user, std::deque<std::string> args) { // TODO: Add paging support, since not all commands will fit into // the screen at once. CommandList* commandList = &m_guestCommands; // defaults std::string commandColor = MC_COLOR_BLUE; if(IS_ADMIN(user->permissions)) { commandList = &m_adminCommands; commandColor = MC_COLOR_RED; // different color for admin commands } else if(IS_OP(user->permissions)) { commandList = &m_opCommands; commandColor = MC_COLOR_GREEN; } else if(IS_MEMBER(user->permissions)) { commandList = &m_memberCommands; } if(args.size() == 0) { for(CommandList::iterator it = commandList->begin(); it != commandList->end(); it++) { std::string args = it->second->arguments; std::string description = it->second->description; sendMsg(user, commandColor + CHATCMDPREFIX + it->first + " " + args + " : " + MC_COLOR_YELLOW + description, Chat::USER); } } else { CommandList::iterator iter; if((iter = commandList->find(args.front())) != commandList->end()) { std::string args = iter->second->arguments; std::string description = iter->second->description; sendMsg(user, commandColor + CHATCMDPREFIX + iter->first + " " + args, Chat::USER); sendMsg(user, MC_COLOR_YELLOW + CHATCMDPREFIX + description, Chat::USER); } else { sendMsg(user, MC_COLOR_RED + "Unknown Command: " + args.front(), Chat::USER); } } }
void SwgSnapshot::decodeBattlefieldParticipants(const NetworkId &objectId, Archive::ReadIterator &data, bool isBaseline) { typedef Archive::AutoDeltaMap<NetworkId, uint32> MapType; typedef std::vector<MapType::Command> CommandList; CommandList commands; if (isBaseline) MapType::unpack(data, commands); else MapType::unpackDelta(data, commands); for (CommandList::const_iterator i = commands.begin(); i != commands.end(); ++i) { switch ((*i).cmd) { case MapType::Command::ERASE: m_battlefieldParticipantBuffer.removeParticipantForRegion(objectId, (*i).key); break; case MapType::Command::ADD: case MapType::Command::SET: m_battlefieldParticipantBuffer.setParticipantForRegion(objectId, (*i).key, (*i).value); break; default: FATAL(true,("Unknown AutoDeltaMap command.\n")); } } }
void SwgSnapshot::decodeManufactureSchematicAttributes(const NetworkId &objectId, Archive::ReadIterator &data, bool isBaseline) { typedef Archive::AutoDeltaMap<StringId, float> MapType; typedef std::vector<MapType::Command> CommandList; CommandList commands; if (isBaseline) MapType::unpack(data, commands); else MapType::unpackDelta(data, commands); for (CommandList::const_iterator i = commands.begin(); i != commands.end(); ++i) { switch ((*i).cmd) { case MapType::Command::ERASE: m_manufactureSchematicAttributeBuffer.removeManufactureSchematicAttribute(objectId,(*i).key.getCanonicalRepresentation()); break; case MapType::Command::ADD: case MapType::Command::SET: m_manufactureSchematicAttributeBuffer.setManufactureSchematicAttribute(objectId,(*i).key.getCanonicalRepresentation(),(*i).value); break; default: FATAL(true,("Unknown AutoDeltaMap command.\n")); } } }
void SwgSnapshot::decodeExperience(const NetworkId &objectId, Archive::ReadIterator &data, bool isBaseline) { typedef Archive::AutoDeltaMap<std::string, int> MapType; typedef std::vector<MapType::Command> CommandList; CommandList commands; if (isBaseline) MapType::unpack(data, commands); else MapType::unpackDelta(data, commands); for (CommandList::const_iterator i = commands.begin(); i != commands.end(); ++i) { switch ((*i).cmd) { case MapType::Command::ERASE: m_experienceBuffer.removeExperience(objectId, (*i).key); break; case MapType::Command::ADD: case MapType::Command::SET: m_experienceBuffer.setExperience(objectId, (*i).key, (*i).value); break; default: FATAL(true,("Unknown AutoDeltaMap command.\n")); } } }
void SwgSnapshot::decodePropertyList(const NetworkId &objectId, int listId, Archive::ReadIterator &data, bool isBaseline) { typedef Archive::AutoDeltaSet<std::string> SetType; typedef std::vector<SetType::Command> CommandList; CommandList commands; if (isBaseline) SetType::unpack(data, commands); else SetType::unpackDelta(data, commands); for (CommandList::const_iterator i = commands.begin(); i != commands.end(); ++i) { switch (i->cmd) { case SetType::Command::ERASE: m_propertyListBuffer.deleteProperty(objectId, listId, i->value); break; case SetType::Command::INSERT: m_propertyListBuffer.insertProperty(objectId, listId, i->value); break; case SetType::Command::CLEAR: m_propertyListBuffer.clearProperties(objectId, listId); break; default: FATAL(true,("Unknown AutoDeltaSet command.\n")); } } }
string usage() { stringstream str; CommandList::const_iterator ci; size_t maxWidth = 0; for (ci = commandList.begin(); ci != commandList.end(); ci++) { if ((*ci)->getName().length() > maxWidth) { maxWidth = (*ci)->getName().length(); } } str << "Usage: " << binaryBaseName << " <COMMAND> [OPTIONS] [ARGUMENTS]" << endl << endl << "Commands (can be abbreviated):" << endl; str << left; for (ci = commandList.begin(); ci != commandList.end(); ci++) { str << " " << setw(maxWidth) << (*ci)->getName() << " " << (*ci)->getBriefDescription() << endl; } str << endl << "Global options:" << endl << " --master -m <master> Comma separated list of masters" << endl << " to select, ranges are allowed." << endl << " Examples: '1,3', '5-7,9', '-3'." << endl << " Default: '-' (all)." << endl << " --force -f Force a command." << endl << " --quiet -q Output less information." << endl << " --verbose -v Output more information." << endl << " --help -h Show this help." << endl << endl << Command::numericInfo() << endl << "Call '" << binaryBaseName << " <COMMAND> --help' for command-specific help." << endl << endl << "Send bug reports to " << PACKAGE_BUGREPORT << "." << endl; return str.str(); }
void CommandExec::run(CommandList& list, ZonePtr z) { if (list.size() == 0) { debugC(3, kDebugExec, "runCommands: nothing to do"); return; } _execZone = z; debugC(3, kDebugExec, "runCommands starting"); runList(list.begin(), list.end()); debugC(3, kDebugExec, "runCommands completed"); }
list<Command *> getMatchingCommands(const string &cmdStr) { CommandList::iterator ci; list<Command *> res; // find matching commands from beginning of the string for (ci = commandList.begin(); ci != commandList.end(); ci++) { if ((*ci)->matchesSubstr(cmdStr)) { res.push_back(*ci); } } if (!res.size()) { // nothing found // find /any/ matching commands for (ci = commandList.begin(); ci != commandList.end(); ci++) { if ((*ci)->matchesAbbrev(cmdStr)) { res.push_back(*ci); } } } return res; }
void RTCommandEngine::evaluateCommands( TimeStamp timeStamp ) { mergeIncomingCommands(); CommandList* commandList = getDueCommands( timeStamp ); if( commandList ) { // XXX: evaluate commands that came in first first, basically what a queue should do, // but the queue used here is actually a LIFO ringbuffer, so we have to reverse // the list of commands -> ugly commandList->reverse(); std::for_each( commandList->begin(), commandList->end(), processCommand ); scheduleCommandListForDeletion( commandList ); } }
KopeteCommandGUIClient( Kopete::ChatSession *manager ) : QObject(manager), KXMLGUIClient(manager) { setXMLFile( QString::fromLatin1("kopetecommandui.rc") ); QDomDocument doc = domDocument(); QDomNode menu = doc.documentElement().firstChild().firstChild().firstChild(); CommandList mCommands = Kopete::CommandHandler::commandHandler()->commands( manager->protocol() ); CommandList::Iterator it, itEnd = mCommands.end(); for( it = mCommands.begin(); it != itEnd; ++it ) { KAction *a = static_cast<KAction*>( it.value() ); actionCollection()->addAction( a->objectName(), a ); QDomElement newNode = doc.createElement( QString::fromLatin1("Action") ); newNode.setAttribute( QString::fromLatin1("name"), a->objectName() ); bool added = false; for( QDomElement n = menu.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { if( a->objectName() < n.attribute(QString::fromLatin1("name"))) { menu.insertBefore( newNode, n ); added = true; break; } } if( !added ) { menu.appendChild( newNode ); } } setDOMDocument( doc ); }
void SwgSnapshot::decodeComponents(NetworkId const & objectId, Archive::ReadIterator &data, bool isBaseline) { typedef Archive::AutoDeltaSet<int> SetType; typedef std::vector<SetType::Command> CommandList; CommandList commands; if (isBaseline) SetType::unpack(data, commands); else SetType::unpackDelta(data, commands); for (CommandList::const_iterator i = commands.begin(); i != commands.end(); ++i) { switch (i->cmd) { case SetType::Command::ERASE: { char buffer[50]; _itoa(i->value,buffer,10); m_propertyListBuffer.deleteProperty(objectId, 11, buffer); break; } case SetType::Command::INSERT: { char buffer[50]; _itoa(i->value,buffer,10); m_propertyListBuffer.insertProperty(objectId, 11, buffer); break; } case SetType::Command::CLEAR: m_propertyListBuffer.clearProperties(objectId, 11); break; default: FATAL(true,("Unknown AutoDeltaSet command.\n")); } } }
bool chatCommandFunction(const char* userIn,const char* cmdIn, int argc, char** argv) { std::string user(userIn); std::string command(cmdIn); std::deque<std::string> cmd(argv, argv+argc); if(command.size() == 0) { return false; } std::string logMsg = user + ": " + command; mineserver->logger.log(LOG_INFO, "plugin.commands", logMsg.c_str()); // User commands CommandList::iterator iter; if((iter = m_Commands.find(command)) != m_Commands.end()) { iter->second->callback(user, command, cmd); return true; } return false; }