HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

PingMe function (using the idea of GetHost)

08-17-2006, 12:31 PM#1
iNfraNe
Quote:
Originally Posted by Tennis @ wc3jass
I wrote a "PingMe" function, just for fun, using these Sync natives and GetLocalPlayer to only call them for one person, and it was surprisingly accurate of that player's visible delay to the host, within the time blocks.

I've been wondering how the guy did this. If you only run the sync functions for 1 player wouldnt that cause a desync?

Also, how does he meassure the time? A timer?
08-17-2006, 12:55 PM#2
Vexorian
My guess is that he measures the time for LocalPlayer and then Syncs the time measured
08-17-2006, 01:24 PM#3
iNfraNe
But im wondering how he meassures the time for localplayer. I dont really need to sync the time afterwards since im just gonna display it ingame (which shouldnt desync right?)
08-17-2006, 03:07 PM#4
PitzerMike
He may just have started a timer at 0.00 game time and then GetTimerElapsed().
He may also have used the jAPI GetTicks native with a loader.
08-17-2006, 06:24 PM#5
iNfraNe
So then, this should be correct?
Collapse JASS:
function PingPlayer takes player p returns real
  local timer t = CreateTimer()
  local real r
  call StoreInteger(GC(), "a", "a", 1)
  call TimerStart(t, 10., false, function CleanPingTimer)
  if GetLocalPlayer() == p then
    call TriggerSyncStart()
    call SyncStoredInteger(GC(), "a", "a")
    call TriggerSyncReady()
  endif
  set r = TimerGetElapsed(t)
  set t = null
  return r
endfunction

And it should return 0.00 for all other players than the one being pinged.

If this is correct so far then I'd like to know how to make player2 aware of player1's delay, how could I sync the real value?

Edit: this function desyncs, which I thought it would :( any ideas?
08-17-2006, 09:43 PM#6
PipeDream
the only way known to reliably transmit information is via SyncSelections
Transform the real into 12 bit fixed precision and then search around for Mike's optimized Sync12BitInteger.
08-18-2006, 11:18 AM#7
iNfraNe
I tried that...
Collapse JASS:
set udg_Latency[i] = Sync12BitInteger(Player(i), R2I(PingPlayer(Player(i)) * 1000))

But it still desyncs... Any idea how to fix?
08-18-2006, 12:31 PM#8
DioD
Delay returns to wrong local player.
08-18-2006, 05:31 PM#9
iNfraNe
Erm, as always, I dont see your point. Be more clear please.
08-19-2006, 01:51 AM#10
DioD
if GetLocalPlayer() == p then
call TriggerSyncStart()
call SyncStoredInteger(GC(), "a", "a")
call TriggerSyncReady()

Sync with others localy....
08-19-2006, 01:18 PM#11
iNfraNe
Quote:
Originally Posted by DioD
if GetLocalPlayer() == p then
call TriggerSyncStart()
call SyncStoredInteger(GC(), "a", "a")
call TriggerSyncReady()

Sync with others localy....
Well yes, it would seem desyncy, but tennis claims its possible:

Quote:
Originally Posted by Tennis
using these Sync natives and GetLocalPlayer to only call them for one person