From fcd65f0b99543cacf039047180e05bc8491acd29 Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Wed, 23 Apr 2025 23:58:36 +0300 Subject: [PATCH] Fix type checks --- src/client/game.cpp | 2 +- src/network/clientpackethandler.cpp | 6 +++--- src/script/lua_api/l_object.cpp | 5 +++-- src/server.cpp | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/client/game.cpp b/src/client/game.cpp index b16ba9db8..cc6fede16 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -2867,8 +2867,8 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam) ); } else if ((event->set_sky->type == "skybox" || event->set_sky->type == "skybox_back" || event->set_sky->type == "skybox_front") && event->set_sky->textures.size() == 6) { - // Show the mesh and sky colors only if transparency is used. const bool transparent = event->set_sky->type == "skybox_back" || event->set_sky->type == "skybox_front"; + // Show the mesh and sky colors only if transparency is used. if(transparent) { sky->setVisible(true); sky->setSkyColors(event->set_sky->sky_color); diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 3f5115ed9..5732b3ce2 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1302,8 +1302,8 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) MoonParams moon = SkyboxDefaults::getMoonDefaults(); StarParams stars = SkyboxDefaults::getStarDefaults(); - // Fix for "regular" and "skybox" skies, as color isn't kept: - if (skybox.type == "regular" || skybox.type == "skybox" || + // Fix for "regular", "skybox_back", "skybox_front" skies as color isn't kept: + if (skybox.type == "regular" || skybox.type == "skybox_back" || skybox.type == "skybox_front") { skybox.sky_color = SkyboxDefaults::getSkyColorDefaults(); skybox.fog_tint_type = "default"; @@ -1354,7 +1354,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) skybox.textures.emplace_back(texture); } } - if (skybox.type == "regular" || skybox.type == "skybox" || + if (skybox.type == "regular" || skybox.type == "skybox_back" || skybox.type == "skybox_front") { auto &c = skybox.sky_color; *pkt >> c.day_sky >> c.day_horizon >> c.dawn_sky >> c.dawn_horizon diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 09b234a6a..44fdfe203 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -2141,7 +2141,8 @@ 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") { + if (sky_params.type == "regular" || + sky_params.type == "skybox_back" || sky_params.type == "skybox_front") { sun_params.visible = true; sun_params.sunrise_visible = true; moon_params.visible = true; @@ -2182,7 +2183,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.type == "regular" || params.type == "skybox" || + if (params.type == "regular" || params.type == "skybox_back" || params.type == "skybox_front") { push_ARGB8(L, params.sky_color.day_sky); lua_setfield(L, -2, "day_sky"); diff --git a/src/server.cpp b/src/server.cpp index 714173dcf..90405fdce 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1852,7 +1852,7 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams ¶ms) // Handle prior clients here if (m_clients.getProtocolVersion(peer_id) < 39) { - pkt << params.bgcolor << params.type << std::string("solid") << (u16) params.textures.size(); + pkt << params.bgcolor << params.type << (u16) params.textures.size(); for (const std::string& texture : params.textures) pkt << texture; @@ -1869,7 +1869,7 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams ¶ms) for (const std::string &texture : params.textures) pkt << texture; } - if (params.type == "regular" || params.type == "skybox" || + if (params.type == "regular" || params.type == "skybox_back" || params.type == "skybox_front") { auto &c = params.sky_color; pkt << c.day_sky << c.day_horizon << c.dawn_sky << c.dawn_horizon