From b3317fbe662c946714713f79db407516862f3168 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 1 Jul 2025 23:16:40 +0300 Subject: [PATCH] Minor fixes --- doc/lua_api.md | 4 ++-- src/client/game.cpp | 12 ++++++------ src/client/sky.cpp | 4 ++-- src/network/clientpackethandler.cpp | 6 +++--- src/script/lua_api/l_object.cpp | 8 ++++---- src/server.cpp | 4 ++-- src/skyparams.h | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/doc/lua_api.md b/doc/lua_api.md index 3d8dda5b24..de0688cfdf 100644 --- a/doc/lua_api.md +++ b/doc/lua_api.md @@ -8832,9 +8832,9 @@ child will follow movement and rotation of that bone. * `"regular"`: Uses 0 textures, `base_color` ignored * `"skybox"`: Uses 6 textures, `base_color` used as fog. * `"skybox_back"`: Uses 6 textures, `sky_color` used as fog, stars / sun / moon in foreground. - Note: Requires Luanti client version 5.13 or greater. + Note: Requires Luanti client version 5.13 or greater. * `"skybox_front"`: Uses 6 textures, `sky_color` used as fog, stars / sun / moon in background. - Note: Requires Luanti client version 5.13 or greater. + Note: Requires Luanti client version 5.13 or greater. * `"plain"`: Uses 0 textures, `base_color` used as both fog and sky. (default: `"regular"`) * `textures`: A table containing up to six textures in the following diff --git a/src/client/game.cpp b/src/client/game.cpp index 476013715f..40892125d6 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2859,23 +2859,23 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) { // Handle invalid sky type. - if (!event->set_sky->isSkybox() && !event->set_sky->isTransparent() && event->set_sky->type != "plain") + if (!event->set_sky->isTextured() && !event->set_sky->hasAlpha() && event->set_sky->type != "plain") infostream << "Unknown sky type: " << (event->set_sky->type) << std::endl; // Show the mesh sky if transparent. - sky->setVisible(event->set_sky->isTransparent()); + sky->setVisible(event->set_sky->hasAlpha()); sky->setType(event->set_sky->type); // Whether clouds are visible in front of a custom skybox. sky->setCloudsEnabled(event->set_sky->clouds); // Show the mesh sky and use skybox colours if transparent. - if (event->set_sky->isTransparent()) + if (event->set_sky->hasAlpha()) sky->setSkyColors(event->set_sky->sky_color); else sky->setFallbackBgColor(event->set_sky->bgcolor); // Use horizon tint for regular or skybox skies. - if (event->set_sky->isSkybox() || event->set_sky->isTransparent()) + if (event->set_sky->isTextured() || event->set_sky->hasAlpha()) sky->setHorizonTint( event->set_sky->fog_sun_tint, event->set_sky->fog_moon_tint, @@ -2891,9 +2891,9 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) // Clear the old textures out in case we switch rendering type. sky->clearSkyboxTextures(); // Add textures to skybox. - if(event->set_sky->isSkybox()) { + if (event->set_sky->isTextured()) { for (int i = 0; i < 6; i++) - sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src, event->set_sky->isTransparent()); + sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src, event->set_sky->hasAlpha()); } // Orbit Tilt: diff --git a/src/client/sky.cpp b/src/client/sky.cpp index f190f82104..c56eb11032 100644 --- a/src/client/sky.cpp +++ b/src/client/sky.cpp @@ -215,7 +215,7 @@ void Sky::render() // Draw far cloudy fog thing blended with skycolor // Disabled when using a textured skybox to prevent clipping - if (m_visible && !m_sky_params.isSkybox()) { + if (m_visible && !m_sky_params.isTextured()) { driver->setMaterial(m_materials[1]); for (u32 j = 0; j < 4; j++) { vertices[0] = video::S3DVertex(-1, -0.02, -1, 0, 0, 1, m_bgcolor, t, t); @@ -280,7 +280,7 @@ void Sky::render() // Draw far cloudy fog thing below all horizons in front of sun, moon and stars. // Disabled when using a textured skybox to prevent clipping - if (m_visible && !m_sky_params.isSkybox()) { + if (m_visible && !m_sky_params.isTextured()) { driver->setMaterial(m_materials[1]); for (u32 j = 0; j < 4; j++) { diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 4ee39bd56d..27dcb82b92 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1304,7 +1304,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) StarParams stars = SkyboxDefaults::getStarDefaults(); // Fix for "regular", "skybox_back", "skybox_front" skies as color isn't kept: - if (skybox.isTransparent()) { + if (skybox.hasAlpha()) { skybox.sky_color = SkyboxDefaults::getSkyColorDefaults(); skybox.fog_tint_type = "default"; skybox.fog_moon_tint = video::SColor(255, 255, 255, 255); @@ -1344,7 +1344,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) *pkt >> skybox.bgcolor >> skybox.type >> skybox.clouds >> skybox.fog_sun_tint >> skybox.fog_moon_tint >> skybox.fog_tint_type; - if (skybox.isSkybox()) { + if (skybox.isTextured()) { u16 texture_count; std::string texture; *pkt >> texture_count; @@ -1353,7 +1353,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) skybox.textures.emplace_back(texture); } } - if (skybox.isTransparent()) { + if (skybox.hasAlpha()) { auto &c = skybox.sky_color; *pkt >> c.day_sky >> c.day_horizon >> c.dawn_sky >> c.dawn_horizon >> c.night_sky >> c.night_horizon >> c.indoors; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 8c03e07a8a..c2f7ec896c 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -2067,7 +2067,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.isSkybox()) { + if (lua_istable(L, -1) && sky_params.isTextured()) { lua_pushnil(L); while (lua_next(L, -2) != 0) { // Key is at index -2 and value at index -1 @@ -2161,7 +2161,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.isTransparent()) { + if (sky_params.hasAlpha()) { sun_params.visible = true; sun_params.sunrise_visible = true; moon_params.visible = true; @@ -2183,7 +2183,7 @@ int ObjectRef::l_set_sky(lua_State *L) lua_pop(L, 1); } } - if (sky_params.isSkybox() && sky_params.textures.size() != 6) + if (sky_params.isTextured() && sky_params.textures.size() != 6) throw LuaError("Skybox expects 6 textures."); sky_params.clouds = true; @@ -2202,7 +2202,7 @@ int ObjectRef::l_set_sky(lua_State *L) static void push_sky_color(lua_State *L, const SkyboxParams ¶ms) { lua_newtable(L); - if (params.isTransparent()) { + if (params.hasAlpha()) { push_ARGB8(L, params.sky_color.day_sky); lua_setfield(L, -2, "day_sky"); push_ARGB8(L, params.sky_color.day_horizon); diff --git a/src/server.cpp b/src/server.cpp index 4e07d4001a..e54dfd4587 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1868,12 +1868,12 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams ¶ms) << params.clouds << params.fog_sun_tint << params.fog_moon_tint << params.fog_tint_type; - if (params.isSkybox()) { + if (params.isTextured()) { pkt << (u16) params.textures.size(); for (const std::string &texture : params.textures) pkt << texture; } - if (params.isTransparent()) { + if (params.hasAlpha()) { auto &c = params.sky_color; pkt << c.day_sky << c.day_horizon << c.dawn_sky << c.dawn_horizon << c.night_sky << c.night_horizon << c.indoors; diff --git a/src/skyparams.h b/src/skyparams.h index 16925a53f7..f89a28acac 100644 --- a/src/skyparams.h +++ b/src/skyparams.h @@ -40,11 +40,11 @@ struct SkyboxParams video::SColor fog_color { 0 }; // override, only used if alpha > 0 // Check if this is a textured skybox and whether transparency is used - bool isSkybox() const + bool isTextured() const { return type == "skybox" || type == "skybox_back" || type == "skybox_front"; } - bool isTransparent() const + bool hasAlpha() const { return type == "regular" || type == "skybox_back" || type == "skybox_front"; }