| 05-10-2008, 01:33 AM | #1 |
How do you destroy/remove stuff that you are passing through a struct? would this work? JASS:struct a group g static method create takes group g returns a local a dat = a.allocate() set dat.g = g return dat endmethod endstruct function qwe takes nothing returns boolean local a dat = TT_GetData() //Cohadar's //stuff call DestroyGroup(dat.g) call dat.destroy() return true endfunction function asd takes nothing returns nothing local group g = CreateGroup() call TT_Start(function qwe, a.create(g)) //Cohadar's set g = null endfunction |
| 05-10-2008, 01:41 AM | #2 |
Create an onDestroy method which will do the cleaning of the components of your struct. In your example: JASS:struct a group g static method create takes group g returns a local a dat = a.allocate() set dat.g = g return dat endmethod method onDestroy takes nothing returns nothing call GroupClear(.g) endmethod endstruct ... function qwe takes nothing returns boolean local a dat = TT_GetData() //Cohadar's //stuff //call DestroyGroup(dat.g) <= not needed anymore, dat.destroy() will do now the stuff for you :) call dat.destroy() return true endfunction |
| 05-10-2008, 01:42 AM | #3 |
can't you test it yourself? A good way is to use onDestroy, but that one works as well. |
| 05-10-2008, 03:56 AM | #4 |
In case you're confused, Moyack means to say: JASS:method onDestroy takes nothing returns nothing call DestroyGroup(.g) endmethod |
