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

Commit

Permalink
fix handling of post pyro update demos
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Oct 24, 2017
1 parent a5a1642 commit 8c29265
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/Parser/Packet/GameEventList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ import {GameEventListPacket} from '../../Data/Packet';
export function ParseGameEventList(stream: BitStream): GameEventListPacket { // 30: gameEventList
// list of game events and parameters
const numEvents = stream.readBits(9);

const length = stream.readBits(20);
const listData = stream.readBitStream(length);
const eventList: Map<number, GameEventDefinition<GameEventType>> = new Map();
for (let i = 0; i < numEvents; i++) {
const id = stream.readBits(9);
const name = stream.readASCIIString() as GameEvent['name'];
let type = stream.readBits(3);
const id = listData.readBits(9);
const name = listData.readASCIIString() as GameEvent['name'];
let type = listData.readBits(3);
const entries: GameEventEntry[] = [];
while (type !== 0) {
entries.push({
type,
name: stream.readASCIIString()
name: listData.readASCIIString()
});
type = stream.readBits(3);
type = listData.readBits(3);
}
eventList.set(id, {
id,
Expand Down
12 changes: 11 additions & 1 deletion src/Parser/Packet/VoiceInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function ParseVoiceInit(stream: BitStream): VoiceInitPacket {
const quality = stream.readUint8();

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

return {
packetType: 'voiceInit',
Expand All @@ -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) {
stream.writeASCIIString(packet.codec);
stream.writeUint8(packet.quality);
Expand Down

0 comments on commit 8c29265

Please sign in to comment.