HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Handle To (returnbugs ^^)

09-12-2009, 06:58 PM#1
Arkless
I don't know if it's already public knowlege, but the return bug is still possible (thought not with integers -_-).

Well, they migth be usefull to someone else so I will just post my H2 lib.

Expand H2 Library:

names: H2_ + first 3 chars of the first word and 1 of the following words (first letters are capital^^)
means: multiboarditem = MulBI
=> H2_MulBI

This library does NOT contain every vartype, only those I think I will need^^.
09-12-2009, 08:53 PM#2
Vexorian
that's messed up, though probably not necessary as we could use SaveAgentHandle anyway (and it is safer too)
09-12-2009, 09:10 PM#3
azlier
Can you create B2I and I2B? While you said integers could still not be typecasted into handles, what about booleans? Those are the only ones I'm interested in.
09-12-2009, 09:25 PM#4
Arkless
Quote:
Originally Posted by azlier
Can you create B2I and I2B? While you said integers could still not be typecasted into handles, what about booleans? Those are the only ones I'm interested in.
Collapse JASS:
function B2I takes boolean b returns integer
if b then
return 1
else
return 0
endif
endfunction

function I2B takes integer i returns boolean
if i == 1 then
return true
elseif i == 0 then
return false
endif
endfunction
O.o sry, I didnt use the returnbug but I suppose that's what you want ^^


edit:
Quote:
Originally Posted by Vexorian
that's messed up, though probably not necessary as we could use SaveAgentHandle anyway (and it is safer too)
well O.o I found this when I copied a timerstack and my groupstack didnt work (coz it created timers >.<)...
so I just made me a list of functions I might need somewhere in the future (I got some ideas xDDD my weird way of mapping^^)

and you know, this exists... so why keep it for myself? maybe someone else can use it for something usefull^^ (afterall I didn't even try to submit it as a code resource^^)
09-12-2009, 09:30 PM#5
ToukoAozaki
Quote:
Originally Posted by azlier
Can you create B2I and I2B? While you said integers could still not be typecasted into handles, what about booleans? Those are the only ones I'm interested in.

Isn't that possible with just plain ifs? Such as:

Collapse JASS:
function I2B takes integer i returns boolean
    if i == 0 then
        return false
    endif
    return true
endfunction
09-12-2009, 09:57 PM#6
Vexorian
booleans are not necessarily 0 or 1.
09-12-2009, 10:04 PM#7
Arkless
Collapse JASS:
function B2I takes boolean b returns integer
if b then
return 1
elseif not b then
return 0
else
return 2
endif
endfunction

function I2B takes integer i returns boolean
if i == 1 then
return true
elseif i == 0 then
return false
elseif i == 2 then
return null
endif
endfunction
09-12-2009, 10:24 PM#8
azlier
I needed B2I and I2B for a sort of perfect trigger attachment I invented. No hashtables, arrays, H2I - 0x100000, nothing. O(1) all over, write and read.

Bah. Nevermind. I needed B2I and I2B using the return bug.
09-12-2009, 10:27 PM#9
Vexorian
It won't though, blizz will destroy this because it will not be shocking the I2C will work with a variation like this.

Nobody really needs trigger attachment anyway...
09-12-2009, 10:31 PM#10
azlier
Ah, but the one who can attach to a trigger can attach to the world. (Trackables, regions, blah...)
09-12-2009, 11:05 PM#11
Storyyeller
Quote:
Originally Posted by Arkless
Collapse JASS:
function B2I takes boolean b returns integer
if b then
return 1
elseif not b then
return 0
else
return 2
endif
endfunction

function I2B takes integer i returns boolean
if i == 1 then
return true
elseif i == 0 then
return false
elseif i == 2 then
return null
endif
endfunction

You're I2B function is still wrong.
You aren't returning in the case when i is not 0,1, or 2
09-13-2009, 12:27 AM#12
azlier
So, uh... yeah.
09-13-2009, 01:32 AM#13
Arkless
Quote:
Originally Posted by Storyyeller
You're I2B function is still wrong.
You aren't returning in the case when i is not 0,1, or 2
you are right, just make the null the last else without if <.<

edit:
Quote:
Originally Posted by azlier
So, uh... yeah.
o.o quite cool, I knew returning from nothing but i never guessed that it would still work ^^

thought its said... will probably lead to another bugloaded fix from blizz... hope they will just ignore it <.<
09-14-2009, 05:20 AM#14
weaaddar
By the way PJass disallow null return syntax which is a good thing but unfortuantely doesn't catch return bug forms::
Collapse JASS:
unit H2U(handle h)
{
    return h; // should throw a compilation error doesn't
}

unit H2U(handle h)
{
    unit u;
    if(false)
    
       return h; // throws a compilation error, but shouldn't.
    
}
09-14-2009, 06:17 AM#15
DioD
null == false

0 == null == false without typecast....