[Snippet] GetClosestWidget

Level 24
Joined
Mar 19, 2008
Messages
3,136
The answer is:
Back in time I haven't come up with such idea and now it would break compatibility.

I don't know if it's approriate to change argument type from boolexpr into code at this point.

@Ceday - you are right, DestroyBoolExpr might be unnecessary considering the occurance rate of And and Or methods.
 
Level 24
Joined
Mar 19, 2008
Messages
3,136
Updated - fixed issues similar to null-rect case. One of them involved replacing bj_mapInitialPlayableArea with GetWorldBounds().
I couldn't reproduce any other bugs. This is tested heavily - as with previous update, those "issues" could never occur, nonetheless I wanted this to have highest quality.

Also, textmacros + globals weren't doing what they were suppose to do. As of now, globals required for each module are hidden within private struct so after compilation is done, only those globals which are required become declared. Improved documentation, it's more readable. Also, added extra space within code to avoid code-blocks.

Demo code has been below snippets code. No API changes whatsoever.
 
Last edited:
Level 13
Joined
May 11, 2008
Messages
1,198
JASS:
function GetClosestDestructable takes real x, real y, boolexpr filter returns destructable

I don't understand why the boolexpr is even in there since you can't ask if it's a tree if you haven't got destructable yet. I don't think that is a usable boolexpr but if someone knows better, feel free to tell about it.

It looks like I have to use EnumDestructablesInRect but I don't understand the final part about code actionfunc.
I don't seem to be good at understanding enumeration, unfortunately. Ugh.
I have another function lying around somewhere that enumerates units and uses a group, but that's different, I can't put trees in groups and this function doesn't take that same entry code actionfunc. You cheated and used null in your demo/example so I don't know how to proceed.
 
Last edited:
Level 19
Joined
Aug 13, 2013
Messages
1,680
I apologize for hijacking this thread but just wanted to share my experience recently as a user of this resource that: functions under the GROUP module could be avoided as the performance impact is very terrible when used periodically with filters on, code-wise: I don't know maybe it's because of the sorting algorithm used for it. I've just substitute to GroupEnum...(group) in conjunction with GetClosestUnitInGroup(group) instead and use it like how FirstOfGroup() loop works to enumerate a counted closest units which is naively performant than the available functions for it.
JASS:
//globals: source, destination, picked
                    call GroupEnumUnitsInRange(source,x,y,range,filter)
                    loop
                        set picked = GetClosestUnitInGroup(x,y,source)
                        exitwhen picked == null or i == count
                        set i = i + 1
                        // actions (already sorted from closest to farthest)
                        // call GroupAddUnit(destination,picked)
                        call GroupRemoveUnit(source,picked)
                    endloop

// ^ is much more performant and works properly than these;
                   call GetClosestNUnitsInRange(x,y,range,count,source,filter)
                   call GetClosestNUnitsInGroup(x,y,count,source,destination)
The first method just remedied these performance drops I'm having, with proper results.
Note that these claims are only from my experience, didn't test those extensively yet.....
 
Level 8
Joined
Jul 4, 2016
Messages
494
I recall this library having a GetClosestDestructable(s) function, which would then provide an array of destructables where you can loop through.

Was that removed or am I thinking a different library?
 
Level 24
Joined
Mar 19, 2008
Messages
3,136
@Clanzion There are no native destructible groups exposed in Blizzard's interface. Maybe these were introduced in one of Reforged patches, not as fluent in changes they brought.

Because of this, don't believe functions you speak of were actually ever part of this library. Don't be afraid to challenge me on this, but some guidance i.e. pointing to some specific post would be required.

Crafting custom destructible group is probably is a lot of overhead. Target audience is also very niche.
 
Top