diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2017-08-13 23:02:32 +0200 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2017-08-13 23:02:32 +0200 |
commit | d65d6160d83a47311ceb33738d2a5e249e76e4c0 (patch) | |
tree | 210984937e091895dd449cae65bf042bff46e06c | |
parent | 2ea26e655d90be538c75aad5cc7ede2c5709179f (diff) | |
download | minetest-d65d6160d83a47311ceb33738d2a5e249e76e4c0.tar.gz minetest-d65d6160d83a47311ceb33738d2a5e249e76e4c0.tar.bz2 minetest-d65d6160d83a47311ceb33738d2a5e249e76e4c0.zip |
Cleanup LocalPlayer::applyControl
* Use Environment interface instead of ClientEnvironemnt
* Don't create slippery variable and then re-affect it
* itemgroup_get return a int, properly test != 0 to be clearer
-rw-r--r-- | src/localplayer.cpp | 7 | ||||
-rw-r--r-- | src/localplayer.h | 2 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index f72da1b18..517cefe6e 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -444,7 +444,7 @@ void LocalPlayer::move(f32 dtime, Environment *env, f32 pos_max_d) move(dtime, env, pos_max_d, NULL); } -void LocalPlayer::applyControl(float dtime, ClientEnvironment *env) +void LocalPlayer::applyControl(float dtime, Environment *env) { // Clear stuff swimming_vertical = false; @@ -660,11 +660,10 @@ void LocalPlayer::applyControl(float dtime, ClientEnvironment *env) else incH = incV = movement_acceleration_default * BS * dtime; - INodeDefManager *nodemgr = env->getGameDef()->ndef(); + const INodeDefManager *nodemgr = env->getGameDef()->ndef(); Map *map = &env->getMap(); - bool slippery = false; const ContentFeatures &f = nodemgr->get(map->getNodeNoEx(getStandingNodePos())); - slippery = itemgroup_get(f.groups, "slippery"); + bool slippery = (itemgroup_get(f.groups, "slippery") != 0); // Accelerate to target speed with maximum increment accelerateHorizontal(speedH * physics_override_speed, incH * physics_override_speed, slippery); diff --git a/src/localplayer.h b/src/localplayer.h index 67b22b656..3d293ecf4 100644 --- a/src/localplayer.h +++ b/src/localplayer.h @@ -79,7 +79,7 @@ public: void old_move(f32 dtime, Environment *env, f32 pos_max_d, std::vector<CollisionInfo> *collision_info); - void applyControl(float dtime, ClientEnvironment *env); + void applyControl(float dtime, Environment *env); v3s16 getStandingNodePos(); v3s16 getFootstepNodePos(); |