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

Fix type checks

This commit is contained in:
MirceaKitsune 2025-04-23 23:58:36 +03:00
parent de5328c851
commit fcd65f0b99
4 changed files with 9 additions and 8 deletions

View file

@ -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" || } 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) { 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"; 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) { if(transparent) {
sky->setVisible(true); sky->setVisible(true);
sky->setSkyColors(event->set_sky->sky_color); sky->setSkyColors(event->set_sky->sky_color);

View file

@ -1302,8 +1302,8 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
MoonParams moon = SkyboxDefaults::getMoonDefaults(); MoonParams moon = SkyboxDefaults::getMoonDefaults();
StarParams stars = SkyboxDefaults::getStarDefaults(); StarParams stars = SkyboxDefaults::getStarDefaults();
// Fix for "regular" and "skybox" skies, as color isn't kept: // Fix for "regular", "skybox_back", "skybox_front" skies as color isn't kept:
if (skybox.type == "regular" || skybox.type == "skybox" || if (skybox.type == "regular" ||
skybox.type == "skybox_back" || skybox.type == "skybox_front") { skybox.type == "skybox_back" || skybox.type == "skybox_front") {
skybox.sky_color = SkyboxDefaults::getSkyColorDefaults(); skybox.sky_color = SkyboxDefaults::getSkyColorDefaults();
skybox.fog_tint_type = "default"; skybox.fog_tint_type = "default";
@ -1354,7 +1354,7 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt)
skybox.textures.emplace_back(texture); skybox.textures.emplace_back(texture);
} }
} }
if (skybox.type == "regular" || skybox.type == "skybox" || if (skybox.type == "regular" ||
skybox.type == "skybox_back" || skybox.type == "skybox_front") { skybox.type == "skybox_back" || skybox.type == "skybox_front") {
auto &c = skybox.sky_color; auto &c = skybox.sky_color;
*pkt >> c.day_sky >> c.day_horizon >> c.dawn_sky >> c.dawn_horizon *pkt >> c.day_sky >> c.day_horizon >> c.dawn_sky >> c.dawn_horizon

View file

@ -2141,7 +2141,8 @@ int ObjectRef::l_set_sky(lua_State *L)
// Preserve old behavior of the sun, moon and stars // Preserve old behavior of the sun, moon and stars
// when using the old set_sky call. // 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.visible = true;
sun_params.sunrise_visible = true; sun_params.sunrise_visible = true;
moon_params.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 &params) static void push_sky_color(lua_State *L, const SkyboxParams &params)
{ {
lua_newtable(L); lua_newtable(L);
if (params.type == "regular" || params.type == "skybox" || if (params.type == "regular" ||
params.type == "skybox_back" || params.type == "skybox_front") { params.type == "skybox_back" || params.type == "skybox_front") {
push_ARGB8(L, params.sky_color.day_sky); push_ARGB8(L, params.sky_color.day_sky);
lua_setfield(L, -2, "day_sky"); lua_setfield(L, -2, "day_sky");

View file

@ -1852,7 +1852,7 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams &params)
// Handle prior clients here // Handle prior clients here
if (m_clients.getProtocolVersion(peer_id) < 39) { 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) for (const std::string& texture : params.textures)
pkt << texture; pkt << texture;
@ -1869,7 +1869,7 @@ void Server::SendSetSky(session_t peer_id, const SkyboxParams &params)
for (const std::string &texture : params.textures) for (const std::string &texture : params.textures)
pkt << texture; pkt << texture;
} }
if (params.type == "regular" || params.type == "skybox" || if (params.type == "regular" ||
params.type == "skybox_back" || params.type == "skybox_front") { params.type == "skybox_back" || params.type == "skybox_front") {
auto &c = params.sky_color; auto &c = params.sky_color;
pkt << c.day_sky << c.day_horizon << c.dawn_sky << c.dawn_horizon pkt << c.day_sky << c.day_horizon << c.dawn_sky << c.dawn_horizon