From cec8d75b7dfe33ffd0b4824eac6517487ae6f4c0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 14 Jan 2024 20:10:50 +0300 Subject: [PATCH] added content error message screen on world creation --- src/frontend/menu.cpp | 12 ++++++++++-- src/logic/scripting/api_lua.cpp | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontend/menu.cpp b/src/frontend/menu.cpp index 0cc216df..e8ab749c 100644 --- a/src/frontend/menu.cpp +++ b/src/frontend/menu.cpp @@ -280,10 +280,18 @@ void create_new_world_panel(Engine* engine, PagesControl* menu) { std::cout << "world seed: " << seed << std::endl; auto folder = paths->getWorldsFolder()/fs::u8path(nameutf8); + + try { + engine->loadAllPacks(); + engine->loadContent(); + } catch (const std::runtime_error& error) { + guiutil::alert(engine->getGUI(), + langs::get(L"Content Error", L"menu")+ + L": "+util::str2wstr_utf8(error.what())); + return; + } fs::create_directories(folder); - engine->loadAllPacks(); - engine->loadContent(); Level* level = World::create( nameutf8, folder, seed, engine->getSettings(), diff --git a/src/logic/scripting/api_lua.cpp b/src/logic/scripting/api_lua.cpp index f2450c9d..a73c966e 100644 --- a/src/logic/scripting/api_lua.cpp +++ b/src/logic/scripting/api_lua.cpp @@ -14,13 +14,11 @@ #include "../../lighting/Lighting.h" #include "../../logic/BlocksController.h" -#if (LUA_VERSION_NUM < 502) inline void luaL_openlib(lua_State* L, const char* name, const luaL_Reg* libfuncs, int nup) { lua_newtable(L); luaL_setfuncs(L, libfuncs, nup); lua_setglobal(L, name); } -#endif /* == world library ==*/ static int l_world_get_day_time(lua_State* L) {