Enumerations

weaaddar

New Member
Reaction score
6
ForGroup does filter them out but piss poorly. It actually leaves shadow references, and for some reason with each iteration these shadow references cost a lot of memory. There's a reason that GroupRefresh exists.

Eitherway,[ljass] if(GetWidgetLife(someUnit) < .405) [/ljass] is lightening fast.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
ForGroup does filter them out but piss poorly. It actually leaves shadow references, and for some reason with each iteration these shadow references cost a lot of memory. There's a reason that GroupRefresh exists.

Eitherway,[ljass] if(GetWidgetLife(someUnit) < .405) [/ljass] is lightening fast.

AFAIK a ghost unit doesn't fire ForGroup, or i'm wrong ?
I'm aware about ghost units, read again my previous post.

But i don't really understand this sentence :
and for some reason with each iteration these shadow references cost a lot of memory
You mean each time we do a ForGroup it leaks when we have ghost units inside it ?!

Checking the life isn't safe.
Without modify the life with triggers i've already got a dead hero with hp more than 0.405 hp because of a bugged ability.
You've also to care about life when you change it, else you can got a dead unit with more than 0.405 hp.

But i supposed if you code carefully and trigger all abilities then you can use it.
 

weaaddar

New Member
Reaction score
6
I remember reading somewhere that forgrouping through a group that had lots of removed units costed more memory. I've never tested it admittedly.
There are more complicated ways to determine if a unit is alive (adding an ability and seeing if the unit has it), and i imagine since its 4 times faster then the forGroup you can still beat the forGroup statement.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Ok if you say it, i'm bad with speed theories anyway.
I will test the eventual leak of ghost units on each ForGroup call later though, if it's confirmed i won't use group for more than one instant anymore ...
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
About the leak :

JASS:
scope testGroupLeak initializer onInit

globals
    private group Grp
    private timer Tim
endglobals

private function Callback takes nothing returns nothing
endfunction

private function Handler takes nothing returns nothing
    call ForGroup(Grp,function Callback)
endfunction

private function Actions takes nothing returns nothing
    call BJDebugMsg(&quot;test begin&quot;)
    call TimerStart(Tim,0.01,true,function Handler)
endfunction

