| 07-31-2004, 03:49 PM | #1 |
I bet somebody would like to store values of a handle (unit, trig, etc) by gamecache with return bug. But I found that it's unsafe. For example, if unit A's pointer is 12345678. When it dies, it will be removed when its corpse faded. Then 12345678 refers to nothing. But when a new object is created, it will use the empty pointer number again. So maybe a new-created unit(or trig, timer, location, or whatever) will have the pointer 12345678. And as a result, if you store some value, and uses the unit's pointer as the key. When you use the same way to load the value of unit B, you'll load unit A's, not empty value. :< It's unsafe isn't it? Does someone have an idea to solve this problem? |
| 07-31-2004, 04:04 PM | #2 |
remove the refference when the unit dies |
| 08-01-2004, 12:13 AM | #3 | |
Quote:
I don't think it always work, for example, what if the unit can be revived?? |
| 08-01-2004, 10:30 PM | #4 | |
Quote:
Set corpse stay to 75 seconds On Unit Death: Wait 70 Seconds If Unit Still Dead - then - remove corpse, reset cache data That way you get 70 seconds of corpse stay with the corpse removed and the data removed at the same time. If the unit comes back, no big deal because it handles that. The only thing it DOESNT handle would be if the unit comes alive again and then dies again after 69 seconds, it would be removed instantly. This can be fixed, but it is more complicated than I care to explain |
| 08-02-2004, 04:10 PM | #5 | |
Quote:
Are you sure that it reuses pointers. I think it just keeps going upwards untill it comes up to a limit, where the emergency garbage collection thingy kicks off, and then it starts reusing old pointers. But if this is really a concern, you can use this quick fix that should work: Code:
function ReferenceHandle takes handle h returns nothing local handle ref = h endfunction If you call this function with a handle, it "should" never be re-used, if our theories are correct. But please note that this is only a concern if you're a vivid leak-fighter and allways null your local handles. ~Cubasis |
| 08-02-2004, 04:48 PM | #6 |
The likely hood of it happening is low. If you worry then put controlls in the situation to make it more managable. |
| 08-03-2004, 09:23 PM | #7 |
For units, you can just wait till their maximum life is 0 |
| 08-04-2004, 10:36 AM | #8 | ||
Quote:
Yes I am sure. You can test for yourself. Quote:
|
| 08-04-2004, 08:29 PM | #9 | |
Quote:
|
