From f91111aec8799ee05bd10502ffcac09eb14c986e Mon Sep 17 00:00:00 2001 From: Deiz Date: Fri, 14 Sep 2012 05:38:29 +0000 Subject: [PATCH] Load default MP player name from the config. This was SVN commit r12673. --- binaries/data/config/default.cfg | 3 +++ source/gui/scripting/ScriptFunctions.cpp | 6 ++++-- source/ps/GameSetup/Config.cpp | 2 ++ source/ps/GameSetup/Config.h | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/binaries/data/config/default.cfg b/binaries/data/config/default.cfg index 529666ad08..1bc370375d 100644 --- a/binaries/data/config/default.cfg +++ b/binaries/data/config/default.cfg @@ -23,6 +23,9 @@ windowed = false ; Pause the game on window focus loss (Only applicable to single player mode) pauseonfocusloss = true +; Default player name to use in multiplayer +; playername = "anonymous" + ; Force a particular resolution. (If these are 0, the default is ; to keep the current desktop resolution in fullscreen mode or to ; use 1024x768 in windowed mode.) diff --git a/source/gui/scripting/ScriptFunctions.cpp b/source/gui/scripting/ScriptFunctions.cpp index d2be90ab32..95c81574f5 100644 --- a/source/gui/scripting/ScriptFunctions.cpp +++ b/source/gui/scripting/ScriptFunctions.cpp @@ -169,8 +169,10 @@ int GetPlayerID(void* UNUSED(cbdata)) std::wstring GetDefaultPlayerName(void* UNUSED(cbdata)) { - // TODO: this should come from a config file or something - std::wstring name = sys_get_user_name(); + std::wstring name = g_PlayerName.FromUTF8(); + if (name.empty()) + name = sys_get_user_name(); + if (name.empty()) name = L"anonymous"; return name; diff --git a/source/ps/GameSetup/Config.cpp b/source/ps/GameSetup/Config.cpp index a2856cc633..7bb7db644c 100644 --- a/source/ps/GameSetup/Config.cpp +++ b/source/ps/GameSetup/Config.cpp @@ -34,6 +34,7 @@ bool g_NoGLAutoMipmap = false; bool g_NoGLVBO = false; bool g_PauseOnFocusLoss = false; +CStr g_PlayerName = ""; bool g_Shadows = false; bool g_ShadowPCF = false; @@ -76,6 +77,7 @@ static void LoadGlobals() CFG_GET_USER_VAL("noautomipmap", Bool, g_NoGLAutoMipmap); CFG_GET_USER_VAL("novbo", Bool, g_NoGLVBO); CFG_GET_USER_VAL("pauseonfocusloss", Bool, g_PauseOnFocusLoss); + CFG_GET_USER_VAL("playername", String, g_PlayerName); CFG_GET_USER_VAL("shadows", Bool, g_Shadows); CFG_GET_USER_VAL("shadowpcf", Bool, g_ShadowPCF); CFG_GET_USER_VAL("fancywater", Bool, g_FancyWater); diff --git a/source/ps/GameSetup/Config.h b/source/ps/GameSetup/Config.h index a160722eb2..758900acbd 100644 --- a/source/ps/GameSetup/Config.h +++ b/source/ps/GameSetup/Config.h @@ -44,6 +44,9 @@ extern bool g_NoGLVBO; // flag to pause the game on window focus loss extern bool g_PauseOnFocusLoss; +// default player name to use in multiplayer +extern CStr g_PlayerName; + // flag to switch on shadows extern bool g_Shadows; // flag to switch on reflective/refractive water