Skip to content

Commit 777fbf4

Browse files
committed
doc/teehistorian: Explain tick calculation
1 parent 28a1a84 commit 777fbf4

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

doc/teehistorian.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,28 @@ The following data types are used:
114114
* uuid is 16 bytes of a UUID
115115

116116
the UUIDs are version 3 UUIDs, with the teeworlds namespace e05ddaaa-c4e6-4cfb-b642-5d48e80c0029
117-
a tick is implicit in these messages when a player with lower cid is recorded using any of PLAYER\_DIFF, PLAYER\_NEW, PLAYER\_OLD
118-
e.g.
119-
PLAYER\_DIFF cid=0 … PLAYER\_NEW cid=5 … PLAYER\_OLD cid=3 has an implicit tick between the cid=5 and the cid=3 message
120-
another correction:
121-
the header is the teehistorian uuid followed by a zero-terminated string containing json in a self-explanatory format
117+
118+
(Implicit) Ticks
119+
----------------
120+
121+
Teehistorian messages are associated with in-game tick numbers. The tick of a
122+
message depends on all previous messages. It can't be calculated locally.
123+
124+
* TICK\_SKIP messages explicitly increase the tick by `dt + 1`.
125+
* PLAYER\_DIFF, PLAYER\_NEW, PLAYER\_OLD can implicity increment the tick by 1.
126+
They imply a tick increment, if the last message of the three kinds held an
127+
equal or lower cid and there wasn't a TICK\_SKIP message inbetween.
128+
129+
In Python-like pseudocode:
130+
```py
131+
tick = 0
132+
implicit_cid = None
133+
for message in messages:
134+
if message.kind == TICK_SKIP:
135+
tick += message.dt + 1
136+
implicit_cid = None
137+
if message.kind is in [PLAYER_DIFF, PLAYER_NEW, PLAYER_OLD]:
138+
if implicit_cid is not None and message.cid <= implicit_cid:
139+
tick += 1
140+
implicit_cid = message.cid
141+
```

0 commit comments

Comments
 (0)