@@ -653,7 +653,7 @@ void LooksBlocks::setCostumeByIndex(Target *target, long index)
653653 index = std::fmod (index, costumeCount);
654654 }
655655
656- target->setCurrentCostume (index + 1 );
656+ target->setCostumeIndex (index);
657657}
658658
659659unsigned int LooksBlocks::switchCostumeToByIndex (VirtualMachine *vm)
@@ -693,15 +693,15 @@ unsigned int LooksBlocks::switchCostumeTo(VirtualMachine *vm)
693693unsigned int LooksBlocks::nextCostume (VirtualMachine *vm)
694694{
695695 if (Target *target = vm->target ())
696- setCostumeByIndex (target, target->currentCostume () );
696+ setCostumeByIndex (target, target->costumeIndex () + 1 );
697697
698698 return 0 ;
699699}
700700
701701unsigned int LooksBlocks::previousCostume (VirtualMachine *vm)
702702{
703703 if (Target *target = vm->target ())
704- setCostumeByIndex (target, target->currentCostume () - 2 );
704+ setCostumeByIndex (target, target->costumeIndex () - 1 );
705705
706706 return 0 ;
707707}
@@ -710,7 +710,7 @@ void LooksBlocks::startBackdropScripts(VirtualMachine *vm, bool wait)
710710{
711711 if (Stage *stage = vm->engine ()->stage ()) {
712712 if (stage->costumes ().size () > 0 )
713- vm->engine ()->broadcastByPtr (stage->costumeAt (stage-> currentCostume () - 1 )->broadcast (), vm, wait);
713+ vm->engine ()->broadcastByPtr (stage->currentCostume ()->broadcast (), vm, wait);
714714 }
715715}
716716
@@ -749,13 +749,13 @@ void LooksBlocks::switchBackdropToImpl(VirtualMachine *vm)
749749void LooksBlocks::nextBackdropImpl (VirtualMachine *vm)
750750{
751751 if (Stage *stage = vm->engine ()->stage ())
752- setCostumeByIndex (stage, stage->currentCostume () );
752+ setCostumeByIndex (stage, stage->costumeIndex () + 1 );
753753}
754754
755755void LooksBlocks::previousBackdropImpl (VirtualMachine *vm)
756756{
757757 if (Stage *stage = vm->engine ()->stage ())
758- setCostumeByIndex (stage, stage->currentCostume () - 2 );
758+ setCostumeByIndex (stage, stage->costumeIndex () - 1 );
759759}
760760
761761void LooksBlocks::randomBackdropImpl (VirtualMachine *vm)
@@ -767,7 +767,7 @@ void LooksBlocks::randomBackdropImpl(VirtualMachine *vm)
767767 std::size_t count = stage->costumes ().size ();
768768
769769 if (count > 0 )
770- stage->setCurrentCostume (rng->randint (1 , count));
770+ stage->setCostumeIndex (rng->randint (0 , count - 1 ));
771771 }
772772}
773773
@@ -854,7 +854,7 @@ unsigned int LooksBlocks::randomBackdropAndWait(VirtualMachine *vm)
854854unsigned int LooksBlocks::checkBackdropScripts (VirtualMachine *vm)
855855{
856856 if (Stage *stage = vm->engine ()->stage ()) {
857- if ((stage->costumes ().size () > 0 ) && vm->engine ()->broadcastByPtrRunning (stage->costumeAt (stage-> currentCostume () - 1 )->broadcast (), vm))
857+ if ((stage->costumes ().size () > 0 ) && vm->engine ()->broadcastByPtrRunning (stage->currentCostume ()->broadcast (), vm))
858858 vm->stop (true , true , true );
859859 }
860860
@@ -864,7 +864,7 @@ unsigned int LooksBlocks::checkBackdropScripts(VirtualMachine *vm)
864864unsigned int LooksBlocks::costumeNumber (VirtualMachine *vm)
865865{
866866 if (Target *target = vm->target ())
867- vm->addReturnValue (target->currentCostume () );
867+ vm->addReturnValue (target->costumeIndex () + 1 );
868868 else
869869 vm->addReturnValue (0 );
870870
@@ -874,7 +874,7 @@ unsigned int LooksBlocks::costumeNumber(VirtualMachine *vm)
874874unsigned int LooksBlocks::costumeName (VirtualMachine *vm)
875875{
876876 if (Target *target = vm->target ()) {
877- auto costume = target->costumeAt (target-> currentCostume () - 1 );
877+ auto costume = target->currentCostume ();
878878
879879 if (costume)
880880 vm->addReturnValue (costume->name ());
@@ -889,7 +889,7 @@ unsigned int LooksBlocks::costumeName(VirtualMachine *vm)
889889unsigned int LooksBlocks::backdropNumber (VirtualMachine *vm)
890890{
891891 if (Stage *stage = vm->engine ()->stage ())
892- vm->addReturnValue (stage->currentCostume () );
892+ vm->addReturnValue (stage->costumeIndex () + 1 );
893893 else
894894 vm->addReturnValue (0 );
895895
@@ -899,7 +899,7 @@ unsigned int LooksBlocks::backdropNumber(VirtualMachine *vm)
899899unsigned int LooksBlocks::backdropName (VirtualMachine *vm)
900900{
901901 if (Stage *stage = vm->engine ()->stage ()) {
902- auto costume = stage->costumeAt (stage-> currentCostume () - 1 );
902+ auto costume = stage->currentCostume ();
903903
904904 if (costume)
905905 vm->addReturnValue (costume->name ());
0 commit comments