HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Game Cache

04-14-2005, 01:09 AM#1
Zandose
Could someone comfirm that I'm using the game cache trigger right?

Game Cache - Store Value as Label of Category in (Last created game cache)

Code:
Game Cache - Store [b]1.00[/b] as [b]size[/b] of [b]real[/b] in ([b]Last created game cache[/b])
Set Real_i = (Load [b]size[/b] of [b]real[/b] from ([b]Last created game cache[/b]))
04-14-2005, 09:22 PM#2
TheGreatCheese
I don't know if you just didn't post it ir u don't have them in your triggers, but u need to have a create game cache before those and a save game cache after them.... That would be the only obvious thing i could think of, again idk if u have them but just didn't post them....
04-14-2005, 09:34 PM#3
Zandose
I do create a game cache but I don't save it because the map is going to be on b.net. I'm just using game cache instead of triggers for faster gameplay and larger storage of variables.
04-14-2005, 10:20 PM#4
Raptor--
personally i use this for gamecache related

Code:
//##Start                                                                                         ##
//##Handle Variables                                                                              ##
//==================================================================================================
function H2I takes handle h returns integer
    return h
    return 0
endfunction

//==================================================================================================
function LocalVars takes nothing returns gamecache
    return InitGameCache("jasslocalvars.w3v")
endfunction

//==================================================================================================
//DISREGARD
function SetInvInt takes string subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(), subject,name)
    else
        call StoreInteger(LocalVars(), subject, name, value)
    endif
endfunction

//==================================================================================================
function SetInvHandle takes string subject, string name, handle value returns nothing
    call SetInvInt( subject, name, H2I(value) )
endfunction

//==================================================================================================
function SetHandleBoolean takes handle subject, string name,boolean value returns nothing
    if (not value) then
        call FlushStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

//==================================================================================================
function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

//==================================================================================================
function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

//==================================================================================================
function SetHandleString takes handle subject,string name,string value returns nothing
    if value=="" then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

//==================================================================================================
function SetHandleHandle takes handle subject, string name, handle value returns nothing
    call SetHandleInt( subject, name, H2I(value) )
endfunction

//==================================================================================================
function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

//==================================================================================================
function GetInvHandle takes string subject, string name returns handle
    return GetStoredInteger(LocalVars(), subject, name)
    return null
endfunction

//==================================================================================================
function GetHandleBoolean takes handle subject,string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction

//==================================================================================================
function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction

//==================================================================================================
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction

//==================================================================================================
function GetHandleString takes handle subject,string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

//==================================================================================================
function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
//##End                                                                                           ##

though if you're just using it to store basic variables i don't see why you don't just use built in variable features... i mean, personally i think gamecache is mostly useful for having 'object-tagged' variables so to speak
04-14-2005, 10:39 PM#5
Zandose
Variables become a problem when you use variable array's over 8000 or something. And I use many of these. 8000x6 or more and it's going to get bigger.

Raptor how does that trigger work?
04-14-2005, 10:44 PM#6
Jackyquah
Quote:
Originally Posted by Zandose
I do create a game cache but I don't save it because the map is going to be on b.net. I'm just using game cache instead of triggers for faster gameplay and larger storage of variables.


perhaps I am wrong but store and load integer on gamecache is slower than set integer variable, I think, or Is it faster ?
04-14-2005, 11:38 PM#7
Zandose
Anyways I can't use variables because it causes problems with the amount/size that I'm using.
04-15-2005, 02:55 AM#8
Raptor--
i did a test, seems like 6520 is the max an integer array will go

why do u need 8000x6 integers anyways?
04-15-2005, 02:59 AM#9
Raptor--
and you use it like any other function, ex
call SetHandleInt(handle subject, string name, integer value) where a handle is basically anything, destructable, unit, trigger, timer, anything really
the stuff i put up is mostly for, like i said, 'tagging' variables to objects

retrieved by set X = GetHandleInt(handle subject, string name)
04-15-2005, 04:03 AM#10
Zandose
I'm using the game cache to store information about doodads. Location, size, type, etc....
04-15-2005, 07:54 AM#11
Raptor--
i still can't imagine why you have to know everything about (i assume u mean destructibles)
04-15-2005, 12:25 PM#12
Zandose
Ok, I have a map with 12 different zones and each zone has its own land (tiles, hills, doodads). So i need to store each land deformation and doodad and its place, size, etc... After a while it gets pretty big.
04-15-2005, 03:00 PM#13
Guest
I'm new to the game cache. I was looking into making a trigger multi instance. Is this why i'd use a game cache. If so, any examples on one? I basically need another function to use a local variable from the calling function.
04-16-2005, 02:56 AM#14
Raptor--
Quote:
Originally Posted by iooin
I'm new to the game cache. I was looking into making a trigger multi instance. Is this why i'd use a game cache. If so, any examples on one? I basically need another function to use a local variable from the calling function.

a trigger can be multi-instanced just using local variables
04-16-2005, 06:52 AM#15
Anitarf
Quote:
Originally Posted by Raptor--
a trigger can be multi-instanced just using local variables
Or, you can simulate locals by storing things to gamecache using the handle of some local object, like "summoned unit", as a label or category? Am I right? Am I?

Forgive my enthusiasm, I'm just exploring the possibilities of gamecache and locals and am a bit excited. I was wondering, are there any memory leaks associated with the use of locals and gamecache, I mean other than the usual "point or group objects staying in memory after you use them"? I mean, are there any performance issues with using these things extensively, like for whole map-wide systems, operating with hundreds of values on periodic events, stuff like that?