jlong JNICALL ScriptMethodsMountNamespace::getRiderId(JNIEnv *env, jobject self, jlong mountId) { UNREF(env); UNREF(self); //-- Ignore calls if mounts are disabled. if (!ConfigServerGame::getMountsEnabled()) return 0; //-- Get the rider object. bool const throwIfNotOnServer = false; CreatureObject const *const mountObject = JavaLibrary::getCreatureThrow(env, mountId, "getRiderId(): error in mountId arg", throwIfNotOnServer); if (!mountObject) return 0; CreatureObject const *const riderObject = mountObject->getPrimaryMountingRider(); NetworkId const riderNetworkId = (riderObject ? riderObject->getNetworkId() : NetworkId::cms_invalid); return riderNetworkId.getValue(); }
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; }
void put(ByteStream & target, const NetworkId & source) { //uint64 tmp = source.getValue(); put(target, source.getValue()); //target.put(&tmp,8); }
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; }
void BindableNetworkId::setValue(const NetworkId &buffer) { BindableInt64::setValue(buffer.getValue()); }
BindableNetworkId::BindableNetworkId (const NetworkId &rhs) : BindableInt64(rhs.getValue()) { }