From 06328cf838f6ff06ca32a1642dc18a4cdaf3949b Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Wed, 23 Nov 2022 11:07:06 +0100 Subject: [PATCH] Support snap items with unknown size --- lib/snapshot/unpacker.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/snapshot/unpacker.rb b/lib/snapshot/unpacker.rb index 606ac2b..8255f61 100644 --- a/lib/snapshot/unpacker.rb +++ b/lib/snapshot/unpacker.rb @@ -233,6 +233,28 @@ class SnapshotUnpacker "type=#{item_type} ddnet_ex_reg" ]) notes += DDNetSnapItem.parse(u, item_type) + elsif item_type < 50 # TODO: i made up this magic number xd + # figure out what a sane + # limit for the type is + # something that is a bit + # future proof + # and also strict enough + # to alert when something + # goes wrong + # item with non pre-agreed size + # first int of the payload is the size of the payload + id = u.get_int + p = u.parsed.last + notes.push([:cyan, p[:pos], p[:len], "id=#{id}"]) + len = u.get_int + p = u.parsed.last + notes.push([:green, p[:pos], p[:len], "len=#{len}"]) + (0...len).each do |i| + val = u.get_int + p = u.parsed.last + col = (i % 2).zero? ? :bg_pink : :bg_yellow + notes.push([col, p[:pos], p[:len], "val=#{val}"]) + end else invalid = true notes.push([