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

fix writeVarInt when writing 128

This commit is contained in:
Robin Appelman 2017-11-11 17:30:17 +01:00
commit c9c764aad0
2 changed files with 2 additions and 8 deletions

View file

@ -149,6 +149,7 @@ export function ParsePacketEntities(
for (let i = 0; i < updatedEntries; i++) {
const diff = readUBitVar(stream);
entityId += 1 + diff;
const pvs = readPVSType(stream);
if (pvs === PVS.ENTER) {
const packetEntity = readEnterPVS(stream, entityId, state, baseLine);
@ -167,10 +168,6 @@ export function ParsePacketEntities(
if (!sendTable) {
throw new Error(`Unknown sendTable ${packetEntity.serverClass.dataTable}`);
}
if (entityId === 55) {
console.log(`decode preserve: ${entityId} = ${sendTable.name}, ${receivedEntities.length}/${i} ${stream.index} ${end} tick ${state.tick}`);
console.log(receivedEntities[receivedEntities.length - 1], start, entityId, diff);
}
const updatedProps = getEntityUpdate(sendTable, stream);
packetEntity.applyPropUpdate(updatedProps);
receivedEntities.push(packetEntity);
@ -238,9 +235,6 @@ export function EncodePacketEntities(packet: PacketEntitiesPacket, stream: BitSt
writeEnterPVS(entity, stream, state, packet.baseLine);
} else if (entity.pvs === PVS.PRESERVE) {
const sendTable = getSendTable(state, entity.serverClass.dataTable);
if (entity.entityIndex === 55) {
console.log(`encode preserve: ${entity.entityIndex} = ${entity.serverClass.dataTable}`);
}
encodeEntityUpdate(entity.props, sendTable, stream);
}
}

View file

@ -72,7 +72,7 @@ export function writeVarInt(value: number, stream: BitStream, signed: boolean =
do {
const byte = value & 0x7F;
const resumeBit = (value > 128) ? 0x80 : 0;
const resumeBit = (value >= 128) ? 0x80 : 0;
stream.writeUint8(byte | resumeBit);
value = value >> 7;
} while (value > 0);