3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
22 #include "irrlichttypes_bloated.h"
23 #include "inventory.h"
24 #include "constants.h"
25 #include "network/networkprotocol.h"
26 #include "util/basic_macros.h"
30 #define PLAYERNAME_SIZE 20
32 #define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
33 #define PLAYERNAME_ALLOWED_CHARS_USER_EXPL "'a' to 'z', 'A' to 'Z', '0' to '9', '-', '_'"
37 PlayerControl() = default;
52 float a_sidew_move_joystick_axis,
53 float a_forw_move_joystick_axis
68 sidew_move_joystick_axis = a_sidew_move_joystick_axis;
69 forw_move_joystick_axis = a_forw_move_joystick_axis;
83 float sidew_move_joystick_axis = 0.0f;
84 float forw_move_joystick_axis = 0.0f;
89 bool free_move = false;
90 bool fast_move = false;
91 bool continuous_forward = false;
92 bool always_fly_fast = false;
93 bool aux1_descends = false;
96 void readGlobalSettings();
100 struct CollisionInfo;
108 Player(const char *name, IItemDefManager *idef);
109 virtual ~Player() = 0;
111 DISABLE_CLASS_COPY(Player);
113 virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
115 virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
116 std::vector<CollisionInfo> *collision_info)
119 const v3f &getSpeed() const
124 void setSpeed(const v3f &speed)
129 const char *getName() const { return m_name; }
133 size_t size = hud.size();
134 for (size_t i = 0; i != size; i++) {
141 v3f eye_offset_first;
142 v3f eye_offset_third;
146 f32 movement_acceleration_default;
147 f32 movement_acceleration_air;
148 f32 movement_acceleration_fast;
149 f32 movement_speed_walk;
150 f32 movement_speed_crouch;
151 f32 movement_speed_fast;
152 f32 movement_speed_climb;
153 f32 movement_speed_jump;
154 f32 movement_liquid_fluidity;
155 f32 movement_liquid_fluidity_smooth;
156 f32 movement_liquid_sink;
157 f32 movement_gravity;
159 v2s32 local_animations[4];
160 float local_animation_speed;
162 std::string inventory_formspec;
163 std::string formspec_prepend;
165 PlayerControl control;
166 const PlayerControl& getPlayerControl() { return control; }
167 PlayerSettings &getPlayerSettings() { return m_player_settings; }
168 static void settingsChangedCallback(const std::string &name, void *data);
172 HudElement* getHud(u32 id);
173 u32 addHud(HudElement* hud);
174 HudElement* removeHud(u32 id);
178 s32 hud_hotbar_itemcount;
180 char m_name[PLAYERNAME_SIZE];
183 std::vector<HudElement *> hud;
185 // Protect some critical areas
186 // hud for example can be modified by EmergeThread
189 PlayerSettings m_player_settings;