1
0
Fork 0
mirror of https://github.com/demostf/demo.js synced 2026-06-03 16:44:12 +02:00

caching of parsed static baselines

This commit is contained in:
Robin Appelman 2017-09-16 16:20:21 +02:00
commit 358aa6aa21
2 changed files with 6 additions and 9 deletions

View file

@ -67,7 +67,7 @@ export class PacketEntity {
if (existingProp) {
existingProp.value = prop.value;
} else {
this.props.push(prop);
this.props.push(prop.clone());
}
}
}

View file

@ -52,16 +52,13 @@ function readEnterPVS(stream: BitStream, entityId: EntityId, state: ParserState,
} else {
const staticBaseLine = state.staticBaseLines.get(serverClass.id);
if (staticBaseLine) {
const cachedBaseline = state.staticBaselineCache.get(serverClass.id);
if (cachedBaseline) {
entity.applyPropUpdate(cachedBaseline);
} else {
let baseline = state.staticBaselineCache.get(serverClass.id);
if (!baseline) {
staticBaseLine.index = 0;
const props = getEntityUpdate(sendTable, staticBaseLine);
entity.applyPropUpdate(props);
// TODO: cache
// state.staticBaselineCache.set(serverClass.id, props.map(prop => prop.clone()));
baseline = getEntityUpdate(sendTable, staticBaseLine);
state.staticBaselineCache.set(serverClass.id, baseline);
}
entity.applyPropUpdate(baseline);
// if (staticBaseLine.bitsLeft > 7) {
// console.log(staticBaseLine.length, staticBaseLine.index);
// throw new Error('Unexpected data left at the end of staticBaseline, ' + staticBaseLine.bitsLeft + ' bits left');