mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 09:04:13 +02:00
encoder wip
This commit is contained in:
parent
5b2665bdc9
commit
a5a1642782
13 changed files with 876 additions and 35 deletions
|
|
@ -4,8 +4,6 @@ import {GameEvent, GameEventType} from '../../Data/GameEventTypes';
|
|||
import {GameEventListPacket} from '../../Data/Packet';
|
||||
|
||||
export function ParseGameEventList(stream: BitStream): GameEventListPacket { // 30: gameEventList
|
||||
const s = stream.index;
|
||||
|
||||
// list of game events and parameters
|
||||
const numEvents = stream.readBits(9);
|
||||
const length = stream.readBits(20);
|
||||
|
|
@ -28,6 +26,7 @@ export function ParseGameEventList(stream: BitStream): GameEventListPacket { //
|
|||
entries
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
packetType: 'gameEventList',
|
||||
eventList
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ export function ParsePacketEntities(
|
|||
const updatedEntries = stream.readBits(11);
|
||||
const length = stream.readBits(20);
|
||||
const updatedBaseLine = stream.readBoolean();
|
||||
const start = stream.index;
|
||||
const end = stream.index + length;
|
||||
let entityId = -1;
|
||||
|
||||
|
|
@ -166,6 +167,10 @@ 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);
|
||||
|
|
@ -173,7 +178,7 @@ export function ParsePacketEntities(
|
|||
const packetEntity = getPacketEntityForExisting(entityId, state, pvs);
|
||||
receivedEntities.push(packetEntity);
|
||||
} else {
|
||||
// throw new Error(`No existing entity to update with id ${entityId}`);
|
||||
throw new Error(`No existing entity to update with id ${entityId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +238,9 @@ 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue