HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Store units in gamecache

03-09-2007, 12:38 PM#1
anXieTy
well, i tried to search for this problem, but i didnt get any pleasant results. So i just opened another thread going to bore you ^^

So, i have a problem, you can store integers, reals and so on in gamecache, but why cant i store units? i cant refer to "GetStoredUnit", this isnt marked as a function, so what shall i type instead?

or is there a trick?

i would like to thank everybody helping me,

anX
03-09-2007, 12:53 PM#2
Skater
You can use H2I and then u save this integer in the gamecache.
Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction
To get the unit u use I2Unit
Collapse JASS:
function I2Unit takes integer i returns unit
    return i
    return null
endfunction

e: Hey anx^^
03-09-2007, 12:57 PM#3
anXieTy
Code:
function I2Unit takes integer i returns unit
    return i
    return null
endfunction

Why I2Unit and not I2U?
03-09-2007, 12:59 PM#4
Skater
Hmm i dont know.
You can name your function also to "bla" or what ever you want.
03-09-2007, 01:00 PM#5
Blubb-Tec
because names are unimportant^^ no but as i told u, use handle vars! they do the same what you want, but take the work of you..
03-09-2007, 01:01 PM#6
Skater
Yeah or any other "ReturnCache".
03-09-2007, 01:06 PM#7
StockBreak
You must use the "Return Bug". There are a LOT of articles about this "bug" (look at this and this).
Basically you don't need to store a unit, but an integer which is a sort of "pointer" to that unit:
Collapse JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

Units (just like locations, groups, points etc...) are "handles" and, using the function above, you can obtain an integer which is a sort of a pointer to that handle.
To get your stored unit again you will need a function like I2Unit, converting your integer in your unit again.
It is better that you read the articles. I hope it helped. Cheers.
03-10-2007, 07:38 AM#8
botanic
Also however i dont recomend using the game cache if at all possible because it can cause problems with memory leaks...