Bump.
Actually, there was something that could be optimised (and maybe still is).
Turned this:
Into this:
Notice that there is no more O(n) search (the loop) for this part anymore. It is done in the other loop now.
This actually increased efficiency quite a bit (able to run even more hooks at once). This is because I was stupidly doing 2 O(n) type searches for the "chain links" per interval, when I could have only been doing 1. So yeah, I will update this when I get the chance. The new version will be far more efficient.
Also:
Please comment on this someone. Some hard work went into it.
Can't actually see anything that could need some optimising.
Actually, there was something that could be optimised (and maybe still is).
Turned this:
JASS:
set linkx = this.list.first
// Chain links may bunch up after bouncing off of walls.
// Sometimes the distance between every second chain is equivalent
// to the distance between each chain, therefore we can remove the middle one.
loop
exitwhen linkx == 0 or linkx.next.next == 0
set temp = linkx.link
set temx = GetUnitX(temp)
set temy = GetUnitY(temp)
set next = linkx.next.next.link
set newx = GetUnitX(next)
set newy = GetUnitY(next)
if IsUnitInRange(temp,next,(this.speed * 0.75)) then
call this.list.detach(linkx.next)
call SetUnitFacing(temp,Atan2((newy - temy),(newx - temx)) * bj_RADTODEG)
endif
set linkx = linkx.next
endloop
Into this:
JASS:
if linkx.next.next != 0 then
set dumm = linkx.next.next.link
if IsUnitInRange(temp,dumm,(this.speed * 0.75)) then
call this.list.detach(linkx.next)
call SetUnitFacing(temp,(Atan2((GetUnitY(dumm) - temy),(GetUnitX(dumm) - temx)) * bj_RADTODEG) + 180.00)
endif
endif
Notice that there is no more O(n) search (the loop) for this part anymore. It is done in the other loop now.
This actually increased efficiency quite a bit (able to run even more hooks at once). This is because I was stupidly doing 2 O(n) type searches for the "chain links" per interval, when I could have only been doing 1. So yeah, I will update this when I get the chance. The new version will be far more efficient.
Also:
Please comment on this someone. Some hard work went into it.