Warcraft (WC3) Modding > Rejected Codes & Snippets

[vJass] Rect Utils

(1/2) > >>

Wareditor:

Magtheridon96:
Currently, this could crash the thread if someone calls GetTriggeringRect() at the wrong time.
The solution is to initially set the value of TriggerRegion in the globals to null.

edit
Also, making 5000 iterations on map init isn't a very good solution :/
What are the Pros of using this though? =o

The only utility I use for rects is this:


--- Code: jass ---/****************************************   RegisterRectEvent*   v1.0.0.0*   By Magtheridon96**   - Used to register onEnter/onLeave code for a rect.**   API:*   ----**       - function RegisterRectEvent takes rect r, code onEnter, code onLeave returns nothing*           - Registers the codes onEnter and onLeave to the rect r.***************************************/library RegisterRectEvent        function RegisterRectEvent takes rect r, code onEnter, code onLeave returns nothing        local trigger t = null        local region rg = null        local boolean b = (onEnter != null)        local boolean c = (onLeave != null)        local boolean d = (b or c)                if (d) then            set rg = CreateRegion()            call RegionAddRect(rg, r)        endif                if (b) then            set t = CreateTrigger()            call TriggerRegisterEnterRegion(t, rg, null)            call TriggerAddCondition(t, Filter(onEnter))            set t = null        endif                if (c) then            set t = CreateTrigger()            call TriggerRegisterLeaveRegion(t, rg, null)            call TriggerAddCondition(t, Filter(onLeave))            set t = null        endif                if (d) then            set rg = null        endif    endfunction    endlibrary

moyack:
Hmmm, I think this code can be improved. First of all the looping though 5000 items is very inneficient. I'd go for using a hashtable, making the search faster.

In order to give more suggestions, could you give me an example of usage of your script?

Additionally, you should add this link for JNGP with the latest jass helper: http://wc3modding.info/4263/jass-newgen-pack-jngp/ or
--- Code: ---[smg id=12 type=box]
--- End code ---
[smg id=12 type=box]

Wareditor:
Updated the code.
About the use, look at my demo.

moyack:
I've checked the new version of the code and now it looks better. I was just wondering about the releaserect, shouldn't be better to remove the rect and free that memory?

Navigation

[0] Message Index

[#] Next page

Go to full version