From 40c644520fb5aa29af6d53c6c8a472b226e8f20f Mon Sep 17 00:00:00 2001 From: MCorbo7 <84733317+MCorbo7@users.noreply.github.com> Date: Wed, 6 May 2026 19:47:14 -0300 Subject: [PATCH 1/2] Update Edif.Runtime.cpp This properly resets object iteration within loops --- DarkEdif/Lib/Shared/Edif.Runtime.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DarkEdif/Lib/Shared/Edif.Runtime.cpp b/DarkEdif/Lib/Shared/Edif.Runtime.cpp index 332ef1ae..6895217c 100644 --- a/DarkEdif/Lib/Shared/Edif.Runtime.cpp +++ b/DarkEdif/Lib/Shared/Edif.Runtime.cpp @@ -226,7 +226,10 @@ void Edif::Runtime::GenerateEvent(int EventID) // This action count won't be reset, so to allow multiple of the same event with different object selection, // we change the count every time, and in an increasing manner. //rhPtr->SetRH2ActionCount(oldActionCount + (++steadilyIncreasing)); - //rhPtr->SetRH2ActionLoopCount(0); + // ^ we swapped that with a non global state, selectionRefreshCounter was declared at DarkEdif\Inc\Shared\Edif.hpp + rhPtr->SetRH2ActionCount(oldActionCount + (++selectionRefreshCounter)); + // uncommenting this V to go along with the previous fix + rhPtr->SetRH2ActionLoopCount(0); // Saving tokens allows events to be run from inside expressions // https://community.clickteam.com/forum/thread/108993-application-crashed-in-some-cases-when-calling-an-event-via-expression/?postID=769763#post769763 @@ -1342,7 +1345,8 @@ void Edif::Runtime::GenerateEvent(int EventID) // This action count won't be reset, so to allow multiple of the same event with different object selection, // we change the count every time, and in an increasing manner. - rhPtr->SetRH2ActionCount(oldActionCount + (++steadilyIncreasing)); + // For some reason this was uncommented here. Let's make it consistent with the windows edit + rhPtr->SetRH2ActionCount(oldActionCount + (++selectionRefreshCounter)); rhPtr->SetRH2ActionLoopCount(0); // In older Fusion builds, the expression token became invalidated and that was the only problem. From 40237ec0c9f62f7efea2202685679a36abd0ea41 Mon Sep 17 00:00:00 2001 From: Phi Date: Sat, 13 Jun 2026 15:03:02 +0100 Subject: [PATCH 2/2] DarkEdif: Re-added rh2ActionCount incr int It's been so long, I'm not entirely sure what scenarios rh2ActionCount gets clobbered during event generation. I couldn't reproduce the bug for rh2ActionCount with fastloops/created objects, possibly due to CF25 296.9 runtime fixes, due to the fix being too broad and only erroneous in specific scenarios, or due to rh2ActionOn being fixed. If it's actions' expressions generating events that do fastloops that breaks ActionCount, then this ActionCount DE fix is too broad and should've been in DS. It may only be a problem when rh2EventCount is rolled back, too. Which would be DS' job to work out, not DE itself. I should also note these fixes aren't in iOS/Mac side. Probably not HTML5/UWP either. But I'll keep rh2ActionCount being set and incremented for now, until I've done enough tests to understand rh2ActionCount and rh2ActionLoopCount's purpose. --- DarkEdif/Inc/Shared/Edif.hpp | 18 ++++++++++++++++++ DarkEdif/Lib/Shared/Edif.Runtime.cpp | 13 +++++-------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/DarkEdif/Inc/Shared/Edif.hpp b/DarkEdif/Inc/Shared/Edif.hpp index ec6ccfb9..8dcaa784 100644 --- a/DarkEdif/Inc/Shared/Edif.hpp +++ b/DarkEdif/Inc/Shared/Edif.hpp @@ -234,6 +234,24 @@ namespace Edif void Rehandle(); + // Used to allow the rough selection restore to work when multiple events are triggered. + // @remarks The following explanation is dubious. I can't reproduce the bug scenario anymore. + // My original scenario it occurred in was in DarkScript, which generates events from expressions, + // and restores object selection across its generated events. Most objects don't do that. + // Until I've isolated ActionCount's change scenarios, I'm keeping this in SDK. + // + // Dubious explanation: + // oilActionCount must differ to rhActionCount for a new event to properly loop + // object instances during actions. rhActionCount is normally incremented by runtime when a new generated + // event is run to cause that difference. + // However, that difference invalidates selection in the event that started the generated one, + // like running a fastloop will. + // To keep caller event selection, DarkEdif rolls back all selection variables to their original + // after the generated event. But that same original being incremented means the runtime rhActionCount + // is re-incremented to the same value on both first and second generated event. + // That breaks the 2nd+ generated event's selection, so instead we increase rhActionCount by 1, 2, etc. + static int actionLoopIncrement; + // Immediately creates an event, calling that condition ID in this object, and invalidating object selection. void GenerateEvent(int EventID); // Queues an event to run at the end of the actions, which will ccall this condition ID. diff --git a/DarkEdif/Lib/Shared/Edif.Runtime.cpp b/DarkEdif/Lib/Shared/Edif.Runtime.cpp index 6895217c..638b5447 100644 --- a/DarkEdif/Lib/Shared/Edif.Runtime.cpp +++ b/DarkEdif/Lib/Shared/Edif.Runtime.cpp @@ -153,6 +153,9 @@ std::size_t CRunAppMultiPlat::GetNumFusionFrames() { #endif } +// Static definition +int Edif::Runtime::actionLoopIncrement = 0; + #if TEXT_OEFLAG_EXTENSION std::uint32_t Edif::Runtime::GetRunObjectTextColor() const { @@ -212,7 +215,6 @@ void Edif::Runtime::Rehandle() CallRunTimeFunction2(hoPtr, RFUNCTION::REHANDLE, 0, 0); } -//static int steadilyIncreasing = 0; void Edif::Runtime::GenerateEvent(int EventID) { auto rhPtr = hoPtr->hoAdRunHeader; @@ -225,10 +227,7 @@ void Edif::Runtime::GenerateEvent(int EventID) // This action count won't be reset, so to allow multiple of the same event with different object selection, // we change the count every time, and in an increasing manner. - //rhPtr->SetRH2ActionCount(oldActionCount + (++steadilyIncreasing)); - // ^ we swapped that with a non global state, selectionRefreshCounter was declared at DarkEdif\Inc\Shared\Edif.hpp - rhPtr->SetRH2ActionCount(oldActionCount + (++selectionRefreshCounter)); - // uncommenting this V to go along with the previous fix + rhPtr->SetRH2ActionCount(oldActionCount + (++actionLoopIncrement)); rhPtr->SetRH2ActionLoopCount(0); // Saving tokens allows events to be run from inside expressions @@ -1331,7 +1330,6 @@ void Edif::Runtime::Rehandle() // GenEdifFunction reHandle } -static int steadilyIncreasing = 0; void Edif::Runtime::GenerateEvent(int EventID) { const auto& rhPtr = this->ObjectSelection.pExtension->rhPtr; @@ -1345,8 +1343,7 @@ void Edif::Runtime::GenerateEvent(int EventID) // This action count won't be reset, so to allow multiple of the same event with different object selection, // we change the count every time, and in an increasing manner. - // For some reason this was uncommented here. Let's make it consistent with the windows edit - rhPtr->SetRH2ActionCount(oldActionCount + (++selectionRefreshCounter)); + rhPtr->SetRH2ActionCount(oldActionCount + (++actionLoopIncrement)); rhPtr->SetRH2ActionLoopCount(0); // In older Fusion builds, the expression token became invalidated and that was the only problem.