diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2018-03-08 22:19:25 +0100 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-03-08 23:00:17 +0100 |
commit | c7c03ad7a60b77040d0dfc360a79f065e0c2c971 (patch) | |
tree | 148e6617ced494a4f1cae085666bcd06eb14a1d3 /src/script | |
parent | c7656edaa57a951f2496d454a42cdf899459b572 (diff) | |
download | minetest-c7c03ad7a60b77040d0dfc360a79f065e0c2c971.tar.gz minetest-c7c03ad7a60b77040d0dfc360a79f065e0c2c971.tar.bz2 minetest-c7c03ad7a60b77040d0dfc360a79f065e0c2c971.zip |
Cleanup & bugfix
* ObjectRef::set_local_animation: fix wrong lua return (should push a boolean, currently returns nil)
* ObjectRef::set_eye_offset: fix wrong lua return (should push a boolean, currently returns nil)
* Fix various Server functions which depends on RemotePlayer objet and return true/false when player object is nil whereas it's a caller implementation error. Change those bool functions to void and add sanitize_check call instead. Current callers are always checking player object validity
* Optimize Server::setClouds : use CloudParams object ref instead of attribute deserialization from structure & perform RemotePlayer::setCloudParams directly in server class like many other calls
* Optimize Server::SendCloudParams: use CloudParams object ref instead of deserialized attributes
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_object.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 03bd84d52..f72a81d32 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -493,11 +493,9 @@ int ObjectRef::l_set_local_animation(lua_State *L) if (!lua_isnil(L, 6)) frame_speed = lua_tonumber(L, 6); - if (!getServer(L)->setLocalPlayerAnimations(player, frames, frame_speed)) - return 0; - + getServer(L)->setLocalPlayerAnimations(player, frames, frame_speed); lua_pushboolean(L, true); - return 0; + return 1; } // get_local_animation(self) @@ -544,11 +542,9 @@ int ObjectRef::l_set_eye_offset(lua_State *L) /* TODO: if possible: improve the camera colision detetion to allow Y <= -1.5) */ offset_third.Y = rangelim(offset_third.Y,-10,15); //1.5*BS - if (!getServer(L)->setPlayerEyeOffset(player, offset_first, offset_third)) - return 0; - + getServer(L)->setPlayerEyeOffset(player, offset_first, offset_third); lua_pushboolean(L, true); - return 0; + return 1; } // get_eye_offset(self) @@ -1559,9 +1555,7 @@ int ObjectRef::l_set_sky(lua_State *L) if (lua_isboolean(L, 5)) clouds = lua_toboolean(L, 5); - if (!getServer(L)->setSky(player, bgcolor, type, params, clouds)) - return 0; - + getServer(L)->setSky(player, bgcolor, type, params, clouds); lua_pushboolean(L, true); return 1; } @@ -1631,14 +1625,7 @@ int ObjectRef::l_set_clouds(lua_State *L) } lua_pop(L, 1); - if (!getServer(L)->setClouds(player, cloud_params.density, - cloud_params.color_bright, cloud_params.color_ambient, - cloud_params.height, cloud_params.thickness, - cloud_params.speed)) - return 0; - - player->setCloudParams(cloud_params); - + getServer(L)->setClouds(player, cloud_params); lua_pushboolean(L, true); return 1; } |