• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Unit-Group Fun

Status
Not open for further replies.
Custom script: if udg_kamegroup99[udg_kameindex99] == null then
Custom script: set udg_kamegroup99[udg_kameindex99] = CreateGroup()
Custom script: endif

Because unit-groups are bugged in GUI, wouldn't those lines of JASS fix unit-group arrays? For some reason it is bugging and also can't be destroyed. I usually just remove all data from one with loop in it then loop it to index.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
you can destroy group with call DestroyGroup(groupToDestroy)

and yes that is the only way of fixing the GUI's problem with Unit Group, if you dont want to init it to like 8191 size, which I dont recommend, because that really heaviers the Main thread running when map starts to load all Blizzard's globals, call Init Functions and stuff. You may get to point that some Init Functions wont even get called
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
In that spell code you are using

Custom script: if udg_kamegroup99[udg_kameloop99] == null then
Custom script: set udg_kamegroup99[udg_kameloop99] = CreateGroup()
Custom script: endif

array index variable is wrong.
 
I didn't read the entire thread, but make sure you assign the global to null after you destroy it. For example:

  • Custom script: call DestroyGroup(udg_kamegroup99[udg_kameindex99])
  • Custom script: set udg_kamegroup99[udg_kameindex99] = null
If I recall correctly, destroying a global doesn't mean that it will equate with null. It'll just point to a destroyed object (which isn't the same as "null"). Here is an example:
JASS:
call DestroyGroup(udg_kamegroup99[udg_kameindex99])
if udg_kamegroup99[udg_kameindex99] == null then
    call BJDebugMsg("Null")
else
    call BJDebugMsg("Not null")
endif
If memory serves me correctly, then this will display "not null".
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
PurgeandFire is right with the assumption that the reference still exists, therefore it will print out: "not null".

Group arrays can be destroyed like normal groups. For instance:
JASS:
set TestGroup[1] = CreateGroup()
call DestroyGroup(TestGroup[1])
set TestGroup[1] = null
 
Here is the issue:
  • Set kamegroup99[kameloop99] = kamegroup99[kameindex99]
  • Custom script: call DestroyGroup(udg_kamegroup99[udg_kameindex99])
  • Custom script: set udg_kamegroup99[udg_kameindex99] = null
Let "current" represent "kameloop99", "last" represent "kameindex99", "G" represent kamegroup99

You first set:
G[current] = G[last]

This is necessary, but you are basically abandoning G[current]. The next line destroys G[last]. But G[last] was never changed! It still points to the same group it did before. It doesn't point to G[current]'s old group just because you set G[current] to G[last]. They'll both end up pointing to that group. Therefore, you are destroying the "last" group. That causes issues. Here is the fixed code:
  • Custom script: call DestroyGroup(udg_kamegroup99[udg_kameloop99])
  • Set kamegroup99[kameloop99] = kamegroup99[kameindex99]
  • Custom script: set udg_kamegroup99[udg_kameindex99] = null
That will be the proper recycling (basically, I just moved the line upward and changed kameindex99 to kameloop99), and unless I'm mistaken, it should work.
 
Status
Not open for further replies.
Top