]> git.lizzy.rs Git - minetest.git/blobdiff - src/client/client.cpp
content_cao: Fix behavior of legacy "textures" field for wielditems
[minetest.git] / src / client / client.cpp
index 941fc203dea603fefab8a62e701df4aa1d8cdb17..34f97a9de356fb7abbd9b5b77aa067461e9deca1 100644 (file)
@@ -64,6 +64,14 @@ extern gui::IGUIEnvironment* guienv;
        Utility classes
 */
 
+u32 PacketCounter::sum() const
+{
+       u32 n = 0;
+       for (const auto &it : m_packets)
+               n += it.second;
+       return n;
+}
+
 void PacketCounter::print(std::ostream &o) const
 {
        for (const auto &it : m_packets) {
@@ -357,9 +365,11 @@ void Client::step(float dtime)
                if(counter <= 0.0f)
                {
                        counter = 30.0f;
+                       u32 sum = m_packetcounter.sum();
+                       float avg = sum / counter;
 
-                       infostream << "Client packetcounter (" << m_packetcounter_timer
-                                       << "s):"<<std::endl;
+                       infostream << "Client packetcounter (" << counter << "s): "
+                                       << "sum=" << sum << " avg=" << avg << "/s" << std::endl;
                        m_packetcounter.print(infostream);
                        m_packetcounter.clear();
                }
@@ -660,11 +670,9 @@ void Client::step(float dtime)
        }
 }
 
-bool Client::loadMedia(const std::string &data, const std::string &filename)
+bool Client::loadMedia(const std::string &data, const std::string &filename,
+       bool from_media_push)
 {
-       // Silly irrlicht's const-incorrectness
-       Buffer<char> data_rw(data.c_str(), data.size());
-
        std::string name;
 
        const char *image_ext[] = {
@@ -680,6 +688,9 @@ bool Client::loadMedia(const std::string &data, const std::string &filename)
                io::IFileSystem *irrfs = RenderingEngine::get_filesystem();
                video::IVideoDriver *vdrv = RenderingEngine::get_video_driver();
 
+               // Silly irrlicht's const-incorrectness
+               Buffer<char> data_rw(data.c_str(), data.size());
+
                // Create an irrlicht memory file
                io::IReadFile *rfile = irrfs->createMemoryReadFile(
                                *data_rw, data_rw.getSize(), "_tempreadfile");
@@ -717,7 +728,6 @@ bool Client::loadMedia(const std::string &data, const std::string &filename)
                ".x", ".b3d", ".md2", ".obj",
                NULL
        };
-
        name = removeStringEnd(filename, model_ext);
        if (!name.empty()) {
                verbosestream<<"Client: Storing model into memory: "
@@ -734,6 +744,8 @@ bool Client::loadMedia(const std::string &data, const std::string &filename)
        };
        name = removeStringEnd(filename, translate_ext);
        if (!name.empty()) {
+               if (from_media_push)
+                       return false;
                TRACESTREAM(<< "Client: Loading translation: "
                                << "\"" << filename << "\"" << std::endl);
                g_client_translations->loadTranslation(data);