aboutsummaryrefslogtreecommitdiff
path: root/src/client/localplayer.cpp
diff options
context:
space:
mode:
authorElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:57:41 +0100
committerElias Fleckenstein <eliasfleckenstein@web.de>2020-11-04 16:57:41 +0100
commit6ccb5835ff55d85156be91473c598eca9d6cb9a6 (patch)
tree7f1eaf8b94694c8e24e206909ba8f55a1ebfbb3e /src/client/localplayer.cpp
parent244713971a976e43e8740b6a9d9d122e37020ef2 (diff)
downloaddragonfireclient-6ccb5835ff55d85156be91473c598eca9d6cb9a6.tar.xz
Revert "Make Lint Happy"
This reverts commit ad148587dcf5244c2d2011dba339786c765c54c4.
Diffstat (limited to 'src/client/localplayer.cpp')
-rw-r--r--src/client/localplayer.cpp255
1 files changed, 117 insertions, 138 deletions
diff --git a/src/client/localplayer.cpp b/src/client/localplayer.cpp
index 324055796..00195cd02 100644
--- a/src/client/localplayer.cpp
+++ b/src/client/localplayer.cpp
@@ -34,8 +34,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer
*/
-LocalPlayer::LocalPlayer(Client *client, const char *name) :
- Player(name, client->idef()), m_client(client)
+LocalPlayer::LocalPlayer(Client *client, const char *name):
+ Player(name, client->idef()),
+ m_client(client)
{
}
@@ -56,11 +57,20 @@ static aabb3f getNodeBoundingBox(const std::vector<aabb3f> &nodeboxes)
return b_max;
}
-bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, const v3f &sneak_max)
+bool LocalPlayer::updateSneakNode(Map *map, const v3f &position,
+ const v3f &sneak_max)
{
- static const v3s16 dir9_center[9] = {v3s16(0, 0, 0), v3s16(1, 0, 0),
- v3s16(-1, 0, 0), v3s16(0, 0, 1), v3s16(0, 0, -1), v3s16(1, 0, 1),
- v3s16(-1, 0, 1), v3s16(1, 0, -1), v3s16(-1, 0, -1)};
+ static const v3s16 dir9_center[9] = {
+ v3s16( 0, 0, 0),
+ v3s16( 1, 0, 0),
+ v3s16(-1, 0, 0),
+ v3s16( 0, 0, 1),
+ v3s16( 0, 0, -1),
+ v3s16( 1, 0, 1),
+ v3s16(-1, 0, 1),
+ v3s16( 1, 0, -1),
+ v3s16(-1, 0, -1)
+ };
const NodeDefManager *nodemgr = m_client->ndef();
MapNode node;
@@ -73,8 +83,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, const v3f &snea
position_y_mod = m_sneak_node_bb_top.MaxEdge.Y - position_y_mod;
// Get position of current standing node
- const v3s16 current_node =
- floatToInt(position - v3f(0.0f, position_y_mod, 0.0f), BS);
+ const v3s16 current_node = floatToInt(position - v3f(0.0f, position_y_mod, 0.0f), BS);
if (current_node != m_sneak_node) {
new_sneak_node_exists = false;
@@ -103,19 +112,18 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, const v3f &snea
fabs(diff.Y) > (0.5f + 0.1f) * BS + sneak_max.Z)
continue;
+
// The node to be sneaked on has to be walkable
node = map->getNode(p, &is_valid_position);
- if (!is_valid_position || !nodemgr->get(node).walkable)
+ if (!is_valid_position || ! nodemgr->get(node).walkable)
continue;
// And the node(s) above have to be nonwalkable
bool ok = true;
if (!physics_override_sneak_glitch) {
- u16 height = ceilf((m_collisionbox.MaxEdge.Y -
- m_collisionbox.MinEdge.Y) /
- BS);
+ u16 height =
+ ceilf((m_collisionbox.MaxEdge.Y - m_collisionbox.MinEdge.Y) / BS);
for (u16 y = 1; y <= height; y++) {
- node = map->getNode(
- p + v3s16(0, y, 0), &is_valid_position);
+ node = map->getNode(p + v3s16(0, y, 0), &is_valid_position);
if (!is_valid_position || nodemgr->get(node).walkable) {
ok = false;
break;
@@ -124,7 +132,7 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, const v3f &snea
} else {
// legacy behaviour: check just one node
node = map->getNode(p + v3s16(0, 1, 0), &is_valid_position);
- ok = is_valid_position && !nodemgr->get(node).walkable;
+ ok = is_valid_position && ! nodemgr->get(node).walkable;
}
if (!ok)
continue;
@@ -146,13 +154,14 @@ bool LocalPlayer::updateSneakNode(Map *map, const v3f &position, const v3f &snea
if (physics_override_sneak_glitch) {
// Detect sneak ladder:
// Node two meters above sneak node must be solid
- node = map->getNode(m_sneak_node + v3s16(0, 2, 0), &is_valid_position);
+ node = map->getNode(m_sneak_node + v3s16(0, 2, 0),
+ &is_valid_position);
if (is_valid_position && nodemgr->get(node).walkable) {
// Node three meters above: must be non-solid
node = map->getNode(m_sneak_node + v3s16(0, 3, 0),
- &is_valid_position);
- m_sneak_ladder_detected =
- is_valid_position && !nodemgr->get(node).walkable;
+ &is_valid_position);
+ m_sneak_ladder_detected = is_valid_position &&
+ ! nodemgr->get(node).walkable;
}
}
return true;
@@ -163,7 +172,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
{
if (m_cao && m_cao->m_waiting_for_reattach > 0)
m_cao->m_waiting_for_reattach -= dtime;
-
+
// Node at feet position, update each ClientEnvironment::step()
if (!collision_info || collision_info->empty())
m_standing_node = floatToInt(m_position, BS);
@@ -218,13 +227,13 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
*/
// If in liquid, the threshold of coming out is at higher y
- if (in_liquid) {
+ if (in_liquid)
+ {
pp = floatToInt(position + v3f(0.0f, BS * 0.1f, 0.0f), BS);
node = map->getNode(pp, &is_valid_position);
if (is_valid_position) {
in_liquid = nodemgr->get(node.getContent()).isLiquid();
- liquid_viscosity =
- nodemgr->get(node.getContent()).liquid_viscosity;
+ liquid_viscosity = nodemgr->get(node.getContent()).liquid_viscosity;
} else {
in_liquid = false;
}
@@ -235,13 +244,13 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
node = map->getNode(pp, &is_valid_position);
if (is_valid_position) {
in_liquid = nodemgr->get(node.getContent()).isLiquid();
- liquid_viscosity =
- nodemgr->get(node.getContent()).liquid_viscosity;
+ liquid_viscosity = nodemgr->get(node.getContent()).liquid_viscosity;
} else {
in_liquid = false;
}
}
+
/*
Check if player is in liquid (the stable value)
*/
@@ -267,16 +276,14 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
is_climbing = false;
} else {
is_climbing = (nodemgr->get(node.getContent()).climbable ||
- nodemgr->get(node2.getContent())
- .climbable) &&
- !free_move;
+ nodemgr->get(node2.getContent()).climbable) && !free_move;
}
/*
Collision uncertainty radius
Make it a bit larger than the maximum distance of movement
*/
- // f32 d = pos_max_d * 1.1;
+ //f32 d = pos_max_d * 1.1;
// A fairly large value in here makes moving smoother
f32 d = 0.15f * BS;
@@ -285,21 +292,19 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
// Player object property step height is multiplied by BS in
// /src/script/common/c_content.cpp and /src/content_sao.cpp
- float player_stepheight =
- (m_cao == nullptr) ? 0.0f
- : (touching_ground ? m_cao->getStepHeight()
- : (0.2f * BS));
+ float player_stepheight = (m_cao == nullptr) ? 0.0f :
+ (touching_ground ? m_cao->getStepHeight() : (0.2f * BS));
v3f accel_f;
const v3f initial_position = position;
const v3f initial_speed = m_speed;
- collisionMoveResult result = collisionMoveSimple(env, m_client, pos_max_d,
- m_collisionbox, player_stepheight, dtime, &position, &m_speed,
- accel_f, NULL, true, true);
+ collisionMoveResult result = collisionMoveSimple(env, m_client,
+ pos_max_d, m_collisionbox, player_stepheight, dtime,
+ &position, &m_speed, accel_f, NULL, true, true);
- bool could_sneak = control.sneak && !free_move && !in_liquid && !is_climbing &&
- physics_override_sneak;
+ bool could_sneak = control.sneak && !free_move && !in_liquid &&
+ !is_climbing && physics_override_sneak;
// Add new collisions to the vector
if (collision_info && !free_move) {
@@ -362,10 +367,10 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
// (BS * 0.6f) is the basic stepheight while standing on ground
if (y_diff < BS * 0.6f) {
// Only center player when they're on the node
- position.X = rangelim(position.X, bmin.X - sneak_max.X,
- bmax.X + sneak_max.X);
- position.Z = rangelim(position.Z, bmin.Z - sneak_max.Z,
- bmax.Z + sneak_max.Z);
+ position.X = rangelim(position.X,
+ bmin.X - sneak_max.X, bmax.X + sneak_max.X);
+ position.Z = rangelim(position.Z,
+ bmin.Z - sneak_max.Z, bmax.Z + sneak_max.Z);
if (position.X != old_pos.X)
m_speed.X = 0.0f;
@@ -388,7 +393,8 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
if (m_speed.Y == 0.0f || m_sneak_ladder_detected)
sneak_can_jump = true;
- if (collision_info && m_speed.Y - old_speed.Y > BS) {
+ if (collision_info &&
+ m_speed.Y - old_speed.Y > BS) {
// Collide with sneak node, report fall damage
CollisionInfo sn_info;
sn_info.node_p = m_sneak_node;
@@ -417,8 +423,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
*/
if (!result.standing_on_object && !touching_ground_was && touching_ground) {
- m_client->getEventManager()->put(
- new SimpleTriggerEvent(MtEvent::PLAYER_REGAIN_GROUND));
+ m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_REGAIN_GROUND));
// Set camera impact value to be used for view bobbing
camera_impact = getSpeed().Y * -1;
@@ -438,18 +443,16 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
Check properties of the node on which the player is standing
*/
const ContentFeatures &f = nodemgr->get(map->getNode(m_standing_node));
- const ContentFeatures &f1 =
- nodemgr->get(map->getNode(m_standing_node + v3s16(0, 1, 0)));
+ const ContentFeatures &f1 = nodemgr->get(map->getNode(m_standing_node + v3s16(0, 1, 0)));
// Determine if jumping is possible
m_disable_jump = itemgroup_get(f.groups, "disable_jump") ||
- itemgroup_get(f1.groups, "disable_jump");
- m_can_jump = ((touching_ground && !is_climbing) || sneak_can_jump) &&
- !m_disable_jump;
+ itemgroup_get(f1.groups, "disable_jump");
+ m_can_jump = ((touching_ground && !is_climbing) || sneak_can_jump) && !m_disable_jump;
// Jump key pressed while jumping off from a bouncy block
if (m_can_jump && control.jump && itemgroup_get(f.groups, "bouncy") &&
- m_speed.Y >= -0.5f * BS) {
+ m_speed.Y >= -0.5f * BS) {
float jumpspeed = movement_speed_jump * physics_override_jump;
if (m_speed.Y > 1.0f) {
// Reduce boost when speed already is high
@@ -458,7 +461,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d,
m_speed.Y += jumpspeed;
}
setSpeed(m_speed);
- if (!m_freecam)
+ if (! m_freecam)
m_legit_speed = m_speed;
m_can_jump = false;
}
@@ -500,8 +503,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
bool free_move = fly_allowed && player_settings.free_move;
bool fast_move = fast_allowed && player_settings.fast_move;
bool pitch_move = (free_move || in_liquid) && player_settings.pitch_move;
- // When aux1_descends is enabled the fast key is used to go down, so fast isn't
- // possible
+ // When aux1_descends is enabled the fast key is used to go down, so fast isn't possible
bool fast_climb = fast_move && control.aux1 && !player_settings.aux1_descends;
bool always_fly_fast = player_settings.always_fly_fast;
@@ -578,8 +580,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
speedH -= v3f(0.0f, 0.0f, 1.0f);
if (!control.up && !control.down)
- speedH -= v3f(0.0f, 0.0f, 1.0f) *
- (control.forw_move_joystick_axis / 32767.f);
+ speedH -= v3f(0.0f, 0.0f, 1.0f) * (control.forw_move_joystick_axis / 32767.f);
if (control.left)
speedH += v3f(-1.0f, 0.0f, 0.0f);
@@ -588,8 +589,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
speedH += v3f(1.0f, 0.0f, 0.0f);
if (!control.left && !control.right)
- speedH += v3f(1.0f, 0.0f, 0.0f) *
- (control.sidew_move_joystick_axis / 32767.f);
+ speedH += v3f(1.0f, 0.0f, 0.0f) * (control.sidew_move_joystick_axis / 32767.f);
if (m_autojump) {
// release autojump after a given time
@@ -621,8 +621,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
if (speedJ.Y >= -0.5f * BS) {
speedJ.Y = movement_speed_jump * physics_override_jump;
setSpeed(speedJ);
- m_client->getEventManager()->put(new SimpleTriggerEvent(
- MtEvent::PLAYER_JUMP));
+ m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_JUMP));
}
} else if (in_liquid && !m_disable_jump) {
if (fast_climb)
@@ -642,8 +641,7 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
if (superspeed || (is_climbing && fast_climb) ||
((in_liquid || in_liquid_stable) && fast_climb))
speedH = speedH.normalize() * movement_speed_fast;
- else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable &&
- !g_settings->getBool("no_slow"))
+ else if (control.sneak && !free_move && !in_liquid && !in_liquid_stable && !g_settings->getBool("no_slow"))
speedH = speedH.normalize() * movement_speed_crouch;
else
speedH = speedH.normalize() * movement_speed_walk;
@@ -679,8 +677,8 @@ void LocalPlayer::applyControl(float dtime, Environment *env)
// Accelerate to target speed with maximum increment
accelerate((speedH + speedV) * physics_override_speed,
- incH * physics_override_speed * slip_factor,
- incV * physics_override_speed, pitch_move);
+ incH * physics_override_speed * slip_factor, incV * physics_override_speed,
+ pitch_move);
}
v3s16 LocalPlayer::getStandingNodePos()
@@ -715,15 +713,13 @@ v3s16 LocalPlayer::getLightPosition() const
v3f LocalPlayer::getEyeOffset() const
{
- float eye_height =
- camera_barely_in_ceiling ? m_eye_height - 0.125f : m_eye_height;
+ float eye_height = camera_barely_in_ceiling ? m_eye_height - 0.125f : m_eye_height;
return v3f(0.0f, BS * eye_height, 0.0f);
}
ClientActiveObject *LocalPlayer::getParent() const
{
- return (m_cao && !g_settings->getBool("entity_speed")) ? m_cao->getParent()
- : nullptr;
+ return (m_cao && ! g_settings->getBool("entity_speed")) ? m_cao->getParent() : nullptr;
}
bool LocalPlayer::isDead() const
@@ -741,19 +737,17 @@ void LocalPlayer::tryReattach(int id)
bool LocalPlayer::isWaitingForReattach() const
{
- return g_settings->getBool("entity_speed") && m_cao && !m_cao->getParent() &&
- m_cao->m_waiting_for_reattach > 0;
+ return g_settings->getBool("entity_speed") && m_cao && ! m_cao->getParent() && m_cao->m_waiting_for_reattach > 0;
}
// 3D acceleration
void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H,
- const f32 max_increase_V, const bool use_pitch)
+ const f32 max_increase_V, const bool use_pitch)
{
const f32 yaw = getYaw();
const f32 pitch = getPitch();
v3f flat_speed = m_speed;
- // Rotate speed vector by -yaw and -pitch to make it relative to the player's yaw
- // and pitch
+ // Rotate speed vector by -yaw and -pitch to make it relative to the player's yaw and pitch
flat_speed.rotateXZBy(-yaw);
if (use_pitch)
flat_speed.rotateYZBy(-pitch);
@@ -790,7 +784,7 @@ void LocalPlayer::accelerate(const v3f &target_speed, const f32 max_increase_H,
// Temporary option for old move code
void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
- std::vector<CollisionInfo> *collision_info)
+ std::vector<CollisionInfo> *collision_info)
{
Map *map = &env->getMap();
const NodeDefManager *nodemgr = m_client->ndef();
@@ -840,8 +834,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
node = map->getNode(pp, &is_valid_position);
if (is_valid_position) {
in_liquid = nodemgr->get(node.getContent()).isLiquid();
- liquid_viscosity =
- nodemgr->get(node.getContent()).liquid_viscosity;
+ liquid_viscosity = nodemgr->get(node.getContent()).liquid_viscosity;
} else {
in_liquid = false;
}
@@ -851,8 +844,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
node = map->getNode(pp, &is_valid_position);
if (is_valid_position) {
in_liquid = nodemgr->get(node.getContent()).isLiquid();
- liquid_viscosity =
- nodemgr->get(node.getContent()).liquid_viscosity;
+ liquid_viscosity = nodemgr->get(node.getContent()).liquid_viscosity;
} else {
in_liquid = false;
}
@@ -881,15 +873,13 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
is_climbing = false;
else
is_climbing = (nodemgr->get(node.getContent()).climbable ||
- nodemgr->get(node2.getContent())
- .climbable) &&
- !free_move;
+ nodemgr->get(node2.getContent()).climbable) && !free_move;
/*
Collision uncertainty radius
Make it a bit larger than the maximum distance of movement
*/
- // f32 d = pos_max_d * 1.1;
+ //f32 d = pos_max_d * 1.1;
// A fairly large value in here makes moving smoother
f32 d = 0.15f * BS;
// This should always apply, otherwise there are glitches
@@ -917,8 +907,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
/*
Collision seems broken, since player is sinking when
sneaking over the edges of current sneaking_node.
- TODO (when fixed): Set Y-speed only to 0 when position.Y <
- new_y.
+ TODO (when fixed): Set Y-speed only to 0 when position.Y < new_y.
*/
if (m_speed.Y < 0.0f)
m_speed.Y = 0.0f;
@@ -932,9 +921,9 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
const v3f initial_position = position;
const v3f initial_speed = m_speed;
- collisionMoveResult result = collisionMoveSimple(env, m_client, pos_max_d,
- m_collisionbox, player_stepheight, dtime, &position, &m_speed,
- accel_f, NULL, true, true);
+ collisionMoveResult result = collisionMoveSimple(env, m_client,
+ pos_max_d, m_collisionbox, player_stepheight, dtime,
+ &position, &m_speed, accel_f, NULL, true, true);
// Positition was slightly changed; update standing node pos
if (touching_ground)
@@ -951,7 +940,7 @@ 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
@@ -977,51 +966,44 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
if (m_need_to_get_new_sneak_node && physics_override_sneak) {
m_sneak_node_bb_ymax = 0.0f;
- v3s16 pos_i_bottom = floatToInt(
- position - v3f(0.0f, position_y_mod, 0.0f), BS);
+ v3s16 pos_i_bottom = floatToInt(position - v3f(0.0f, position_y_mod, 0.0f), BS);
v2f player_p2df(position.X, position.Z);
f32 min_distance_f = 100000.0f * BS;
// If already seeking from some node, compare to it.
v3s16 new_sneak_node = m_sneak_node;
- for (s16 x = -1; x <= 1; x++)
- for (s16 z = -1; z <= 1; z++) {
- v3s16 p = pos_i_bottom + v3s16(x, 0, z);
- v3f pf = intToFloat(p, BS);
- v2f node_p2df(pf.X, pf.Z);
- f32 distance_f = player_p2df.getDistanceFrom(node_p2df);
- f32 max_axis_distance_f = MYMAX(
- std::fabs(player_p2df.X - node_p2df.X),
- std::fabs(player_p2df.Y - node_p2df.Y));
-
- if (distance_f > min_distance_f ||
- max_axis_distance_f >
- 0.5f * BS + sneak_max +
- 0.1f * BS)
- continue;
+ for (s16 x= -1; x <= 1; x++)
+ for (s16 z= -1; z <= 1; z++) {
+ v3s16 p = pos_i_bottom + v3s16(x, 0, z);
+ v3f pf = intToFloat(p, BS);
+ v2f node_p2df(pf.X, pf.Z);
+ f32 distance_f = player_p2df.getDistanceFrom(node_p2df);
+ f32 max_axis_distance_f = MYMAX(
+ std::fabs(player_p2df.X - node_p2df.X),
+ std::fabs(player_p2df.Y - node_p2df.Y));
+
+ if (distance_f > min_distance_f ||
+ max_axis_distance_f > 0.5f * BS + sneak_max + 0.1f * BS)
+ continue;
- // The node to be sneaked on has to be walkable
- node = map->getNode(p, &is_valid_position);
- if (!is_valid_position || !nodemgr->get(node).walkable)
- continue;
- // And the node above it has to be nonwalkable
- node = map->getNode(
- p + v3s16(0, 1, 0), &is_valid_position);
+ // The node to be sneaked on has to be walkable
+ node = map->getNode(p, &is_valid_position);
+ if (!is_valid_position || !nodemgr->get(node).walkable)
+ continue;
+ // And the node above it has to be nonwalkable
+ node = map->getNode(p + v3s16(0, 1, 0), &is_valid_position);
+ if (!is_valid_position || nodemgr->get(node).walkable)
+ continue;
+ // If not 'sneak_glitch' the node 2 nodes above it has to be nonwalkable
+ if (!physics_override_sneak_glitch) {
+ node = map->getNode(p + v3s16(0, 2, 0), &is_valid_position);
if (!is_valid_position || nodemgr->get(node).walkable)
continue;
- // If not 'sneak_glitch' the node 2 nodes above it has to
- // be nonwalkable
- if (!physics_override_sneak_glitch) {
- node = map->getNode(p + v3s16(0, 2, 0),
- &is_valid_position);
- if (!is_valid_position ||
- nodemgr->get(node).walkable)
- continue;
- }
-
- min_distance_f = distance_f;
- new_sneak_node = p;
}
+ min_distance_f = distance_f;
+ new_sneak_node = p;
+ }
+
bool sneak_node_found = (min_distance_f < 100000.0f * BS * 0.9f);
m_sneak_node = new_sneak_node;
@@ -1065,8 +1047,7 @@ void LocalPlayer::old_move(f32 dtime, Environment *env, f32 pos_max_d,
}
if (!result.standing_on_object && !touching_ground_was && touching_ground) {
- m_client->getEventManager()->put(
- new SimpleTriggerEvent(MtEvent::PLAYER_REGAIN_GROUND));
+ m_client->getEventManager()->put(new SimpleTriggerEvent(MtEvent::PLAYER_REGAIN_GROUND));
// Set camera impact value to be used for view bobbing
camera_impact = getSpeed().Y * -1.0f;
}
@@ -1134,8 +1115,8 @@ float LocalPlayer::getSlipFactor(Environment *env, const v3f &speedH)
}
void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
- const collisionMoveResult &result, const v3f &initial_position,
- const v3f &initial_speed, f32 pos_max_d)
+ const collisionMoveResult &result, const v3f &initial_position,
+ const v3f &initial_speed, f32 pos_max_d)
{
PlayerSettings &player_settings = getPlayerSettings();
if (!player_settings.autojump)
@@ -1145,11 +1126,11 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
return;
bool control_forward = control.up ||
- (!control.up && !control.down &&
- control.forw_move_joystick_axis < -0.05f);
+ (!control.up && !control.down &&
+ control.forw_move_joystick_axis < -0.05f);
bool could_autojump =
- m_can_jump && !control.jump && !control.sneak && control_forward;
+ m_can_jump && !control.jump && !control.sneak && control_forward;
if (!could_autojump)
return;
@@ -1176,14 +1157,12 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
bool is_position_valid;
for (s16 z = ceilpos_min.Z; z <= ceilpos_max.Z; ++z) {
for (s16 x = ceilpos_min.X; x <= ceilpos_max.X; ++x) {
- MapNode n = env->getMap().getNode(
- v3s16(x, ceilpos_max.Y, z), &is_position_valid);
+ MapNode n = env->getMap().getNode(v3s16(x, ceilpos_max.Y, z), &is_position_valid);
if (!is_position_valid)
- break; // won't collide with the void outside
+ break; // won't collide with the void outside
if (n.getContent() == CONTENT_IGNORE)
- return; // players collide with ignore blocks -> same as
- // walkable
+ return; // players collide with ignore blocks -> same as walkable
const ContentFeatures &f = ndef->get(n);
if (f.walkable)
return; // would bump head, don't jump
@@ -1196,8 +1175,7 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
// try at peak of jump, zero step height
collisionMoveResult jump_result = collisionMoveSimple(env, m_client, pos_max_d,
- m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f),
- NULL, true, true);
+ m_collisionbox, 0.0f, dtime, &jump_pos, &jump_speed, v3f(0.0f), NULL, true, true);
// see if we can get a little bit farther horizontally if we had
// jumped
@@ -1210,3 +1188,4 @@ void LocalPlayer::handleAutojump(f32 dtime, Environment *env,
m_autojump_time = 0.1f;
}
}
+