From 46b7e533ec8b629def434f344239f45e49c23317 Mon Sep 17 00:00:00 2001 From: NeKz Date: Mon, 15 Apr 2024 14:34:50 +0200 Subject: [PATCH] Update demo repair --- src/server/demo.ts | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/server/demo.ts b/src/server/demo.ts index 5a0782d..8c84cf6 100644 --- a/src/server/demo.ts +++ b/src/server/demo.ts @@ -545,11 +545,28 @@ export const getPlayerInfo = (demo: SourceDemo): PlayerInfoData => { // Imported from: https://github.com/NeKzor/sdp/blob/master/examples/repair.ts export const repairDemo = (buffer: Uint8Array): Uint8Array => { - const parser = SourceDemoParser.default(); + const parser = SourceDemoParser.default() + .setOptions({ packets: true, dataTables: true }); - const demo = parser - .setOptions({ packets: true }) - .parse(buffer); + const demo = SourceDemo.default(); + + try { + const buf = parser.prepare(buffer); + demo.readHeader(buf) + .readMessages(buf); + } catch (err) { + console.error(err); + } + try { + demo.readDataTables(); + } catch (err) { + console.error(err); + } + try { + demo.readPackets(); + } catch (err) { + console.error(err); + } const tryFixup = () => { const dt = demo.findMessage(Messages.DataTable)?.dataTable;