• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] 2 JASS Questions

Status
Not open for further replies.
Level 8
Joined
Jul 3, 2011
Messages
251
Hey Hive, i got 2 JASS related questions that i cannot for the life of me figure out. Will be very greatfull to anyone who can answer them.

1. If you save a local group to a hashtable, then set a local group as the saved group, must you destroy the loaded group or will that also destroy the saved group? I never really had to save unit groups into hashtables so only now is this becomming an issue, since i dont want leaks.

2. How can you create a rect between 1 unit to another give or take 50 units wide? I am not sure what calculation (if any) is required to achieve this.
 
Level 8
Joined
Jul 3, 2011
Messages
251
1. I dont mean about the hashtable leaking, i mean about the loaded group leaking, every time i load a group from a hashtable, must i destroy it? Or just null it and destroy it when i flush the hashtable?

2. Like Tether from DotA, the blue lightning between 2 units where they create a rect to pick units to stun in, how can i make a rect like that?

 
Level 26
Joined
Mar 19, 2008
Messages
3,140
1. Take a look:
JASS:
// Lets say you have saved group handle and now you load it
local group g = LoadGroupHandle(somehash, someid, 0)
// stuff related to manipulate the group
call DestroyGroup(g)
set g = null
// If saved handle is needed no more you can either
call RemoveSavedHandle(somehash, someid, 0) // to remove just child key

// Or if you want to clear whole parent key
call FlushChildHashtable(somehash, someid)
2. I think there it's all about creating temporary regions with:
JASS:
native SetRect                  takes rect whichRect, real minx, real miny, real maxx, real maxy returns nothing
Where minx/y will be referend to caster's position and maxx/y to the target's position.
 
Level 8
Joined
Jul 3, 2011
Messages
251
Ok thanks spinnaker about 1, however 2 wont create a wide rect since its just a rect from 1 pos to another, it will be pencil line thin most likely, how can i make it 50 units wide? And sry baassee i dont really understand that code nor what it is meant to do.
 
1. I dont mean about the hashtable leaking, i mean about the loaded group leaking, every time i load a group from a hashtable, must i destroy it? Or just null it and destroy it when i flush the hashtable?
Depends on what you do with that group or if you have other references to the group.
I think you mistake the hashtable for something it isn't. A hashtable is nothing else than a two-dimensional array.

If you store a group into an array and retrieve it when you need it, you wouldn't ask that question, would you?
If you save a group to a hashtable, you don't really put that group into there, all you do is storing a "link" to that group there. If you remove a group from a hashtable by using "RemoveSavedHandle", the link gets destroyed, but not the group. If you "DestroyGroup" inside the hashtable, the entire group gets destroyed. If you used it elsewhere, it doesn't work anymore.
Hope this was the answer to your question?
 
Status
Not open for further replies.
Top