]> git.lizzy.rs Git - minetest.git/blobdiff - src/client.cpp
Add player:set_sky() with simple skybox support
[minetest.git] / src / client.cpp
index 1c7ecf3f36225ef0446a33d508e54140778795ba..48b00377f36138077191cf76399ce92a2ef7c8a3 100644 (file)
@@ -383,13 +383,6 @@ void Client::step(float dtime)
                // 0ms
                ReceiveAll();
        }
-       
-       {
-               //TimeTaker timer("m_con_mutex + m_con.RunTimeouts()", m_device);
-               // 0ms
-               //JMutexAutoLock lock(m_con_mutex); //bulk comment-out
-               m_con.RunTimeouts(dtime);
-       }
 
        /*
                Packet counter
@@ -758,6 +751,7 @@ void Client::step(float dtime)
        if (m_media_downloader && m_media_downloader->isStarted()) {
                m_media_downloader->step(this);
                if (m_media_downloader->isDone()) {
+                       received_media();
                        delete m_media_downloader;
                        m_media_downloader = NULL;
                }
@@ -1610,11 +1604,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                }
 
                m_media_downloader->step(this);
-               if (m_media_downloader->isDone()) {
-                       // might be done already if all media is in the cache
-                       delete m_media_downloader;
-                       m_media_downloader = NULL;
-               }
        }
        else if(command == TOCLIENT_MEDIA)
        {
@@ -1666,11 +1655,6 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                        m_media_downloader->conventionalTransferDone(
                                        name, data, this);
                }
-
-               if (m_media_downloader->isDone()) {
-                       delete m_media_downloader;
-                       m_media_downloader = NULL;
-               }
        }
        else if(command == TOCLIENT_TOOLDEF)
        {
@@ -1844,6 +1828,10 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                float size = readF1000(is);
                bool collisiondetection = readU8(is);
                std::string texture = deSerializeLongString(is);
+               bool vertical = false;
+               try {
+                       vertical = readU8(is);
+               } catch (...) {}
 
                ClientEvent event;
                event.type = CE_SPAWN_PARTICLE;
@@ -1855,6 +1843,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                event.spawn_particle.size = size;
                event.spawn_particle.collisiondetection =
                                collisiondetection;
+               event.spawn_particle.vertical = vertical;
                event.spawn_particle.texture = new std::string(texture);
 
                m_client_event_queue.push_back(event);
@@ -1879,6 +1868,10 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                bool collisiondetection = readU8(is);
                std::string texture = deSerializeLongString(is);
                u32 id = readU32(is);
+               bool vertical = false;
+               try {
+                       vertical = readU8(is);
+               } catch (...) {}
 
                ClientEvent event;
                event.type = CE_ADD_PARTICLESPAWNER;
@@ -1897,6 +1890,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                event.add_particlespawner.minsize = minsize;
                event.add_particlespawner.maxsize = maxsize;
                event.add_particlespawner.collisiondetection = collisiondetection;
+               event.add_particlespawner.vertical = vertical;
                event.add_particlespawner.texture = new std::string(texture);
                event.add_particlespawner.id = id;
 
@@ -1931,6 +1925,10 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                u32 dir          = readU32(is);
                v2f align        = readV2F1000(is);
                v2f offset       = readV2F1000(is);
+               v3f world_pos;
+               try{
+                       world_pos    = readV3F1000(is);
+               }catch(SerializationError &e) {};
 
                ClientEvent event;
                event.type = CE_HUDADD;
@@ -1945,6 +1943,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                event.hudadd.dir    = dir;
                event.hudadd.align  = new v2f(align);
                event.hudadd.offset = new v2f(offset);
+               event.hudadd.world_pos = new v3f(world_pos);
                m_client_event_queue.push_back(event);
        }
        else if(command == TOCLIENT_HUDRM)
@@ -1963,6 +1962,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
        {
                std::string sdata;
                v2f v2fdata;
+               v3f v3fdata;
                u32 intdata = 0;
                
                std::string datastring((char *)&data[2], datasize - 2);
@@ -1976,6 +1976,8 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                        v2fdata = readV2F1000(is);
                else if (stat == HUD_STAT_NAME || stat == HUD_STAT_TEXT)
                        sdata = deSerializeString(is);
+               else if (stat == HUD_STAT_WORLD_POS)
+                       v3fdata = readV3F1000(is);
                else
                        intdata = readU32(is);
                
@@ -1984,6 +1986,7 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                event.hudchange.id      = id;
                event.hudchange.stat    = (HudElementStat)stat;
                event.hudchange.v2fdata = new v2f(v2fdata);
+               event.hudchange.v3fdata = new v3f(v3fdata);
                event.hudchange.sdata   = new std::string(sdata);
                event.hudchange.data    = intdata;
                m_client_event_queue.push_back(event);
@@ -2023,6 +2026,25 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
                        ((LocalPlayer *) player)->hotbar_selected_image = value;
                }
        }
+       else if(command == TOCLIENT_SET_SKY)
+       {
+               std::string datastring((char *)&data[2], datasize - 2);
+               std::istringstream is(datastring, std::ios_base::binary);
+
+               video::SColor *bgcolor = new video::SColor(readARGB8(is));
+               std::string *type = new std::string(deSerializeString(is));
+               u16 count = readU16(is);
+               std::vector<std::string> *params = new std::vector<std::string>;
+               for(size_t i=0; i<count; i++)
+                       params->push_back(deSerializeString(is));
+
+               ClientEvent event;
+               event.type = CE_SET_SKY;
+               event.set_sky.bgcolor = bgcolor;
+               event.set_sky.type = type;
+               event.set_sky.params = params;
+               m_client_event_queue.push_back(event);
+       }
        else
        {
                infostream<<"Client: Ignoring unknown command "