Skip to content

Commit

Permalink
Disable autoforward if player is dead
Browse files Browse the repository at this point in the history
  • Loading branch information
ClobberXD authored and SmallJoker committed Aug 20, 2019
1 parent ded5da7 commit 3c395d9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/client/content_cao.cpp
Expand Up @@ -1541,6 +1541,9 @@ void GenericCAO::processMessage(const std::string &data)

m_hp = result_hp;

if (m_is_local_player)
m_env->getLocalPlayer()->hp = m_hp;

if (damage > 0)
{
if (m_hp <= 0)
Expand Down
4 changes: 2 additions & 2 deletions src/client/game.cpp
Expand Up @@ -2466,7 +2466,7 @@ void Game::updatePlayerControl(const CameraOrientation &cam)
}

// autoforward if set: simulate "up" key
if (player->getPlayerSettings().continuous_forward) {
if (player->getPlayerSettings().continuous_forward && !player->isDead()) {
control.up = true;
keypress_bits |= 1U << 0;
}
Expand All @@ -2483,7 +2483,7 @@ inline void Game::step(f32 *dtime)
bool can_be_and_is_paused =
(simple_singleplayer_mode && g_menumgr.pausesGame());

if (can_be_and_is_paused) { // This is for a singleplayer server
if (can_be_and_is_paused) { // This is for a singleplayer server
*dtime = 0; // No time passes
} else {
if (server)
Expand Down
8 changes: 4 additions & 4 deletions src/client/localplayer.cpp
Expand Up @@ -259,7 +259,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
}

/*
Check if player is climbing
Check if player is climbing
*/


Expand Down Expand Up @@ -489,7 +489,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
PlayerSettings &player_settings = getPlayerSettings();

// All vectors are relative to the player's yaw,
// (and pitch if pitch fly mode enabled),
// (and pitch if pitch move mode enabled),
// and will be rotated at the end
v3f speedH = v3f(0,0,0); // Horizontal (X, Z)
v3f speedV = v3f(0,0,0); // Vertical (Y)
Expand Down Expand Up @@ -930,11 +930,11 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
bool touching_ground_was = touching_ground;
touching_ground = result.touching_ground;

//bool standing_on_unloaded = result.standing_on_unloaded;
//bool standing_on_unloaded = result.standing_on_unloaded;

/*
Check the nodes under the player to see from which node the
player is sneaking from, if any. If the node from under
player is sneaking from, if any. If the node from under
the player has been removed, the player falls.
*/
f32 position_y_mod = 0.05 * BS;
Expand Down
4 changes: 3 additions & 1 deletion src/client/localplayer.h
Expand Up @@ -100,7 +100,7 @@ class LocalPlayer : public Player
bool makes_footstep_sound = true;

int last_animation = NO_ANIM;
float last_animation_speed;
float last_animation_speed = 0.0f;

std::string hotbar_image = "";
std::string hotbar_selected_image = "";
Expand Down Expand Up @@ -149,6 +149,8 @@ class LocalPlayer : public Player

bool getAutojump() const { return m_autojump; }

bool isDead() const { return hp <= 0; }

inline void addVelocity(const v3f &vel)
{
added_velocity += vel;
Expand Down

0 comments on commit 3c395d9

Please sign in to comment.