This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit f40756bc4648c67cc389aef44f1913b72b171ffe
Author: tomangelo2 <tomang...@wp.pl>
Date:   Wed Oct 11 18:50:57 2017 +0200

    Fix turn(1) doesn't draining energy
    
    Fix using @Melex750 example, thanks!
    Fix issue #136
---
 src/object/task/taskturn.cpp | 14 ++++++++++++--
 src/object/task/taskturn.h   |  1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/object/task/taskturn.cpp b/src/object/task/taskturn.cpp
index d07dfde..69799b8 100644
--- a/src/object/task/taskturn.cpp
+++ b/src/object/task/taskturn.cpp
@@ -109,7 +109,7 @@ Error CTaskTurn::IsEnded()
 
     if ( m_bLeft )
     {
-        if ( angle <= m_startAngle+m_angle )
+        if ( angle <= m_finalAngle )
         {
             m_physics->SetMotorSpeedZ(0.0f);
 //?         m_physics->SetCirMotionY(MO_MOTSPEED, 0.0f);
@@ -118,10 +118,15 @@ Error CTaskTurn::IsEnded()
             m_object->SetRotationY(m_finalAngle);
             return ERR_STOP;
         }
+        if ( !m_bDecel && angle <= m_startAngle+m_angle)
+        {
+            m_bDecel = true;
+            m_physics->SetMotorSpeedZ(-0.5f);
+        }
     }
     else
     {
-        if ( angle >= m_startAngle+m_angle )
+        if ( angle >= m_finalAngle )
         {
             m_physics->SetMotorSpeedZ(0.0f);
 //?         m_physics->SetCirMotionY(MO_MOTSPEED, 0.0f);
@@ -130,6 +135,11 @@ Error CTaskTurn::IsEnded()
             m_object->SetRotationY(m_finalAngle);
             return ERR_STOP;
         }
+        if ( !m_bDecel && angle >= m_startAngle+m_angle)
+        {
+            m_bDecel = true;
+            m_physics->SetMotorSpeedZ(0.5f);
+        }
     }
 
     return ERR_CONTINUE;
diff --git a/src/object/task/taskturn.h b/src/object/task/taskturn.h
index ddc696c..4232950 100644
--- a/src/object/task/taskturn.h
+++ b/src/object/task/taskturn.h
@@ -41,4 +41,5 @@ protected:
     float       m_finalAngle = 0.0f;
     bool        m_bLeft = false;
     bool        m_bError = false;
+    bool        m_bDecel = false;
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/colobot.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to