]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/content_sao.h
Add dtime_s to entity activation
[dragonfireclient.git] / src / content_sao.h
index f3b9f8b2f353af6641fddd20fa9dfc998ebfb3c9..05c77e2cb92e861b5be28437cca61255aeb281d8 100644 (file)
@@ -3,16 +3,16 @@ Minetest-c55
 Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 of the License, or
 (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+GNU Lesser General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
+You should have received a copy of the GNU Lesser General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
@@ -43,7 +43,7 @@ class LuaEntitySAO : public ServerActiveObject
        { return ACTIVEOBJECT_TYPE_LUAENTITY; }
        u8 getSendType() const
        { return ACTIVEOBJECT_TYPE_GENERIC; }
-       virtual void addedToEnvironment();
+       virtual void addedToEnvironment(u32 dtime_s);
        static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
                        const std::string &data);
        void step(float dtime, bool send_recommended);
@@ -105,7 +105,8 @@ class LuaEntitySAO : public ServerActiveObject
 class PlayerSAO : public ServerActiveObject
 {
 public:
-       PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_);
+       PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_,
+                       const std::set<std::string> &privs, bool is_singleplayer);
        ~PlayerSAO();
        u8 getType() const
        { return ACTIVEOBJECT_TYPE_PLAYER; }
@@ -117,7 +118,7 @@ class PlayerSAO : public ServerActiveObject
                Active object <-> environment interface
        */
 
-       void addedToEnvironment();
+       void addedToEnvironment(u32 dtime_s);
        void removingFromEnvironment();
        bool isStaticAllowed() const;
        bool unlimitedTransferDistance() const;
@@ -162,8 +163,6 @@ class PlayerSAO : public ServerActiveObject
 
        void disconnected();
 
-       void createCreativeInventory();
-
        Player* getPlayer()
        {
                return m_player;
@@ -172,6 +171,9 @@ class PlayerSAO : public ServerActiveObject
        {
                return m_peer_id;
        }
+
+       // Cheat prevention
+
        v3f getLastGoodPosition() const
        {
                return m_last_good_position;
@@ -182,6 +184,32 @@ class PlayerSAO : public ServerActiveObject
                m_time_from_last_punch = 0.0;
                return r;
        }
+       void noCheatDigStart(v3s16 p)
+       {
+               m_nocheat_dig_pos = p;
+               m_nocheat_dig_time = 0;
+       }
+       v3s16 getNoCheatDigPos()
+       {
+               return m_nocheat_dig_pos;
+       }
+       float getNoCheatDigTime()
+       {
+               return m_nocheat_dig_time;
+       }
+       void noCheatDigEnd()
+       {
+               m_nocheat_dig_pos = v3s16(32767, 32767, 32767);
+       }
+
+       // Other
+
+       void updatePrivileges(const std::set<std::string> &privs,
+                       bool is_singleplayer)
+       {
+               m_privs = privs;
+               m_is_singleplayer = is_singleplayer;
+       }
 
 private:
        std::string getPropertyPacket();
@@ -189,15 +217,23 @@ class PlayerSAO : public ServerActiveObject
        Player *m_player;
        u16 m_peer_id;
        Inventory *m_inventory;
+
+       // Cheat prevention
        v3f m_last_good_position;
        float m_last_good_position_age;
        float m_time_from_last_punch;
+       v3s16 m_nocheat_dig_pos;
+       float m_nocheat_dig_time;
+
        int m_wield_index;
        bool m_position_not_sent;
        ItemGroupList m_armor_groups;
        bool m_armor_groups_sent;
        bool m_properties_sent;
        struct ObjectProperties m_prop;
+       // Cached privileges for enforcement
+       std::set<std::string> m_privs;
+       bool m_is_singleplayer;
 
 public:
        // Some flags used by Server