Collision detection tweak #2 (#9365)
[oweals/minetest.git] / src / content_sao.h
index 1321edb91633e84de419e064736333aad6aa6ac4..e9047daf0aa47131c27a4ab2811d0225400c119d 100644 (file)
@@ -46,20 +46,24 @@ public:
        inline bool isAttached() const
        { return getParent(); }
 
+       inline bool isImmortal() const
+       { return itemgroup_get(getArmorGroups(), "immortal"); }
+
        void setArmorGroups(const ItemGroupList &armor_groups);
-       const ItemGroupList &getArmorGroups();
+       const ItemGroupList &getArmorGroups() const;
        void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop);
        void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop);
        void setAnimationSpeed(float frame_speed);
        void setBonePosition(const std::string &bone, v3f position, v3f rotation);
        void getBonePosition(const std::string &bone, v3f *position, v3f *rotation);
        void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation);
-       void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation);
+       void getAttachment(int *parent_id, std::string *bone, v3f *position,
+                       v3f *rotation) const;
        void clearChildAttachments();
        void clearParentAttachment();
        void addAttachmentChild(int child_id);
        void removeAttachmentChild(int child_id);
-       const std::unordered_set<int> &getAttachmentChildIds();
+       const std::unordered_set<int> &getAttachmentChildIds() const;
        ServerActiveObject *getParent() const;
        ObjectProperties* accessObjectProperties();
        void notifyObjectPropertiesModified();
@@ -104,7 +108,7 @@ class LuaEntitySAO : public UnitSAO
 {
 public:
        LuaEntitySAO(ServerEnvironment *env, v3f pos,
-                    const std::string &name, const std::string &state);
+               const std::string &name, const std::string &state);
        ~LuaEntitySAO();
        ActiveObjectType getType() const
        { return ACTIVEOBJECT_TYPE_LUAENTITY; }
@@ -112,16 +116,16 @@ public:
        { return ACTIVEOBJECT_TYPE_GENERIC; }
        virtual void addedToEnvironment(u32 dtime_s);
        static ServerActiveObject* create(ServerEnvironment *env, v3f pos,
-                       const std::string &data);
+               const std::string &data);
        void step(float dtime, bool send_recommended);
        std::string getClientInitializationData(u16 protocol_version);
        bool isStaticAllowed() const
        { return m_prop.static_save; }
        void getStaticData(std::string *result) const;
-       int punch(v3f dir,
-                       const ToolCapabilities *toolcap=NULL,
-                       ServerActiveObject *puncher=NULL,
-                       float time_from_last_punch=1000000);
+       u16 punch(v3f dir,
+               const ToolCapabilities *toolcap = nullptr,
+               ServerActiveObject *puncher = nullptr,
+               float time_from_last_punch = 1000000.0f);
        void rightClick(ServerActiveObject *clicker);
        void setPos(const v3f &pos);
        void moveTo(v3f pos, bool continuous);
@@ -129,6 +133,7 @@ public:
        std::string getDescription();
        void setHP(s32 hp, const PlayerHPChangeReason &reason);
        u16 getHP() const;
+
        /* LuaEntitySAO-specific */
        void setVelocity(v3f velocity);
        void addVelocity(v3f velocity)
@@ -214,7 +219,7 @@ class PlayerSAO : public UnitSAO
 public:
        PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t peer_id_,
                        bool is_singleplayer);
-       ~PlayerSAO();
+
        ActiveObjectType getType() const
        { return ACTIVEOBJECT_TYPE_PLAYER; }
        ActiveObjectType getSendType() const
@@ -253,7 +258,7 @@ public:
                Interaction interface
        */
 
-       int punch(v3f dir,
+       u16 punch(v3f dir,
                const ToolCapabilities *toolcap,
                ServerActiveObject *puncher,
                float time_from_last_punch);
@@ -267,16 +272,13 @@ public:
        /*
                Inventory interface
        */
-
-       Inventory* getInventory();
-       const Inventory* getInventory() const;
+       Inventory *getInventory() const;
        InventoryLocation getInventoryLocation() const;
-       std::string getWieldList() const;
-       ItemStack getWieldedItem() const;
-       ItemStack getWieldedItemOrHand() const;
+       void setInventoryModified() {}
+       std::string getWieldList() const { return "main"; }
+       u16 getWieldIndex() const;
+       ItemStack getWieldedItem(ItemStack *selected, ItemStack *hand = nullptr) const;
        bool setWieldedItem(const ItemStack &item);
-       int getWieldIndex() const;
-       void setWieldIndex(int i);
 
        /*
                PlayerSAO-specific
@@ -320,6 +322,7 @@ public:
        {
                return m_dig_pool;
        }
+       void setMaxSpeedOverride(const v3f &vel);
        // Returns true if cheated
        bool checkMovementCheat();
 
@@ -350,7 +353,6 @@ private:
 
        RemotePlayer *m_player = nullptr;
        session_t m_peer_id = 0;
-       Inventory *m_inventory = nullptr;
 
        // Cheat prevention
        LagPool m_dig_pool;
@@ -360,13 +362,14 @@ private:
        float m_time_from_last_punch = 0.0f;
        v3s16 m_nocheat_dig_pos = v3s16(32767, 32767, 32767);
        float m_nocheat_dig_time = 0.0f;
+       float m_max_speed_override_time = 0.0f;
+       v3f m_max_speed_override = v3f(0.0f, 0.0f, 0.0f);
 
        // Timers
        IntervalLimiter m_breathing_interval;
        IntervalLimiter m_drowning_interval;
        IntervalLimiter m_node_hurt_interval;
 
-       int m_wield_index = 0;
        bool m_position_not_sent = false;
 
        // Cached privileges for enforcement