]> git.lizzy.rs Git - dragonfireclient.git/blob - src/localplayer.h
Fix hovering after mining a block underneath you while sneaking
[dragonfireclient.git] / src / localplayer.h
1 /*
2 Minetest-c55
3 Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifndef LOCALPLAYER_HEADER
21 #define LOCALPLAYER_HEADER
22
23 #include "player.h"
24
25 struct PlayerControl
26 {
27         PlayerControl()
28         {
29                 up = false;
30                 down = false;
31                 left = false;
32                 right = false;
33                 jump = false;
34                 aux1 = false;
35                 sneak = false;
36                 pitch = 0;
37                 yaw = 0;
38         }
39         PlayerControl(
40                 bool a_up,
41                 bool a_down,
42                 bool a_left,
43                 bool a_right,
44                 bool a_jump,
45                 bool a_aux1,
46                 bool a_sneak,
47                 float a_pitch,
48                 float a_yaw
49         )
50         {
51                 up = a_up;
52                 down = a_down;
53                 left = a_left;
54                 right = a_right;
55                 jump = a_jump;
56                 aux1 = a_aux1;
57                 sneak = a_sneak;
58                 pitch = a_pitch;
59                 yaw = a_yaw;
60         }
61         bool up;
62         bool down;
63         bool left;
64         bool right;
65         bool jump;
66         bool aux1;
67         bool sneak;
68         float pitch;
69         float yaw;
70 };
71
72 class LocalPlayer : public Player
73 {
74 public:
75         LocalPlayer(IGameDef *gamedef);
76         virtual ~LocalPlayer();
77
78         bool isLocal() const
79         {
80                 return true;
81         }
82         
83         void move(f32 dtime, Map &map, f32 pos_max_d,
84                         core::list<CollisionInfo> *collision_info);
85         void move(f32 dtime, Map &map, f32 pos_max_d);
86
87         void applyControl(float dtime);
88
89         v3s16 getStandingNodePos();
90         
91         PlayerControl control;
92
93 private:
94         // This is used for determining the sneaking range
95         v3s16 m_sneak_node;
96         // Whether the player is allowed to sneak
97         bool m_sneak_node_exists;
98         // Node below player, used to determine whether it has been removed,
99         // and its old type
100         v3s16 m_old_node_below;
101         std::string m_old_node_below_type;
102         // Whether recalculation of the sneak node is needed
103         bool m_need_to_get_new_sneak_node;
104 };
105
106 #endif
107