| 07-05-2008, 12:09 PM | #1 | |
Is it possible to pass a unit to gamecache? I was looking at CSSafeCache yesterday, and couldn't find anything relating to attaching handles (and, more specifically, units). Can you only pass non-handle types to cache? And yes, I do know I can use a struct, and so on, so forth, but I just want to pass a single unit, and I don't want to use a struct unless it's absolutely necessary. So, is there any way at all (that's safe to use) of passing a unit directly to gamecache, without a struct, and retrieving it from another function? And yes, I know there are alternatives to gamecache (which may/may not be better than GC) but (1) I want to mess around with various ways of passing data between functions, just for the hell of it, and (2) Quote:
|
| 07-05-2008, 12:23 PM | #2 |
The only way to pass a unit to gamecache is to use Blizzard's return bugs Unit to Integer:function H2I takes handle h returns integer return h return 0 endfunction Integer to Unit:function I2U takes handle h returns integer return 0 return null endfunction But this is not advisable since there are many problems concerning Integer to Handle typecasting. Instead, use structs, which return an integer. |
| 07-05-2008, 12:28 PM | #3 |
I know that I2H is dangerous :P So, there is no safe way to pass a unit, or any other handle for that matter, to cache without a struct? |
| 07-05-2008, 12:37 PM | #4 |
Correct. GC can only store basic types (integer, real, string). |
| 07-05-2008, 12:37 PM | #5 |
I don't know of any methods. There is a StoreUnit function but it does not work like the others. |
| 07-05-2008, 12:40 PM | #6 | |
Quote:
Don't you mean boolean, not handle? Well, thanks for the info. Time to mess around and see what I get :) |
| 07-05-2008, 02:37 PM | #7 |
Yeah, that was a typo, I'll edit it out before I confuse anyone else. |
| 07-05-2008, 04:36 PM | #8 | |
Quote:
|
| 07-06-2008, 03:36 PM | #9 |
so when you call RestoreUnit() it creates an exact copy of the unit you stored? It would be good if blizzard adds handle support for gamecache. |
