mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 09:04:13 +02:00
add encoder for parseSounds
This commit is contained in:
parent
f360011ef4
commit
9406937f08
7 changed files with 255 additions and 15 deletions
|
|
@ -5,11 +5,27 @@ export function ParseParseSounds(stream: BitStream): ParseSoundsPacket { // 17:
|
|||
const reliable = stream.readBoolean();
|
||||
const num = (reliable) ? 1 : stream.readUint8();
|
||||
const length = (reliable) ? stream.readUint8() : stream.readUint16();
|
||||
stream.index += length;
|
||||
const data = stream.readBitStream(length);
|
||||
|
||||
return {
|
||||
packetType: 'parseSounds',
|
||||
reliable,
|
||||
num,
|
||||
length,
|
||||
data
|
||||
};
|
||||
}
|
||||
|
||||
export function EncodeParseSounds(packet: ParseSoundsPacket, stream: BitStream) {
|
||||
stream.writeBoolean(packet.reliable);
|
||||
if (packet.reliable) {
|
||||
stream.writeUint8(packet.length);
|
||||
} else {
|
||||
stream.writeUint8(packet.num);
|
||||
stream.writeUint16(packet.length);
|
||||
}
|
||||
|
||||
packet.data.index = 0;
|
||||
stream.writeBitStream(packet.data, packet.length);
|
||||
packet.data.index = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,4 @@ export function EncodeVoiceData(packet: VoiceDataPacket, stream: BitStream) {
|
|||
packet.data.index = 0;
|
||||
stream.writeBitStream(packet.data, packet.length);
|
||||
packet.data.index = 0;
|
||||
|
||||
const length = stream.index;
|
||||
|
||||
stream.index = 0;
|
||||
console.log(stream.readArrayBuffer(Math.ceil(length / 8)));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue