| 04-28-2006, 04:07 AM | #1 |
Is there a disadvantage to using large arrays and not using up all the space? For example, would it make any significant difference between a size 10 array filled up completely or a size 1000 array filled with only 10 values? Would this cause lag in any way? It seems that it would (or JASS wouldn't have array sizes), but I need to ask for my project. Also, if it does make a significant (key word there), is there an alternative (besides GameCache) to storing large amounts of data with no approximation of how much data needs to be stored? In other words, is there another way to store an unknown amount of data? |
| 04-28-2006, 05:16 AM | #2 |
I'm probably completely wrong (its 1:00 A.M here ) but I was under the impression that all arrays in World Editor work like arraylists. I remember from a test earlier that (using GUI as an example) I could set the array size of an int to 10 but put a value in index 12. I might just be "mis-remembering" though... |
| 04-28-2006, 05:20 AM | #3 |
All arrays in jass are 8192 elements long. The first element is 0 and the last is 8191. The size in the variable editor is how many elements it initializes. I believe you can rely on the default initialization to be 0 and to set all sizes to 1 if 0 is what you want. In general I recommend setting all sizes to 1 and manually initializing (if it's even necessary) so that you have precise control over the thread-hasn't-slept-suicide-limit. I don't understand the second part of your question. You can use strings to store and work with data, but if you do a lot of manipulation you will leak a bunch. The game cache is quite lovely. |
| 04-28-2006, 06:18 AM | #4 |
not quite. Try this it works local integer array i set i[8192]=5 call BJDebugMsg(I2S(i[8192])) is indded valid. You can actually assign them to any location, but there can only be 8192 elements. |
| 04-28-2006, 07:51 AM | #5 |
If for example you use a variable timer array or group, this is what it does in the initialization: JASS:local integer i = 0 loop exitwhen i > [max array size you put] set udg_GroupArray[i] = CreateGroup() // or on that note, CreateTimer() for timers set i=i+1 endloop |
| 04-28-2006, 08:40 AM | #6 |
Maybe that was the case in an older version? Here's my test: JASS:function Trig_test_Actions takes nothing returns nothing local integer array x call TriggerSleepAction(0.) call BJDebugMsg(I2S(x[8192])) set x[8192] = 1 call BJDebugMsg(I2S(x[8192])) endfunction |
| 04-29-2006, 09:18 PM | #7 |
Thanks, but after posting I realized that the array size (not counting the 8192 limit) is only in the GUI. I've never really worked with arrays in JASS, so that's why I got confused. |
| 04-29-2006, 09:20 PM | #8 |
The size is not there in jass as in you can easily put a higher value there and it will save without errors and everything. It just won't work when the script runs. |
| 04-29-2006, 09:28 PM | #9 | |
Quote:
Is there some way to make a global array with an infinite size? Because I have no clue how big the array is going to need to be on my map (it will vary every time you play). |
| 04-29-2006, 09:40 PM | #10 |
No. If you need something like that, I'd recommend using a gamecache. |
| 04-29-2006, 10:26 PM | #11 | |
Quote:
Thanks for the replies. However, my question was no quite answered: if I were to use a huge array, would it lag if it were too big? |
| 04-29-2006, 10:29 PM | #12 |
GameCache works perfect in multiplayer, unless you want to save/load to/from it. If you just want to save data there during the game, like in a normal array, gamecache will work perfect. |
| 04-29-2006, 10:30 PM | #13 | |
Quote:
|
| 04-29-2006, 10:31 PM | #14 |
Well, it works fine during the course of a single map but you can't transfer data from one map to the next through B.Net. |
| 04-29-2006, 10:35 PM | #15 | |
Quote:
Rep+ to Blade and paidan. |
