| 08-06-2007, 04:58 AM | #1 |
I know you guys havent had enough of them from me so heres another one... say you have a struct JASS:struct holycondata unit u unit target integer count = 0 endstruct is it necessary (preferable) to have an ondestroy method like 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 |
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 |
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 |
or just clean it up.. saves you code space! |
| 08-06-2007, 09:05 AM | #5 |
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 |
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 |
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 |
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 |
onDestroy is good if u need to destroy some struct that belongs to destroying struct. |
| 08-06-2007, 01:17 PM | #10 | |
Quote:
|
| 08-06-2007, 09:35 PM | #11 |
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 |
