MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / turn

Method turn

src/Savegame/BattleUnit.cpp:610–684  ·  view source on GitHub ↗

* Advances the turning towards the target direction. * @param turret True to turn the turret, false to turn the unit. */

Source from the content-addressed store, hash-verified

608 * @param turret True to turn the turret, false to turn the unit.
609 */
610void BattleUnit::turn(bool turret)
611{
612 int a = 0;
613
614 if (turret)
615 {
616 if (_directionTurret == _toDirectionTurret)
617 {
618 abortTurn();
619 return;
620 }
621 a = _toDirectionTurret - _directionTurret;
622 }
623 else
624 {
625 if (_direction == _toDirection)
626 {
627 abortTurn();
628 return;
629 }
630 a = _toDirection - _direction;
631 }
632
633 if (a != 0) {
634 if (a > 0) {
635 if (a <= 4) {
636 if (!turret) {
637 if (_turretType > -1)
638 _directionTurret++;
639 _direction++;
640 } else _directionTurret++;
641 } else {
642 if (!turret) {
643 if (_turretType > -1)
644 _directionTurret--;
645 _direction--;
646 } else _directionTurret--;
647 }
648 } else {
649 if (a > -4) {
650 if (!turret) {
651 if (_turretType > -1)
652 _directionTurret--;
653 _direction--;
654 } else _directionTurret--;
655 } else {
656 if (!turret) {
657 if (_turretType > -1)
658 _directionTurret++;
659 _direction++;
660 } else _directionTurret++;
661 }
662 }
663 if (_direction < 0) _direction = 7;
664 if (_direction > 7) _direction = 0;
665 if (_directionTurret < 0) _directionTurret = 7;
666 if (_directionTurret > 7) _directionTurret = 0;
667 if (_visible || _faction == FACTION_PLAYER)

Callers 7

setupPatrolMethod · 0.80
meleeAttackMethod · 0.80
thinkMethod · 0.80
postPathProceduresMethod · 0.80
thinkMethod · 0.80
thinkMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected