Skip to content

Commit 53bec00

Browse files
committed
Fix edge-activated hats without fields
1 parent f9ee2fc commit 53bec00

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
@@ -516,9 +516,16 @@ void Engine::step()
516516
bool oldValue = false;
517517
auto hatBlock = thread->script()->topBlock();
518518
assert(hatBlock);
519-
assert(hatBlock->fieldAt(0)); // TODO: Edge-activated hats currently support only one field
520-
int fieldValueId = hatBlock->fieldAt(0)->specialValueId();
521-
assert(fieldValueId != -1);
519+
520+
// TODO: Edge-activated hats currently support only one field
521+
// If there isn't any field, -1 is used as the field value ID
522+
int fieldValueId = -1;
523+
524+
if (hatBlock->fieldAt(0)) {
525+
fieldValueId = hatBlock->fieldAt(0)->specialValueId();
526+
assert(fieldValueId != -1);
527+
}
528+
522529
auto it = m_edgeActivatedHatValues.find(hatType);
523530

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

0 commit comments

Comments
 (0)