static void Skins_SetSurfacePrefs(ModelContainer_t *pContainer, StringVector_t &SurfaceNames, SurfaceOnOff_t eStatus) { bool bFailureOccured = false; for (int i=0; i<SurfaceNames.size() && !bFailureOccured; i++) { string strSurfaceName = SurfaceNames[i]; if (!Model_GLMSurface_SetStatus( pContainer->hModel, strSurfaceName.c_str(), eStatus)) bFailureOccured = true; } }
bool ConsoleCommandParser::performParsing(const NetworkId & /* track */, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *) { bool successResult = false; if(isCommand(argv[0], "planet")) { if(argv.size() > 2) { if(isCommand(argv[2], "runState")) { successResult = true; result += Unicode::narrowToWide("running"); } } } return successResult; }
bool ConsoleCommandParser::performParsing(const NetworkId & track, const StringVector_t & argv, const String_t &, String_t & result, const CommandParser *) { bool successResult = false; if(isCommand(argv[0], "transfer")) { if(isCommand(argv[1], "requestMove")) { if(argv.size() > 5) { std::string stationIdString = Unicode::wideToNarrow(argv[2]); std::string characterName = Unicode::wideToNarrow(argv[3]); std::string sourceServer = Unicode::wideToNarrow(argv[4]); std::string destinationServer = Unicode::wideToNarrow(argv[5]); LOG("CustomerService", ("CharacterTransfer: received console request to transfer %s, belonging to %s from %s to %s", characterName.c_str(), stationIdString.c_str(), sourceServer.c_str(), destinationServer.c_str())); result += Unicode::narrowToWide("Received request to move "); result += Unicode::narrowToWide(characterName); result += Unicode::narrowToWide(" owned by station ID "); result += Unicode::narrowToWide(stationIdString); result += Unicode::narrowToWide(" on cluster "); result += Unicode::narrowToWide(sourceServer); result += Unicode::narrowToWide(" to cluster "); result += Unicode::narrowToWide(destinationServer); const unsigned int stationId = static_cast<const unsigned int>(atoi (stationIdString.c_str())); const unsigned int trackId = static_cast<const unsigned int>(track.getValue()); //todo : drive these through the command handler, just testing // basic functionality for now. const bool withItems = true; const bool allowOverride = true; TransferServer::requestMove(trackId, "en", sourceServer, destinationServer, characterName, characterName, stationId, stationId, trackId, withItems, allowOverride); successResult = true; } else { std::string messageString = "not enough arguments to 'requestMove <station id> <character name> <source server> <destination server>'"; StringVector_t::const_iterator i; for(i = argv.begin(); i != argv.end(); ++i) { messageString = messageString + Unicode::wideToNarrow(*i) + " | "; } LOG("CustomerService", ("CharacterTransfer: %s", messageString.c_str())); result += Unicode::narrowToWide(messageString); } } else if (isCommand(argv[1], "requestAccountMove")) { if (argv.size() > 3) { std::string sourceStationIdString = Unicode::wideToNarrow(argv[2]); std::string destinationStationIdString = Unicode::wideToNarrow(argv[3]); LOG("CustomerService", ("CharacterTransfer: received console request to transfer account from station ID %s to station ID %s", sourceStationIdString.c_str(), destinationStationIdString.c_str())); result += Unicode::narrowToWide("Received request to move from station ID "); result += Unicode::narrowToWide(sourceStationIdString); result += Unicode::narrowToWide(" to station ID "); result += Unicode::narrowToWide(destinationStationIdString); result += Unicode::narrowToWide("\n"); const unsigned int sourceStationId = static_cast<const unsigned int>(atoi (sourceStationIdString.c_str())); const unsigned int destinationStationId = static_cast<const unsigned int>(atoi (destinationStationIdString.c_str())); const unsigned int trackId = static_cast<const unsigned int>(track.getValue()); TransferServer::requestTransferAccount(trackId, sourceStationId, destinationStationId, trackId); successResult = true; } else { std::string messageString = "not enough arguments to 'requestAccountMove <source station id> <destination station id>'"; StringVector_t::const_iterator i; for(i = argv.begin(); i != argv.end(); ++i) { messageString = messageString + Unicode::wideToNarrow(*i) + " | "; } LOG("CustomerService", ("CharacterTransfer: %s\n", messageString.c_str())); result += Unicode::narrowToWide(messageString); result += Unicode::narrowToWide("\n"); } } } return successResult; }
bool ConsoleCommandParserGame::performParsing(const NetworkId & track, const StringVector_t & argv,const String_t & originalCommand,String_t & result,const CommandParser *) { bool successResult = false; if(isCommand(argv[0], CommandNames::game)) { if(argv.size() > 1) { std::string cmd = Unicode::wideToNarrow(argv[1]); if(cmd == "any") { // grab a random game server to execute this command GameServerConnection * gameConn = CentralServer::getInstance().getRandomGameServer(); if(gameConn) { ConGenericMessage cm(Unicode::wideToNarrow(originalCommand), static_cast<unsigned int>(track.getValue())); gameConn->send(cm, true); successResult = true; } else { result += Unicode::narrowToWide("No game servers available to service request"); ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } } else if(cmd == "kill") { // kill the game server process specified (by disconnecting it from central) if(argv.size() > 2) { unsigned int pid; sscanf(Unicode::wideToNarrow(argv[2]).c_str(), "%d", &pid); GameServerConnection * gameConn = CentralServer::getInstance().getGameServer(pid); if(gameConn) { gameConn->setDisconnectReason("Central ConsoleCommandParserGame kill command"); gameConn->disconnect(); successResult = true; ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } } } else if(cmd == "enumerate") { std::vector<const GameServerConnection *> gameServers = CentralServer::getInstance().getGameServers(); std::vector<const GameServerConnection *>::const_iterator i; for(i = gameServers.begin(); i != gameServers.end(); ++i) { char entry[256] = {"\0"}; IGNORE_RETURN(snprintf(entry, sizeof(entry), "%lu, %lu, %s, %s\n", (*i)->getProcessId(), (*i)->getOsProcessId(), (*i)->getRemoteAddress().c_str(), (*i)->getSceneId().c_str())); result += Unicode::narrowToWide(entry); } ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } else if( cmd == "abortShutdown" ) { LOG("ServerConsole", ("Received command to abort the current shutdown sequence.")); CentralServer::getInstance().abortShutdownProcess(); result += Unicode::narrowToWide("Instructing Central Server to abort shutdown sequence.\n"); successResult = true; ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } // starts the shutdown process else if(cmd == "shutdown") { if( argv.size() > 4 ) { LOG("ServerConsole", ("Received command to shutdown the cluster.")); uint32 timeToShutdown = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), NULL, 10); uint32 maxTime = strtoul(Unicode::wideToNarrow(argv[3]).c_str(), NULL, 10); Unicode::String systemMessage = Unicode::narrowToWide(""); for(unsigned int i = 4; i < argv.size(); ++i) { systemMessage += argv[i] + Unicode::narrowToWide(" "); } CentralServer::getInstance().startShutdownProcess(timeToShutdown, maxTime, systemMessage); result += Unicode::narrowToWide("Instructing Central Server to begin shutdown sequence.\n"); successResult = true; ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } // failed to provide enough parameters else { LOG("ServerConsole", ("Received an improperly formatted shutdown command.")); result += Unicode::narrowToWide("Not enough parameters specified. Usage is \"game shutdown <time to shutdown in seconds> <max time to wait in seconds> <system broadcast message>\"\n"); ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } } else if(cmd == "authorizeTransfer") { if(argv.size() > 1) { unsigned int stationId = strtoul(Unicode::wideToNarrow(argv[2]).c_str(), NULL, 10); if(stationId > 0) { GenericValueTypeMessage<unsigned int> auth("AuthorizeDownload", stationId); CentralServer::getInstance().sendToTransferServer(auth); result += Unicode::narrowToWide("sent authorization request"); } } ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } else if(cmd == "requestMove") { if(argv.size() > 5) { ConGenericMessage cm(Unicode::wideToNarrow(originalCommand), static_cast<unsigned int>(track.getValue())); CentralServer::getInstance().sendToTransferServer(cm); } } else { if(! isalpha(cmd.c_str()[0])) { // check to see if the next parameter is a pid to send the command to uint32 pid; sscanf(Unicode::wideToNarrow(argv[1]).c_str(), "%lu", &pid); GameServerConnection * gameConn = CentralServer::getInstance().getGameServer(pid); if(gameConn) { ConGenericMessage cm(Unicode::wideToNarrow(originalCommand), static_cast<unsigned int>(track.getValue())); gameConn->send(cm, true); successResult = true; } else { result += Unicode::narrowToWide("No game servers available to service request"); ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } } else { // a planet GameServerConnection * gameConn = CentralServer::getInstance().getGameServer(Unicode::wideToNarrow(argv[1])); if(gameConn) { ConGenericMessage cm(Unicode::wideToNarrow(originalCommand), static_cast<unsigned int>(track.getValue())); gameConn->send(cm, true); successResult = true; } else { result += Unicode::narrowToWide("No game servers available to service request"); ConsoleConnection::onCommandComplete(Unicode::wideToNarrow(result), static_cast<int>(track.getValue())); } } } } else { // select a game server to execute this command result += Unicode::narrowToWide("insufficient arguments"); successResult = true; } } return successResult; }
bool ConsoleCommandParserSpawner::performParsing (const NetworkId &, const StringVector_t & argv, const String_t & , String_t & result, const CommandParser *) { // ---------------------------------------------------------------- if (isCommand (argv[0], CommandNames::showQueue)) { CreatureObject::showSpawnQueue(result); return true; } else if(isCommand (argv[0], CommandNames::showCreatures)) { bool npcOnly = false; bool pcOnly = false; if(argv.size() >= 2) { std::string arg2 = Unicode::wideToNarrow(argv[1]); if(arg2 == "npc") { npcOnly = true; } else if(arg2 == "pc") { pcOnly = true; } } static const Unicode::String header(Unicode::narrowToWide(std::string("Creature Listing - ID: POS: Auth Server: Template Name\n"))); result += header; const CreatureObject::AllCreaturesSet & creatureList = CreatureObject::getAllCreatures(); CreatureObject::AllCreaturesSet::const_iterator i; int count = 0; for(i = creatureList.begin(); i != creatureList.end(); ++i) { const CreatureObject * creature = (*i); if(creature) { if(pcOnly && (!creature->isPlayerControlled()) ) continue; if(npcOnly && creature->isPlayerControlled()) continue; std::string creatureEntry = creature->getNetworkId().getValueString(); creatureEntry += ": "; char locBuffer[32] = {"\0"}; Vector loc = creature->getTransform_o2w().getPosition_p(); snprintf(locBuffer, sizeof(locBuffer), "%.0f, %.0f: ", loc.x, loc.z); creatureEntry += locBuffer; snprintf(locBuffer, sizeof(locBuffer), "%lu: ", creature->getAuthServerProcessId()); creatureEntry += locBuffer; creatureEntry += creature->getObjectTemplateName(); creatureEntry += "\n"; result += Unicode::narrowToWide(creatureEntry); count++; } } char countBuffer[32] = {"\0"}; snprintf(countBuffer, sizeof(countBuffer), "%d creatures listed: ", count); result += Unicode::narrowToWide(std::string(countBuffer)); return true; } else { result += getErrorMessage (argv[0], ERR_NO_HANDLER); return false; } return true; }
bool ConsoleCommandParserResource::performParsing (const NetworkId & userId, const StringVector_t & argv, const String_t & originalCommand, String_t & result, const CommandParser * node) { NOT_NULL (node); UNREF (userId); UNREF(originalCommand); //----------------------------------------------------------------- if (isCommand( argv [0], "activate")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_activateInstallation),0.0f,new MessageQueueActivateInstallation(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "harvest")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } //TODO: Make all of these into function calls instead of sending messages Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_installationHarvest),0.0f,new MessageQueueInstallationHarvest(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "discardHopper")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); HarvesterInstallationObject* harvesterObject = dynamic_cast<HarvesterInstallationObject*>(harvester.getObject()); if (!harvesterObject) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } harvesterObject->discardAllHopperContents (); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "deactivate")) { CachedNetworkId harvester(Unicode::wideToNarrow (argv[1])); ServerObject* harvesterObject = safe_cast<ServerObject*>(harvester.getObject()); if (harvesterObject == NULL) { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); return true; } Controller *const controller = harvesterObject->getController(); NOT_NULL(controller); controller->appendMessage(static_cast<int>(CM_deactivateInstallation),0.0f,new MessageQueueDeactivateInstallation(), GameControllerMessageFlags::SEND | GameControllerMessageFlags::RELIABLE | GameControllerMessageFlags::DEST_AUTH_SERVER); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "tree")) { ServerUniverse & universe = ServerUniverse::getInstance(); ResourceClassObject * root = 0; if (argv.size () > 1) root = universe.getResourceClassByName (Unicode::wideToNarrow (argv [1])); else root = universe.getResourceTreeRoot(); if (root) { std::string temp; root->debugOutput(temp); result += Unicode::narrowToWide(temp); result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "pools")) { PlanetObject* planet=ServerUniverse::getInstance().getPlanetByName(Unicode::wideToNarrow(argv[1])); if (planet) { std::string temp; planet->debugOutputPools(temp); result += Unicode::narrowToWide(temp); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "name")) { NetworkId resourceId(Unicode::wideToNarrow (argv[1])); ResourceTypeObject * const resource = ServerUniverse::getInstance().getResourceTypeById(resourceId); if (resource) { resource->setName(Unicode::wideToNarrow(argv[2])); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "viewcontainer")) { CachedNetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(contId.getObject()); if (container) { result += Unicode::narrowToWide(container->debugPrint()+'\n'); result += getErrorMessage(argv[0], ERR_SUCCESS); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "addtocontainer")) { NetworkId const contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject * const container = dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); std::string const & resourcePath = Unicode::wideToNarrow(argv[2]); ResourceTypeObject * const resType = ServerUniverse::getInstance().getResourceTypeByName(resourcePath); int const amount = strtol(Unicode::wideToNarrow (argv[3]).c_str (), NULL, 10); NetworkId const source(Unicode::wideToNarrow (argv[4])); if (container && resType) { if (container->addResource(CachedNetworkId(resType->getNetworkId()),amount, source)) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "fillcontainer")) { NetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); if (container != NULL) { NetworkId sourceId; if (argv.size() >= 3) sourceId = NetworkId(Unicode::wideToNarrow (argv[2])); if (container->addResource(container->getResourceType(), container->getMaxQuantity() - container->getQuantity(), sourceId)) { result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "recycle")) { NetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(NetworkIdManager::getObjectById(contId)); if (container != NULL) { if (container->debugRecycle()) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += Unicode::narrowToWide("The resource in the container could not be recycled.\n"); } else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "removefromcontainer")) { CachedNetworkId contId (Unicode::wideToNarrow (argv[1])); ResourceContainerObject* container=dynamic_cast<ResourceContainerObject*>(contId.getObject()); ResourceTypeObject *resType=ServerUniverse::getInstance().getResourceTypeByName(Unicode::wideToNarrow(argv[2])); int amount=strtol(Unicode::wideToNarrow (argv[3]).c_str (), NULL, 10); if (container && resType) { NetworkId sourcePlayer(NetworkId::cms_invalid); typedef std::vector<std::pair<NetworkId, int> > SourcesType; SourcesType sources; if (container->removeResource(resType->getNetworkId(),amount,&sources)) { char buffer[50]; for(SourcesType::iterator i=sources.begin(); i!=sources.end(); ++i) { IGNORE_RETURN(snprintf(buffer,50,"%i",i->second)); result += Unicode::narrowToWide(std::string("Removed ") + buffer + " resources harvested by player " + i->first.getValueString() + '\n'); } result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv[0], ERR_INVALID_CONTAINER_TRANSFER); } else { result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } } else if (isCommand( argv [0], "getSurveyList")) { std::string parentResourceClassName(Unicode::wideToNarrow(argv[1])); CachedNetworkId tool(Unicode::wideToNarrow (argv[2])); SurveySystem::getInstance().requestResourceListForSurvey(userId, tool, parentResourceClassName); result += getErrorMessage(argv[0], ERR_SUCCESS); } else if (isCommand( argv [0], "survey")) { const std::string parentResourceClassName (Unicode::wideToNarrow(argv[1])); const std::string resourceTypeName (Unicode::wideToNarrow(argv[2])); const int surveyRange = strtol(Unicode::wideToNarrow(argv[3]).c_str(),NULL,10); const int numPoints = strtol(Unicode::wideToNarrow(argv[4]).c_str(),NULL,10); const Object * player = NetworkIdManager::getObjectById(userId); if (player) { SurveySystem::getInstance().requestSurvey(userId, parentResourceClassName, resourceTypeName, player->getPosition_w(), surveyRange, numPoints); result += getErrorMessage(argv[0], ERR_SUCCESS); } else result += getErrorMessage(argv [0], ERR_INVALID_OBJECT); } else if (isCommand( argv [0], "deplete")) { NetworkId resourceId (Unicode::wideToNarrow (argv[1])); if (ServerUniverse::getInstance().manualDepleteResource(resourceId)) result += getErrorMessage(argv[0], ERR_SUCCESS); else result += getErrorMessage (argv [0], ERR_INVALID_OBJECT); } return true; } // ConsoleCommandParserResource::performParsing