Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 8c29265

Browse files
committed
fix handling of post pyro update demos
1 parent a5a1642 commit 8c29265

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/Parser/Packet/GameEventList.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,21 @@ import {GameEventListPacket} from '../../Data/Packet';
66
export function ParseGameEventList(stream: BitStream): GameEventListPacket { // 30: gameEventList
77
// list of game events and parameters
88
const numEvents = stream.readBits(9);
9+
910
const length = stream.readBits(20);
11+
const listData = stream.readBitStream(length);
1012
const eventList: Map<number, GameEventDefinition<GameEventType>> = new Map();
1113
for (let i = 0; i < numEvents; i++) {
12-
const id = stream.readBits(9);
13-
const name = stream.readASCIIString() as GameEvent['name'];
14-
let type = stream.readBits(3);
14+
const id = listData.readBits(9);
15+
const name = listData.readASCIIString() as GameEvent['name'];
16+
let type = listData.readBits(3);
1517
const entries: GameEventEntry[] = [];
1618
while (type !== 0) {
1719
entries.push({
1820
type,
19-
name: stream.readASCIIString()
21+
name: listData.readASCIIString()
2022
});
21-
type = stream.readBits(3);
23+
type = listData.readBits(3);
2224
}
2325
eventList.set(id, {
2426
id,

src/Parser/Packet/VoiceInit.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
66
const quality = stream.readUint8();
77

88
// no clue, from 2017-2-14 update
9-
const extraData = (codec === 'vaudio_celt' && quality === 255) ? stream.readUint16() : 0;
9+
const extraData = readExtraData(stream, codec, quality);
1010

1111
return {
1212
packetType: 'voiceInit',
@@ -16,6 +16,16 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
1616
};
1717
}
1818

19+
function readExtraData(stream: BitStream, codec: string, quality: number) {
20+
if (quality === 255) {
21+
return stream.readUint16();
22+
} else if (codec === 'vaudio_celt') {
23+
return 11025;
24+
} else {
25+
return 0;
26+
}
27+
}
28+
1929
export function EncodeVoiceInit(packet: VoiceInitPacket, stream: BitStream) {
2030
stream.writeASCIIString(packet.codec);
2131
stream.writeUint8(packet.quality);

0 commit comments

Comments
 (0)