• 🏆 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!

[JASS] HandleVars

Status
Not open for further replies.
Level 2
Joined
Jun 15, 2007
Messages
12
I'm ripping my hair out trying to figure these out. I already understand they assign locals to another handle but I'm still really sketchy on the usage.

Daelins advanced tutorial didnt help me that much. Could someone explain it really fast with an example?
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Oh god...please, don't listen to anything in the above post. It's basically all wrong.

It's too late for me to be bothered to write up an explaination of handles and handle variables, but basically...don't use handle variables to attach anything except for ints, strings and reals. That's been superceeded by safer and faster methods. Handle variables for types other than ints strings and reals are unsafe.
 
Level 2
Joined
Jun 15, 2007
Messages
12
Oh god...please, don't listen to anything in the above post. It's basically all wrong.

It's too late for me to be bothered to write up an explaination of handles and handle variables, but basically...don't use handle variables to attach anything except for ints, strings and reals. That's been superceeded by safer and faster methods. Handle variables for types other than ints strings and reals are unsafe.

This is exactly what I'm talking about. There's basically no tutorials available for it... espcially with WC3C (and now the helper?) down. And now that entire post was BAD information. I wish someone would just set the record straight

But thanks for the links to Kattanas tutorials
 
Oh god...please, don't listen to anything in the above post. It's basically all wrong.

It's too late for me to be bothered to write up an explaination of handles and handle variables, but basically...don't use handle variables to attach anything except for ints, strings and reals. That's been superceeded by safer and faster methods. Handle variables for types other than ints strings and reals are unsafe.

K. I removed everything but the links.

Where did you get that idea? Did you get it from Vex? I need proof before I actually trust something (most of the time).

@Beardo: KaTTaNa is the creator, so read his tuts.

Also, TH isn't down, it is majorly active right now. I don't know how people come up with some of those ludacris ideas.
 
Level 2
Joined
Jun 15, 2007
Messages
12
Also, TH isn't down, it is majorly active right now. I don't know how people come up with some of those ludacris ideas.

When I goto thehelper.net net i get 'Cannot Find Server'. Looks down to me


PS here's what I still dont understand


JASS:
call SetHandleInt(myUnit, "abc", i) // Set "abc" on myUnit to 250

I dont get the 'myUnit' part. If you wrote it out as a syntax, what would my unit represent. I.E SetHandleInt(???, Label, Int)
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Basically, H2I returns a unique integer for each handle (a handle is an object class, of which all other objects, except string real int and code are sub-classes). This integer refers to the slot in the handle index (basically that integer relates to the slot that the variable, which is a pointer, points at).

Local Handle Variables convert that integer to a string, and then uses the game cache to attach to the handle slot that the handle is occupying. Note if the handle is destroyed, the slot may be reused and then, if not defensively programmed, data can be transferred incorrectly from one object to another (this doesn't occur with variables, which keep a reference and so switch to null when the object is destroyed).

Where did you get that idea? Did you get it from Vex? I need proof before I actually trust something (most of the time).

We've got working examples of the handle stack being corrupted, for example (eg: in cases of handle objects. Any system based on handle slots instantly go boom. Any handle variables may get screwed by that, but those attaching ints/reals/strings suffer less from it, and are less likely to screw up from what I gather.

I'm a bit hazy on the exact details, and it's late, so take everything in the last paragraph with a pinch of salt, and go speak to Vex or PipeDream or someone if you want the details.


EDIT:

The 'myUnit' part is any handle variable, such as a unit variable, eg: udg_Unit.
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Appon changing an object new handle values for it are generated. This makes badly written scripts malfunction if they are change dependant. Otherwise handlevars work perfectly, I use a modified version of them but still they work as well.

...aside from the chance of a complete and utter colapse of all your systems, yes. They are vulnerable. And they are also slow.

I would recommend if you are going to use them, at least use direct game cache usage. It means you know what is happening, and it also makes your code execute faster, not least because you can optimise it by not calling I2S(H2I(handle)) every time.
 
Level 11
Joined
Oct 13, 2005
Messages
233
I have yet to experience problems with the handle vars system. I used them in one of my maps for a long time and none of the spells or triggers had problems aside from a little bad coding every now and then. You shouldn't have to worry about overlapping data if you flush the index that the handle you're referring to was using, which is just a good idea to do anyways. As for speed, unless you're coding a very intensive system, you probably wont really notice any difference in how "slow" they are.

That being said, I've heard of handle corruption. However, I have never looked at something as proof of it happening so I can't really say anything there.
 
Level 3
Joined
May 27, 2007
Messages
43
Is there any faster/safer method to send info to another functions or to attach info to stuff other than with HandleVars? I've heard about Vexorian's tables but since wc3c is down I really can't check this out.
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
Structs. You still have to attach an integer to the object, but you can use custom data or TimerAttach or gamecache (for attaching an integer only), and then from that struct you can attatch anything you want.

That requires JASShelper, which is a preprocessor (can be used via Grimoire or WEHelper, both of which don't crash on JASS codes, and have various helpful stuff for each).
 
Level 3
Joined
May 27, 2007
Messages
43
I use JASShelper and I once saw someone saying structs are very unnefective and uggy. Guess I really can't check it out since wc3c is down.
 
I use JASShelper and I once saw someone saying structs are very unnefective and buggy. Guess I really can't check it out since wc3c is down.

"sure they are" give me name of that person and next day it will lay down in blood.

structs are nothing but a visual cheat, what is happening before you eyes and how it truely looks in code is 100% different.
 
Level 5
Joined
Feb 16, 2006
Messages
151
Structs are 100% safe, but I did find a more or less striking bug in JassNewGenPack 3c (I think it was the pjass within it) right before WC3 went offline:
Giving a variable a value while declaring is not considered as a syntrax error if you do something like this:
JASS:
local integer i 0
This however still cripples the function...
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
You can update pJASS independantly of JASShelper, so I'd try doing that first before contacting Pitzer.

I use JASShelper and I once saw someone saying structs are very unnefective and uggy. Guess I really can't check it out since wc3c is down.

That person was an idiot. They are very effective at being structs.

As for ugly, many people call JASS2's syntax ugly, and structs use the same syntax.
 
Status
Not open for further replies.
Top