1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Universal skybox type checks, simplify sky type application, formatting fixes

This commit is contained in:
MirceaKitsune 2025-06-01 00:28:48 +03:00
parent 79f46800f3
commit cc363a77d7
8 changed files with 55 additions and 68 deletions

View file

@ -2065,8 +2065,7 @@ int ObjectRef::l_set_sky(lua_State *L)
lua_getfield(L, 2, "textures");
sky_params.textures.clear();
if (lua_istable(L, -1) && (sky_params.type == "skybox" ||
sky_params.type == "skybox_back" || sky_params.type == "skybox_front")) {
if (lua_istable(L, -1) && sky_params.isSkybox()) {
lua_pushnil(L);
while (lua_next(L, -2) != 0) {
// Key is at index -2 and value at index -1
@ -2160,8 +2159,7 @@ int ObjectRef::l_set_sky(lua_State *L)
// Preserve old behavior of the sun, moon and stars
// when using the old set_sky call.
if (sky_params.type == "regular" ||
sky_params.type == "skybox_back" || sky_params.type == "skybox_front") {
if (sky_params.isTransparent()) {
sun_params.visible = true;
sun_params.sunrise_visible = true;
moon_params.visible = true;
@ -2183,7 +2181,7 @@ int ObjectRef::l_set_sky(lua_State *L)
lua_pop(L, 1);
}
}
if (sky_params.type == "skybox" && sky_params.textures.size() != 6)
if (sky_params.isSkybox() && sky_params.textures.size() != 6)
throw LuaError("Skybox expects 6 textures.");
sky_params.clouds = true;
@ -2202,8 +2200,7 @@ int ObjectRef::l_set_sky(lua_State *L)
static void push_sky_color(lua_State *L, const SkyboxParams &params)
{
lua_newtable(L);
if (params.type == "regular" ||
params.type == "skybox_back" || params.type == "skybox_front") {
if (params.isTransparent()) {
push_ARGB8(L, params.sky_color.day_sky);
lua_setfield(L, -2, "day_sky");
push_ARGB8(L, params.sky_color.day_horizon);