diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/network/clientpackethandler.cpp | 6 | ||||
-rw-r--r-- | src/network/networkprotocol.h | 1 | ||||
-rw-r--r-- | src/remoteplayer.h | 8 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 15 | ||||
-rw-r--r-- | src/script/lua_api/l_object.h | 4 | ||||
-rw-r--r-- | src/server.cpp | 12 | ||||
-rw-r--r-- | src/server.h | 6 | ||||
-rw-r--r-- | src/sky.cpp | 2 | ||||
-rw-r--r-- | src/sky.h | 7 |
11 files changed, 48 insertions, 17 deletions
diff --git a/src/client.h b/src/client.h index e8db7de44..0dd519308 100644 --- a/src/client.h +++ b/src/client.h @@ -174,6 +174,7 @@ struct ClientEvent video::SColor *bgcolor; std::string *type; std::vector<std::string> *params; + bool clouds; } set_sky; struct{ bool do_override; diff --git a/src/game.cpp b/src/game.cpp index ba6530d80..7dd9c942d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -3255,6 +3255,8 @@ void Game::processClientEvents(CameraOrientation *cam) case CE_SET_SKY: sky->setVisible(false); + // Whether clouds are visible in front of a custom skybox + sky->setCloudsEnabled(event.set_sky.clouds); if (skybox) { skybox->remove(); @@ -3264,6 +3266,7 @@ void Game::processClientEvents(CameraOrientation *cam) // Handle according to type if (*event.set_sky.type == "regular") { sky->setVisible(true); + sky->setCloudsEnabled(true); } else if (*event.set_sky.type == "skybox" && event.set_sky.params->size() == 6) { sky->setFallbackBgColor(*event.set_sky.bgcolor); diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 4316a77d4..c3626158e 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -1192,11 +1192,17 @@ void Client::handleCommand_HudSetSky(NetworkPacket* pkt) for (size_t i = 0; i < count; i++) params->push_back(deSerializeString(is)); + bool clouds = true; + try { + clouds = readU8(is); + } catch (...) {} + ClientEvent event; event.type = CE_SET_SKY; event.set_sky.bgcolor = bgcolor; event.set_sky.type = type; event.set_sky.params = params; + event.set_sky.clouds = clouds; m_client_event_queue.push(event); } diff --git a/src/network/networkprotocol.h b/src/network/networkprotocol.h index 70cad85d8..7126c237b 100644 --- a/src/network/networkprotocol.h +++ b/src/network/networkprotocol.h @@ -584,6 +584,7 @@ enum ToClientCommand foreach count: u8 len u8[len] param + u8 clouds (boolean) */ TOCLIENT_OVERRIDE_DAY_NIGHT_RATIO = 0x50, diff --git a/src/remoteplayer.h b/src/remoteplayer.h index b9d9c74f5..7d46205c5 100644 --- a/src/remoteplayer.h +++ b/src/remoteplayer.h @@ -85,19 +85,21 @@ public: } void setSky(const video::SColor &bgcolor, const std::string &type, - const std::vector<std::string> ¶ms) + const std::vector<std::string> ¶ms, bool &clouds) { m_sky_bgcolor = bgcolor; m_sky_type = type; m_sky_params = params; + m_sky_clouds = clouds; } void getSky(video::SColor *bgcolor, std::string *type, - std::vector<std::string> *params) + std::vector<std::string> *params, bool *clouds) { *bgcolor = m_sky_bgcolor; *type = m_sky_type; *params = m_sky_params; + *clouds = m_sky_clouds; } void setCloudParams(const CloudParams &cloud_params) @@ -165,6 +167,8 @@ private: std::string m_sky_type; video::SColor m_sky_bgcolor; std::vector<std::string> m_sky_params; + bool m_sky_clouds; + CloudParams m_cloud_params; }; diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 6cd852299..6f61ab55c 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -1662,7 +1662,7 @@ int ObjectRef::l_hud_get_hotbar_selected_image(lua_State *L) return 1; } -// set_sky(self, bgcolor, type, list) +// set_sky(self, bgcolor, type, list, clouds = true) int ObjectRef::l_set_sky(lua_State *L) { NO_MAP_LOCK_REQUIRED; @@ -1678,9 +1678,8 @@ int ObjectRef::l_set_sky(lua_State *L) std::vector<std::string> params; if (lua_istable(L, 4)) { - int table = lua_gettop(L); lua_pushnil(L); - while (lua_next(L, table) != 0) { + while (lua_next(L, 4) != 0) { // key at index -2 and value at index -1 if (lua_isstring(L, -1)) params.push_back(lua_tostring(L, -1)); @@ -1694,7 +1693,11 @@ int ObjectRef::l_set_sky(lua_State *L) if (type == "skybox" && params.size() != 6) throw LuaError("skybox expects 6 textures"); - if (!getServer(L)->setSky(player, bgcolor, type, params)) + bool clouds = true; + if (lua_isboolean(L, 5)) + clouds = lua_toboolean(L, 5); + + if (!getServer(L)->setSky(player, bgcolor, type, params, clouds)) return 0; lua_pushboolean(L, true); @@ -1712,8 +1715,9 @@ int ObjectRef::l_get_sky(lua_State *L) video::SColor bgcolor(255, 255, 255, 255); std::string type; std::vector<std::string> params; + bool clouds; - player->getSky(&bgcolor, &type, ¶ms); + player->getSky(&bgcolor, &type, ¶ms, &clouds); type = type == "" ? "regular" : type; push_ARGB8(L, bgcolor); @@ -1726,6 +1730,7 @@ int ObjectRef::l_get_sky(lua_State *L) lua_rawseti(L, -2, i); i++; } + lua_pushboolean(L, clouds); return 3; } diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h index 0912a1c49..9801ce02b 100644 --- a/src/script/lua_api/l_object.h +++ b/src/script/lua_api/l_object.h @@ -283,10 +283,10 @@ private: // hud_get_hotbar_selected_image(self) static int l_hud_get_hotbar_selected_image(lua_State *L); - // set_sky(self, type, list) + // set_sky(self, bgcolor, type, list, clouds = true) static int l_set_sky(lua_State *L); - // get_sky(self, type, list) + // get_sky(self) static int l_get_sky(lua_State *L); // set_clouds(self, {density=, color=, ambient=, height=, thickness=, speed=}) diff --git a/src/server.cpp b/src/server.cpp index 190a1baf2..bf01fb7eb 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1871,7 +1871,8 @@ void Server::SendHUDSetParam(u16 peer_id, u16 param, const std::string &value) } void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor, - const std::string &type, const std::vector<std::string> ¶ms) + const std::string &type, const std::vector<std::string> ¶ms, + bool &clouds) { NetworkPacket pkt(TOCLIENT_SET_SKY, 0, peer_id); pkt << bgcolor << type << (u16) params.size(); @@ -1879,6 +1880,8 @@ void Server::SendSetSky(u16 peer_id, const video::SColor &bgcolor, for(size_t i=0; i<params.size(); i++) pkt << params[i]; + pkt << clouds; + Send(&pkt); } @@ -3254,13 +3257,14 @@ bool Server::setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third) } bool Server::setSky(RemotePlayer *player, const video::SColor &bgcolor, - const std::string &type, const std::vector<std::string> ¶ms) + const std::string &type, const std::vector<std::string> ¶ms, + bool &clouds) { if (!player) return false; - player->setSky(bgcolor, type, params); - SendSetSky(player->peer_id, bgcolor, type, params); + player->setSky(bgcolor, type, params, clouds); + SendSetSky(player->peer_id, bgcolor, type, params, clouds); return true; } diff --git a/src/server.h b/src/server.h index 5e6211637..2e735e77c 100644 --- a/src/server.h +++ b/src/server.h @@ -335,7 +335,8 @@ public: bool setPlayerEyeOffset(RemotePlayer *player, v3f first, v3f third); bool setSky(RemotePlayer *player, const video::SColor &bgcolor, - const std::string &type, const std::vector<std::string> ¶ms); + const std::string &type, const std::vector<std::string> ¶ms, + bool &clouds); bool setClouds(RemotePlayer *player, float density, const video::SColor &color_bright, const video::SColor &color_ambient, @@ -410,7 +411,8 @@ private: void SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask); void SendHUDSetParam(u16 peer_id, u16 param, const std::string &value); void SendSetSky(u16 peer_id, const video::SColor &bgcolor, - const std::string &type, const std::vector<std::string> ¶ms); + const std::string &type, const std::vector<std::string> ¶ms, + bool &clouds); void SendCloudParams(u16 peer_id, float density, const video::SColor &color_bright, const video::SColor &color_ambient, diff --git a/src/sky.cpp b/src/sky.cpp index 7f999feb0..5414f74bd 100644 --- a/src/sky.cpp +++ b/src/sky.cpp @@ -85,6 +85,8 @@ Sky::Sky(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, } m_directional_colored_fog = g_settings->getBool("directional_colored_fog"); + + m_clouds_enabled = true; } @@ -65,10 +65,12 @@ public: return m_visible ? m_skycolor : m_fallback_bg_color; } - bool getCloudsVisible() { return m_clouds_visible && m_visible; } + bool getCloudsVisible() { return m_clouds_visible && m_clouds_enabled; } const video::SColorf &getCloudColor() { return m_cloudcolor_f; } void setVisible(bool visible) { m_visible = visible; } + // Set only from set_sky API + void setCloudsEnabled(bool clouds_enabled) { m_clouds_enabled = clouds_enabled; } void setFallbackBgColor(const video::SColor &fallback_bg_color) { m_fallback_bg_color = fallback_bg_color; @@ -123,7 +125,8 @@ private: bool m_sunlight_seen; float m_brightness; float m_cloud_brightness; - bool m_clouds_visible; + bool m_clouds_visible; // Whether clouds are disabled due to player underground + bool m_clouds_enabled; // Initialised to true, reset only by set_sky API bool m_directional_colored_fog; video::SColorf m_bgcolor_bright_f; video::SColorf m_skycolor_bright_f; |