summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-03-21 16:01:07 +0100
committerkrzys-h <krzys_h@interia.pl>2014-03-21 16:01:07 +0100
commite2cc06f84c861eb3a0657a35c072e2f2c21f1252 (patch)
tree931f7855129d1c654cd44ff107e381f8020062c2 /src/object
parente569fd6c3938ca885bfca0978d143def154abd73 (diff)
parenta2a4eb75cb196b10c4af243f13e49563d59b321c (diff)
downloadcolobot-e2cc06f84c861eb3a0657a35c072e2f2c21f1252.tar.gz
colobot-e2cc06f84c861eb3a0657a35c072e2f2c21f1252.tar.bz2
colobot-e2cc06f84c861eb3a0657a35c072e2f2c21f1252.zip
Merge pull request #296 from kosmakoff/dev
Fixes for issue #295
Diffstat (limited to 'src/object')
-rw-r--r--src/object/task/taskgungoal.cpp24
-rw-r--r--src/object/task/taskgungoal.h2
2 files changed, 24 insertions, 2 deletions
diff --git a/src/object/task/taskgungoal.cpp b/src/object/task/taskgungoal.cpp
index 3373610..c9c8d30 100644
--- a/src/object/task/taskgungoal.cpp
+++ b/src/object/task/taskgungoal.cpp
@@ -26,6 +26,7 @@
CTaskGunGoal::CTaskGunGoal(CObject* object) : CTask(object)
{
+ m_aimImpossible = false;
}
// Object's destructor.
@@ -116,6 +117,12 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
m_progress = 0.0f;
+ // direction was constrainted, hence resulting in impossible move
+ if (dirV != m_finalDirV || dirH != m_finalDirH)
+ {
+ m_aimImpossible = true;
+ }
+
return ERR_OK;
}
@@ -126,12 +133,25 @@ Error CTaskGunGoal::IsEnded()
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_initialDirV == m_finalDirV &&
- m_initialDirH == m_finalDirH ) return ERR_STOP;
- if ( m_progress < 1.0f ) return ERR_CONTINUE;
+ m_initialDirH == m_finalDirH )
+ {
+ if ( m_aimImpossible )
+ return ERR_AIM_IMPOSSIBLE;
+ else
+ return ERR_STOP;
+ }
+
+ if ( m_progress < 1.0f ) return ERR_CONTINUE;
m_object->SetGunGoalV(m_finalDirV);
m_object->SetGunGoalH(m_finalDirH);
Abort();
+
+ if ( m_aimImpossible )
+ {
+ return ERR_AIM_IMPOSSIBLE;
+ }
+
return ERR_STOP;
}
diff --git a/src/object/task/taskgungoal.h b/src/object/task/taskgungoal.h
index c6f010b..9fc509d 100644
--- a/src/object/task/taskgungoal.h
+++ b/src/object/task/taskgungoal.h
@@ -44,5 +44,7 @@ protected:
float m_finalDirV; // direction to reach
float m_initialDirH; // initial direction
float m_finalDirH; // direction to reach
+
+ bool m_aimImpossible; // set to true if impossible aim was set
};