/* ======================== idSignInManagerWin::RegisterLocalUser ======================== */ void idSignInManagerWin::RegisterLocalUser( int inputDevice ) { if ( GetLocalUserByInputDevice( inputDevice ) != NULL ) { return; } static char machineName[128]; DWORD len = 128; ::GetComputerName( machineName, &len ); const char * nameSource = machineName; idStr name( nameSource ); int nameLength = name.Length(); if ( idStr::IsValidUTF8( nameSource, nameLength ) ) { int nameIndex = 0; int numChars = 0; name.Empty(); while ( nameIndex < nameLength && numChars++ < idLocalUserWin::MAX_GAMERTAG_CHARS ) { uint32 c = idStr::UTF8Char( nameSource, nameIndex ); name.AppendUTF8Char( c ); } } idLocalUserWin & localUser = *localUsers.Alloc(); localUser.Init( inputDevice, name.c_str(), localUsers.Num() ); localUser.SetLocalUserHandle( GetUniqueLocalUserHandle( localUser.GetGamerTag() ) ); session->OnLocalUserSignin( &localUser ); }
/* ======================== idSignInManagerWin::RegisterLocalUser ======================== */ void idSignInManagerWin::RegisterLocalUser( int inputDevice ) { if( GetLocalUserByInputDevice( inputDevice ) != NULL ) { return; } static char machineName[128]; // DG: support for ui_name const char* nameSource = ui_name.GetString(); if( idStr::Length( nameSource ) == 0 ) { // ui_name was empty => default to hostname #ifdef _WIN32 DWORD len = 128; ::GetComputerName( machineName, &len ); #else gethostname( machineName, sizeof( machineName ) ); #endif nameSource = machineName; } // DG end idStr name( nameSource ); int nameLength = name.Length(); if( idStr::IsValidUTF8( nameSource, nameLength ) ) { int nameIndex = 0; int numChars = 0; name.Empty(); while( nameIndex < nameLength && numChars++ < idLocalUserWin::MAX_GAMERTAG_CHARS ) { uint32 c = idStr::UTF8Char( nameSource, nameIndex ); name.AppendUTF8Char( c ); } } idLib::Printf( "Added local user: %s\n", name.c_str() ); idLocalUserWin& localUser = *localUsers.Alloc(); localUser.Init( inputDevice, name.c_str(), localUsers.Num() ); localUser.SetLocalUserHandle( GetUniqueLocalUserHandle( localUser.GetGamerTag() ) ); session->OnLocalUserSignin( &localUser ); }