void TestUtilities::testStringAllowed() { UASSERT(string_allowed("hello", "abcdefghijklmno") == true); UASSERT(string_allowed("123", "abcdefghijklmno") == false); UASSERT(string_allowed_blacklist("hello", "123") == true); UASSERT(string_allowed_blacklist("hello123", "123") == false); }
void accepted(std::wstring name, std::string gameid) { std::string name_narrow = wide_to_narrow(name); if(!string_allowed_blacklist(name_narrow, WORLDNAME_BLACKLISTED_CHARS)) { wchar_t* text = wgettext("Cannot create world: Name contains invalid characters"); m_menu->displayMessageMenu(text); delete[] text; return; } std::vector<WorldSpec> worlds = getAvailableWorlds(); for(std::vector<WorldSpec>::iterator i = worlds.begin(); i != worlds.end(); i++) { if((*i).name == name_narrow) { wchar_t* text = wgettext("Cannot create world: A world by this name already exists"); m_menu->displayMessageMenu(text); delete[] text; return; } } m_menu->createNewWorld(name, gameid); }