HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Couple of quick JASS questions

04-02-2004, 03:55 AM#1
Narwanza
First off, what is the max integral value that an array data can be called from. Or in other words, what is the max array index?

Second off, what is the code parameter taken by the TimerStart() native used for?

Quote:

native TimerStart(timer whichTimer, real timeout, boolean periodic, code handlerFunc)returns nothing
04-02-2004, 09:49 AM#2
AIAndy
The max array index is 8192 (or slightly more or less, there is a constant for that in common.j).
If you pass a function to that code parameter, then that function will be called when the timer expires.
04-02-2004, 10:09 AM#3
Cubasis
Oh, and, while the maximum element-count is 8192, I think only the integer range limits the index in it you can put it to.

So you might have MyArray[821000-829192] all up taken if you'd prefer for some wierd reason. Or whatever combination of sizes, as long as you don't use more than 8192 elements in the end.
04-02-2004, 07:03 PM#4
PEON1577
Would someone please tell me why in JASS would someone want to have >8k entities in a single array? I can't see the information that an array can only hold up to 8192 entrys as anything more than trivia, someone please tell me differently.

Thanks!
04-02-2004, 10:07 PM#5
AIAndy
If you emulate a multi dimensional array on it, then it is not hard to fill up that many array slots.
04-02-2004, 10:48 PM#6
Narwanza
Or, in my case, you are using the handle pointers of generated triggers to store data in global arrays defined in the blizzard.j and I have to shrink the integers because the actual handle pointer is larger than arrays can handle, so I needed to know how far to shrink them.
04-03-2004, 12:36 AM#7
Cubasis
Narwanza....

Read my thread.... :) You should be able to put something in any index of a array except a negative one. The over-all COUNT of "used" indexes can just not be more than 8192.

Cubasis
04-03-2004, 04:22 AM#8
Narwanza
No Cubasis, I would have to disagree there. You try calling an array value stored in an array with an index pointer of a handle index pointer. It will return 0 whatever you try and do. Arrays have their limits, and they fall short of Warcrafts limits. Here run this function.

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

function Test takes nothing returns nothing
    local unit u = CreateUnitAtLoc(Player(0),'hfoo',GetRectCenter(GetEntireMapRect()),270)
    local integer temp = H2I(u)
    set bj_ghoul[temp] = u
    call DisplayTextToForce(GetPlayersAll(),GetUnitName(bj_ghoul[temp]))
endfunction

You may be surprised when it displays nothing to you, it is because the handle pointer for the unit is larger than the array indexes are able to handle.
04-03-2004, 11:08 AM#9
weaaddar
Why in gods name would you want to store units by there handle number?
If you really have to do it I suggest using gamecache.
I.e.
StoreInteger(myCache,"units",I2S(H2I(MyUnit)),H2I(MyUnit) )
This would store a unit in the gamecache emulated array.
04-03-2004, 12:51 PM#10
Cubasis
woah, that's wierd,

Didn't know that, for some reason I had imagined that with the array system being dynamic, that it could only not have more total indexes taken than 8192. But you're true. It can't store 1 in element 8192, just 8191.

Anyways, thanks for prooving me wrong.

Cubasis
04-03-2004, 01:39 PM#11
Narwanza
It was finally me that proved you wrong instead of the other way around. Yay! j/k. Weaaddar, that is what I eventually did, but I was using this as a temporary solution with a periodic timer event. What I did to shrink the integers smaller was
Code:
local integer temp = (ModuloInteger(H2I(Timer),2854) + 15)
but then I went the gamecache way just this morning because it is more efficient.
04-04-2004, 12:56 PM#12
jmoritz
And also because that code with modulo is bugged :)