Skip to content

Commit 8039bf5

Browse files
committed
Fix edge-activated hats without fields
1 parent 56af9bd commit 8039bf5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/engine/internal/engine.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,16 @@ void Engine::step()
505505
bool oldValue = false;
506506
auto hatBlock = thread->script()->topBlock();
507507
assert(hatBlock);
508-
assert(hatBlock->fieldAt(0)); // TODO: Edge-activated hats currently support only one field
509-
int fieldValueId = hatBlock->fieldAt(0)->specialValueId();
510-
assert(fieldValueId != -1);
508+
509+
// TODO: Edge-activated hats currently support only one field
510+
// If there isn't any field, -1 is used as the field value ID
511+
int fieldValueId = -1;
512+
513+
if (hatBlock->fieldAt(0)) {
514+
fieldValueId = hatBlock->fieldAt(0)->specialValueId();
515+
assert(fieldValueId != -1);
516+
}
517+
511518
auto it = m_edgeActivatedHatValues.find(hatType);
512519

513520
if (it == m_edgeActivatedHatValues.cend()) {

0 commit comments

Comments
 (0)