Configurable username for Multi-Player (ui_name), com_pause no cheat

D3BFG gets the username from Steam, in the GPL release it just
uses the hostname.
Now it's possible to set a custom name with the ui_name CVAR
(like in classic doom3). If ui_name is empty ("") the hostname
is used.

The window losing focus in MP resulted in the console being spammed
with "changing com_pause not allowed in Multi Player" (or similar)
messages. Added CVAR_NOCHEAT flag to com_pause to get rid of that.
This commit is contained in:
Daniel Gibson 2013-03-04 00:41:39 +01:00
parent 4040a3a9ef
commit a203345897
4 changed files with 32 additions and 6 deletions

View file

@ -91,6 +91,7 @@ typedef enum
CVAR_GUI = BIT( 6 ), // gui variable CVAR_GUI = BIT( 6 ), // gui variable
CVAR_GAME = BIT( 7 ), // game variable CVAR_GAME = BIT( 7 ), // game variable
CVAR_TOOL = BIT( 8 ), // tool variable CVAR_TOOL = BIT( 8 ), // tool variable
// original doom3 used to have CVAR_USERINFO ("sent to servers, available to menu") here
CVAR_SERVERINFO = BIT( 10 ), // sent from servers, available to menu CVAR_SERVERINFO = BIT( 10 ), // sent from servers, available to menu
CVAR_NETWORKSYNC = BIT( 11 ), // cvar is synced from the server to clients CVAR_NETWORKSYNC = BIT( 11 ), // cvar is synced from the server to clients
CVAR_STATIC = BIT( 12 ), // statically declared, not user created CVAR_STATIC = BIT( 12 ), // statically declared, not user created

View file

@ -89,7 +89,7 @@ idCVar preload_CommonAssets( "preload_CommonAssets", "1", CVAR_SYSTEM | CVAR_BOO
idCVar net_inviteOnly( "net_inviteOnly", "1", CVAR_BOOL | CVAR_ARCHIVE, "whether or not the private server you create allows friends to join or invite only" ); idCVar net_inviteOnly( "net_inviteOnly", "1", CVAR_BOOL | CVAR_ARCHIVE, "whether or not the private server you create allows friends to join or invite only" );
// DG: add cvar for pause // DG: add cvar for pause
idCVar com_pause( "com_pause", "0", CVAR_BOOL | CVAR_SYSTEM , "set to 1 to pause game, to 0 to unpause again" ); idCVar com_pause( "com_pause", "0", CVAR_BOOL | CVAR_SYSTEM | CVAR_NOCHEAT, "set to 1 to pause game, to 0 to unpause again" );
// DG end // DG end
extern idCVar g_demoMode; extern idCVar g_demoMode;

View file

@ -41,6 +41,11 @@ idCVar win_isInParty( "win_isInParty", "0", CVAR_BOOL, "debugging cvar for platf
idCVar win_partyCount( "win_partyCount", "0", CVAR_INTEGER, "debugginc var for platform party count" ); idCVar win_partyCount( "win_partyCount", "0", CVAR_INTEGER, "debugginc var for platform party count" );
#endif #endif
// DG: D3BFG got the username from steam, in the GPL release it just uses the hostname.
// this adds a name to set a player name
idCVar ui_name( "ui_name", "", CVAR_ARCHIVE, "player name - leave empty for default name (system's hostname)" );
// DG end
/* /*
======================== ========================
idSignInManagerWin::Shutdown idSignInManagerWin::Shutdown
@ -106,9 +111,16 @@ void idSignInManagerWin::RegisterLocalUser( int inputDevice )
} }
static char machineName[128]; static char machineName[128];
gethostname( machineName, sizeof( machineName ) ); // DG: support for ui_name
const char* nameSource = ui_name.GetString();
const char* nameSource = machineName; if( idStr::Length( nameSource ) == 0 )
{
// ui_name was empty => default to hostname
gethostname( machineName, sizeof( machineName ) );
nameSource = machineName;
}
// DG end
idStr name( nameSource ); idStr name( nameSource );
int nameLength = name.Length(); int nameLength = name.Length();
@ -124,6 +136,8 @@ void idSignInManagerWin::RegisterLocalUser( int inputDevice )
} }
} }
idLib::Printf( "Added local user: %s\n", name.c_str() );
idLocalUserWin& localUser = *localUsers.Alloc(); idLocalUserWin& localUser = *localUsers.Alloc();
localUser.Init( inputDevice, name.c_str(), localUsers.Num() ); localUser.Init( inputDevice, name.c_str(), localUsers.Num() );

View file

@ -39,6 +39,11 @@ idCVar win_isInParty( "win_isInParty", "0", CVAR_BOOL, "debugging cvar for platf
idCVar win_partyCount( "win_partyCount", "0", CVAR_INTEGER, "debugginc var for platform party count" ); idCVar win_partyCount( "win_partyCount", "0", CVAR_INTEGER, "debugginc var for platform party count" );
#endif #endif
// DG: D3BFG got the username from steam, in the GPL release it just uses the hostname.
// this adds a name to set a player name
idCVar ui_name( "ui_name", "", CVAR_ARCHIVE, "player name - leave empty for default name (system's hostname)" );
// DG end
/* /*
======================== ========================
idSignInManagerWin::Shutdown idSignInManagerWin::Shutdown
@ -104,10 +109,16 @@ void idSignInManagerWin::RegisterLocalUser( int inputDevice )
} }
static char machineName[128]; static char machineName[128];
DWORD len = 128; // DG: support for ui_name
::GetComputerName( machineName, &len ); const char* nameSource = ui_name.GetString();
const char* nameSource = machineName; if( idStr::Length( nameSource ) == 0 )
{
DWORD len = 128;
::GetComputerName( machineName, &len );
nameSource = machineName;
}
// DG end
idStr name( nameSource ); idStr name( nameSource );
int nameLength = name.Length(); int nameLength = name.Length();