diff options
Diffstat (limited to 'src/player.h')
-rw-r--r-- | src/player.h | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/src/player.h b/src/player.h index f1b848a2a..9a7e1d5b6 100644 --- a/src/player.h +++ b/src/player.h @@ -29,7 +29,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define PLAYERNAME_SIZE 20 -#define PLAYERNAME_ALLOWED_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" +#define PLAYERNAME_ALLOWED_CHARS \ + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_" #define PLAYERNAME_ALLOWED_CHARS_USER_EXPL "'a' to 'z', 'A' to 'Z', '0' to '9', '-', '_'" struct PlayerFovSpec @@ -48,22 +49,10 @@ struct PlayerControl { PlayerControl() = default; - PlayerControl( - bool a_up, - bool a_down, - bool a_left, - bool a_right, - bool a_jump, - bool a_aux1, - bool a_sneak, - bool a_zoom, - bool a_LMB, - bool a_RMB, - float a_pitch, - float a_yaw, - float a_sidew_move_joystick_axis, - float a_forw_move_joystick_axis - ) + PlayerControl(bool a_up, bool a_down, bool a_left, bool a_right, bool a_jump, + bool a_aux1, bool a_sneak, bool a_zoom, bool a_LMB, bool a_RMB, + float a_pitch, float a_yaw, float a_sidew_move_joystick_axis, + float a_forw_move_joystick_axis) { up = a_up; down = a_down; @@ -108,10 +97,9 @@ struct PlayerSettings bool noclip = false; bool autojump = false; - const std::string setting_names[9] = { - "free_move", "pitch_move", "fast_move", "freecam", "continuous_forward", "always_fly_fast", - "aux1_descends", "noclip", "autojump" - }; + const std::string setting_names[9] = {"free_move", "pitch_move", "fast_move", + "freecam", "continuous_forward", "always_fly_fast", + "aux1_descends", "noclip", "autojump"}; void readGlobalSettings(); }; @@ -123,27 +111,20 @@ class Environment; class Player { public: - Player(const char *name, IItemDefManager *idef); virtual ~Player() = 0; DISABLE_CLASS_COPY(Player); - virtual void move(f32 dtime, Environment *env, f32 pos_max_d) - {} + virtual void move(f32 dtime, Environment *env, f32 pos_max_d) {} virtual void move(f32 dtime, Environment *env, f32 pos_max_d, std::vector<CollisionInfo> *collision_info) - {} - - const v3f &getSpeed() const { - return m_speed; } - void setSpeed(const v3f &speed) - { - m_speed = speed; - } + const v3f &getSpeed() const { return m_speed; } + + void setSpeed(const v3f &speed) { m_speed = speed; } const char *getName() const { return m_name; } @@ -182,7 +163,7 @@ public: std::string formspec_prepend; PlayerControl control; - const PlayerControl& getPlayerControl() { return control; } + const PlayerControl &getPlayerControl() { return control; } PlayerSettings &getPlayerSettings() { return m_player_settings; } static void settingsChangedCallback(const std::string &name, void *data); @@ -191,22 +172,16 @@ public: void setWieldIndex(u16 index); u16 getWieldIndex() const { return m_wield_index; } - void setFov(const PlayerFovSpec &spec) - { - m_fov_override_spec = spec; - } + void setFov(const PlayerFovSpec &spec) { m_fov_override_spec = spec; } - const PlayerFovSpec &getFov() const - { - return m_fov_override_spec; - } + const PlayerFovSpec &getFov() const { return m_fov_override_spec; } u32 keyPressed = 0; - HudElement* getHud(u32 id); - u32 addHud(HudElement* hud); - HudElement* removeHud(u32 id); - void clearHud(); + HudElement *getHud(u32 id); + u32 addHud(HudElement *hud); + HudElement *removeHud(u32 id); + void clearHud(); u32 hud_flags; s32 hud_hotbar_itemcount; @@ -215,9 +190,10 @@ protected: char m_name[PLAYERNAME_SIZE]; v3f m_speed; u16 m_wield_index = 0; - PlayerFovSpec m_fov_override_spec = { 0.0f, false, 0.0f }; + PlayerFovSpec m_fov_override_spec = {0.0f, false, 0.0f}; std::vector<HudElement *> hud; + private: // Protect some critical areas // hud for example can be modified by EmergeThread |