Skip to content

Commit

Permalink
Update demo repair
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Apr 15, 2024
1 parent 16620d2 commit 46b7e53
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/server/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 46b7e53

Please sign in to comment.