| 1644 | */ |
| 1645 | |
| 1646 | void CSequencer::CheckLoop( CBlock **command , CIcarus* icarus) |
| 1647 | { |
| 1648 | IGameInterface* game = icarus->GetGame(); |
| 1649 | CBlockMember *bm; |
| 1650 | CBlock *block = *command; |
| 1651 | float min, max; |
| 1652 | int iterations; |
| 1653 | int loopID; |
| 1654 | int memberNum = 0; |
| 1655 | |
| 1656 | if ( block == NULL ) |
| 1657 | return; |
| 1658 | |
| 1659 | //Check for a loop |
| 1660 | if ( block->GetBlockID() == CIcarus::ID_LOOP ) |
| 1661 | { |
| 1662 | //Get the loop ID |
| 1663 | bm = block->GetMember( memberNum++ ); |
| 1664 | |
| 1665 | if ( bm->GetID() == CIcarus::ID_RANDOM ) |
| 1666 | { |
| 1667 | //Parse out the random number |
| 1668 | min = *(float *) block->GetMemberData( memberNum++ ); |
| 1669 | max = *(float *) block->GetMemberData( memberNum++ ); |
| 1670 | |
| 1671 | iterations = (int) game->Random( min, max ); |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | iterations = (int) (*(float *) bm->GetData()); |
| 1676 | } |
| 1677 | |
| 1678 | loopID = (int) (*(float *) block->GetMemberData( memberNum++ )); |
| 1679 | |
| 1680 | CSequence *loop = GetSequence( loopID ); |
| 1681 | |
| 1682 | //TODO: Emit warning |
| 1683 | assert( loop ); |
| 1684 | if ( loop == NULL ) |
| 1685 | { |
| 1686 | game->DebugPrint(IGameInterface::WL_ERROR, "Unable to find 'loop' sequence!\n" ); |
| 1687 | *command = NULL; |
| 1688 | return; |
| 1689 | } |
| 1690 | |
| 1691 | assert( loop->GetParent() ); |
| 1692 | if ( loop->GetParent() == NULL ) |
| 1693 | { |
| 1694 | *command = NULL; |
| 1695 | return; |
| 1696 | } |
| 1697 | |
| 1698 | //Restore the count if it has been lost |
| 1699 | loop->SetIterations( iterations ); |
| 1700 | |
| 1701 | //Only save the loop command if the calling sequence is retained |
| 1702 | if ( m_curSequence->HasFlag( CSequence::SQ_RETAIN ) ) |
| 1703 | { |
nothing calls this directly
no test coverage detected