| 09-12-2009, 06:58 PM | #1 |
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. H2 Library:library function Gro takes handle h returns group local group g if false then return g else return h endif endfunction function Uni takes handle h returns unit local unit u if false then return u else return h endif endfunction function Tim takes handle h returns timer local timer t if false then return t else return h endif endfunction function Eve takes handle h returns event local event e if false then return e else return h endif endfunction function Pla takes handle h returns player local player p if false then return p else return h endif endfunction function Abi takes handle h returns ability local ability ab if false then return ab else return h endif endfunction function For takes handle h returns force local force f if false then return f else return h endif endfunction function Tri takes handle h returns trigger local trigger t if false then return t else return h endif endfunction function TriC takes handle h returns triggercondition local triggercondition t if false then return t else return h endif endfunction function TriA takes handle h returns triggeraction local triggeraction t if false then return t else return h endif endfunction function Des takes handle h returns destructable local destructable d if false then return d else return h endif endfunction function Ite takes handle h returns item local item i if false then return i else return h endif endfunction function Buf takes handle h returns buff local buff b if false then return b else return h endif endfunction function Loc takes handle h returns location local location l if false then return l else return h endif endfunction function Reg takes handle h returns region local region r if false then return r else return h endif endfunction function Rec takes handle h returns rect local rect r if false then return r else return h endif endfunction function Boo takes handle h returns boolexpr local boolexpr b if false then return b else return h endif endfunction function Sou takes handle h returns sound local sound s if false then return s else return h endif endfunction function ConF takes handle h returns conditionfunc local conditionfunc c if false then return c else return h endif endfunction function FilF takes handle h returns filterfunc local filterfunc f if false then return f else return h endif endfunction function UniP takes handle h returns unitpool local unitpool p if false then return p else return h endif endfunction function IteP takes handle h returns itempool local itempool i if false then return i else return h endif endfunction function Rac takes handle h returns race local race r if false then return r else return h endif endfunction function AllT takes handle h returns alliancetype local alliancetype a if false then return a else return h endif endfunction function IgaS takes handle h returns igamestate local igamestate i if false then return i else return h endif endfunction function FgaS takes handle h returns fgamestate local fgamestate f if false then return f else return h endif endfunction function PlaS takes handle h returns playerstate local playerstate p if false then return p else return h endif endfunction function UniS takes handle h returns unitstate local unitstate u if false then return u else return h endif endfunction function EveI takes handle h returns eventid local eventid e if false then return e else return h endif endfunction function CamF takes handle h returns camerafield local camerafield c if false then return c else return h endif endfunction function CamS takes handle h returns camerasetup local camerasetup c if false then return c else return h endif endfunction function Eff takes handle h returns effect local effect e if false then return e else return h endif endfunction function EffT takes handle h returns effecttype local effecttype e if false then return e else return h endif endfunction function Dia takes handle h returns dialog local dialog d if false then return d else return h endif endfunction function But takes handle h returns button local button b if false then return b else return h endif endfunction function Qes takes handle h returns quest local quest q if false then return q else return h endif endfunction function QesI takes handle h returns questitem local questitem q if false then return q else return h endif endfunction function DefC takes handle h returns defeatcondition local defeatcondition d if false then return d else return h endif endfunction function TimD takes handle h returns timerdialog local timerdialog t if false then return t else return h endif endfunction function LeaB takes handle h returns leaderboard local leaderboard l if false then return l else return h endif endfunction function MulB takes handle h returns multiboard local multiboard m if false then return m else return h endif endfunction function MuLBI takes handle h returns multiboarditem local multiboarditem m if false then return m else return h endif endfunction function Tra takes handle h returns trackable local trackable t if false then return t else return h endif endfunction function GamC takes handle h returns gamecache local gamecache g if false then return g else return h endif endfunction function IteT takes handle h returns itemtype local itemtype i if false then return i else return h endif endfunction function TexT takes handle h returns texttag local texttag t if false then return t else return h endif endfunction function AttT takes handle h returns attacktype local attacktype a if false then return a else return h endif endfunction function DamT takes handle h returns damagetype local damagetype d if false then return d else return h endif endfunction function WeaT takes handle h returns weapontype local weapontype w if false then return w else return h endif endfunction function SouT takes handle h returns soundtype local soundtype s if false then return s else return h endif endfunction function Lig takes handle h returns lightning local lightning l if false then return l else return h endif endfunction function PatT takes handle h returns pathingtype local pathingtype p if false then return p else return h endif endfunction function Ima takes handle h returns image local image i if false then return i else return h endif endfunction function UbeS takes handle h returns ubersplat local ubersplat u if false then return u else return h endif endfunction function HasT takes handle h returns hashtable local hashtable ha if false then return ha else return h endif endfunction endlibrary 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 |
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 |
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 | ||
Quote:
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 edit: Quote:
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 | |
Quote:
Isn't that possible with just plain ifs? Such as: 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 |
booleans are not necessarily 0 or 1. |
| 09-12-2009, 10:04 PM | #7 |
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 |
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 |
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 |
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 | |
Quote:
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 |
So, uh... yeah. |
| 09-13-2009, 01:32 AM | #13 | ||
Quote:
edit: Quote:
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 |
By the way PJass disallow null return syntax which is a good thing but unfortuantely doesn't catch return bug forms:: 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 |
null == false 0 == null == false without typecast.... |
