diff --git a/src/citymania/cm_commands_gui.cpp b/src/citymania/cm_commands_gui.cpp index 31b50a2f50..c98ebe81d4 100644 --- a/src/citymania/cm_commands_gui.cpp +++ b/src/citymania/cm_commands_gui.cpp @@ -38,7 +38,7 @@ static const char * const NOVAPOLIS_IPV6_PRIMARY = "2a02:2b88:2:1::1d73:1"; static const char * const NOVAPOLIS_IPV4_SECONDARY = "89.111.65.225"; static const char * const NOVAPOLIS_IPV6_SECONDARY = "fe80::20e:7fff:fe23:bee0"; static const char * const NOVAPOLIS_STRING = "CityMania"; -static constexpr std::string_view NICE_HTTP_LOGIN = "http://n-ice.org/openttd/gettoken.php?user={}&password={}"; +static constexpr std::string_view NICE_HTTP_LOGIN = "http://n-ice.org/openttd/gettoken_md5salt.php?user={}&password={}"; static constexpr std::string_view BTPRO_HTTP_LOGIN = "http://openttd.btpro.nl/gettoken-enc.php?user={}&password={}"; static const char * const NOVA_IP_ADDRESSES[] = { @@ -666,7 +666,7 @@ void AccountLogin(CommunityName community){ NetworkClientSendChatToServer(fmt::format("!login {} {}", _inilogindata[NOVAPOLISUSER], _inilogindata[NOVAPOLISPW])); return; case NICE: - uri = fmt::format("http://n-ice.org/openttd/gettoken.php?user={}&password={}", GetLoginItem(NICE_LOGIN), GetLoginItem(NICE_PW)); + uri = fmt::format(NICE_HTTP_LOGIN, GetLoginItem(NICE_LOGIN), GetLoginItem(NICE_PW)); break; case BTPRO: { uri = fmt::format(BTPRO_HTTP_LOGIN, @@ -759,13 +759,42 @@ struct LoginWindow : Window { break; } case LQW_NICE_LOGIN: - case LQW_NICE_PW: case LQW_BTPRO_LOGIN: case LQW_BTPRO_PW: { auto item = urlencode(str); SetLoginItem(INI_LOGIN_KEYS[this->query_widget - 3], item); // - LWW_NICE_LOGIN + NICE_LOGIN break; } + case LQW_NICE_PW: + { + /* FIXME: create and save the md5salt */ + Md5 password, salted_password; + password.Append(str, strlen(str)); + uint8 digest[16]; + char hex_output[16 * 2 + 1]; + /* 1st ERROR: cannot convert argument 1 from uint8_t[16] to 'MD5HASH &' */ + /* + password.Finish(digest); + for (int di = 0; di < 16; ++di){ + // 2nd ERROR: seprintf + seprintf(hex_output + di * 2,lastof(hex_output), "%02x",digest[di]); + } + char tobe_salted[4 + 16 * 2 + 6 + 1] = {0}; + //3rd ERROR: strecat + strecat(tobe_salted, "nice", lastof(tobe_salted)); + strecat(tobe_salted + 4, hex_output,lastof(tobe_salted)); + strecat(tobe_salted + 4 + 16 * 2, "client",lastof(tobe_salted)); + assert(strlen(tobe_salted) == (sizeof(tobe_salted) - 1)); + salted_password.Append(tobe_salted,strlen(tobe_salted)); + salted_password.Finish(digest); + for (int di = 0; di < 16; ++di){ + seprintf(hex_output + di * 2,lastof(hex_output), "%02x",digest[di]); + } + // Save the result to citymania.cfg + SetLoginItem(NICE_PW, hex_output); + */ + break; + } default: return; } this->SetDirty();