Add congestion control settings to minetest.conf
[oweals/minetest.git] / src / environment.cpp
index 4abba63599f4f3a1157a99677d2dca56260e53f4..e70cb39b784d42a38a6e93f118e408a9e3c3e5f9 100644 (file)
@@ -43,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #endif
 #include "daynightratio.h"
 #include "map.h"
+#include "util/serialize.h"
 
 #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
 
@@ -328,7 +329,8 @@ ServerEnvironment::ServerEnvironment(ServerMap *map, lua_State *L,
        m_send_recommended_timer(0),
        m_active_block_interval_overload_skip(0),
        m_game_time(0),
-       m_game_time_fraction_counter(0)
+       m_game_time_fraction_counter(0),
+       m_recommended_send_interval(0.1)
 {
 }
 
@@ -939,6 +941,11 @@ void ServerEnvironment::step(float dtime)
        /* Step time of day */
        stepTimeOfDay(dtime);
 
+       // Update this one
+       // NOTE: This is kind of funny on a singleplayer game, but doesn't
+       // really matter that much.
+       m_recommended_send_interval = g_settings->getFloat("dedicated_server_step");
+
        /*
                Increment game time
        */
@@ -2296,8 +2303,9 @@ void ClientEnvironment::addActiveObject(u16 id, u8 type,
        {
                errorstream<<"ClientEnvironment::addActiveObject():"
                                <<" id="<<id<<" type="<<type
-                               <<": SerializationError in initialize(),"
-                               <<" init_data="<<serializeJsonString(init_data)
+                               <<": SerializationError in initialize(): "
+                               <<e.what()
+                               <<": init_data="<<serializeJsonString(init_data)
                                <<std::endl;
        }
 
@@ -2315,7 +2323,7 @@ void ClientEnvironment::removeActiveObject(u16 id)
                                <<"id="<<id<<" not found"<<std::endl;
                return;
        }
-       obj->removeFromScene();
+       obj->removeFromScene(true);
        delete obj;
        m_active_objects.remove(id);
 }