Question about username

All your questions answered.
Post Reply
Question
Singing, Happy Drunk
Posts: 5
Joined: Mon 23.11.2009, 09:35

Question about username

Post by Question » Mon 23.11.2009, 10:16

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.

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Question about username

Post by PowerWyrm » Mon 23.11.2009, 12:40

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.

Thorbear
Two-Headed Troll
Posts: 131
Joined: Wed 12.01.2005, 15:00
Contact:

Re: Question about username

Post by Thorbear » Fri 27.11.2009, 21:07

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.
I am Thorbear...

Question
Singing, Happy Drunk
Posts: 5
Joined: Mon 23.11.2009, 09:35

Re: Question about username

Post by Question » Mon 30.11.2009, 08:41

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.

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Question about username

Post by PowerWyrm » Mon 30.11.2009, 12:21

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.

Thorbear
Two-Headed Troll
Posts: 131
Joined: Wed 12.01.2005, 15:00
Contact:

Re: Question about username

Post by Thorbear » Mon 30.11.2009, 13:09

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).
I am Thorbear...

Question
Singing, Happy Drunk
Posts: 5
Joined: Mon 23.11.2009, 09:35

Re: Question about username

Post by Question » Mon 30.11.2009, 15:38

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.

Ace
Crystal Ooze
Posts: 368
Joined: Fri 15.02.2008, 12:50

Re: Question about username

Post by Ace » Fri 04.12.2009, 12:13

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.

Question
Singing, Happy Drunk
Posts: 5
Joined: Mon 23.11.2009, 09:35

Re: Question about username

Post by Question » Wed 16.12.2009, 12:21

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?

PowerWyrm
Balrog
Posts: 1574
Joined: Sun 27.11.2005, 15:57

Re: Question about username

Post by PowerWyrm » Wed 16.12.2009, 12:24

I'd say yes...

Question
Singing, Happy Drunk
Posts: 5
Joined: Mon 23.11.2009, 09:35

Re: Question about username

Post by Question » Wed 23.12.2009, 17:36

Ok, thanks.

Post Reply