1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-04 09:04:13 +02:00

Work around parsing errors for post MyM pov demos

This commit is contained in:
Robin Appelman 2016-12-22 00:02:24 +01:00
commit 265f87fe54
11 changed files with 37 additions and 24 deletions

View file

@ -49,10 +49,10 @@ const getGameEventValue = function (stream: BitStream, entry: GameEventEntry): G
export function GameEvent(stream: BitStream, match: Match): Packet { // 25: game event
const length = stream.readBits(11);
const end = stream._index + length;
const end = stream.index + length;
const eventId = stream.readBits(9);
const event = parseGameEvent(eventId, stream, match.eventDefinitions);
stream._index = end;
stream.index = end;
return {
packetType: 'gameEvent',
event: event

View file

@ -58,9 +58,9 @@ function readEnterPVS(stream: BitStream, entityId: number, match: Match, baseLin
} else {
const staticBaseLine = match.staticBaseLines[serverClass.id];
if (staticBaseLine) {
const streamStart = staticBaseLine._index;
const streamStart = staticBaseLine.index;
applyEntityUpdate(entity, staticBaseLine);
staticBaseLine._index = streamStart;
staticBaseLine.index = streamStart;
}
}
return entity;
@ -85,10 +85,10 @@ export function PacketEntities(stream: BitStream, match: Match): Packet { //26:
const updatedEntries = stream.readBits(11);
const length = stream.readBits(20);
const updatedBaseLine = stream.readBoolean();
const end = stream._index + length;
const end = stream.index + length;
let entityId = -1;
stream._index = end;
stream.index = end;
return {
packetType: 'packetEntities'
};
@ -144,7 +144,7 @@ export function PacketEntities(stream: BitStream, match: Match): Packet { //26:
}
}
stream._index = end;
stream.index = end;
return {
packetType: 'packetEntities'
};

View file

@ -4,7 +4,8 @@ import {Packet} from "../../Data/Packet";
export function PacketStringTable(stream: BitStream):Packet {
//todo
// https://coldemoplayer.googlecode.com/svn/branches/2.0/code/plugins/CDP.Source/Messages/SvcCreateStringTable.cs
stream._index = stream._view._view.byteLength * 8;
// throw new Error('packetstringtable not implemented');
stream.index = stream.length; // no idea, skip to the end of the
return {
packetType: 'stringTableTODO'
};

View file

@ -5,7 +5,7 @@ export function ParseSounds(stream: BitStream): Packet { // 17: parseSounds
const reliable = stream.readBoolean();
const num = (reliable) ? 1 : stream.readUint8();
const length = (reliable) ? stream.readUint8() : stream.readUint16();
stream._index += length;
stream.index += length;
return {
packetType: 'parseSounds',
reliable: reliable,

View file

@ -7,7 +7,7 @@ import {applyEntityUpdate} from "../EntityDecoder";
export function TempEntities(stream: BitStream, match: Match): Packet { // 10: classInfo
const entityCount = stream.readBits(8);
const length = readVarInt(stream);
const end = stream._index + length;
const end = stream.index + length;
// let entity: Entity|null = null;
// let entities: Entity[] = [];
@ -29,11 +29,11 @@ export function TempEntities(stream: BitStream, match: Match): Packet { // 10: c
// }
// console.log(entity);
// }
// if (end - stream._index > 8) {
// if (end - stream.index > 8) {
// throw new Error("unexpected content after TempEntities");
// }
stream._index = end;
stream.index = end;
return {
'packetType': 'tempEntities'
}

View file

@ -72,7 +72,7 @@ const userMessageParsers = {
export function UserMessage(stream: BitStream): Packet { // 23: user message
const type = stream.readBits(8);
const length = stream.readBits(11);
const pos = stream._index;
const pos = stream.index;
let result;
if (userMessageParsers[type]) {
result = userMessageParsers[type](stream);
@ -82,6 +82,6 @@ export function UserMessage(stream: BitStream): Packet { // 23: user message
type: type
}
}
stream._index = pos + length;
stream.index = pos + length;
return result;
}