HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Array sizes

03-04-2004, 04:11 AM#1
Narwanza
From everything that I have been taught about programming from my brothers and you guys is that an array really doesn't need a size assigned to it. Why did blizzard add a GUI array size thing? I don't get it. Arrays still work properly if you leave the size at 1 (or whatever is default). When coding in JASS I never go local unit array size 100 them = GetUnitsWithinLocAll() because we all know that would give multiple compile errors. So, back to my original point, why did blizzard put this seemingly useless function into Warcraft?

[edit] another little JASS qeustion I had was: When strings get stored into the string thing that Warcraft generates with your map, when you delete the action that calls that string does that mean that that string is deleted? Because if that wasn't the case I would have a lot of extra strings just laying around taking up space.
03-04-2004, 05:59 AM#2
PitzerMike
The problem was that using uninitialized variables causes a thread crash. An example:

local integer array I
set I[0] = I[0] + 1
----> Thread Crash

Normally, when you only assign a value to that var there's no problem. Example:

local integer I
set I[0] = 1
----> Works of course

Blizzard changed it so array variables would be initialized for the specified range at map initialization eg.
set I[0] = 0

so set I[0] = I[0] + 1 won't cause a thread crash any more coz it's already got a value



Regarding the other question: Yes, strings are deleted from the wts file when there's no reference to them any more.
03-04-2004, 01:48 PM#3
Narwanza
Ohhh.... So they did do it for some stupid reason for the general public. I c now. Anyone know about the string question?
03-04-2004, 03:33 PM#4
AIAndy
Quote:
Originally Posted by Narwanza
Ohhh.... So they did do it for some stupid reason for the general public. I c now. Anyone know about the string question?
Actually the reason is not so stupid as it allows the usage of dialog arrays and similar stuff that needs initialization with a special native. That was not possible from GUI before that.
Note though that Blizzard did a pretty stupid thing there as this initialization is done in the main initialization thread and this thread is cancelled like any other thread when it runs too many statements. So if you set the array size very high, it causes the thread to be stopped before it reaches the InitTrig functions of all the triggers, so the triggers are not registered or initialized.
03-04-2004, 03:49 PM#5
Vexorian
Quote:
Originally Posted by AIAndy
Actually the reason is not so stupid as it allows the usage of dialog arrays and similar stuff that needs initialization with a special native. That was not possible from GUI before that.
Note though that Blizzard did a pretty stupid thing there as this initialization is done in the main initialization thread and this thread is cancelled like any other thread when it runs too many statements. So if you set the array size very high, it causes the thread to be stopped before it reaches the InitTrig functions of all the triggers, so the triggers are not registered or initialized.

It is good to know that
03-04-2004, 10:05 PM#6
Narwanza
Ahhh.... I take what I can do in JASS for granted then. I never even thought that I couldn't do this in GUI.
Code:
local group them = CreateGroup()
Now it makes sense why they have array sizes. Does anyone know about the string question I posed earlier though?
03-05-2004, 07:21 AM#7
Krakou
Quote:
Originally Posted by Narwanza
Does anyone know about the string question I posed earlier though?

..........

Quote:
Originally Posted by PitzerMike
Regarding the other question: Yes, strings are deleted from the wts file when there's no reference to them any more.
03-05-2004, 01:55 PM#8
Narwanza
Sorry my bad. This thread has served its purpose, could some mod delete it plz?
03-05-2004, 02:04 PM#9
AIAndy
I will definitely not delete this thread as it contains some useful information that should be available via the search function.