From f0a1379e5a9ebc954e95d07c1ad5d71587adc6bc Mon Sep 17 00:00:00 2001 From: est31 Date: Fri, 17 Apr 2015 06:10:30 +0200 Subject: Refactor around translatePassword Change types for passed password from wstring to string, which removes converting back and forth in most cases. Move the narrow_to_wide conversion, where its neccessary, closer to irrlicht. Remove trailing spaces in guiPasswordChange.cpp. Make parameters for translatePassword passed as const reference. --- src/util/string.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/util/string.cpp') diff --git a/src/util/string.cpp b/src/util/string.cpp index 02a0586e7..c0f0e97fd 100644 --- a/src/util/string.cpp +++ b/src/util/string.cpp @@ -181,12 +181,13 @@ std::string wide_to_narrow(const std::wstring &wcs) // their password. (Exception : if the password field is // blank, we send a blank password - this is for backwards // compatibility with password-less players). -std::string translatePassword(std::string playername, std::wstring password) +std::string translatePassword(const std::string &playername, + const std::string &password) { if (password.length() == 0) return ""; - std::string slt = playername + wide_to_narrow(password); + std::string slt = playername + password; SHA1 sha1; sha1.addBytes(slt.c_str(), slt.length()); unsigned char *digest = sha1.getDigest(); -- cgit v1.2.3