Don't allow whitespace player names, closes #840

dev-buzzingcars
krzys-h 2016-11-11 17:13:32 +01:00
parent 6e4764b97c
commit 856ee9a0fe
2 changed files with 5 additions and 1 deletions

View File

@ -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;

View File

@ -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);