• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Mass Data Sync?

Status
Not open for further replies.
Level 31
Joined
Jul 10, 2007
Messages
6,306
I made an interesting test script... I'm wondering what would happen if it were run : )

JASS:
struct tester extends array
    private static string array playing
    private static gamecache gc
    
    private static method test takes nothing returns nothing
        local integer i = 11
        
        set gc = InitGameCache("hello")
        set playing[GetPlayerId(GetLocalPlayer())] = "t"
        call StoreString(tester.syncer, "data", I2S(GetPlayerId(GetLocalPlayer())), "t")
        
        call TriggerSyncStart()
        call SyncStoredString(tester.syncer, "data", I2S(GetPlayerId(GetLocalPlayer())))
        call TriggerSyncReady()
        
        loop
            if (playing[i] != null) then
                call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetPlayerName(Player(i)) + " is playing")
            endif
            exitwhen i == 0
            set i = i - 1
        endloop
    endmethod
    
    private static method onInit takes nothing returns nothing
        call TimerStart(CreateTimer(), 0, false, function thistype.test)
    endmethod
endstruct

Will all of the syncs run or will it stop when it gets a sync?

o-o


I'd test it myself, but I can't test it solo and I don't have any friends online to test with, so I'm stuck ^_^. Nobody ever joins a game hosted for testing something anymore.
 
JASS:
struct tester extends array
    private static method onInit takes nothing returns nothing
        local integer i = 11
        local boolean array playing
        set playing[GetPlayerId(GetLocalPlayer())] = true
        
        call TriggerSleepAction(0.)
        
        loop
            if (playing[i]) then
                call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, GetPlayerName(Player(i)) + " is playing")
            endif
            exitwhen i == 0
            set i = i - 1
        endloop
    endmethod
endstruct

The above works because struct initialization is done via ExecuteFunc, so each has its own thread.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I actually highly doubt my method would work. I believe it would show for each player that only one player is playing. But I am not sure what you are trying to accomplish by syncing something that has nothing to do with the variable you set, unless somehow you are taking advantage of that "strings get stored to a table" nonsense that blizzard STUPIDLY implemented.
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
It's probably not worth your time examining how blizzard sync natives work; I doubt they even work as they were originally intended, the only useful trait about them is tracking the host-player and it doesn't even work 100% of the time.

A real sync native should sync the values of all the players to that of the host, not simply the first person that is pinged. That doesn't even make any sense for a sync native it's too random. Your time is best spent in more established areas of the World Editor.
 
Status
Not open for further replies.
Top