diff options
author | kwolekr <kwolekr@minetest.net> | 2015-10-04 02:54:25 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-10-04 16:27:50 -0400 |
commit | 0850d3bb930ac5e2cfd71a58fd49725e4c2a4c96 (patch) | |
tree | 15a5f3a2e0e350d6b5ea46caaac104d39d3f5c9b /src/script | |
parent | 1f9c5a4a7b15ab49e717d81162fe58e4202c0814 (diff) | |
download | minetest-0850d3bb930ac5e2cfd71a58fd49725e4c2a4c96.tar.gz minetest-0850d3bb930ac5e2cfd71a58fd49725e4c2a4c96.tar.bz2 minetest-0850d3bb930ac5e2cfd71a58fd49725e4c2a4c96.zip |
Add emerge completion callback mechanism
Major refactor of emerge.cpp and Map::init/finishBlockMake
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 92311d6fc..d28925d5c 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -706,16 +706,13 @@ int ModApiMainMenu::l_set_topleft_text(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_mapgen_names(lua_State *L) { - lua_newtable(L); - - std::list<const char *> names; - EmergeManager::getMapgenNames(names); + std::vector<const char *> names; + EmergeManager::getMapgenNames(&names); - int i = 1; - for (std::list<const char *>::const_iterator - it = names.begin(); it != names.end(); ++it) { - lua_pushstring(L, *it); - lua_rawseti(L, -2, i++); + lua_newtable(L); + for (size_t i = 0; i != names.size(); i++) { + lua_pushstring(L, names[i]); + lua_rawseti(L, -2, i + 1); } return 1; @@ -725,8 +722,8 @@ int ModApiMainMenu::l_get_mapgen_names(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_modpath(lua_State *L) { - std::string modpath - = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "mods" + DIR_DELIM); + std::string modpath = fs::RemoveRelativePathComponents( + porting::path_user + DIR_DELIM + "mods" + DIR_DELIM); lua_pushstring(L, modpath.c_str()); return 1; } @@ -734,8 +731,8 @@ int ModApiMainMenu::l_get_modpath(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_gamepath(lua_State *L) { - std::string gamepath - = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "games" + DIR_DELIM); + std::string gamepath = fs::RemoveRelativePathComponents( + porting::path_user + DIR_DELIM + "games" + DIR_DELIM); lua_pushstring(L, gamepath.c_str()); return 1; } @@ -743,44 +740,46 @@ int ModApiMainMenu::l_get_gamepath(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_texturepath(lua_State *L) { - std::string gamepath - = fs::RemoveRelativePathComponents(porting::path_user + DIR_DELIM + "textures"); + std::string gamepath = fs::RemoveRelativePathComponents( + porting::path_user + DIR_DELIM + "textures"); lua_pushstring(L, gamepath.c_str()); return 1; } int ModApiMainMenu::l_get_texturepath_share(lua_State *L) { - std::string gamepath - = fs::RemoveRelativePathComponents(porting::path_share + DIR_DELIM + "textures"); + std::string gamepath = fs::RemoveRelativePathComponents( + porting::path_share + DIR_DELIM + "textures"); lua_pushstring(L, gamepath.c_str()); return 1; } /******************************************************************************/ int ModApiMainMenu::l_create_dir(lua_State *L) { - const char *path = luaL_checkstring(L, 1); + const char *path = luaL_checkstring(L, 1); if (ModApiMainMenu::isMinetestPath(path)) { - lua_pushboolean(L,fs::CreateAllDirs(path)); + lua_pushboolean(L, fs::CreateAllDirs(path)); return 1; } - lua_pushboolean(L,false); + + lua_pushboolean(L, false); return 1; } /******************************************************************************/ int ModApiMainMenu::l_delete_dir(lua_State *L) { - const char *path = luaL_checkstring(L, 1); + const char *path = luaL_checkstring(L, 1); std::string absolute_path = fs::RemoveRelativePathComponents(path); if (ModApiMainMenu::isMinetestPath(absolute_path)) { - lua_pushboolean(L,fs::RecursiveDelete(absolute_path)); + lua_pushboolean(L, fs::RecursiveDelete(absolute_path)); return 1; } - lua_pushboolean(L,false); + + lua_pushboolean(L, false); return 1; } |