Handle - ?

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Could someone give me the full definition of a handle (in other words - what is a handle)?
And why is leaking handles bad? What does it affect when you get above 8191?
 

Vestras

Retired
Reaction score
248
A handle is an object - like a unit, a timer, everything.
Units, timers and all that (except booleans, strings, reals and integers) extends the handle type variable, and therefore leaks.
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
Almost every Warcraft III type is a handle - unit, effect, lightning, location, etc. but that does not include real, integer, string and boolean basically. Handles themselves actually are integers when it comes down to it, and that's what makes handle attachment systems possible (such as Kattana's or Vexorian's CSData). Handle variables do not store values, yet instead the address of one (in other words - they store the reference to an object). Not nulling or not destroying handles results in a handle leak.
Is this definition right? And still:
And why is leaking handles bad? What does it affect when you get above 8191?
 

Vestras

Retired
Reaction score
248
Yes, except for one thing; handles are not integers, they are handles, that's why people have to use the "H2I" function: (Handle 2 Integer)

JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction


(You can basicly do the same thing with everything, like H2S, S2H, because there's a bug, or a blessing, that when returning something, the compiler only compiles the last return, that's why the last return is 0)
 

Flare

Stops copies me!
Reaction score
662
And why is leaking handles bad? What does it affect when you get above 8191?
It can break some attachment systems (since some work on the basis of H2I(h) - FIRST_HANDLE_INDEX and storing the in an array using the result of the subtraction as the array index, and if the result of H2I(h) - FIRST_HANDLE_INDEX is greater than 8191, it'll be too large for a standard array :p)

handles are not integers
I think the common.j says something about that

Anyway, it's possible that they are, if you break them down :p If handles couldn't be 'broken down' to integers, wouldn't the whole concept of H2I not work at all? Wouldn't it result in 0 or something equivalent to null if it had no association with integers?
 
Reaction score
332
A handle isn't an integer any more than it is a string. "Type" defines how data is used, not how it exists.
 

Romek

Super Moderator
Reaction score
963
Having more than 8191 handles really isn't a problem unless you're using attachment systems. Even then, you'll need all of your handles to be using that system at the exact same time.

Anyway, it's possible that they are, if you break them down :p If handles couldn't be 'broken down' to integers, wouldn't the whole concept of H2I not work at all? Wouldn't it result in 0 or something equivalent to null if it had no association with integers?

I'm not too sure about this, so I won't argue about it much.
If you've ever tried changing the file extension of a song or a movie to '.txt' and you opened it (in NotePad), you'd see loads of random symbols and stuff.
Does this mean .mp3 files (just an example) are associated with text files?
Just like Handles would be associated with Integers.

I think it doesn't return 0 because the handle has a value. 0 means... well, nothing.
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> Having more than 8191 handles really isn't a problem
Hm, why have I remained with a wrong impression that leaking handles causes lag in-game or crashes (but not from attachment systems) ... Anyway, thanks for pointing out guys.
 
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