mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
fix handling of post pyro update demos
This commit is contained in:
parent
a5a1642782
commit
8c29265bb2
2 changed files with 18 additions and 6 deletions
|
|
@ -6,19 +6,21 @@ import {GameEventListPacket} from '../../Data/Packet';
|
||||||
export function ParseGameEventList(stream: BitStream): GameEventListPacket { // 30: gameEventList
|
export function ParseGameEventList(stream: BitStream): GameEventListPacket { // 30: gameEventList
|
||||||
// list of game events and parameters
|
// list of game events and parameters
|
||||||
const numEvents = stream.readBits(9);
|
const numEvents = stream.readBits(9);
|
||||||
|
|
||||||
const length = stream.readBits(20);
|
const length = stream.readBits(20);
|
||||||
|
const listData = stream.readBitStream(length);
|
||||||
const eventList: Map<number, GameEventDefinition<GameEventType>> = new Map();
|
const eventList: Map<number, GameEventDefinition<GameEventType>> = new Map();
|
||||||
for (let i = 0; i < numEvents; i++) {
|
for (let i = 0; i < numEvents; i++) {
|
||||||
const id = stream.readBits(9);
|
const id = listData.readBits(9);
|
||||||
const name = stream.readASCIIString() as GameEvent['name'];
|
const name = listData.readASCIIString() as GameEvent['name'];
|
||||||
let type = stream.readBits(3);
|
let type = listData.readBits(3);
|
||||||
const entries: GameEventEntry[] = [];
|
const entries: GameEventEntry[] = [];
|
||||||
while (type !== 0) {
|
while (type !== 0) {
|
||||||
entries.push({
|
entries.push({
|
||||||
type,
|
type,
|
||||||
name: stream.readASCIIString()
|
name: listData.readASCIIString()
|
||||||
});
|
});
|
||||||
type = stream.readBits(3);
|
type = listData.readBits(3);
|
||||||
}
|
}
|
||||||
eventList.set(id, {
|
eventList.set(id, {
|
||||||
id,
|
id,
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
|
||||||
const quality = stream.readUint8();
|
const quality = stream.readUint8();
|
||||||
|
|
||||||
// no clue, from 2017-2-14 update
|
// no clue, from 2017-2-14 update
|
||||||
const extraData = (codec === 'vaudio_celt' && quality === 255) ? stream.readUint16() : 0;
|
const extraData = readExtraData(stream, codec, quality);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
packetType: 'voiceInit',
|
packetType: 'voiceInit',
|
||||||
|
|
@ -16,6 +16,16 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function readExtraData(stream: BitStream, codec: string, quality: number) {
|
||||||
|
if (quality === 255) {
|
||||||
|
return stream.readUint16();
|
||||||
|
} else if (codec === 'vaudio_celt') {
|
||||||
|
return 11025;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function EncodeVoiceInit(packet: VoiceInitPacket, stream: BitStream) {
|
export function EncodeVoiceInit(packet: VoiceInitPacket, stream: BitStream) {
|
||||||
stream.writeASCIIString(packet.codec);
|
stream.writeASCIIString(packet.codec);
|
||||||
stream.writeUint8(packet.quality);
|
stream.writeUint8(packet.quality);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue