[colobot] 11/100: Don't allow whitespace player names, closes #840

Didier Raboud odyx at moszumanska.debian.org
Thu Jun 1 18:10:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 856ee9a0fe7ae60d0106ed70902241d30427270c
Author: krzys-h <krzys_h at interia.pl>
Date:   Fri Nov 11 17:13:32 2016 +0100

    Don't allow whitespace player names, closes #840
---
 src/level/player_profile.cpp           | 2 +-
 src/ui/screen/screen_player_select.cpp | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/level/player_profile.cpp b/src/level/player_profile.cpp
index d3603f1..bedd76c 100644
--- a/src/level/player_profile.cpp
+++ b/src/level/player_profile.cpp
@@ -133,7 +133,7 @@ std::string CPlayerProfile::GetLastName()
 {
     std::string name;
 
-    if(!GetConfigFile().GetStringProperty("Gamer", "LastName", name))
+    if(!GetConfigFile().GetStringProperty("Gamer", "LastName", name) || name.empty())
         GetResource(RES_TEXT, RT_NAME_DEFAULT, name);
 
     return name;
diff --git a/src/ui/screen/screen_player_select.cpp b/src/ui/screen/screen_player_select.cpp
index 4bcd139..e3a9c2f 100644
--- a/src/ui/screen/screen_player_select.cpp
+++ b/src/ui/screen/screen_player_select.cpp
@@ -40,6 +40,8 @@
 #include "ui/controls/list.h"
 #include "ui/controls/window.h"
 
+#include <boost/algorithm/string/trim.hpp>
+
 namespace Ui
 {
 
@@ -245,6 +247,7 @@ void CScreenPlayerSelect::UpdateNameControl()
     total = pl->GetTotal();
     sel   = pl->GetSelect();
     name = pe->GetText(100);
+    boost::trim(name);
 
     pb = static_cast<CButton*>(pw->SearchControl(EVENT_INTERFACE_NDELETE));
     if ( pb != nullptr )
@@ -379,6 +382,7 @@ bool CScreenPlayerSelect::NameCreate()
 
     std::string name;
     name = pe->GetText(100);
+    boost::trim(name);
     if ( name.empty() )
     {
         m_sound->Play(SOUND_TZOING);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list