1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-10-01 00:34:06 +02:00
Commit graph

581 commits

Author SHA1 Message Date
b01bd5262c 0.7.1 2026-09-09 20:46:29 +02:00
8a07fb8fd5 add llm guidelines 2026-09-08 01:51:51 +02:00
Robin Appelman
d7c26a8ae4 Merge pull request 'reencode: rewrite instance baselines after the array size fixup' (#11) from pet0r/demostf-parser:fix-baseline-reencode into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/11
2026-09-07 23:17:46 +02:00
Peter
51af06e0be reencode: use the handler's table names to find instancebaseline
Drops the id tracking. userinfo entries are numeric too, so anything
looser than matching the table name would decode one as a baseline.
2026-09-07 21:41:11 +01:00
Peter
582e8b9b3c reencode: rewrite instance baselines after the array size fixup
Raising the MAX_PLAYERS arrays widens their length fields, so the
baselines no longer decode at the offsets the client reads them at.
SourceTV demos just get wrong team data. POV demos set update_baseline
and overflow the merge buffer, taking the game down with
"RecvTable_MergeDeltas: overflowed in RecvTable 'DT_TFTeam'".

Finding the send tables needs a pass of its own - instancebaseline is
created in the first signon packet, the tables arrive a few packets
later.
2026-09-07 10:09:11 +01:00
Peter
03ae55e0f8 Add StaticBaseline::reencode
A baseline is packed entity data, only meaningful against the table it
was written with. Anything that edits a send table has to rewrite the
baselines of every class using the changed props.
2026-09-07 10:09:11 +01:00
Peter
892b713acc Derive PartialEq for send prop definitions
Needed to tell whether editing a send table actually changed how its
props encode.
2026-09-07 10:09:11 +01:00
84b1e704c7 release 0.7.0 2026-09-01 14:46:47 +02:00
1d3ea813b2 cleanup nix 2026-09-01 14:38:57 +02:00
6aebc0c5f4 changelog 2026-09-01 14:38:57 +02:00
2dfcac6efa msrv 2026-09-01 14:21:37 +02:00
83e605d6ec iai-callgrind -> gungraun 2026-09-01 00:35:34 +02:00
b9f483d4d0 fix "trace" feature breaking parsing the stop tick 2026-09-01 00:12:33 +02:00
6cfd4990a6 clippy fixes 2026-08-31 23:07:45 +02:00
1a5960f7c4 cargo updates 2026-08-31 23:02:58 +02:00
802165d6fa flake update 2026-08-31 22:52:27 +02:00
Robin Appelman
8393f1517c Merge pull request 'Fix reencoding of demos recorded on older protocols' (#10) from pet0r/demostf-parser:fix-reencode-protocol-version into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/10
Reviewed-by: Robin Appelman <icewind@noreply.codeberg.org>
2026-08-31 22:50:48 +02:00
Peter
56f0856441 Write protocol dependent lengths when encoding
CreateStringTable and TempEntities both read their payload length as a fixed
width field on protocol 23 and older and as a var int after that, but the
encoders always write the var int. Reencoding an older demo therefore hands
the game a length it can't read: string tables come back as "bogus substring
index", and any packet carrying temp entities is malformed from there on,
taking whatever messages follow it in that packet with it.

The threshold and both widths are taken from the read paths a few lines up in
these same two files rather than worked out separately, so the two sides can't
drift: > 23, with 20 bits for CreateStringTable and 17 for TempEntities. The
engine agrees, for what it's worth - netmessages.cpp reads both of these under
> PROTOCOL_VERSION_23 at NET_MAX_PAYLOAD_BITS_V23 + 3 and
NET_MAX_PAYLOAD_BITS_V23 respectively, and that constant is 17.

serverinfo and prefetch already branch on the protocol on both sides, these
two were the only ones that didn't.

On a protocol 15 demo that was 28909 of 92518 reencoded packets failing to
parse back; on test_data/protocol23.dem, 13220 of 43327. Both are zero now,
so protocol23.dem can join the reencode round trip test. Protocol 24 output
is unchanged, byte for byte.
2026-08-31 11:58:21 +01:00
Peter
7c5c596d17 Use the demo's protocol version when reencoding
DemoHandler::default() starts out at protocol 24 and relies on handle_header
to replace that with whatever the demo actually is. Parsing through DemoParser
does this for you, but reencode drives the handler itself and never did, so
every demo got read as protocol 24.

Older protocols put a few fields at different widths, so the message stream
desyncs partway in. RawPacketStream reports that as a truncated demo rather
than an error, which is why nothing complains about it: reencode_demo on
test_data/protocol23.dem writes 1076 bytes, prints a truncation warning and
still exits 0.

The reencode test missed this because protocol23.dem was never in its list,
and because nothing checked the demo had been read to the end. Add a test for
that and the same assert to the existing round trip.

Output for protocol 24 demos is unchanged, byte for byte.
2026-08-31 11:14:15 +01:00
19d790d45c dont unwrap when casting ints to Class 2026-04-06 20:33:58 +02:00
Robin Appelman
d29508a25b Merge pull request 'Fix SendPropValue::Vector encoding when the float definition is NormalFloatVar' (#9) from glyphpoch/parser:fix/send-prop-vector-encoding into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/9
Reviewed-by: Robin Appelman <icewind@noreply.codeberg.org>
2026-04-06 20:20:59 +02:00
glyphpoch
660b9dc1d7 Fix SendPropValue::Vector encoding when the float definition is NormalFloatVar
This is a follow up to PR #4. Handling for the Vector prop needs to be
fixed on the write/encoding side as well. When the float definition is
NormalFloatVar we need to skip writing the last component (z) to the
stream, since it's calculated from the first two components (x, y), and
just write out its sign.
2026-04-06 18:20:25 +01:00
Robin Appelman
4b7a0c7320 Merge pull request 'Fix parsing of SayText2 messages starting with color codes other than \x01' (#7) from pet0r/demostf-parser:broaden_saytext_detection into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/7
2026-04-05 16:01:19 +02:00
Peter
a1b1db6f84 Fix parsing of SayText2 messages starting with color codes other than \x01
SayText2 messages can use a simplified format where the body is just
client, raw, and a single null-terminated colored text string, without
the usual kind/from/text fields. The parser detected this by peeking
the first byte after client and raw and checking if it was \x01 (color
code for default color), but the text can also start with other color
codes such as \x07 (6-char hex color). When this happened, the parser
would consume the entire message text as the kind string (falling back
to ChatAll), leaving the text and from fields empty.
2026-04-05 10:48:27 +01:00
b500fe772a update schemars to 1.0 2025-09-17 00:14:27 +02:00
Robin Appelman
6143e0289b Merge pull request 'Avoid sign-extending unsigned VarInts' (#5) from nocrex/parser:unsigned-varint-fix into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/5
2025-09-16 22:59:08 +02:00
3dcbf2a4cf fix sendprop roundtrip test 2025-09-16 22:58:29 +02:00
Nocrex
363821a545 Avoid sign-extending unsigned VarInts 2025-09-15 21:05:32 +02:00
Robin Appelman
b8d747fe51 Merge pull request 'Fix SendPropValue::Vector parsing when the float definition is NormalFloatVar' (#4) from glyphpoch/parser:fix/send-prop-vector-parsing into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/4
Reviewed-by: Robin Appelman <icewind@noreply.codeberg.org>
2025-08-29 18:52:27 +02:00
glyphpoch
a8f379965c Fix SendPropValue::Vector parsing when the float definition is NormalFloatVar
When the float definition is NormalFloatVar, the last component (z)
should be skipped and calculated from the first two components (x and
y), otherwise we can read too many bits, causing decoding failures:
* 744d6eb003/src/engine/dt_encode.cpp (L119-L143)

This is what was causing the issue with demos recorded on the
jump_classics_a3 map:
* https://codeberg.org/demostf/parser/issues/2
2025-08-28 21:03:30 +01:00
f104bad12f clippy fixes 2025-08-08 13:08:48 +02:00
2c113f9a18 fix outer map not using baselines 2025-08-08 00:06:46 +02:00
e303969606 store last medic target 2025-08-07 23:22:35 +02:00
42b63cc7eb fix player handles 2025-08-07 22:57:48 +02:00
af5ed45f2c flake update 2025-08-07 22:46:05 +02:00
38e12f04b4 cleanup dependencies 2025-07-15 16:15:11 +02:00
fbaca025b6 feature gate write support, use hash to compare game event definitions 2025-07-15 16:06:23 +02:00
6ef2b1cea8 remove some bounds checks 2025-07-14 14:56:14 +02:00
b328db85e9 msrv 2025-07-13 23:50:09 +02:00
aa8da5f582 formatting 2025-07-13 23:41:22 +02:00
f7190dca0f clippy fixes 2025-07-13 23:40:28 +02:00
b9d311f16f no need to allocate for 4 byte magic 2025-07-13 23:40:28 +02:00
ec3685bfb3 move benchmarks to iai-callgrind 2025-07-13 23:40:28 +02:00
2ab3e91774 formatting 2025-07-12 22:53:27 +02:00
8da61fb3d8 update snapshots 2025-07-12 22:27:36 +02:00
Robin Appelman
9403297c30 Merge pull request 'Fix custom_file field in RawPlayerInfo by adjusting padding' (#3) from seercat/demo-parser:seercat/playerinfo-padding into master
Reviewed-on: https://codeberg.org/demostf/parser/pulls/3
2025-07-12 22:25:22 +02:00
Seercat3160
2e7d3eb96f
Move the padding in RawPlayerInfo to make the custom_file field have correct alignment 2025-07-12 21:01:51 +10:00
33e40ca99b live sentry rotation 2025-07-05 15:49:42 +02:00
e3810b0b03 sentry shield 2025-07-03 00:15:57 +02:00
b93390d1e4 split up gamestateanalyser 2025-07-02 21:54:35 +02:00