summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_inventory.cpp
diff options
context:
space:
mode:
authorLoïc Blot <nerzhul@users.noreply.github.com>2017-08-20 13:30:50 +0200
committerGitHub <noreply@github.com>2017-08-20 13:30:50 +0200
commit1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch)
tree03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/script/cpp_api/s_inventory.cpp
parent50669cd2822a11570ae462972194eeb2d585a8c1 (diff)
downloadminetest-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/cpp_api/s_inventory.cpp')
-rw-r--r--src/script/cpp_api/s_inventory.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/script/cpp_api/s_inventory.cpp b/src/script/cpp_api/s_inventory.cpp
index c90c7d4e2..251ddb221 100644
--- a/src/script/cpp_api/s_inventory.cpp
+++ b/src/script/cpp_api/s_inventory.cpp
@@ -218,8 +218,7 @@ bool ScriptApiDetached::getDetachedInventoryCallback(
lua_getfield(L, -1, name.c_str());
lua_remove(L, -2);
// Should be a table
- if(lua_type(L, -1) != LUA_TTABLE)
- {
+ if (lua_type(L, -1) != LUA_TTABLE) {
errorstream<<"Detached inventory \""<<name<<"\" not defined"<<std::endl;
lua_pop(L, 1);
return false;
@@ -230,20 +229,17 @@ bool ScriptApiDetached::getDetachedInventoryCallback(
lua_getfield(L, -1, callbackname);
lua_remove(L, -2);
// Should be a function or nil
- if(lua_type(L, -1) == LUA_TFUNCTION)
- {
+ if (lua_type(L, -1) == LUA_TFUNCTION) {
return true;
}
- else if(lua_isnil(L, -1))
- {
- lua_pop(L, 1);
- return false;
- }
- else
- {
- errorstream<<"Detached inventory \""<<name<<"\" callback \""
- <<callbackname<<"\" is not a function"<<std::endl;
+
+ if (lua_isnil(L, -1)) {
lua_pop(L, 1);
return false;
}
+
+ errorstream << "Detached inventory \"" << name << "\" callback \""
+ << callbackname << "\" is not a function" << std::endl;
+ lua_pop(L, 1);
+ return false;
}