HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Questions about CSSafeCache.

07-09-2008, 01:49 PM#1
the-thingy
1) Do you need to clear data from gamecache with CSSafeCache?

2) If so, how? I know there is the CleanAttachedVars but doesn't that clean EVERYTHING associated with the handle (even if it wasn't related to the data you wanted to clear)? Or does CleanAttachedVars have a different purpose

3) How exactly do you use CS Pairs? Would someone be able to post a small example of what they are used for, and how to use them?
07-09-2008, 02:24 PM#2
Vexorian
There is no reason to use cspairs, the following code replaces all of cspairs' functionality :
Collapse JASS:
struct cspair[16000]
    integer x
    integer y
endstruct

AttachInt / SetTableInt will flush the value automatically when you use a 0. It is better to do CleanAttachedVars when the handle dies though.
07-09-2008, 02:31 PM#3
Silvenon
Uhh, there is no CSSafeCache... Maybe you meant CSSafety? In that case you still have to clean the variables. CleanAttacedVars clears all the variables attached to a handle, but you can clean a single variable with attaching a null value of the attached variable. Example:

Collapse JASS:
AttachInt(t, "i", 1)
// ...
AttachInt(t, "i", 0)

or

Collapse JASS:
AttachHandle(t, "u", CreateUnit(...))
// ...
AttachHandle(t, "u", null)

etc.

CSSafety is used only for avoiding timer bugs (also, you don't have to null them).

Or maybe you meant SetCSData/GetCSData?
07-09-2008, 02:32 PM#4
Vexorian
Quote:
Uhh, there is no CSSafeCache...
There is.
07-09-2008, 02:43 PM#5
the-thingy
Quote:
AttachInt / SetTableInt will flush the value automatically when you use a 0. It is better to do CleanAttachedVars when the handle dies though.

So, I just have to do call AttachInt (myHandle, myKey, 0) when I'm finished with it? What about reals (I'm guessing 0 or 0.),strings (I'm guessing "") and booleans (haven't a clue)

Quote:
Uhh, there is no CSSafeCache...

Take a look at the Caster System, it's there :)

Collapse JASS:
AttachHandle(t, "u", CreateUnit(...))
// ...
AttachHandle(t, "u", null)

Isn't that potentially dangerous since you would have to do I2H to retrieve the unit?

EDIT: Just took a look at the code for booleans
Collapse JASS:
    function AttachBoolean takes handle h, string label, boolean x returns nothing
        if not x then
            call FlushStoredBoolean(cs_cache,I2S(CS_H2I(h)),label)
        else
            call StoreBoolean(cs_cache,I2S(CS_H2I(h)),label,x)
        endif
    endfunction

That confuses me. To flush it, I use the opposite value to what was stored i.e. store using true, flush using false?
07-09-2008, 03:18 PM#6
Vexorian
You shouldn't use AttachHandle.

To flush reals always use 0.0, to use booleans always use false. I think null or "" should work to flush strings.
07-09-2008, 03:32 PM#7
the-thingy
Quote:
to use booleans always use false

So, I have to do call AttachBoolean (myHandle, myKey, false) to store or to flush?
07-10-2008, 01:15 PM#8
Silvenon
Quote:
There is.

I searched in CSCache, but then it's obviously not there (maybe the search feature is broken). I don't want to bother you, but where/what exactly is it?
07-10-2008, 01:30 PM#9
the-thingy
CS v15.2 has it (not sure about any previous versions of CS though)