• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Return bug

Status
Not open for further replies.
Can somedy explain me the return bug, what it does, how come it does not show error (Usually programming languages do not allow double return statements), what really executes, how can be exploited and be useful (handlevars!), who discovered it (omg!) and why it works on some situations?

I know that it was the first script on wc3sear.ch.
 

DeT

DeT

Level 2
Joined
Dec 27, 2006
Messages
14
yes it is.
RB allow u to store habdles as integer 4 example in cache and use it like variables...

Compiler looks only at last "return" and if it's write it doesn't show an error, so u can create f-ns like H2I I2H I2U etc...
 
Level 14
Joined
Nov 20, 2005
Messages
1,156
No. You can 'attach' things to a handle slot with it, or store a pointer to a handle slot in integer form.

Handle index usage, unlike handle variables (eg: unit/location types), doesn't keep the reference, so can be accidently transfered. That's why new structs are safer (not to mention faster).
 
Level 11
Joined
Oct 13, 2005
Messages
233
As far as I know, all data types in JASS are 4 bytes in size (excluding strings obviously). The JASS syntax checker overlooks multiple return statements in a single function, only the last return value has to be of the right type (an integer if the function returns an integer, for example). So my guess is in the H2I function, it only returns the handle, but in integer form. Handle variables just take advantage of Gamecache, and store values under the index that the handle points to (each handle has a unique 'index' or number). So you'd use H2I to convert a handle to integer form, and then use I2S to convert that integer to a string and store a value under that:
JASS:
call StoreInteger(gamecache, I2S(H2I(<handle>)), "some string", <value>)
 
Status
Not open for further replies.
Top