HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

H2I wtf????

08-06-2008, 07:33 PM#1
d07.RiV
Maybe its a well known problem but why does
Collapse JASS:
  local location l1 = Location (0, 0)
  local location l2 = Location (0, 0)
  call BJDebugMsg (I2S (H2I (l1) - H2I (l2)))
Print out some weird number (its close to 0x80000000 but it changes by 2 each time I run this).
08-06-2008, 08:15 PM#2
Anitarf
Have you tried l2 - l1?
08-06-2008, 08:22 PM#3
d07.RiV
Tried now. Also tried some other stuff, it works awfully:
Code:
2 + H2I (l1) = 2
2 - H2I (l1) = -<rubbish>
H2I (l1) - H2I (l2) == H2I (l2) - H2I (l2)
H2I (l1) + H2I (l1) == H2I (l1) + H2I (l2) == 0
H2I (l1) + 2 works correctly
I think I need to find where game.dll does this stuff ><
08-06-2008, 08:23 PM#4
Captain Griffen
That's the whole 'don't use two return bugs on a line' thing. It causes JASS to go crazy and forget how to do maths.

This meanwhile works fine:

Collapse JASS:
function Trig_Test_Actions takes nothing returns nothing
  local location l1 = Location (0, 0)
  local location l2 = Location (0, 0)
  local integer i1 = H2I(l1)
  local integer i2 = H2I(l2)
  call BJDebugMsg(I2S(i1 - i2))
endfunction
08-06-2008, 10:05 PM#5
d07.RiV
Er I don't have WE at the moment, but I thought I tried it too and it had the same effect (well I didn't use 2 integer variables but instead local integer i = H2I (l1) and set i = i - H2I (l2)
08-06-2008, 11:12 PM#6
Captain Griffen
Without setting to variables, the result was messed up. Setting both to variables, the result wasn't.
08-07-2008, 01:48 AM#7
DioD
there is thread with information about it somewhere.
08-07-2008, 12:42 PM#8
Strilanc
The values returned from return-bug functions almost have the correct type. Sometimes you need to store the return value in a variable before it can be used.

For example: http://wc3campaigns.net/showthread.php?t=99903