From ad148587dcf5244c2d2011dba339786c765c54c4 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 16:19:54 +0100 Subject: Make Lint Happy --- src/script/lua_api/l_object.cpp | 514 ++++++++++++++++++++-------------------- 1 file changed, 260 insertions(+), 254 deletions(-) (limited to 'src/script/lua_api/l_object.cpp') diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index e7394133a..5d48ee93d 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -39,16 +39,16 @@ with this program; if not, write to the Free Software Foundation, Inc., ObjectRef */ - -ObjectRef* ObjectRef::checkobject(lua_State *L, int narg) +ObjectRef *ObjectRef::checkobject(lua_State *L, int narg) { luaL_checktype(L, narg, LUA_TUSERDATA); void *ud = luaL_checkudata(L, narg, className); - if (!ud) luaL_typerror(L, narg, className); - return *(ObjectRef**)ud; // unbox pointer + if (!ud) + luaL_typerror(L, narg, className); + return *(ObjectRef **)ud; // unbox pointer } -ServerActiveObject* ObjectRef::getobject(ObjectRef *ref) +ServerActiveObject *ObjectRef::getobject(ObjectRef *ref) { ServerActiveObject *co = ref->m_object; if (co && co->isGone()) @@ -56,24 +56,24 @@ ServerActiveObject* ObjectRef::getobject(ObjectRef *ref) return co; } -LuaEntitySAO* ObjectRef::getluaobject(ObjectRef *ref) +LuaEntitySAO *ObjectRef::getluaobject(ObjectRef *ref) { ServerActiveObject *obj = getobject(ref); if (obj == NULL) return NULL; if (obj->getType() != ACTIVEOBJECT_TYPE_LUAENTITY) return NULL; - return (LuaEntitySAO*)obj; + return (LuaEntitySAO *)obj; } -PlayerSAO* ObjectRef::getplayersao(ObjectRef *ref) +PlayerSAO *ObjectRef::getplayersao(ObjectRef *ref) { ServerActiveObject *obj = getobject(ref); if (obj == NULL) return NULL; if (obj->getType() != ACTIVEOBJECT_TYPE_PLAYER) return NULL; - return (PlayerSAO*)obj; + return (PlayerSAO *)obj; } RemotePlayer *ObjectRef::getplayer(ObjectRef *ref) @@ -87,9 +87,10 @@ RemotePlayer *ObjectRef::getplayer(ObjectRef *ref) // Exported functions // garbage collector -int ObjectRef::gc_object(lua_State *L) { +int ObjectRef::gc_object(lua_State *L) +{ ObjectRef *o = *(ObjectRef **)(lua_touserdata(L, 1)); - //infostream<<"ObjectRef::gc_object: o="<(L, -1))) { + !reason.setTypeFromString( + readParam(L, -1))) { errorstream << "Bad type given!" << std::endl; } lua_pop(L, 1); @@ -287,7 +295,8 @@ int ObjectRef::l_get_inventory(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it InventoryLocation loc = co->getInventoryLocation(); if (getServerInventoryMgr(L)->getInventory(loc) != NULL) @@ -347,7 +356,8 @@ int ObjectRef::l_set_wielded_item(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it ItemStack item = read_item(L, 2, getServer(L)->idef()); bool success = co->setWieldedItem(item); @@ -364,7 +374,8 @@ int ObjectRef::l_set_armor_groups(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it ItemGroupList groups; read_groups(L, 2, groups); @@ -391,8 +402,9 @@ int ObjectRef::l_set_physics_override(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO *co = (PlayerSAO *) getobject(ref); - if (co == NULL) return 0; + PlayerSAO *co = (PlayerSAO *)getobject(ref); + if (co == NULL) + return 0; // Do it if (lua_istable(L, 2)) { co->m_physics_override_speed = getfloatfield_default( @@ -403,8 +415,8 @@ int ObjectRef::l_set_physics_override(lua_State *L) L, 2, "gravity", co->m_physics_override_gravity); co->m_physics_override_sneak = getboolfield_default( L, 2, "sneak", co->m_physics_override_sneak); - co->m_physics_override_sneak_glitch = getboolfield_default( - L, 2, "sneak_glitch", co->m_physics_override_sneak_glitch); + co->m_physics_override_sneak_glitch = getboolfield_default(L, 2, + "sneak_glitch", co->m_physics_override_sneak_glitch); co->m_physics_override_new_move = getboolfield_default( L, 2, "new_move", co->m_physics_override_new_move); co->m_physics_override_sent = false; @@ -457,7 +469,8 @@ int ObjectRef::l_set_animation(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it v2f frames = v2f(1, 1); if (!lua_isnil(L, 2)) @@ -484,7 +497,7 @@ int ObjectRef::l_get_animation(lua_State *L) if (co == NULL) return 0; // Do it - v2f frames = v2f(1,1); + v2f frames = v2f(1, 1); float frame_speed = 15; float frame_blend = 0; bool frame_loop = true; @@ -507,9 +520,9 @@ int ObjectRef::l_set_local_animation(lua_State *L) return 0; // Do it v2s32 frames[4]; - for (int i=0;i<4;i++) { - if (!lua_isnil(L, 2+1)) - frames[i] = read_v2s32(L, 2+i); + for (int i = 0; i < 4; i++) { + if (!lua_isnil(L, 2 + 1)) + frames[i] = read_v2s32(L, 2 + i); } float frame_speed = 30; if (!lua_isnil(L, 6)) @@ -559,10 +572,10 @@ int ObjectRef::l_set_eye_offset(lua_State *L) offset_third = read_v3f(L, 3); // Prevent abuse of offset values (keep player always visible) - offset_third.X = rangelim(offset_third.X,-10,10); - offset_third.Z = rangelim(offset_third.Z,-5,5); + offset_third.X = rangelim(offset_third.X, -10, 10); + offset_third.Z = rangelim(offset_third.Z, -5, 5); /* 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 + offset_third.Y = rangelim(offset_third.Y, -10, 15); // 1.5*BS getServer(L)->setPlayerEyeOffset(player, offset_first, offset_third); lua_pushboolean(L, true); @@ -627,7 +640,8 @@ int ObjectRef::l_set_bone_position(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); ServerActiveObject *co = getobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it std::string bone; if (!lua_isnil(L, 2)) @@ -680,7 +694,8 @@ int ObjectRef::l_set_attach(lua_State *L) return 0; if (co == parent) - throw LuaError("ObjectRef::set_attach: attaching object to itself is not allowed."); + throw LuaError("ObjectRef::set_attach: attaching object to itself is not " + "allowed."); // Do it int parent_id = 0; @@ -851,7 +866,8 @@ int ObjectRef::l_set_velocity(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; v3f pos = checkFloatPos(L, 2); // Do it co->setVelocity(pos); @@ -878,7 +894,8 @@ int ObjectRef::l_get_velocity(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it v3f v = co->getVelocity(); pushFloatPos(L, v); @@ -891,7 +908,8 @@ int ObjectRef::l_set_acceleration(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // pos v3f pos = checkFloatPos(L, 2); // Do it @@ -905,7 +923,8 @@ int ObjectRef::l_get_acceleration(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it v3f v = co->getAcceleration(); pushFloatPos(L, v); @@ -951,7 +970,8 @@ int ObjectRef::l_set_yaw(lua_State *L) ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; if (isNaN(L, 2)) throw LuaError("ObjectRef::set_yaw: NaN value is not allowed."); @@ -980,7 +1000,8 @@ int ObjectRef::l_set_texture_mod(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it std::string mod = luaL_checkstring(L, 2); co->setTextureMod(mod); @@ -993,7 +1014,8 @@ int ObjectRef::l_get_texture_mod(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it std::string mod = co->getTextureMod(); lua_pushstring(L, mod.c_str()); @@ -1007,9 +1029,10 @@ int ObjectRef::l_set_sprite(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it - v2s16 p(0,0); + v2s16 p(0, 0); if (!lua_isnil(L, 2)) p = readParam(L, 2); int num_frames = 1; @@ -1032,8 +1055,9 @@ int ObjectRef::l_get_entity_name(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - log_deprecated(L,"Deprecated call to \"get_entity_name"); - if (co == NULL) return 0; + log_deprecated(L, "Deprecated call to \"get_entity_name"); + if (co == NULL) + return 0; // Do it std::string name = co->getName(); lua_pushstring(L, name.c_str()); @@ -1046,7 +1070,8 @@ int ObjectRef::l_get_luaentity(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); LuaEntitySAO *co = getluaobject(ref); - if (co == NULL) return 0; + if (co == NULL) + return 0; // Do it luaentity_get(L, co->getId()); return 1; @@ -1060,7 +1085,7 @@ int ObjectRef::l_is_player_connected(lua_State *L) NO_MAP_LOCK_REQUIRED; // This method was once added for a bugfix, but never documented log_deprecated(L, "is_player_connected is undocumented and " - "will be removed in a future release"); + "will be removed in a future release"); ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); lua_pushboolean(L, (player != NULL && player->getPeerId() != PEER_ID_INEXISTENT)); @@ -1119,13 +1144,14 @@ int ObjectRef::l_get_look_dir(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it float pitch = co->getRadLookPitchDep(); float yaw = co->getRadYawDep(); - v3f v(std::cos(pitch) * std::cos(yaw), std::sin(pitch), std::cos(pitch) * - std::sin(yaw)); + v3f v(std::cos(pitch) * std::cos(yaw), std::sin(pitch), + std::cos(pitch) * std::sin(yaw)); push_v3f(L, v); return 1; } @@ -1136,12 +1162,13 @@ int ObjectRef::l_get_look_pitch(lua_State *L) { NO_MAP_LOCK_REQUIRED; - log_deprecated(L, - "Deprecated call to get_look_pitch, use get_look_vertical instead"); + log_deprecated(L, "Deprecated call to get_look_pitch, use get_look_vertical " + "instead"); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it lua_pushnumber(L, co->getRadLookPitchDep()); return 1; @@ -1153,12 +1180,13 @@ int ObjectRef::l_get_look_yaw(lua_State *L) { NO_MAP_LOCK_REQUIRED; - log_deprecated(L, - "Deprecated call to get_look_yaw, use get_look_horizontal instead"); + log_deprecated(L, "Deprecated call to get_look_yaw, use get_look_horizontal " + "instead"); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it lua_pushnumber(L, co->getRadYawDep()); return 1; @@ -1169,8 +1197,9 @@ int ObjectRef::l_get_look_vertical(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it lua_pushnumber(L, co->getRadLookPitch()); return 1; @@ -1181,8 +1210,9 @@ int ObjectRef::l_get_look_horizontal(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it lua_pushnumber(L, co->getRadRotation().Y); return 1; @@ -1193,8 +1223,9 @@ int ObjectRef::l_set_look_vertical(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; float pitch = readParam(L, 2) * core::RADTODEG; // Do it co->setLookPitchAndSend(pitch); @@ -1206,8 +1237,9 @@ int ObjectRef::l_set_look_horizontal(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; float yaw = readParam(L, 2) * core::RADTODEG; // Do it co->setPlayerYawAndSend(yaw); @@ -1220,12 +1252,13 @@ int ObjectRef::l_set_look_pitch(lua_State *L) { NO_MAP_LOCK_REQUIRED; - log_deprecated(L, - "Deprecated call to set_look_pitch, use set_look_vertical instead."); + log_deprecated(L, "Deprecated call to set_look_pitch, use set_look_vertical " + "instead."); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; float pitch = readParam(L, 2) * core::RADTODEG; // Do it co->setLookPitchAndSend(pitch); @@ -1238,12 +1271,13 @@ int ObjectRef::l_set_look_yaw(lua_State *L) { NO_MAP_LOCK_REQUIRED; - log_deprecated(L, - "Deprecated call to set_look_yaw, use set_look_horizontal instead."); + log_deprecated(L, "Deprecated call to set_look_yaw, use set_look_horizontal " + "instead."); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; float yaw = readParam(L, 2) * core::RADTODEG; // Do it co->setPlayerYawAndSend(yaw); @@ -1259,11 +1293,10 @@ int ObjectRef::l_set_fov(lua_State *L) if (!player) return 0; - player->setFov({ - static_cast(luaL_checknumber(L, 2)), - readParam(L, 3, false), - lua_isnumber(L, 4) ? static_cast(luaL_checknumber(L, 4)) : 0.0f - }); + player->setFov({static_cast(luaL_checknumber(L, 2)), + readParam(L, 3, false), + lua_isnumber(L, 4) ? static_cast(luaL_checknumber(L, 4)) + : 0.0f}); getServer(L)->SendPlayerFov(player->getPeerId()); return 0; @@ -1291,8 +1324,9 @@ int ObjectRef::l_set_breath(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; u16 breath = luaL_checknumber(L, 2); co->setBreath(breath); @@ -1304,22 +1338,23 @@ int ObjectRef::l_get_breath(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); - if (co == NULL) return 0; + PlayerSAO *co = getplayersao(ref); + if (co == NULL) + return 0; // Do it u16 breath = co->getBreath(); - lua_pushinteger (L, breath); + lua_pushinteger(L, breath); return 1; } // set_attribute(self, attribute, value) int ObjectRef::l_set_attribute(lua_State *L) { - log_deprecated(L, - "Deprecated call to set_attribute, use MetaDataRef methods instead."); + log_deprecated(L, "Deprecated call to set_attribute, use MetaDataRef methods " + "instead."); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); + PlayerSAO *co = getplayersao(ref); if (co == NULL) return 0; @@ -1336,11 +1371,11 @@ int ObjectRef::l_set_attribute(lua_State *L) // get_attribute(self, attribute) int ObjectRef::l_get_attribute(lua_State *L) { - log_deprecated(L, - "Deprecated call to get_attribute, use MetaDataRef methods instead."); + log_deprecated(L, "Deprecated call to get_attribute, use MetaDataRef methods " + "instead."); ObjectRef *ref = checkobject(L, 1); - PlayerSAO* co = getplayersao(ref); + PlayerSAO *co = getplayersao(ref); if (co == NULL) return 0; @@ -1355,7 +1390,6 @@ int ObjectRef::l_get_attribute(lua_State *L) return 0; } - // get_meta(self, attribute) int ObjectRef::l_get_meta(lua_State *L) { @@ -1368,14 +1402,14 @@ int ObjectRef::l_get_meta(lua_State *L) return 1; } - // set_inventory_formspec(self, formspec) int ObjectRef::l_set_inventory_formspec(lua_State *L) { NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); - if (player == NULL) return 0; + if (player == NULL) + return 0; std::string formspec = luaL_checkstring(L, 2); player->inventory_formspec = formspec; @@ -1390,7 +1424,8 @@ int ObjectRef::l_get_inventory_formspec(lua_State *L) NO_MAP_LOCK_REQUIRED; ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); - if (player == NULL) return 0; + if (player == NULL) + return 0; std::string formspec = player->inventory_formspec; lua_pushlstring(L, formspec.c_str(), formspec.size()); @@ -1421,7 +1456,7 @@ int ObjectRef::l_get_formspec_prepend(lua_State *L) ObjectRef *ref = checkobject(L, 1); RemotePlayer *player = getplayer(ref); if (player == NULL) - return 0; + return 0; std::string formspec = player->formspec_prepend; lua_pushlstring(L, formspec.c_str(), formspec.size()); @@ -1573,14 +1608,14 @@ int ObjectRef::l_hud_set_flags(lua_State *L) return 0; u32 flags = 0; - u32 mask = 0; + u32 mask = 0; bool flag; const EnumString *esp = es_HudBuiltinElement; for (int i = 0; esp[i].str; i++) { if (getboolfield(L, 2, esp[i].str, flag)) { flags |= esp[i].num * flag; - mask |= esp[i].num; + mask |= esp[i].num; } } if (!getServer(L)->hudSetFlags(player, flags, mask)) @@ -1735,7 +1770,8 @@ int ObjectRef::l_set_sky(lua_State *L) lua_pushnil(L); while (lua_next(L, -2) != 0) { // Key is at index -2 and value at index -1 - skybox_params.textures.emplace_back(readParam(L, -1)); + skybox_params.textures.emplace_back( + readParam(L, -1)); // Removes the value, but keeps the key for iteration lua_pop(L, 1); } @@ -1748,11 +1784,12 @@ int ObjectRef::l_set_sky(lua_State *L) using "regular" or "plain" skybox modes as textures aren't needed. */ - if (skybox_params.textures.size() != 6 && skybox_params.textures.size() > 0) + if (skybox_params.textures.size() != 6 && + skybox_params.textures.size() > 0) throw LuaError("Skybox expects 6 textures!"); - skybox_params.clouds = getboolfield_default(L, 2, - "clouds", skybox_params.clouds); + skybox_params.clouds = getboolfield_default( + L, 2, "clouds", skybox_params.clouds); lua_getfield(L, 2, "sky_color"); if (lua_istable(L, -1)) { @@ -1836,9 +1873,10 @@ int ObjectRef::l_set_sky(lua_State *L) if (lua_istable(L, 4)) { lua_pushnil(L); while (lua_next(L, 4) != 0) { - // Key at index -2, and value at index -1 + // Key at index -2, and value at index -1 if (lua_isstring(L, -1)) - skybox_params.textures.emplace_back(readParam(L, -1)); + skybox_params.textures.emplace_back( + readParam(L, -1)); else skybox_params.textures.emplace_back(""); // Remove the value, keep the key for the next iteration @@ -1878,7 +1916,7 @@ int ObjectRef::l_get_sky(lua_State *L) lua_newtable(L); s16 i = 1; - for (const std::string& texture : skybox_params.textures) { + for (const std::string &texture : skybox_params.textures) { lua_pushlstring(L, texture.c_str(), texture.size()); lua_rawseti(L, -2, i++); } @@ -1896,7 +1934,7 @@ int ObjectRef::l_get_sky_color(lua_State *L) if (!player) return 0; - const SkyboxParams& skybox_params = player->getSkyParams(); + const SkyboxParams &skybox_params = player->getSkyParams(); lua_newtable(L); if (skybox_params.type == "regular") { @@ -1938,25 +1976,20 @@ int ObjectRef::l_set_sun(lua_State *L) SunParams sun_params = player->getSunParams(); - sun_params.visible = getboolfield_default(L, 2, - "visible", sun_params.visible); - sun_params.texture = getstringfield_default(L, 2, - "texture", sun_params.texture); - sun_params.tonemap = getstringfield_default(L, 2, - "tonemap", sun_params.tonemap); - sun_params.sunrise = getstringfield_default(L, 2, - "sunrise", sun_params.sunrise); - sun_params.sunrise_visible = getboolfield_default(L, 2, - "sunrise_visible", sun_params.sunrise_visible); - sun_params.scale = getfloatfield_default(L, 2, - "scale", sun_params.scale); + sun_params.visible = getboolfield_default(L, 2, "visible", sun_params.visible); + sun_params.texture = getstringfield_default(L, 2, "texture", sun_params.texture); + sun_params.tonemap = getstringfield_default(L, 2, "tonemap", sun_params.tonemap); + sun_params.sunrise = getstringfield_default(L, 2, "sunrise", sun_params.sunrise); + sun_params.sunrise_visible = getboolfield_default( + L, 2, "sunrise_visible", sun_params.sunrise_visible); + sun_params.scale = getfloatfield_default(L, 2, "scale", sun_params.scale); getServer(L)->setSun(player, sun_params); lua_pushboolean(L, true); return 1; } -//get_sun(self) +// get_sun(self) int ObjectRef::l_get_sun(lua_State *L) { NO_MAP_LOCK_REQUIRED; @@ -1996,14 +2029,12 @@ int ObjectRef::l_set_moon(lua_State *L) MoonParams moon_params = player->getMoonParams(); - moon_params.visible = getboolfield_default(L, 2, - "visible", moon_params.visible); - moon_params.texture = getstringfield_default(L, 2, - "texture", moon_params.texture); - moon_params.tonemap = getstringfield_default(L, 2, - "tonemap", moon_params.tonemap); - moon_params.scale = getfloatfield_default(L, 2, - "scale", moon_params.scale); + moon_params.visible = getboolfield_default(L, 2, "visible", moon_params.visible); + moon_params.texture = + getstringfield_default(L, 2, "texture", moon_params.texture); + moon_params.tonemap = + getstringfield_default(L, 2, "tonemap", moon_params.tonemap); + moon_params.scale = getfloatfield_default(L, 2, "scale", moon_params.scale); getServer(L)->setMoon(player, moon_params); lua_pushboolean(L, true); @@ -2046,18 +2077,15 @@ int ObjectRef::l_set_stars(lua_State *L) StarParams star_params = player->getStarParams(); - star_params.visible = getboolfield_default(L, 2, - "visible", star_params.visible); - star_params.count = getintfield_default(L, 2, - "count", star_params.count); + star_params.visible = getboolfield_default(L, 2, "visible", star_params.visible); + star_params.count = getintfield_default(L, 2, "count", star_params.count); lua_getfield(L, 2, "star_color"); if (!lua_isnil(L, -1)) read_color(L, -1, &star_params.starcolor); lua_pop(L, 1); - star_params.scale = getfloatfield_default(L, 2, - "scale", star_params.scale); + star_params.scale = getfloatfield_default(L, 2, "scale", star_params.scale); getServer(L)->setStars(player, star_params); lua_pushboolean(L, true); @@ -2100,7 +2128,8 @@ int ObjectRef::l_set_clouds(lua_State *L) CloudParams cloud_params = player->getCloudParams(); - cloud_params.density = getfloatfield_default(L, 2, "density", cloud_params.density); + cloud_params.density = + getfloatfield_default(L, 2, "density", cloud_params.density); lua_getfield(L, 2, "color"); if (!lua_isnil(L, -1)) @@ -2111,8 +2140,9 @@ int ObjectRef::l_set_clouds(lua_State *L) read_color(L, -1, &cloud_params.color_ambient); lua_pop(L, 1); - cloud_params.height = getfloatfield_default(L, 2, "height", cloud_params.height ); - cloud_params.thickness = getfloatfield_default(L, 2, "thickness", cloud_params.thickness); + cloud_params.height = getfloatfield_default(L, 2, "height", cloud_params.height); + cloud_params.thickness = + getfloatfield_default(L, 2, "thickness", cloud_params.thickness); lua_getfield(L, 2, "speed"); if (lua_istable(L, -1)) { @@ -2158,7 +2188,6 @@ int ObjectRef::l_get_clouds(lua_State *L) return 1; } - // override_day_night_ratio(self, brightness=0...1) int ObjectRef::l_override_day_night_ratio(lua_State *L) { @@ -2201,10 +2230,9 @@ int ObjectRef::l_get_day_night_ratio(lua_State *L) return 1; } -ObjectRef::ObjectRef(ServerActiveObject *object): - m_object(object) +ObjectRef::ObjectRef(ServerActiveObject *object) : m_object(object) { - //infostream<<"ObjectRef created for id="<getId()<