Page 1 of 1

account_id == 0

Posted: Thu Jan 08, 2015 4:53 pm
by Lokked
I'm at work, just providing what information I know before I forget:

This function handles received packets from the VGO Client to the WorldServer, prior to connecting to a Chunk Server (where a user could potentially create a character).

Here the packet contains the account ID that is set on the Client. I'm guessing Login Server tells the Client at some point what ID they are. I'll continue looking.

Code: Select all

void Net::HandleNewSession(shared_ptr<Client>& client, PacketStruct *packet_struct) {
    const char *account_id, *session_id;

    account_id = packet_struct->GetString32("AccountId");
    session_id = packet_struct->GetString32("SessionId");

    LogInfo(LOG_NET, 0, "New Session: Account ID: %s  Session ID: '%s'", account_id, session_id);

    client->SetAccountID(atoul(account_id));
    client->SetSessionID(session_id);

    //We know need to request the account name from login :/
    //Yeah, it's the only way to do it since world does not have access to login's database.
    //Once we get the account info, do the rest in SendAccountInfo below
    login.SendAccountInfoRequest(client->GetAccountID(), client->GetConnectionID());
}

Re: account_id == 0

Posted: Thu Jan 08, 2015 4:56 pm
by Lokked
From Login, this is where the Client object first receives it's account_id:

Code: Select all

bool LoginDatabase::LoadAccountInfo(shared_ptr<Client>& client) {
	DatabaseResult result;
    char *session_id_esc = NULL;
    bool success = true;

    if ((session_id_esc = database.Escape(client->GetSessionID())) == NULL)
        return false;

	LogDebug(LOG_ACCOUNT, 0, "Loading Account info...");

	success = database.Select(&result, "SELECT a.`account_id`,a.`account_name`\n"
                                       "FROM `ls_sessions` s\n"
                                       "INNER JOIN `ls_accounts` a ON a.`account_id`=s.`session_account_id`\n"
                                       "WHERE s.`session_id`='%s'", session_id_esc);

    free(session_id_esc);

    if (!success) {
        LogError(LOG_DATABASE, 0, "Error getting account information for session ID '%s': %s", client->GetSessionID(), database.GetError());
        return false;
    }

    if (!result.Next()) {
        LogError(LOG_DATABASE, 0, "No account information found for session ID '%s'", client->GetSessionID());
        LogError(LOG_DATABASE, 0, "If you're testing, simply create an entry in the session table with the session ID '%s'", client->GetSessionID());
        return false;
    }

    client->SetAccountID(result.GetUInt32(0));
    client->SetAccountName(result.GetString(1));
	
	LogDebug(LOG_ACCOUNT, 0, "Loaded Account: %s (%u)", client->GetAccountName(), client->GetAccountID());

	return true;
}
Table ls_accounts.account_id

Re: account_id == 0

Posted: Fri Jan 09, 2015 7:27 pm
by John Adams
Yes, and from a database perspective, it is 100% impossible to create an ls_accounts.account_id of 0 (zero), because it is an auto-increment (for one) and a PK.

Has to be after the account fetch that the connected client is losing it's account_id.

Re: account_id == 0

Posted: Sun Jan 11, 2015 12:13 pm
by John Adams
Here's something interesting from LoginServer log: I hadn't noticed this before. Just happened.

[quote]12:10:29.604 D Net Received character create request...
12:10:29.604 D Net -- Char: 'Tyber', Acct: 443, To World 'New Telon'
12:10:29.604 D Net -- Sending request to world...
12:10:29.604 D Net -- SUCCESS!
12:10:29.604 D WSList Character Request Added: 'Tyber Valens' (0)
12:10:29.604 E TCP Error writing TCP data: client does not exist[/quote]
Still no account_id = 0 in the DB yet though, so could be related to my taking NT down while this player was trying to create a character.