@@ -184,35 +184,39 @@ int Projectile::calculateTrajectory(double accuracy)
184184 targetVoxel = Position (_action.target .x *16 + 8 , _action.target .y *16 + 8 , _action.target .z *24 + 10 );
185185 }
186186 test = _save->getTileEngine ()->calculateLine (originVoxel, targetVoxel, false , &_trajectory, bu);
187- Position hitPos = Position (_trajectory.at (0 ).x /16 , _trajectory.at (0 ).y /16 , _trajectory.at (0 ).z /24 );
188187 if (test == 4 && !_trajectory.empty ())
189188 {
189+ Position hitPos = Position (_trajectory.at (0 ).x /16 , _trajectory.at (0 ).y /16 , _trajectory.at (0 ).z /24 );
190190 if (hitPos.x != targetTile->getPosition ().x || hitPos.y != targetTile->getPosition ().y )
191191 {
192192 _trajectory.clear ();
193193 return -1 ; // still no line of fire as we can't reach the target tile due to a unit blocking
194194 }
195195 }
196- if (test != -1 && !_trajectory.empty () && hitPos != _action. target )
196+ if (test != -1 && !_trajectory.empty ())
197197 {
198- if (test == 2 )
198+ Position hitPos = Position (_trajectory.at (0 ).x /16 , _trajectory.at (0 ).y /16 , _trajectory.at (0 ).z /24 );
199+ if (hitPos != _action.target )
199200 {
200- if (hitPos. y - 1 == _action. target . y )
201+ if (test == 2 )
201202 {
202- _trajectory.clear ();
203- return _save->getTileEngine ()->calculateLine (originVoxel, targetVoxel, true , &_trajectory, bu);
203+ if (hitPos.y - 1 == _action.target .y )
204+ {
205+ _trajectory.clear ();
206+ return _save->getTileEngine ()->calculateLine (originVoxel, targetVoxel, true , &_trajectory, bu);
207+ }
204208 }
205- }
206- if (test == 1 )
207- {
208- if (hitPos.x - 1 == _action.target .x )
209+ if (test == 1 )
209210 {
210- _trajectory.clear ();
211- return _save->getTileEngine ()->calculateLine (originVoxel, targetVoxel, true , &_trajectory, bu);
211+ if (hitPos.x - 1 == _action.target .x )
212+ {
213+ _trajectory.clear ();
214+ return _save->getTileEngine ()->calculateLine (originVoxel, targetVoxel, true , &_trajectory, bu);
215+ }
212216 }
217+ _trajectory.clear ();
218+ return -1 ;
213219 }
214- _trajectory.clear ();
215- return -1 ;
216220 }
217221 _trajectory.clear ();
218222 }
0 commit comments