diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-20 13:30:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-20 13:30:50 +0200 |
commit | 1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch) | |
tree | 03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/script/lua_api/l_inventory.cpp | |
parent | 50669cd2822a11570ae462972194eeb2d585a8c1 (diff) | |
download | minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.gz minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.bz2 minetest-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.zip |
Modernize source code: last part (#6285)
* Modernize source code: last par
* Use empty when needed
* Use emplace_back instead of push_back when needed
* For range-based loops
* Initializers fixes
* constructors, destructors default
* c++ C stl includes
Diffstat (limited to 'src/script/lua_api/l_inventory.cpp')
-rw-r--r-- | src/script/lua_api/l_inventory.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index b0d43090c..f3097582e 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -495,28 +495,29 @@ int ModApiInventory::l_get_inventory(lua_State *L) v3s16 pos = check_v3s16(L, -1); loc.setNodeMeta(pos); - if(getServer(L)->getInventory(loc) != NULL) + if (getServer(L)->getInventory(loc) != NULL) InvRef::create(L, loc); else lua_pushnil(L); return 1; - } else { - NO_MAP_LOCK_REQUIRED; - if(type == "player"){ - std::string name = checkstringfield(L, 1, "name"); - loc.setPlayer(name); - } else if(type == "detached"){ - std::string name = checkstringfield(L, 1, "name"); - loc.setDetached(name); - } + } - if(getServer(L)->getInventory(loc) != NULL) - InvRef::create(L, loc); - else - lua_pushnil(L); - return 1; - // END NO_MAP_LOCK_REQUIRED; + NO_MAP_LOCK_REQUIRED; + if (type == "player") { + std::string name = checkstringfield(L, 1, "name"); + loc.setPlayer(name); + } else if (type == "detached") { + std::string name = checkstringfield(L, 1, "name"); + loc.setDetached(name); } + + if (getServer(L)->getInventory(loc) != NULL) + InvRef::create(L, loc); + else + lua_pushnil(L); + return 1; + // END NO_MAP_LOCK_REQUIRED; + } // create_detached_inventory_raw(name, [player_name]) |