From 4c2ec8315b4ec40627df7853172c2f0d0aac0130 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Wed, 29 Jul 2026 16:37:43 +0100 Subject: [PATCH 1/2] fix(collision): sort events in ascending order fixes my own GM2026 game that uses inheritance for projectiles: before, rock -> projectile collision fired but mine (child of projectile) -> rock did not --- src/runner.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/runner.c b/src/runner.c index c8e2524bc..ff242c2b0 100644 --- a/src/runner.c +++ b/src/runner.c @@ -3081,12 +3081,24 @@ static int sortInstancesByObjectIndexThenInstanceIdAscending(const void* element return 0; } +static int32_t compareIntsAscending(const void* a, const void* b) { + int32_t ia = *(const int32_t*)a; + int32_t ib = *(const int32_t*)b; + return (ia > ib) - (ia < ib); +} + static void dispatchCollisionEvents(Runner* runner) { DataWin* dataWin = runner->dataWin; // Iterate only the objects that have any collision event in their parent chain. - int32_t* selfObjects = (runner->objectsWithAnyEventOfType != nullptr) ? runner->objectsWithAnyEventOfType[EVENT_COLLISION] : nullptr; - if (selfObjects == nullptr) return; - int32_t selfObjCount = (int32_t) arrlen(selfObjects); + int32_t* allSelfObjects = (runner->objectsWithAnyEventOfType != nullptr) ? runner->objectsWithAnyEventOfType[EVENT_COLLISION] : nullptr; + if (allSelfObjects == nullptr) return; + int32_t selfObjCount = (int32_t) arrlen(allSelfObjects); + if (selfObjCount == 0) return; + + // Copy and sort by ascending object index so collision dispatch order matches the native runner's slot-index order. + int32_t* selfObjects = (int32_t*)safeMalloc((size_t)selfObjCount * sizeof(int32_t)); + memcpy(selfObjects, allSelfObjects, (size_t)selfObjCount * sizeof(int32_t)); + qsort(selfObjects, (size_t)selfObjCount, sizeof(int32_t), compareIntsAscending); repeat(selfObjCount, soIdx) { int32_t selfObjIdx = selfObjects[soIdx]; @@ -3273,6 +3285,7 @@ static void dispatchCollisionEvents(Runner* runner) { arrsetlen(runner->instanceSnapshots, selfSnapBase); } + free(selfObjects); } // ===[ View Following + Clamping ]=== From ec62f9b1711195b6f3d076cefa4eac751242f0f5 Mon Sep 17 00:00:00 2001 From: cobaltgit Date: Wed, 29 Jul 2026 17:37:15 +0100 Subject: [PATCH 2/2] fix but why? int and int32_t are literally the same thing --- src/runner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runner.c b/src/runner.c index ff242c2b0..e9f9bdcb0 100644 --- a/src/runner.c +++ b/src/runner.c @@ -3081,7 +3081,7 @@ static int sortInstancesByObjectIndexThenInstanceIdAscending(const void* element return 0; } -static int32_t compareIntsAscending(const void* a, const void* b) { +static int compareIntsAscending(const void* a, const void* b) { int32_t ia = *(const int32_t*)a; int32_t ib = *(const int32_t*)b; return (ia > ib) - (ia < ib);