X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fplayer.h;h=f70b52fe737453a6741a8ca339de8f2f8148da27;hb=0847e550f0b5484471e7c02d54ed35443824a86e;hp=3bbb4034d3ff5bfeb41c8af1404006b91b604aea;hpb=25a7fabed83caccb2c321bb4d080c5907f37b60a;p=dragonfireclient.git diff --git a/src/player.h b/src/player.h index 3bbb4034d..f70b52fe7 100644 --- a/src/player.h +++ b/src/player.h @@ -1,6 +1,6 @@ /* Minetest-c55 -Copyright (C) 2010 celeron55, Perttu Ahola +Copyright (C) 2010-2011 celeron55, Perttu Ahola 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 @@ -17,15 +17,12 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -/* -(c) 2010 Perttu Ahola -*/ - #ifndef PLAYER_HEADER #define PLAYER_HEADER #include "common_irrlicht.h" #include "inventory.h" +#include "collision.h" #define PLAYERNAME_SIZE 20 @@ -42,7 +39,7 @@ class 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() { @@ -114,11 +111,18 @@ class Player 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; + bool craftresult_is_preview; + + u16 hp; + u16 peer_id; protected: @@ -129,6 +133,10 @@ class Player v3f m_position; }; +/* + Player on the server +*/ + class ServerRemotePlayer : public Player { public: @@ -144,15 +152,19 @@ class ServerRemotePlayer : public Player return false; } - virtual void move(f32 dtime, Map &map) + virtual void move(f32 dtime, Map &map, f32 pos_max_d) { } - + private: }; #ifndef SERVER +/* + All the other players on the client are these +*/ + class RemotePlayer : public Player, public scene::ISceneNode { public: @@ -237,7 +249,7 @@ class RemotePlayer : public Player, public scene::ISceneNode } } - void move(f32 dtime, Map &map); + void move(f32 dtime, Map &map, f32 pos_max_d); private: scene::IMeshSceneNode *m_node; @@ -264,6 +276,7 @@ struct PlayerControl right = false; jump = false; aux1 = false; + sneak = false; pitch = 0; yaw = 0; } @@ -274,6 +287,7 @@ struct PlayerControl bool a_right, bool a_jump, bool a_aux1, + bool a_sneak, float a_pitch, float a_yaw ) @@ -284,6 +298,7 @@ struct PlayerControl right = a_right; jump = a_jump; aux1 = a_aux1; + sneak = a_sneak; pitch = a_pitch; yaw = a_yaw; } @@ -293,6 +308,7 @@ struct PlayerControl bool right; bool jump; bool aux1; + bool sneak; float pitch; float yaw; }; @@ -308,13 +324,19 @@ class LocalPlayer : public Player return true; } - void move(f32 dtime, Map &map); + void move(f32 dtime, Map &map, f32 pos_max_d, + core::list *collision_info); + 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_sneak_node; + // Whether the player is allowed to sneak + bool m_sneak_node_exists; }; #endif // !SERVER