Beispiel #1
0
  void
  AccountAvailableState::runCommand(const std::string &command,
      const std::string &args)
  {
    if (CreateAcc == command)
      {

        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string uname = tokeniser.nextToken();
        std::string password = tokeniser.nextToken();
        std::string realname = tokeniser.remainingTokens();

        std::string msg;
        msg = "Creating account: Name: [" + uname + "], Password: [" + password
            + "], Real Name: [" + realname + "]";

        try
          {
            mAccount.createAccount(uname, realname, password);
          }
        catch (const std::exception& except)
          {
            S_LOG_WARNING("Got error on account creation." << except);
            return;
          }
        catch (...)
          {
            S_LOG_WARNING("Got unknown error on account creation.");
            return;
          }

      }
    else if (Login == command)
      {

        // Split string into userid / password pair
        Tokeniser tokeniser = Tokeniser();
        tokeniser.initTokens(args);
        std::string userid = tokeniser.nextToken();
        std::string password = tokeniser.remainingTokens();

        mAccount.login(userid, password);

        std::string msg;
        msg = "Login: [" + userid + "," + password + "]";
        ConsoleBackend::getSingleton().pushMessage(msg, "info");
      }
  }
Beispiel #2
0
void LoggedInState::runCommand(const std::string &command, const std::string &args)
{
	if (Logout == command) {
		ConsoleBackend::getSingleton().pushMessage("Logging out...", "important");
		mAccount.logout();

		// Create Character command
	} else if (CreateChar == command) {
		// Split string into name/type/sex/description
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string name = tokeniser.nextToken();
		std::string sex = tokeniser.nextToken();
		std::string type = tokeniser.nextToken();
		std::string spawnPoint = tokeniser.nextToken();
		std::string description = tokeniser.remainingTokens();

		createCharacter(name, sex, type, description, spawnPoint, Atlas::Message::MapType());

		// Take Character Command
	} else if (TakeChar == command) {

		takeCharacter(args);

		// List Characters Command
	} else if (ListChars == command) {

		mAccount.refreshCharacterInfo();

		// Say (In-Game chat) Command
	}
}
Beispiel #3
0
	void ConfigService::runCommand ( const std::string &command, const std::string &args )
	{
		if ( command == SETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );
			std::string value ( tokeniser.remainingTokens() );

			if ( section == "" || key == "" || value == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: set_value <section> <key> <value>", "help" );
			}
			else
			{
				setValue ( section, key, value );
				ConsoleBackend::getSingleton().pushMessage ( "New value set, section: " +  section + " key: " + key + " value: " + value, "info" );
			}

		}
		else if ( command == GETVALUE )
		{
			Tokeniser tokeniser;
			tokeniser.initTokens ( args );
			std::string section ( tokeniser.nextToken() );
			std::string key ( tokeniser.nextToken() );

			if ( section == "" || key == "" )
			{
				ConsoleBackend::getSingleton().pushMessage ( "Usage: get_value <section> <key>", "help" );
			}
			else
			{
				if ( !hasItem ( section, key ) )
				{
					ConsoleBackend::getSingleton().pushMessage ( "No such value.", "error" );
				}
				else
				{
					varconf::Variable value = getValue ( section, key );
					ConsoleBackend::getSingleton().pushMessage ( std::string ( "Value: " ) + static_cast<std::string> ( value ), "info" );
				}
			}
		}
	}
Beispiel #4
0
void NonConnectedState::runCommand(const std::string &command, const std::string &args)
{
	// Connect command
	if (Connect == command) {
		// Split string into server / port pair
		Tokeniser tokeniser = Tokeniser();
		tokeniser.initTokens(args);
		std::string server = tokeniser.nextToken();
		std::string port = tokeniser.remainingTokens();
		std::string msg;
		msg = "Connecting to: [" + server + "]";
		ConsoleBackend::getSingleton().pushMessage(msg, "info");
		if (port == "")
			connect(server);
		else
			connect(server, (short)atoi(port.c_str()));

		// Disonnect command
	}
}