]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/player.h
Fix build since: "Remove referenced schematics from Decorations on clear"
[dragonfireclient.git] / src / player.h
index 4459b421a29477d2c1af770e8d040def196c6f34..7d8d245e319c09b0a5298bc0d95546e16b2ab50a 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "irrlichttypes_bloated.h"
 #include "inventory.h"
 #include "constants.h" // BS
+#include "jthread/jmutex.h"
 #include <list>
 
 #define PLAYERNAME_SIZE 20
@@ -91,6 +92,9 @@ class PlayerSAO;
 struct HudElement;
 class Environment;
 
+// IMPORTANT:
+// Do *not* perform an assignment or copy operation on a Player or
+// RemotePlayer object!  This will copy the lock held for HUD synchronization
 class Player
 {
 public:
@@ -101,7 +105,7 @@ class Player
        virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
        {}
        virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
-                       std::list<CollisionInfo> *collision_info)
+                       std::vector<CollisionInfo> *collision_info)
        {}
 
        v3f getSpeed()
@@ -113,7 +117,7 @@ class Player
        {
                m_speed = speed;
        }
-       
+
        void accelerateHorizontal(v3f target_speed, f32 max_increase);
        void accelerateVertical(v3f target_speed, f32 max_increase);
 
@@ -202,7 +206,7 @@ class Player
                return m_collisionbox;
        }
 
-       u32 getFreeHudID() const {
+       u32 getFreeHudID() {
                size_t size = hud.size();
                for (size_t i = 0; i != size; i++) {
                        if (!hud[i])
@@ -238,6 +242,9 @@ class Player
                        inventory.setModified(x);
        }
 
+       // Use a function, if isDead can be defined by other conditions
+       bool isDead() { return hp == 0; }
+
        bool touching_ground;
        // This oscillates so that the player jumps a bit above the surface
        bool in_liquid;
@@ -248,7 +255,7 @@ class Player
        bool is_climbing;
        bool swimming_vertical;
        bool camera_barely_in_ceiling;
-       
+
        Inventory inventory;
 
        f32 movement_acceleration_default;
@@ -281,15 +288,15 @@ class Player
        u16 peer_id;
 
        std::string inventory_formspec;
-       
+
        PlayerControl control;
        PlayerControl getPlayerControl()
        {
                return control;
        }
-       
+
        u32 keyPressed;
-       
+
 
        HudElement* getHud(u32 id);
        u32         addHud(HudElement* hud);
@@ -315,6 +322,11 @@ class Player
        bool m_dirty;
 
        std::vector<HudElement *> hud;
+private:
+       // Protect some critical areas
+       // hud for example can be modified by EmergeThread
+       // and ServerThread
+       JMutex m_mutex;
 };
 
 
@@ -337,7 +349,7 @@ class RemotePlayer : public Player
        void setPlayerSAO(PlayerSAO *sao)
        { m_sao = sao; }
        void setPosition(const v3f &position);
-       
+
 private:
        PlayerSAO *m_sao;
 };