X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fenvironment.cpp;h=e70cb39b784d42a38a6e93f118e408a9e3c3e5f9;hb=ab45133ab4826359ca9a5ed50b68150eb462c8ef;hp=05629b09db3613ace46fb0313b2af4ab4bbf97ee;hpb=c4f400acd01d1951c6355e2eec42d10d0a2d871a;p=oweals%2Fminetest.git diff --git a/src/environment.cpp b/src/environment.cpp index 05629b09d..e70cb39b7 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -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) { } @@ -743,19 +745,25 @@ neighbor_found: u32 active_object_count = block->m_static_objects.m_active.size(); // Find out how many objects this and all the neighbors contain u32 active_object_count_wider = 0; + u32 wider_unknown_count = 0; for(s16 x=-1; x<=1; x++) for(s16 y=-1; y<=1; y++) for(s16 z=-1; z<=1; z++) { MapBlock *block2 = map->getBlockNoCreateNoEx( block->getPos() + v3s16(x,y,z)); - if(block2==NULL) + if(block2==NULL){ + wider_unknown_count = 0; continue; + } active_object_count_wider += block2->m_static_objects.m_active.size() + block2->m_static_objects.m_stored.size(); } - + // Extrapolate + u32 wider_known_count = 3*3*3 - wider_unknown_count; + active_object_count_wider += wider_unknown_count * active_object_count_wider / wider_known_count; + // Call all the trigger variations i->abm->trigger(m_env, p, n); i->abm->trigger(m_env, p, n, @@ -784,7 +792,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime) < elapsed_timers = @@ -933,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 */ @@ -1243,7 +1256,7 @@ u16 getFreeServerActiveObjectId( u16 ServerEnvironment::addActiveObject(ServerActiveObject *object) { assert(object); - u16 id = addActiveObjectRaw(object, true); + u16 id = addActiveObjectRaw(object, true, 0); return id; } @@ -1402,7 +1415,7 @@ ActiveObjectMessage ServerEnvironment::getActiveObjectMessage() */ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, - bool set_changed) + bool set_changed, u32 dtime_s) { assert(object); if(object->getId() == 0){ @@ -1442,7 +1455,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, // Register reference in scripting api (must be done before post-init) scriptapi_add_object_reference(m_lua, object); // Post-initialize object - object->addedToEnvironment(); + object->addedToEnvironment(dtime_s); // Add static data to block if(object->isStaticAllowed()) @@ -1465,9 +1478,10 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object, "addActiveObjectRaw"); } else{ + v3s16 p = floatToInt(objectpos, BS); errorstream<<"ServerEnvironment::addActiveObjectRaw(): " <<"could not find block for storing id="<getId() - <<" statically"< new_stored; // Loop through stored static objects @@ -1632,7 +1646,7 @@ void ServerEnvironment::activateObjects(MapBlock *block) <<"activated static object pos="<removeFromScene(); + obj->removeFromScene(true); delete obj; m_active_objects.remove(id); }