Skip to content

Instantly share code, notes, and snippets.

@VictorTaelin
Last active November 5, 2025 16:28
Show Gist options
  • Save VictorTaelin/2573792b790ed5b8696368589b08bd16 to your computer and use it in GitHub Desktop.
Save VictorTaelin/2573792b790ed5b8696368589b08bd16 to your computer and use it in GitHub Desktop.
TIMELINE DE EVENTOS:
000000000011111
012345678901234
____d_D____d_D____________________________________________________________________ A
\ \ / /
\ \/ /
_______\/\/_______________________________________________________________________ Server
\ \
\ \
__________\_\_____________________________________________________________________ B
d D
PROPOSTA NAIVE:
- timestamp oficial = tempo que o server recebeu
- visibilidade de efeitos = apenas quando a mensagem é recebida
TELA DO SERVER TELA DO A TELA DO B
========================================================================== tick=0
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=1
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=2
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=3
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=4 | pacote A→server: "player A pressionou d"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=5
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=6 | pacote A→server: "player A soltou D"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=7 | pacote server→[A&B]: "player A pressionou d no tick 7"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=8
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=9 | pacote server→[A&B]: "player A soltou D no tick 9"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=10
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=11 | A&B recebe "player A pressionou d no tick 7"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
========================================================================== tick=12
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
========================================================================== tick=13 | A&B recebe "player A soltou D no tick 9"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
PROPOSTA MELHORADA:
- timestamp oficial = tempo do client (com tolerância)
- visibilidade de efeitos = apenas quando a mensagem é recebida
TELA DO SERVER TELA DO A TELA DO B
========================================================================== tick=0
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=1
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=2
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=3
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=4 | pacote A→server: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=5
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=6 | pacote A→server: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # | #
========================================================================== tick=7 | pacote server→[A&B]: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=8
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=9 | pacote server→[A&B]: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=10
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # |A # | #
========================================================================== tick=11 | A&B recebe "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
========================================================================== tick=12
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
========================================================================== tick=13 | A&B recebe "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | #
PROPOSTA MELHORADA MESMO (SO QUE NAO):
- timestamp oficial = tempo do client (com tolerância)
- obs: tolerancia: não permitir mensagens MUITO no passado para evitar hack
- visibilidade de efeitos
= para os outros: apenas quando a mensagem é recebida
= para nós mesmos: quando disparamos a mensagem
TELA DO SERVER TELA DO A TELA DO B
========================================================================== tick=0
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=1
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=2
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=3
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=4 | pacote A→server: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=5
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=6 | pacote A→server: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=7 | pacote server→[A&B]: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=8
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=9 | pacote server→[A&B]: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=10
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=11 | A&B recebe "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
========================================================================== tick=12
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
========================================================================== tick=13 | A&B recebe "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
PROPOSTA MELHORADA MESMO FINAL.pdf:
- timestamp oficial = tempo do client (com tolerância)
- obs: tolerancia: não permitir mensagens MUITO no passado para evitar hack
- visibilidade de efeitos
= para os outros: apenas quando a mensagem é recebida
= para nós mesmos: quando disparamos a mensagem
- renderização
= para os outros: desenhamos no passado
= para nós mesmos: desenhamos no presente
TELA DO SERVER TELA DO A TELA DO B
========================================================================== tick=0
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=1
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=2
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=3
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # |A # |A #
========================================================================== tick=4 | pacote A→server: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=5
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=6 | pacote A→server: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
|A # | A # |A #
========================================================================== tick=7 | pacote server→[A&B]: "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=8
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=9 | pacote server→[A&B]: "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=10
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # |A #
========================================================================== tick=11 | A&B recebe "player A pressionou d no tick 4"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
========================================================================== tick=12
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
========================================================================== tick=13 | A&B recebe "player A soltou D no tick 6"
,--------------------→ # ,--------------------→ # ,--------------------→ #
| A # | A # | A #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment