Return Bug

Mad-Ness

New Member
Ok, so im going to explain the return bug.
The return bug in JASS is were you can return a varible different to the varible type to what it says it will return.
Classis example:

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

Here, it actually returns 'h', which is not the a integer.
'h' Is a handle, a handle is a unit, player, unit group, timer, dialog, or anything else that is NOT a integer, string, real or boolean.
The parser that checks if the script is ok, only checks if the last return type is correct.
So you can return practiaclly anything.
example:

function Unit2Integer takes unit u return integer
return u
return 0
endfunction

NOTE: always return 0, and not any other value, this can make your game get very strange if done otherwise.

This is where 'handle varibles' begin.
If you can convert any 'handle' into a integer. You can store any handle into a cache and reload it.
Without the return bug, JASS would be limited to the few BJ's and custom made function that are here today.
Really, it shouldent be called the return bug, more like the return blessing
To make things easier to understand handles and parameters, iv took this list out of common.j and made it easier to understand.

type: event.....Varible Type: handle
type: player.....Varible Type: handle
type: widget.....Varible Type: handle
type: unit.....Varible Type: widget
type: destructable.....Varible Type: widget
type: item.....Varible Type: widget
type: ability.....Varible Type: handle
type: buff.....Varible Type: ability
type: force.....Varible Type: handle
type: group.....Varible Type: handle
type: trigger.....Varible Type: handle
type: triggercondition.....Varible Type: handle
type: triggeraction.....Varible Type: handle
type: timer.....Varible Type: handle
type: location.....Varible Type: handle
type: region.....Varible Type: handle
type: rect.....Varible Type: handle
type: boolexpr.....Varible Type: handle
type: sound.....Varible Type: handle
type: conditionfunc.....Varible Type: boolexpr
type: filterfunc.....Varible Type: boolexpr
type: unitpool.....Varible Type: handle
type: itempool.....Varible Type: handle
type: race.....Varible Type: handle
type: alliancetype.....Varible Type: handle
type: racepreference.....Varible Type: handle
type: gamestate.....Varible Type: handle
type: igamestate.....Varible Type: gamestate
type: fgamestate.....Varible Type: gamestate
type: playerstate.....Varible Type: handle
type: playerscore.....Varible Type: handle
type: playergameresult.....Varible Type: handle
type: unitstate.....Varible Type: handle
type: aidifficulty.....Varible Type: handle

type: eventid.....Varible Type: handle
type: gameevent.....Varible Type: eventid
type: playerevent.....Varible Type: eventid
type: playerunitevent.....Varible Type: eventid
type: unitevent.....Varible Type: eventid
type: limitop.....Varible Type: eventid
type: widgetevent.....Varible Type: eventid
type: dialogevent.....Varible Type: eventid
type: unittype.....Varible Type: handle

type: gamespeed.....Varible Type: handle
type: gamedifficulty.....Varible Type: handle
type: gametype.....Varible Type: handle
type: mapflag.....Varible Type: handle
type: mapvisibility.....Varible Type: handle
type: mapsetting.....Varible Type: handle
type: mapdensity.....Varible Type: handle
type: mapcontrol.....Varible Type: handle
type: playerslotstate.....Varible Type: handle
type: volumegroup.....Varible Type: handle
type: camerafield.....Varible Type: handle
type: camerasetup.....Varible Type: handle
type: playercolor.....Varible Type: handle
type: placement.....Varible Type: handle
type: startlocprio.....Varible Type: handle
type: raritycontrol.....Varible Type: handle
type: blendmode.....Varible Type: handle
type: texmapflags.....Varible Type: handle
type: effect.....Varible Type: handle
type: effecttype.....Varible Type: handle
type: weathereffect.....Varible Type: handle
type: terraindeformation.....Varible Type: handle
type: fogstate.....Varible Type: handle
type: fogmodifier.....Varible Type: handle
type: dialog.....Varible Type: handle
type: button.....Varible Type: handle
type: quest.....Varible Type: handle
type: questitem.....Varible Type: handle
type: defeatcondition.....Varible Type: handle
type: timerdialog.....Varible Type: handle
type: leaderboard.....Varible Type: handle
type: multiboard.....Varible Type: handle
type: multiboarditem.....Varible Type: handle
type: trackable.....Varible Type: handle
type: gamecache.....Varible Type: handle
type: version.....Varible Type: handle
type: itemtype.....Varible Type: handle
type: texttag.....Varible Type: handle
type: attacktype.....Varible Type: handle
type: damagetype.....Varible Type: handle
type: weapontype.....Varible Type: handle
type: soundtype.....Varible Type: handle
type: lightning.....Varible Type: handle
type: pathingtype.....Varible Type: handle
type: image.....Varible Type: handle
type: ubersplat.....Varible Type: handle

Ok, that raps things up, thats the basics about the, the god, 'return bug'
 
Werbung:
Top