Ejemplo n.º 1
0
void LoginManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result)
{
  // Stupid simple hack since we don't have a client for this query
  if (ref == (void*)1)
  {
    _updateServerStatus(result);
    return;
  }

  // This assumes only authentication calls are async right now.  Will change as needed.
  LoginClient* client = (LoginClient*)ref;

  switch (client->getState())
  {
	  case LCSTATE_QueryAuth:
		{
		  // Check authentication
		  _authenticateClient(client, result);
		  break;
		}
	  case LCSTATE_QueryServerList:
		{
		  // Auth was successful, now send the server list.
		  _sendServerList(client, result);

		  // Execute our query
		  client->setState(LCSTATE_QueryCharacterList);
		  mDatabase->ExecuteSqlAsync(this, ref, "SELECT characters.id, characters.firstname, characters.lastname, characters.galaxy_id, character_appearance.base_model_string  FROM characters JOIN (character_appearance) ON (characters.id = character_appearance.character_id) WHERE characters.account_id=%u AND characters.archived=0;", client->getAccountId());
		  break;
		}
	  case LCSTATE_QueryCharacterList:
		{
		  // Query done for the character list, send it out.
		  _sendCharacterList(client, result);
		  break;
		}
		case LCSTATE_DeleteCharacter:
		{
			// TODO: check returncodes, when using sf
			DataBinding* binding = mDatabase->CreateDataBinding(1);
			binding->addField(DFT_uint32,0,4);

			uint32 queryResult;
			result->GetNextRow(binding,&queryResult);

			uint32 deleteFailed = 1;
			if (queryResult == 1)
			{
				deleteFailed = 0;
			}
			mDatabase->DestroyDataBinding(binding);

			_sendDeleteCharacterReply(deleteFailed,client);

			// _sendDeleteCharacterReply(0,client);
		}
		break;

		default:break;
   }
}
Ejemplo n.º 2
0
//======================================================================================================================
void LoginManager::handleDatabaseJobComplete(void* ref, DatabaseResult* result)
{
    // Stupid simple hack since we don't have a client for this query
    if (ref == (void*)1)
    {
        _updateServerStatus(result);
        return;
    }

    // This assumes only authentication calls are async right now.  Will change as needed.
    LoginClient* client = (LoginClient*)ref;

    switch (client->getState())
    {
    case LCSTATE_QueryAuth:
    {
        // Check authentication
        _authenticateClient(client, result);
        break;
    }
    case LCSTATE_QueryServerList:
    {
        // Auth was successful, now send the server list.
        _sendServerList(client, result);

        // Execute our query
        client->setState(LCSTATE_QueryCharacterList);
        mDatabase->executeProcedureAsync(this, ref, "CALL %s.sp_ReturnAccountCharacters(%u);",mDatabase->galaxy(), client->getAccountId());
       
        break;
    }
    case LCSTATE_QueryCharacterList:
    {
        // Query done for the character list, send it out.
        _sendCharacterList(client, result);
        break;
    }
    case LCSTATE_DeleteCharacter:
    {
        // TODO: check returncodes, when using sf
        DataBinding* binding = mDatabase->createDataBinding(1);
        binding->addField(DFT_uint32,0,4);

        uint32 queryResult;
        result->getNextRow(binding,&queryResult);

        uint32 deleteFailed = 1;
        if (queryResult == 1)
        {
            deleteFailed = 0;
        }
        mDatabase->destroyDataBinding(binding);

        _sendDeleteCharacterReply(deleteFailed,client);

        // _sendDeleteCharacterReply(0,client);
    }
    case LCSTATE_RetrieveAccountId:
    {
        //check to see if we have an account id
        _getLauncherSessionKey(client, result);
        break;
    }
    case LCSTATE_RetrieveSessionKey:
    {
        //should have a session key now
        _sendLauncherSessionKey(client, result);
        break;
    }
    break;

    default:
        break;
    }
}