uniformly used 'nick' instead of 'username' and display the nick in question

This commit is contained in:
Gunter Labes 2009-02-11 23:16:10 +00:00
parent ba01d9f46b
commit 7dc056daa2
2 changed files with 21 additions and 19 deletions

View file

@ -328,27 +328,29 @@ static server_type open_connection(game_display& disp, const std::string& origin
// enter a new user name and/or password
std::string error_message;
utils::string_map i18n_symbols;
i18n_symbols["nick"] = login;
if((*error)["error_code"] == MP_UNKNOWN_ERROR) {
error_message = _("Unknown error.");
} else if((*error)["error_code"] == MP_MUST_LOGIN) {
error_message = _("You must login first.");
} else if((*error)["error_code"] == MP_NAME_TAKEN_ERROR) {
error_message = _("The username you chose is already taken.");
error_message = vgettext("The nick '$nick' is already taken.", i18n_symbols);
} else if((*error)["error_code"] == MP_INVALID_CHARS_IN_NAME_ERROR) {
error_message = _("This username contains invalid "
error_message = vgettext("The nick '$nick' contains invalid "
"characters. Only alpha-numeric characters, underscores and "
"hyphens are allowed.");
"hyphens are allowed.", i18n_symbols);
} else if((*error)["error_code"] == MP_NAME_TOO_LONG_ERROR) {
error_message = _("This username is too long. Usernames must "
"be 18 characers or less.");
error_message = vgettext("The nick '$nick' is too long. Nicks must "
"be 18 characers or less.", i18n_symbols);
} else if((*error)["error_code"] == MP_NAME_RESERVED_ERROR) {
error_message = _("The nick you chose is reserved and cannot be used by players");
error_message = vgettext("The nick '$nick' is reserved and cannot be used by players.", i18n_symbols);
} else if((*error)["error_code"] == MP_PASSWORD_REQUEST) {
error_message = _("This username is registered on this server.");
error_message = vgettext("The nick '$nick' is registered on this server.", i18n_symbols);
} else if((*error)["error_code"] == MP_PASSWORD_REQUEST_FOR_LOGGED_IN_NAME) {
error_message = _("This username is registered on this server."
"\n \nWARNING: There is already a client using this username, "
error_message = vgettext("The nick '$nick' is registered on this server.", i18n_symbols)
+ "\n\n" + _("WARNING: There is already a client using this nick, "
"logging in will cause that client to be kicked!");
} else if((*error)["error_code"] == MP_NO_SEED_ERROR) {
error_message = _("Error in the login procedure (the server had no "

View file

@ -1006,13 +1006,13 @@ void server::process_login(const network::connection sock,
// Check if the username is valid (all alpha-numeric plus underscore and hyphen)
std::string username = (*login)["username"].to_string();
if (!utils::isvalid_username(username)) {
send_error(sock, "This username contains invalid "
send_error(sock, ("The nick '" + username + "' contains invalid "
"characters. Only alpha-numeric characters, underscores and hyphens"
"are allowed.", MP_INVALID_CHARS_IN_NAME_ERROR);
"are allowed.").c_str(), MP_INVALID_CHARS_IN_NAME_ERROR);
return;
}
if (username.size() > 18) {
send_error(sock, "This username is too long. Usernames must be 18 characers or less.",
send_error(sock, ("The nick '" + username + "' is too long. Nicks must be 18 characers or less.").c_str(),
MP_NAME_TOO_LONG_ERROR);
return;
}
@ -1023,7 +1023,7 @@ void server::process_login(const network::connection sock,
if (utils::wildcard_string_match(utils::lowercase(username),
utils::lowercase(*d_it)))
{
send_error(sock, "The nick you chose is reserved and cannot be used by players",
send_error(sock, ("The nick '" + username + "' is reserved and cannot be used by players").c_str(),
MP_NAME_RESERVED_ERROR);
return;
}
@ -1071,11 +1071,11 @@ void server::process_login(const network::connection sock,
// This name is registered and no password provided
if(password.empty()) {
if(p == players_.end()) {
send_password_request(sock, ("The username '" + username +"' is registered on this server.").c_str(),
send_password_request(sock, ("The nick '" + username +"' is registered on this server.").c_str(),
username, MP_PASSWORD_REQUEST);
} else {
send_password_request(sock, ("The username '" + username + "' is registered on this server."
"\n \nWARNING: There is already a client using this username, "
send_password_request(sock, ("The nick '" + username + "' is registered on this server."
"\n\nWARNING: There is already a client using this username, "
"logging in will cause that client to be kicked!").c_str(),
username, MP_PASSWORD_REQUEST_FOR_LOGGED_IN_NAME, true);
}
@ -1090,11 +1090,11 @@ void server::process_login(const network::connection sock,
else if(!(user_handler_->login(username, password, seeds_[sock]))) {
// Reset the random seed
seeds_.erase(sock);
send_password_request(sock, ("The password you provided for the username '" + username +
send_password_request(sock, ("The password you provided for the nick '" + username +
"' was incorrect.").c_str(), username, MP_INCORRECT_PASSWORD_ERROR);
LOG_SERVER << network::ip_address(sock) << "\t"
<< "Login attempt with incorrect password for username '" << username << "'.\n";
<< "Login attempt with incorrect password for nick '" << username << "'.\n";
return;
}
// This name exists and the password was neither empty nor incorrect
@ -1110,7 +1110,7 @@ void server::process_login(const network::connection sock,
// If there is already a client using this username kick it
process_command("kick " + p->second.name() + " autokick by registered user", username);
} else {
send_error(sock, "The username you chose is already taken.", MP_NAME_TAKEN_ERROR);
send_error(sock, ("The nick '" + username + "' is already taken.").c_str(), MP_NAME_TAKEN_ERROR);
return;
}
}