aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_mainmenu.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-28 13:48:33 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-28 13:48:33 +0100
commiteb6aca8b4a67ef55108231e71ff29a18a29bf5ae (patch)
treef891914d25cae2cdaa24392381436a287340651e /src/script/lua_api/l_mainmenu.cpp
parent8de51dae97aa2fe6ea02e4cf437bfe2b2a38eb06 (diff)
parentf1d72d212a0661588be27003069abf4bd8092e55 (diff)
downloaddragonfireclient-eb6aca8b4a67ef55108231e71ff29a18a29bf5ae.tar.xz
Merged Minetest
Diffstat (limited to 'src/script/lua_api/l_mainmenu.cpp')
-rw-r--r--src/script/lua_api/l_mainmenu.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp
index f32c477c2..0aa2760e9 100644
--- a/src/script/lua_api/l_mainmenu.cpp
+++ b/src/script/lua_api/l_mainmenu.cpp
@@ -29,7 +29,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "porting.h"
#include "filesys.h"
#include "convert_json.h"
-#include "content/packages.h"
#include "content/content.h"
#include "content/subgames.h"
#include "serverlist.h"
@@ -618,7 +617,7 @@ int ModApiMainMenu::l_create_world(lua_State *L)
std::string path = porting::path_user + DIR_DELIM
"worlds" + DIR_DELIM
- + name;
+ + sanitizeDirName(name, "world_");
std::vector<SubgameSpec> games = getAvailableGames();
@@ -626,10 +625,11 @@ int ModApiMainMenu::l_create_world(lua_State *L)
(gameidx < (int) games.size())) {
// Create world if it doesn't exist
- if (!loadGameConfAndInitWorld(path, games[gameidx])) {
- lua_pushstring(L, "Failed to initialize world");
- } else {
+ try {
+ loadGameConfAndInitWorld(path, name, games[gameidx], true);
lua_pushnil(L);
+ } catch (const BaseException &e) {
+ lua_pushstring(L, (std::string("Failed to initialize world: ") + e.what()).c_str());
}
} else {
lua_pushstring(L, "Invalid game index");