Make rename unit reset the name if it becomes completely empty.

develop
Alexander Gavrilov 2012-12-08 20:39:57 +04:00
parent 10667dfb9e
commit a0e671d75d
1 changed files with 15 additions and 0 deletions

@ -115,6 +115,9 @@ void Translation::setNickname(df::language_name *name, std::string nick)
if (!name->has_name)
{
if (nick.empty())
return;
*name = df::language_name();
name->language = 0;
@ -122,6 +125,18 @@ void Translation::setNickname(df::language_name *name, std::string nick)
}
name->nickname = nick;
// If the nick is empty, check if this made the whole name empty
if (name->nickname.empty() && name->first_name.empty())
{
bool has_words = false;
for (int i = 0; i < 7; i++)
if (name->words[i] >= 0)
has_words = true;
if (!has_words)
name->has_name = false;
}
}
string Translation::TranslateName(const df::language_name * name, bool inEnglish, bool onlyLastPart)