HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

ANOTHER Struct Question

08-06-2007, 04:58 AM#1
Beardo
I know you guys havent had enough of them from me so heres another one...

say you have a struct

Collapse JASS:
struct holycondata
unit u
unit target
integer count = 0
endstruct

is it necessary (preferable) to have an ondestroy method like

Collapse JASS:
method onDestroy takes nothing returns nothing
set .u = null
set .target = null
endmethod

or does vJASS just recycle the space?
08-06-2007, 05:28 AM#2
Ammorth
It will be recycled. I find onDestroy pointless cause its easy enough to clean them up before destroying the struct.
08-06-2007, 08:56 AM#3
The)TideHunter(
A onDestroy is good.

For example, if you know your gonna have an effect, a dummy unit and a lightning effect in your struct. Then use good practice and use the onDestroy method and clean up your effect, dummy and lightning.
08-06-2007, 08:59 AM#4
NightBreeze
or just clean it up.. saves you code space!
08-06-2007, 09:05 AM#5
The)TideHunter(
But isnt good practice. And if somebody reads over it (which they will most likely) it is always good to keep things clean. Bunching stuff up isnt good practice.
Its mildly acceptable in Jass as its slow, but onDestroy is definatly worth using in the case above.
08-06-2007, 09:11 AM#6
NightBreeze
I don't see how it's bunching stuff up, you're just nulling everything on the struct that's being destroyed. No need to read what's being done there, right?
08-06-2007, 09:48 AM#7
The)TideHunter(
Nulling? I'm destroying.
You dont null a variable in a struct thats pointing to an effect before destroying the effect.
You dont need to null structs at all, they get recycled, im talking about removing handles.
08-06-2007, 09:57 AM#8
NightBreeze
You're right, nulling wasn't the word I wanted to use. My point still stands though?

EDIT: nevermind this btw.. quite the worthless discussion :)
08-06-2007, 10:56 AM#9
MaD[Lion]
onDestroy is good if u need to destroy some struct that belongs to destroying struct.
08-06-2007, 01:17 PM#10
Vexorian
Quote:
Originally Posted by Ammorth
It will be recycled. I find onDestroy pointless cause its easy enough to clean them up before destroying the struct.
unless, you destroy the struct on many different places, or you are making it to be used by other people and the contents of the struct might change later...
08-06-2007, 09:35 PM#11
emjlr3
units(or handles in general) in a struct do not need to be nulled, as done above, correct?

i did not thing they did

however, things like effects or locations should be destroy/removed