gamecaches and strings

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

gamecaches and strings

Post by storyyeller »

How do gamecaches work? Can they be used for synchronization? How do you use them?


Also, what characters are allowed in strings? Is there anyway to get unprintable characters? Also, how do escape sequences behave? Are they automatically replaced when the string is evaluated or what?
Would something like "\" + "n" produce a newline? Is there any way to make escape sequences not work?
If you had something like "\n\n\n\n\n\n\n\n\n\n\n\n" etc. with 500 \s and ns, would that be considered a 500 character string or a 1000 character string?
User avatar
Ozzapoo
The Flying Cow!
Posts: 2197
Joined: November 2nd, 2007, 10:34 pm
Location: Melbourne

Re: gamecaches and strings

Post by Ozzapoo »

They're pretty much just like a group of variables with strings as names. What do you mean? StoreInteger, StoreReal, etc. GetStoredInteger, GetStoredReal, etc. All. Why do you need them? Just like any normal string. Automatically, I think. Just making a new line in the editor will do. Use \\? '\n' is not a new line, so 1000.

Why can't you try any of this yourself? It's quicker.
Visit Ozzapoo.net, my blog and the home of AutoCP and Cheatpack Detector!
AutoCP3 now available for free!
User avatar
Senethior459
Forum Staff
Posts: 2619
Joined: June 2nd, 2007, 6:53 pm
Title: I Just Lost the Game

Re: gamecaches and strings

Post by Senethior459 »

Ozzapoo wrote:Why can't you try any of this yourself? It's quicker.

He got a reply in 7 minutes, so quicker is debatable!

storyyeller: I'm pretty sure WC3 allows Unicode/UTF-8. I don't know the answers to most of the rest of your questions, but Ozzapoo seems to have covered most of them.
My Warcraft III Tool Collection
If you want to chat/game with me:
Blizzard: Senethior459#1962
Discord: Kyle#7409
Steam: Spacekidkyle
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: gamecaches and strings

Post by storyyeller »

So there's nothing special about gamecaches synchronization wise? I remember seeing someone claim they could detect who the host was using a gamecache.
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: gamecaches and strings

Post by Risen »

Yea, that syncs an integer to all the players and usually the one receiving the sync call first is usually the host.

I wonder if there's a way to count the blocks it takes to store the integer and return it.. to measure out your real delay?
Image
Wanna learn to hack maps? --> Guide
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: gamecaches and strings

Post by storyyeller »

So do you know of anywhere I could go that would explain that stuff in more detail? When I tried googling it before, all I could find was stuff about single player campaigns.
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: gamecaches and strings

Post by Risen »

Hmm.. Not sure, My best bet would be get an unprotected vJass map and take a look inside of it. An example of getting a host would be..
Spoiler:

Code: Select all

globals
    unit array syncUnits
endglobals

    //************
    //* Host
    //* ¯¯¯¯
    //* When gamecache is told to sync a value, it will usually sync the value of the host. Using this, the host can be
    //* found. To increase the probability of findHost working, the sync part is repeated and the results aggregated.
    //*
    static s_player  host = -1      // Points to the host (after the first second or so after map init).
    static gamecache hostCache      // Gamecache used to find host with.
    // method onHost takes nothing returns nothing                  // Called when a player takes over as host (after a host has left).
    static method findHost takes nothing returns nothing            // Finds host and updates the static host variable.
        local s_player      syncedPlayer
        local s_player      tempPlayer   = 0
        local integer array count

        loop
           exitwhen tempPlayer == 12
           set tempPlayer:count = 0
           set tempPlayer = tempPlayer + 1
        endloop

        loop
           exitwhen tempPlayer == 0

           call StoreInteger(.hostCache, "map", "host", .localPlayer+1)

           call TriggerSyncStart()
           call SyncStoredInteger(.hostCache, "map", "host")
           call TriggerSyncReady()

           set syncedPlayer = GetStoredInteger(.hostCache, "map", "host")-1

           set syncedPlayer:count = syncedPlayer:count + 1

           set tempPlayer = tempPlayer - 1
        endloop

        set syncedPlayer = 0
        loop
           exitwhen tempPlayer == 12

           if syncedPlayer:count < tempPlayer:count then
              set syncedPlayer = tempPlayer
           endif

           set tempPlayer = tempPlayer + 1
        endloop

        if .host != syncedPlayer then
            call syncedPlayer.onHost()
            set .host = syncedPlayer
        endif
    endmethod
    static method hostInit_Delayed takes nothing returns nothing    // Finds host just after map init.
        call DestroyTrigger(GetTriggeringTrigger())
       
        call .findHost()
    endmethod
    static method hostInit takes nothing returns nothing            // Initialises gamecache.
        local trigger t = CreateTrigger()

        set .hostCache = InitGameCache("host.cache")
        call StoreInteger(.hostCache, "missionKey", "key", 1)

        call TriggerRegisterTimerEvent(t, 0, false)
        call TriggerAddAction(t, function s_player.hostInit_Delayed)

        set t = null
    endmethod
    //*
    //***********************************************************************************************************************
Image
Wanna learn to hack maps? --> Guide
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: gamecaches and strings

Post by storyyeller »

Is it possible to get any player of your choice to respond instead of the host? For example, would something like this work? Do I need to add a delay before calling GetStoredInteger?

Also, what are missionKey and key?

Code: Select all

globals
   gamecache mycache
endglobals
function myfunction takes nothing returns nothing
   local integer i
   set i = GetPlayerId(GetLocalPlayer())
   if GetLocalPlayer() == Player(7) then
      call StoreInteger(mycache,"mk","k",i)
   endif
   set i = GetStoredInteger(mycache, "mk", "k")
   //we now have player 8's value for i, right?
endfunction
User avatar
Risen
Forum Staff
Posts: 811
Joined: January 1st, 2008, 12:58 am

Re: gamecaches and strings

Post by Risen »

Should be able to, Missionkey is just a string.

Best way is to test it, Use a BJDebugMsg( I2S( GetStoredInteger....)
Image
Wanna learn to hack maps? --> Guide
storyyeller
Senior Member
Posts: 178
Joined: February 15th, 2009, 9:08 pm

Re: gamecaches and strings

Post by storyyeller »

How can I test local and synchronization code using only one computer?