private function onInit takes nothing returns nothing
    local integer i = 0
    local unit u
    local trigger trig = CreateTrigger()
    
    set Grp = CreateGroup()
    set Tim = CreateTimer()
    call TriggerRegisterPlayerEventEndCinematic(trig,Player(0))
    call TriggerAddAction(trig,function Actions)
    
    loop
    exitwhen i == 1000
    
        set u = CreateUnit(Player(0),&#039;hfoo&#039;,0.,0.,0.)
        call GroupAddUnit(Grp,u)
        call RemoveUnit(u)
        set u = null
        
    set i = i+1
    endloop
    
    call GroupAddUnit(Grp,CreateUnit(Player(0),&#039;hfoo&#039;,0.,0.,0.))
    call BJDebugMsg(&quot;init done&quot;)
endfunction

endscope


Yes i know the callback is empty but still, there is no leak just because of ghost units.
 

Nestharus

o-o
Reaction score
84
I wasn't event personally talking about ForGroup natives ><

I was talking about Enum natives, lol.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Yeah it was off-topic but informative, fair enough, no ?

OFF-TOPIC again

weaaddar said:
There are more complicated ways to determine if a unit is alive (adding an ability and seeing if the unit has it)
Hmm, i don't see how you can handle it properly, AFAIK there is no revive event.
I suppose you can emule it with the defend ability though, maybe grim001 has already did it, i don't care about it anyway, i'm just curious.
For me GetUnitTypeId != 0 and GetUnitState(UNIT_TYPE_DEAD) is just fine.
 

Akolyt0r

New Member
Reaction score
33
Yeah it was off-topic but informative, fair enough, no ?

OFF-TOPIC again


Hmm, i don't see how you can handle it properly, AFAIK there is no revive event.
I suppose you can emule it with the defend ability though, maybe grim001 has already did it, i don't care about it anyway, i'm just curious.
For me GetUnitTypeId != 0 and GetUnitState(UNIT_TYPE_DEAD) is just fine.

u could use UnitAlive from common.ai aswell ;)
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
Let me go on-topic on this one.

When you do a group enumeration with units or an item enumeration or w/e, it probably goes through all of the created handles and if it's like units in range, will see if in range or w/e and then call your code passing in the current enumerated handle.

Yes, you where thinking. Truth is we can't know for sure how enumerations work, we only can observe the behavior of the native and pull conclusions out from it.

Well.. do you guys think it would be faster with JASS with likes AIDS or PUI or something? You'd be eliminating the extra function calls per handle and it could be a massive performance saver.
Perhaps it will be faster, most likely not. But let's assume it is faster, creating a system in Jass to have the same flexibility as enumerations do now will most likely make it slower for sure.

Enumerations are a powerful thing, and looping just can't compare with that.
Although enumerations and looping behave the same way, enumerations are designed with flexibility in mind which is in most cases more important than execution time.

What do those few micro seconds matter to you anyways? These days computers are getting faster and faster and usually the GPU is too slow for those games. But I mean, com'on It's Warcraft III. 1.4Ghz was high at that time when it was released.
 

Lyerae

I keep popping up on this site from time to time.
Reaction score
105
1.4GHz was incredibly high when WC3 was released.
I remember playing it on a 667MHz processor...
 

weaaddar

New Member
Reaction score
6
I suppose if someone were nuts they could create a UnitSet library ontop of AIDS or AutoIndex. For large enough datasets the UnitSets would probably outperform groups (forGroup and Enumeration action of running boolexprs slow it down due to thread launching and what not), but again why reinvent the wheel.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Akolytor said:
u could use UnitAlive from common.ai aswell
No.
Wc3 mapping is already build enough with bug exploits, work around to add one quite useless and not very tested.
 

Viikuna

No Marlo no game.
Reaction score
265
Maybe, but then again theres another way to see it too: [lJASS]GetWidgetLife(unit) > .405[/lJASS] has never failed me, and will not fail me, because I know not to change dead units health.

Shit, I dont even have to remember that all the time, just when I code that one function, which is used to change units current health, and which is then used by systems like Heal system, which is again used by spells that heal units and so on.


You can of course try to find solutions for problems that dont exist, but I personally see no reason to do such thing and I dont wanna see you teaching that bad habit to all these kids.

In other words: Quit the bullshit already, please.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Maybe, but then again theres another way to see it too: [lJASS]GetWidgetLife(unit) > .405[/lJASS] has never failed me, and will not fail me, because I know not to change dead units health.

Shit, I dont even have to remember that all the time, just when I code that one function, which is used to change units current health, and which is then used by systems like Heal system, which is again used by spells that heal units and so on.


You can of course try to find solutions for problems that dont exist, but I personally see no reason to do such thing.

In other words: Quit the bullshit already, please.
Yes i know you are this silly guy which trigger all your abilities.
It was just a personal opinion, and we had already this discussion on an other site, keep you cool, thx.
 

Viikuna

No Marlo no game.
Reaction score
265
Yea.

Well, anyways, everyone has their own taste. Some people prefer to do stuff with GUI, for example. Some guys find that pretty damn stupid.

All we can do is to do stuff in our way, and then argue about why the way we do it is the best.



I myself mostly believe that if you want something done properly, you gotta do it by yourself.

Example being: If I want to make a simple missile spell, like storm bolt but with some extra stuff, I need to either use dummy storm bolt and detect when it hits the target, or trigger that missile movement by myself. Option one might seem to be easier, but it has the downside that once that storm bolt is out there, you cant take it back. This is why later when desinging some new spell I realize I should have triggered that shit in the first place, because right now this new "Take It Back" spell I wanna make, is impossible to do.

edit. Yea, sorry, I know I should not talk about any of this stuff here, but I just cant help myself sometimes.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top