summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorMirceaKitsune <sonichedgehog_hyperblast00@yahoo.com>2012-11-09 16:45:29 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-11-25 19:14:24 +0200
commit4d656963e42766a7c0250b1e0931638933f1b917 (patch)
tree7f028579a6f51f9766fdf3d1924b7c5ee5bc1eba /src/localplayer.cpp
parent9259d028ac99fc699df69ded128df60dece712b9 (diff)
downloadminetest-4d656963e42766a7c0250b1e0931638933f1b917.tar.gz
minetest-4d656963e42766a7c0250b1e0931638933f1b917.tar.bz2
minetest-4d656963e42766a7c0250b1e0931638933f1b917.zip
Fix more things I forgot for attached players. Such players will now properly see themselves moving when attached, and the server will read their position accordingly
Fix attached players being able to bob their view and generate foostep sounds by pressing a movement key (running in place)
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index ecfa4467c..63400cc29 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -34,6 +34,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
LocalPlayer::LocalPlayer(IGameDef *gamedef):
Player(gamedef),
+ isAttached(false),
+ overridePosition(v3f(0,0,0)),
m_sneak_node(32767,32767,32767),
m_sneak_node_exists(false),
m_old_node_below(32767,32767,32767),
@@ -53,6 +55,12 @@ LocalPlayer::~LocalPlayer()
void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
core::list<CollisionInfo> *collision_info)
{
+ INodeDefManager *nodemgr = m_gamedef->ndef();
+
+ v3f position = getPosition();
+
+ v3f old_speed = m_speed;
+
// Copy parent position if local player is attached
if(isAttached)
{
@@ -60,12 +68,6 @@ void LocalPlayer::move(f32 dtime, Map &map, f32 pos_max_d,
return;
}
- INodeDefManager *nodemgr = m_gamedef->ndef();
-
- v3f position = getPosition();
-
- v3f old_speed = m_speed;
-
// Skip collision detection if a special movement mode is used
bool fly_allowed = m_gamedef->checkLocalPrivilege("fly");
bool free_move = fly_allowed && g_settings->getBool("free_move");
@@ -359,7 +361,14 @@ void LocalPlayer::applyControl(float dtime)
setPitch(control.pitch);
setYaw(control.yaw);
-
+
+ // Nullify speed and don't run positioning code if the player is attached
+ if(isAttached)
+ {
+ setSpeed(v3f(0,0,0));
+ return;
+ }
+
v3f move_direction = v3f(0,0,1);
move_direction.rotateXZBy(getYaw());