Skip to content

Commit 987ae10

Browse files
committed
Fix negative costume indices in looks blocks
1 parent 8eae08b commit 987ae10

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/blocks/looksblocks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ extern "C" double looks_size(Sprite *sprite)
424424

425425
extern "C" void looks_set_costume_by_index(Target *target, long index)
426426
{
427-
const size_t costumeCount = target->costumes().size();
427+
const int costumeCount = target->costumes().size();
428428

429429
if (index < 0)
430430
index = (costumeCount + index % (-costumeCount)) % costumeCount;

test/blocks/looks_blocks_test.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ TEST_F(LooksBlocksTest, SwitchCostumeTo_NegativeOutOfRangeNumberIndex)
810810
ScriptBuilder builder(m_extension.get(), m_engine, sprite);
811811

812812
builder.addBlock("looks_switchcostumeto");
813-
builder.addValueInput("COSTUME", -1);
813+
builder.addValueInput("COSTUME", -4);
814814
builder.build();
815815

816816
builder.run();
@@ -1406,7 +1406,7 @@ TEST_F(LooksBlocksTest, SwitchBackdropTo_NegativeOutOfRangeNumberIndex)
14061406
ScriptBuilder builder(m_extension.get(), m_engine, sprite);
14071407

14081408
builder.addBlock("looks_switchbackdropto");
1409-
builder.addValueInput("BACKDROP", -1);
1409+
builder.addValueInput("BACKDROP", -4);
14101410
auto block = builder.currentBlock();
14111411

14121412
Compiler compiler(&m_engineMock, sprite.get());
@@ -2568,7 +2568,7 @@ TEST_F(LooksBlocksTest, SwitchBackdropToAndWait_NegativeOutOfRangeNumberIndex)
25682568
ScriptBuilder builder(m_extension.get(), m_engine, sprite);
25692569

25702570
builder.addBlock("looks_switchbackdroptoandwait");
2571-
builder.addValueInput("BACKDROP", -1);
2571+
builder.addValueInput("BACKDROP", -4);
25722572
auto block = builder.currentBlock();
25732573

25742574
Compiler compiler(&m_engineMock, sprite.get());

0 commit comments

Comments
 (0)