added sneaking/crouching and changelog
[oweals/minetest.git] / src / player.h
index 0b9f014c1274d1a93fdac3bba00055979181f687..27ce1f5aafdc909116a61b9523e65e44e03f3012 100644 (file)
@@ -29,6 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #define PLAYERNAME_SIZE 20
 
+#define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,"
+
 class Map;
 
 class Player
@@ -37,8 +39,10 @@ public:
        Player();
        virtual ~Player();
 
+       void resetInventory();
+
        //void move(f32 dtime, Map &map);
-       virtual void move(f32 dtime, Map &map) = 0;
+       virtual void move(f32 dtime, Map &map, f32 pos_max_d) = 0;
 
        v3f getSpeed()
        {
@@ -96,9 +100,25 @@ public:
        virtual bool isLocal() const = 0;
 
        virtual void updateLight(u8 light_at_pos) {};
+       
+       // NOTE: Use peer_id == 0 for disconnected
+       /*virtual bool isClientConnected() { return false; }
+       virtual void setClientConnected(bool) {}*/
+       
+       /*
+               serialize() writes a bunch of text that can contain
+               any characters except a '\0', and such an ending that
+               deSerialize stops reading exactly at the right point.
+       */
+       void serialize(std::ostream &os);
+       void deSerialize(std::istream &is);
 
        bool touching_ground;
+       // This oscillates so that the player jumps a bit above the surface
        bool in_water;
+       // This is more stable and defines the maximum speed of the player
+       bool in_water_stable;
+       bool swimming_up;
        
        Inventory inventory;
 
@@ -122,12 +142,12 @@ public:
        {
        }
 
-       bool isLocal() const
+       virtual bool isLocal() const
        {
                return false;
        }
 
-       void move(f32 dtime, Map &map)
+       virtual void move(f32 dtime, Map &map, f32 pos_max_d)
        {
        }
 
@@ -220,7 +240,7 @@ public:
                }
        }
        
-       void move(f32 dtime, Map &map);
+       void move(f32 dtime, Map &map, f32 pos_max_d);
 
 private:
        scene::IMeshSceneNode *m_node;
@@ -234,7 +254,7 @@ private:
        v3f m_showpos;
 };
 
-#endif
+#endif // !SERVER
 
 #ifndef SERVER
 struct PlayerControl
@@ -246,7 +266,8 @@ struct PlayerControl
                left = false;
                right = false;
                jump = false;
-               superspeed = false;
+               aux1 = false;
+               sneak = false;
                pitch = 0;
                yaw = 0;
        }
@@ -256,7 +277,8 @@ struct PlayerControl
                bool a_left,
                bool a_right,
                bool a_jump,
-               bool a_superspeed,
+               bool a_aux1,
+               bool a_sneak,
                float a_pitch,
                float a_yaw
        )
@@ -266,7 +288,8 @@ struct PlayerControl
                left = a_left;
                right = a_right;
                jump = a_jump;
-               superspeed = a_superspeed;
+               aux1 = a_aux1;
+               sneak = a_sneak;
                pitch = a_pitch;
                yaw = a_yaw;
        }
@@ -275,7 +298,8 @@ struct PlayerControl
        bool left;
        bool right;
        bool jump;
-       bool superspeed;
+       bool aux1;
+       bool sneak;
        float pitch;
        float yaw;
 };
@@ -291,13 +315,15 @@ public:
                return true;
        }
 
-       void move(f32 dtime, Map &map);
+       void move(f32 dtime, Map &map, f32 pos_max_d);
 
        void applyControl(float dtime);
        
        PlayerControl control;
 
 private:
+       // This is used for determining the sneaking range
+       v3s16 m_last_walked_node;
 };
 #endif // !SERVER