Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Issue with forEach Loops and deleteAt Index #2848

Merged
merged 5 commits into from
Nov 25, 2015
Merged

Conversation

jokoho48
Copy link
Member

No description provided.

@jokoho48 jokoho48 added the kind/bug-fix Release Notes: **FIXED:** label Nov 17, 2015
@jonpas
Copy link
Member

jonpas commented Nov 17, 2015

First SQF Validator fix!? :D

@jokoho48
Copy link
Member Author

what ou mean? you mean that we must integrate this in the SQF Validator?

@jonpas
Copy link
Member

jonpas commented Nov 17, 2015

No, only that it found an error, which is good. :)

@jokoho48
Copy link
Member Author

aha ok yeah i miss click befor and delete a bracket :D

Previously when iterating over an array and modifying the same array via deletion of the current index, incorrect means was used to account for the change in index resulting in any further deletions being applied to the wrong elements.

This solution does not require duplication of the array or the use of external variables to track the number of deleted elements. We simply lower the `_forEachIndex` by 1 whenever an element is removed.
@PabstMirror
Copy link
Contributor

for "_index" from 0 to 5 do {
    diag_log text format ["Adding @ frame %1 - %2", diag_frameNo, _index];
    [{time > 10}, {
        diag_log text format ["Called @ frame %1 - %2", diag_frameNo, _this];
    }, [_index]] call ace_common_fnc_waitUntilAndExecute
};
Adding @ frame 18865 - 0
Adding @ frame 18865 - 1
Adding @ frame 18865 - 2
Adding @ frame 18865 - 3
Adding @ frame 18865 - 4
Adding @ frame 18865 - 5

Called @ frame 19340 - [0]
Called @ frame 19340 - [2]
Called @ frame 19340 - [4]
Called @ frame 19341 - [1]
Called @ frame 19341 - [5]
Called @ frame 19342 - [3]

@jokoho48
Copy link
Member Author

@SilentSpike your code dont work sorry

@kymckay
Copy link
Member

kymckay commented Nov 17, 2015

😢 Should I obliterate it from the branch history or do you want to revert it in a new commit?

@jokoho48
Copy link
Member Author

sorry i dont have much time currently feel free to do :D

@kymckay
Copy link
Member

kymckay commented Nov 18, 2015

I believe this issue is also present in addons/huntir/functions/fnc_cam.sqf

@jokoho48
Copy link
Member Author

yeah posible

@kymckay
Copy link
Member

kymckay commented Nov 18, 2015

That file could use a bit of a minor re-write just to make it more readable anyway. Might be best to handle it in another PR

@thojkooi thojkooi added this to the 3.4.0 milestone Nov 18, 2015
@thojkooi
Copy link
Contributor

Is this done?

@kymckay
Copy link
Member

kymckay commented Nov 25, 2015

I suggest we merge this and handle the huntIR issue elsewhere

kymckay added a commit that referenced this pull request Nov 25, 2015
fix Issue with forEach Loops and deleteAt Index
@kymckay kymckay merged commit c731d83 into master Nov 25, 2015
@kymckay kymckay deleted the fixForEachDeleteAt branch November 25, 2015 14:00
@kymckay kymckay mentioned this pull request Jan 18, 2016
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-fix Release Notes: **FIXED:**
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants