]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/serverenvironment.cpp
[CSM] Add core.get_timeofday & core.get_day_count env calls (#5401)
[dragonfireclient.git] / src / serverenvironment.cpp
index e1962bcff9ac5e54e9078c41a55170ad322418b0..e09c7da16b4435860454a884f908a6cf661718c5 100644 (file)
@@ -28,7 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "profiler.h"
 #include "raycast.h"
 #include "remoteplayer.h"
-#include "scripting_game.h"
+#include "serverscripting.h"
 #include "server.h"
 #include "voxelalgorithms.h"
 #include "util/serialize.h"
@@ -352,8 +352,9 @@ void ActiveBlockList::update(std::vector<v3s16> &active_positions,
 */
 
 ServerEnvironment::ServerEnvironment(ServerMap *map,
-       GameScripting *scriptIface, Server *server,
-       const std::string &path_world) :
+       ServerScripting *scriptIface, Server *server,
+       const std::string &path_world):
+       Environment(server),
        m_map(map),
        m_script(scriptIface),
        m_server(server),
@@ -500,7 +501,8 @@ void ServerEnvironment::saveLoadedPlayers()
        for (std::vector<RemotePlayer *>::iterator it = m_players.begin();
                it != m_players.end();
                ++it) {
-               if ((*it)->checkModified()) {
+               if ((*it)->checkModified() ||
+                       ((*it)->getPlayerSAO() && (*it)->getPlayerSAO()->extendedAttributesModified())) {
                        (*it)->save(players_path, m_server);
                }
        }
@@ -1666,7 +1668,7 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
 
        if (objectpos_over_limit(object->getBasePosition())) {
                v3f p = object->getBasePosition();
-               errorstream << "ServerEnvironment::addActiveObjectRaw(): "
+               warningstream << "ServerEnvironment::addActiveObjectRaw(): "
                        << "object position (" << p.X << "," << p.Y << "," << p.Z
                        << ") outside maximum range" << std::endl;
                if (object->environmentDeletes())
@@ -1694,7 +1696,8 @@ u16 ServerEnvironment::addActiveObjectRaw(ServerActiveObject *object,
        {
                // Add static object to active static list of the block
                v3f objectpos = object->getBasePosition();
-               std::string staticdata = object->getStaticData();
+               std::string staticdata = "";
+               object->getStaticData(&staticdata);
                StaticObject s_obj(object->getType(), objectpos, staticdata);
                // Add to the block where the object is located in
                v3s16 blockpos = getNodeBlockPos(floatToInt(objectpos, BS));
@@ -1939,11 +1942,14 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
 
        If block wasn't generated (not in memory or on disk),
 */
-void ServerEnvironment::deactivateFarObjects(bool force_delete)
+void ServerEnvironment::deactivateFarObjects(bool _force_delete)
 {
        std::vector<u16> objects_to_remove;
        for(ActiveObjectMap::iterator i = m_active_objects.begin();
                i != m_active_objects.end(); ++i) {
+               // force_delete might be overriden per object
+               bool force_delete = _force_delete;
+
                ServerActiveObject* obj = i->second;
                assert(obj);
 
@@ -1980,7 +1986,8 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
                                        <<std::endl;
                                continue;
                        }
-                       std::string staticdata_new = obj->getStaticData();
+                       std::string staticdata_new = "";
+                       obj->getStaticData(&staticdata_new);
                        StaticObject s_obj(obj->getType(), objectpos, staticdata_new);
                        block->m_static_objects.insert(id, s_obj);
                        obj->m_static_block = blockpos_o;
@@ -2020,7 +2027,8 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
                if(obj->isStaticAllowed())
                {
                        // Create new static object
-                       std::string staticdata_new = obj->getStaticData();
+                       std::string staticdata_new = "";
+                       obj->getStaticData(&staticdata_new);
                        StaticObject s_obj(obj->getType(), objectpos, staticdata_new);
 
                        bool stays_in_same_block = false;