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

save more data in packets

This commit is contained in:
Robin Appelman 2017-02-17 23:47:00 +01:00
commit 9981feb8f7
7 changed files with 101 additions and 16 deletions

View file

@ -0,0 +1,13 @@
import {CmdKeyValuesPacket} from "../../Data/Packet";
import {BitStream} from 'bit-buffer';
export function CmdKeyValues(stream: BitStream): CmdKeyValuesPacket {
//'length{32}data{$length}'
const length = stream.readUint32();
const data = stream.readBitStream(length);
return {
packetType: 'cmdKeyValues',
length: length,
data: data
};
}

15
src/Parser/Packet/Menu.ts Normal file
View file

@ -0,0 +1,15 @@
import {MenuPacket} from "../../Data/Packet";
import {BitStream} from 'bit-buffer';
export function Menu(stream: BitStream): MenuPacket {
//'type{16}length{16}_{$length}_{$length}_{$length}_{$length}_{$length}_{$length}_{$length}'
const type = stream.readUint16();
const length = stream.readUint16();
const data = stream.readBitStream(length * 8); //length is in bytes
return {
packetType: 'menu',
type: type,
length: length,
data: data
};
}

View file

@ -63,7 +63,7 @@ export function PacketEntities(stream: BitStream, match: Match): PacketEntitiesP
// https://github.com/PazerOP/DemoLib/blob/5f9467650f942a4a70f9ec689eadcd3e0a051956/TF2Net/NetMessages/NetPacketEntitiesMessage.cs
const maxEntries = stream.readBits(11);
const isDelta = !!stream.readBits(1);
const delta = (isDelta) ? stream.readInt32() : null;
const delta = (isDelta) ? stream.readInt32() : 0;
const baseLine = stream.readBits(1);
const updatedEntries = stream.readBits(11);
const length = stream.readBits(20);
@ -109,6 +109,13 @@ export function PacketEntities(stream: BitStream, match: Match): PacketEntitiesP
return {
packetType: 'packetEntities',
entities: receivedEntities,
removedEntities: removedEntityIds
removedEntities: removedEntityIds,
maxEntries: maxEntries,
isDelta: isDelta,
delta: delta,
baseLine: baseLine,
updatedEntries: updatedEntries,
length: length,
updatedBaseLine: updatedBaseLine
};
}

View file

@ -0,0 +1,17 @@
import {VoiceDataPacket} from "../../Data/Packet";
import {BitStream} from 'bit-buffer';
export function VoiceData(stream: BitStream): VoiceDataPacket {
// 'client{8}proximity{8}length{16}_{$length}'
const client = stream.readUint8();
const proximity = stream.readUint8();
const length = stream.readUint16();
const data = stream.readBitStream(length);
return {
packetType: 'voiceData',
client: client,
proximity: proximity,
length: length,
data: data
};
}

View file

@ -2,17 +2,14 @@ import {VoiceInitPacket} from "../../Data/Packet";
import {BitStream} from 'bit-buffer';
export function VoiceInit(stream: BitStream): VoiceInitPacket {
//ParserGenerator.make('voiceInit', 'codec{s}quality{8}'),
const codec = stream.readASCIIString();
const quality = stream.readUint8();
if (codec === 'vaudio_celt') {
// no clue, from 2017-2-14 update
stream.readUint8();
stream.readUint8();
}
const codec = stream.readASCIIString();
const quality = stream.readUint8();
// no clue, from 2017-2-14 update
const extraData = (codec === 'vaudio_celt') ? stream.readUint16() : 0;
return {
packetType: 'voiceInit',
codec: codec,
quality: quality
}
quality: quality,
extraData: extraData
};
}