| 03-28-2008, 05:27 PM | #1 |
Even though I destroy the struct using: set structname.arrayname[0] = 1 call structname.destroy() I still to get structname.arrayname[0] == 1 How can efficiently destroy the struct so any values it might hold will be reset/destroyed? Another question: Is there a variable that holds the number of structs currently in use? And how can I view it for debugging purposes? |
| 03-28-2008, 05:38 PM | #2 |
You can do it in an onDestroy method. However, I really don't see any point, since you SHOULD reset everything on the creation function, so it would be pointless. |
| 03-28-2008, 05:51 PM | #3 |
You have to manually zero any elements you want zeroed in the onDestroy method. It works that way because it's faster (you shouldn't be accessing destroyed structs anyways). If you want an allocation count, add 1 to a global variable in the create method and subtract 1 in the onDestroy method. |
| 03-28-2008, 06:06 PM | #4 |
Thanks for your responses [+rep]. I didn't know that manually reseting the values was the normal way doing it so thanks for that! The problem came when I created a local struct function funca takes nothing returns nothing local structname a = structname.create() ... endfunction and later used .destroy() on it. When funca was called again the 'local' struct still had all the values it had been assigned in the previous function call. |
