From a203345897cdd5c8402837e5552569722bbce06d Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 4 Mar 2013 00:41:39 +0100 Subject: [PATCH] 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. --- neo/framework/CVarSystem.h | 1 + neo/framework/Common.cpp | 2 +- neo/sys/posix/posix_signin.cpp | 18 ++++++++++++++++-- neo/sys/win32/win_signin.cpp | 17 ++++++++++++++--- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/neo/framework/CVarSystem.h b/neo/framework/CVarSystem.h index 00144b2b..ac3e66eb 100644 --- a/neo/framework/CVarSystem.h +++ b/neo/framework/CVarSystem.h @@ -91,6 +91,7 @@ typedef enum CVAR_GUI = BIT( 6 ), // gui variable CVAR_GAME = BIT( 7 ), // game 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_NETWORKSYNC = BIT( 11 ), // cvar is synced from the server to clients CVAR_STATIC = BIT( 12 ), // statically declared, not user created diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index cae1294c..df870e7d 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -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" ); // 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 extern idCVar g_demoMode; diff --git a/neo/sys/posix/posix_signin.cpp b/neo/sys/posix/posix_signin.cpp index 94716771..95866b1d 100644 --- a/neo/sys/posix/posix_signin.cpp +++ b/neo/sys/posix/posix_signin.cpp @@ -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" ); #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 @@ -106,9 +111,16 @@ void idSignInManagerWin::RegisterLocalUser( int inputDevice ) } 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 ); 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(); localUser.Init( inputDevice, name.c_str(), localUsers.Num() ); diff --git a/neo/sys/win32/win_signin.cpp b/neo/sys/win32/win_signin.cpp index 247347e2..a072cab8 100644 --- a/neo/sys/win32/win_signin.cpp +++ b/neo/sys/win32/win_signin.cpp @@ -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" ); #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 @@ -104,10 +109,16 @@ void idSignInManagerWin::RegisterLocalUser( int inputDevice ) } static char machineName[128]; - DWORD len = 128; - ::GetComputerName( machineName, &len ); + // DG: support for ui_name + 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 ); int nameLength = name.Length();