mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Prevent world creation if the world already exists
This commit is contained in:
parent
5dd1d354f8
commit
c8895dd43b
@ -48,9 +48,22 @@ struct CreateWorldDestMainMenu : public CreateWorldDest
|
||||
{}
|
||||
void accepted(std::wstring name, std::string gameid)
|
||||
{
|
||||
if(!string_allowed_blacklist(wide_to_narrow(name), WORLDNAME_BLACKLISTED_CHARS))
|
||||
std::string name_narrow = wide_to_narrow(name);
|
||||
if(!string_allowed_blacklist(name_narrow, WORLDNAME_BLACKLISTED_CHARS))
|
||||
{
|
||||
m_menu->displayMessageMenu(wgettext("Cannot create world: Name contains invalid characters"));
|
||||
else
|
||||
return;
|
||||
}
|
||||
std::vector<WorldSpec> worlds = getAvailableWorlds();
|
||||
for(std::vector<WorldSpec>::iterator i = worlds.begin();
|
||||
i != worlds.end(); i++)
|
||||
{
|
||||
if((*i).name == name_narrow)
|
||||
{
|
||||
m_menu->displayMessageMenu(wgettext("Cannot create world: A world by this name already exists"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_menu->createNewWorld(name, gameid);
|
||||
}
|
||||
GUIMainMenu *m_menu;
|
||||
|
Loading…
Reference in New Issue
Block a user