Page 1 of 1

Question about username

Posted: Mon 23.11.2009, 10:16
by Question
Greetings.

How to change username, which shows in the game under the "Players" menu ("@") in the "user name@computer name" form (I guess it's like that)?
I tried different ways, but was able to change only the computer name part.

Re: Question about username

Posted: Mon 23.11.2009, 12:40
by PowerWyrm
The name is taken directly from your session user name. If you're under Windows (family edition), you're probably using the default session. Try to close your session and open a new session with a real user name.

Re: Question about username

Posted: Fri 27.11.2009, 21:07
by Thorbear
In windows, I'd assume the most simple explanation is:
"user name@computer name"
'User name' is the name you log into windows with
'Computer name' is the name you give your computer in the network settings.

Re: Question about username

Posted: Mon 30.11.2009, 08:41
by Question
Zaxx wrote:Try to close your session and open a new session
Yes, creating new user profile and logging with it does change the username in Mangband, but I want to keep my current user profile.
Thorbear wrote:'User name' is the name you log into windows with
I tried changing my username in Windows (it doesn't, however, changed the name of the x:\Documents And Settings\username folder, so probably I did something wrong) changing owner' name in registry, but Mangband still take my "old" username out of somewhere.

I tried to search in source code to determine what it does to get username, but got stuck.
I found what function get called if "@" is pressed, in /client/c-cmd.c

Code: Select all

		case '@':
		{
			cmd_players();
			break;
		}
...
void cmd_players(void)
{
	/* Set the hook */
	special_line_type = SPECIAL_FILE_PLAYER;
Then, in /server/netserver.c

Code: Select all

			case SPECIAL_FILE_PLAYER:
				do_cmd_check_players(player, line);
This function is declared in /server/cmd4.c

Code: Select all

void do_cmd_check_players(int Ind, int line)
...
		fprintf(fff, "         %s@%s\n", q_ptr->realname, q_ptr->hostname); 
I found the 'player_type' structure declaration being stored in /common/types.h

Code: Select all

struct player_type
{
	char basename[MAX_CHARS];
	char realname[MAX_CHARS];	/* Userid */
	char hostname[MAX_CHARS];	/* His hostname */ 
And this array is filled in /server/netserver.c

Code: Select all

	strcpy(p_ptr->realname, connp->real);
	strcpy(p_ptr->hostname, connp->host);
...
connp->real = strdup(real);
And this is where I got stuck. Search for 'real', 'host', 'connp' or 'connection_t' gets me nowhere.

Re: Question about username

Posted: Mon 30.11.2009, 12:21
by PowerWyrm
The code is in the client (c-init.c):

Code: Select all

/*
 * Initialize everything, contact the server, and start the loop.
 */
void client_init(char *argv1)
{
...
    /* Get user name */
    if (GetUserName(buffer, &nSize))
    {
        buffer[16] = '\0';
        my_strcpy(real_name, buffer, sizeof(real_name));
    }
}
If you want to hack your client to display anything instead of the default user name, simply change that part of code.

Re: Question about username

Posted: Mon 30.11.2009, 13:09
by Thorbear
Question wrote:I tried changing my username in Windows (it doesn't, however, changed the name of the x:\Documents And Settings\username folder, so probably I did something wrong) changing owner' name in registry, but Mangband still take my "old" username out of somewhere.
Changing the name of your user folder in windows will not change your username (however it might cause quite a few shortcuts in windows to fail).
If you wish to change your windows user account name, you do so through "User Accounts" in the Control Panel.

But if you want to keep your user account name, you'll just have to accept that it's showed in the game.
(Or change the source, but I don't see how this is a "problem" that is so important that changing the source is useful).

Re: Question about username

Posted: Mon 30.11.2009, 15:38
by Question
Zaxx wrote:The code is in the client (c-init.c):
If you want to hack your client to display anything instead of the default user name, simply change that part of code.
Thank you very much! It works!
One more question: can I play on the main server with this modified version of client? I can't find anything related to this not in rules or on forum.
Thorbear wrote:If you wish to change your windows user account name, you do so through "User Accounts" in the Control Panel.
Sorry, I didn't make myself clear enough. I did change the username through the control panel, but even after reboot, my folder in the "Documents and Settings" remained unchanged and new one (with new name) wasn't created. It's not a problem, just a small nuisance, which I thought would be quick to correct.

Re: Question about username

Posted: Fri 04.12.2009, 12:13
by Ace
Actually for the sake of privacy this should not be shown.... also imagine if some people have offensive accountnames.

Not happened yet, but it might be good to show the hostname only to administrators or not at all.

Re: Question about username

Posted: Wed 16.12.2009, 12:21
by Question
Question wrote:One more question: can I play on the main server with this modified version of client? I can't find anything related to this not in rules or on forum.
Anyone?

Re: Question about username

Posted: Wed 16.12.2009, 12:24
by PowerWyrm
I'd say yes...

Re: Question about username

Posted: Wed 23.12.2009, 17:36
by Question
Ok, thanks.