MCPcopy Create free account
hub / github.com/JACoders/OpenJK / ParseLoop

Method ParseLoop

code/icarus/Sequencer.cpp:585–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583*/
584
585int CSequencer::ParseLoop( CBlock *block, bstream_t *bstream , CIcarus* icarus)
586{
587 IGameInterface* game = icarus->GetGame();
588 CSequence *sequence;
589 CBlockMember *bm;
590 float min, max;
591 int rIter;
592 int memberNum = 0;
593
594 //Set the parent
595 sequence = AddSequence( m_curSequence, m_curSequence, ( CSequence::SQ_LOOP | CSequence::SQ_RETAIN ), icarus );
596
597 assert( sequence );
598 if ( sequence == NULL )
599 {
600 game->DebugPrint(IGameInterface::WL_ERROR, "ParseLoop : failed to allocate container sequence" );
601 block->Free(icarus);
602 delete block;
603 block = NULL;
604 return SEQ_FAILED;
605 }
606
607 m_curSequence->AddChild( sequence );
608
609 //Set the number of iterations of this sequence
610
611 bm = block->GetMember( memberNum++ );
612
613 if ( bm->GetID() == CIcarus::ID_RANDOM )
614 {
615 //Parse out the random number
616 min = *(float *) block->GetMemberData( memberNum++ );
617 max = *(float *) block->GetMemberData( memberNum++ );
618
619 rIter = (int) game->Random( min, max );
620 sequence->SetIterations( rIter );
621 }
622 else
623 {
624 sequence->SetIterations ( (int) (*(float *) bm->GetData()) );
625 }
626
627 //Add a unique loop identifier to the block for reference later
628 block->Write( CIcarus::TK_FLOAT, (float) sequence->GetID(), icarus );
629
630 //Push this onto the stack to mark the loop entrance
631 PushCommand( block, CSequence::PUSH_FRONT );
632
633 //Recursively obtain the loop
634 Route( sequence, bstream , icarus);
635
636 return SEQ_OK;
637}
638
639/*
640========================

Callers

nothing calls this directly

Calls 11

DebugPrintMethod · 0.80
RandomMethod · 0.80
GetGameMethod · 0.45
FreeMethod · 0.45
AddChildMethod · 0.45
GetMemberMethod · 0.45
GetIDMethod · 0.45
GetMemberDataMethod · 0.45
SetIterationsMethod · 0.45
GetDataMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected