System GetLatency

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Surely, it would just be tacked on the end (or start) of the Update function... or something.
I was wondering that it may slow down the function. :p
 

quraji

zap
Reaction score
144
Now, I need something explained to me.
a) How does getting the elapsed time of a timer arrive to getting latency? Timers' times aren't sync'd are they? If they are it seems pretty fast and we should start syncing data through timers..

b) Isn't measuring the gap between players on a timer that's been running for the whole game inaccurate? Won't the gap get larger as time goes on? That would suck..

c) I shouldn't do this after just waking up, I'm confusing myself.
 

quraji

zap
Reaction score
144
It does this:

Update:
1) On each computer, stores the time remaining on the timer to gamecache, with a different key for each player.
2) Syncs the gamecache value, whatever that means. I still haven't gotten a clear explanation as to how this operates/behaves.. sometimes I hear that it syncs they value according to what the "host" (fastest responding player) has, sometimes to whom ever calls it...I don't know.

Get Latency:
1) Subtracts the given player's gamecache value from the host's.

I don't see how this gives a latency value. Plus, I think there's an error in that recent code:
JASS:
        call FlushGameCache(InitGameCache("GetLatency"))
        set gc = InitGameCache("GetLatency")
        
        if HaveStoredInteger(gc,"Host","Id") then  // is this pointless or what?
            set HostId = GetStoredInteger(gc,"Host","Id")
        else
            set HostId = GetPlayerId(GetLocalPlayer())
            call StoreInteger(gc,"Host","Id",HostId)
            call SyncStoredInteger(gc,"Host","Id") // I'll assume that the value will be synced to whoever responds the fastest (presumably the host)
        endif
        
        set Host = Player(HostId) // should be "set Host = GetStoredInteger(gc, "Host", "Id")"?
 

saw792

Is known to say things. That is all.
Reaction score
280
@quraji

Normally, using the gamecache sync natives will do what you described, i.e. sync the value to the fastest responding player (which it seems can vary, but is usually the host). However, when the sync natives are called locally they will sync the value that the local player has to all other players. As one of the gamecache keys is different for each player it is effectively performing a local sync for every player in the game on a different location within the cache, which results in each individual player's value being distributed to all other players.

eg:
JASS:
local integer i = GetPlayerId(GetLocalPlayer())
call StoreInteger(gc, "blah", "bleh", i)
call SyncStoredInteger(gc, "blah", "bleh") //Will send the id of the host (usually) to all other players caches

//Result:
//GetStoredInteger(gc, "blah", "bleh") == 0 if red is the host
//...

local integer i = GetPlayerId(GetLocalPlayer())
call StoreInteger(gc, "blah", I2S(i), i)
call SyncStoredInteger(gc, "blah", I2S(i)) //Will send the id of every player to every other player

//Result:
//GetStoredInteger(gc, "blah", 0) == 0
//GetStoredInteger(gc, "blah", 1) == 1
//GetStoredInteger(gc, "blah", 2) == 2
//etc.
 

quraji

zap
Reaction score
144
@saw
That's what I suspected, thanks for clearing that up.

That still doesn't explain how this system is supposed to work :p
 

saw792

Is known to say things. That is all.
Reaction score
280
It's based on the theory that timer progress would be slightly offset from that of the host's due to net traffic, and thus by recording it locally you could then find the difference to find the latency. This means that while a timer may still be running on your local computer, a few ms earlier it may have expired on the host's computer. Or something...

Sounds plausible, right? :p
 

quraji

zap
Reaction score
144
It's based on the theory that timer progress would be slightly offset from that of the host's due to net traffic, and thus by recording it locally you could then find the difference to find the latency. This means that while a timer may still be running on your local computer, a few ms earlier it may have expired on the host's computer. Or something...

Sounds plausible, right? :p

Not to me, haha. That's why I'm waiting for Kingking or someone to say exactly what's going on because I just don't see it.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
It's based on the theory that timer progress would be slightly offset from that of the host's due to net traffic, and thus by recording it locally you could then find the difference to find the latency. This means that while a timer may still be running on your local computer, a few ms earlier it may have expired on the host's computer. Or something...

Sounds plausible, right? :p

It is something like that. :D

JASS:
call FlushGameCache(InitGameCache("GetLatency"))
        set gc = InitGameCache("GetLatency")
        
        if HaveStoredInteger(gc,"Host","Id") then  // Is there any host detected?
            set HostId = GetStoredInteger(gc,"Host","Id")//If there is, you are not the host.
        else
            set HostId = GetPlayerId(GetLocalPlayer()) //If no.. You are the host.
            call StoreInteger(gc,"Host","Id",HostId) //Save the value
            call SyncStoredInteger(gc,"Host","Id") // Sync the value to all players
        endif
        
        set Host = Player(HostId) // The is used to prevent desyncies
 

quraji

zap
Reaction score
144
Okay, I'm just going to flat-out say this will not get latency. Please refute me.
 

quraji

zap
Reaction score
144
:banghead: See the replay.

It will prove nothing, but I'll watch it anyways.

Edit: Watched it, numbers on a multiboard mean nothing to me when the concept still doesn't make sense. And I don't understand why you try to update so often both in the system itself and on the multiboard when gamecache syncing takes time. I thought it was odd that the value was always 375, 500 or 625. What's that mean?

Also, there should be more people in game..
 

Jesus4Lyf

Good Idea™
Reaction score
397
All he needs is a test with someone on lan, and someone in another country, and he can prove that it provides a measure of latency... what's in the replay, in that regard? Does it have in chat who is from where or something, and a clear demo of different latencies being returned for players who are further away?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
I thought it was odd that the value was always 375, 500 or 625. What's that mean?
That the action windows in wc3 bnet hosted games grows with 125ms each time. Eg, the delay on bnet is always (250+125*n) ms. The 250ms is a fixed amount and the reason why lan and some bot hosted games doesn't have the same delay.

The code works somewhat like this:
[ljass]call StoreReal(gc,"Test",Number,TimerGetRemaining(GameTimer))[/ljass]
Wc3 stores a value in the gamecache (duh)

[ljass]call SyncStoredReal(gc,"Test",Number)[/ljass]
The jass engine tells wc3 that it needs some synced network traffic. Based on your recent _ping_ wc3 decides on what action window this action should occur. Eg, 0, 1, 2, 3 ... windows in the future. Your computer sends the action packet to the host, along with a number telling it in what action window this should happen. The host forwards it to all players. When the players get the packet, they wait until the corresponding action window happens.
Since action windows only happens each (250+125*n) ms it's impossible to get another _latency_ than that, this is true for unit orders and the such too.
In this context, latency is not the same thing as ping. Latency is a discrete value only loosely coupled to the ping.
Now, I'm not really an expert on how exactly wc3 syncs actions between different players so there might be some error in here :p
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Interesting way to sync local datas :thup:

Read the last comments :
JASS:
private function Update takes nothing returns nothing
        local integer i = GetPlayerId(GetLocalPlayer())
        //Magic! Does not desync!
        call StoreReal(gc,&quot;Test&quot;,Number<i>,TimerGetRemaining(GameTimer))
        //Store the value of timer.
        call SyncStoredReal(gc,&quot;Test&quot;,Number<i>)
        //Sync the value to other players&#039; gamecache.
        // it happens only one time when all local datas are synchronised, and not X times where X == number of human players ?
        // it might be like that but i just want to be sure
        // call BJDebugMsg(&quot;Sync done&quot;)
    endfunction</i></i>


Also what happens when the game is hosted with a "0 delay host bot" ?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Also what happens when the game is hosted with a "0 delay host bot" ?
Sounds interesting, mind to test it?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top