mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
More precise baseline handling wip
This commit is contained in:
parent
f0c7460007
commit
357b725994
10 changed files with 90 additions and 53 deletions
Binary file not shown.
|
|
@ -38,7 +38,6 @@ const definition2 = propDataDefinition({
|
|||
|
||||
suite('PacketEntity', () => {
|
||||
test('baseLine diff', () => {
|
||||
const baseLine = new PacketEntity(serverClass, 123, PVS.ENTER);
|
||||
const entity = new PacketEntity(serverClass, 123, PVS.ENTER);
|
||||
const prop1 = new SendProp(definition1);
|
||||
prop1.value = 0.03125023842039809;
|
||||
|
|
@ -46,16 +45,15 @@ suite('PacketEntity', () => {
|
|||
prop2.value = 0;
|
||||
const prop3 = new SendProp(definition2);
|
||||
prop3.value = 0.03125023842039809;
|
||||
baseLine.props = [prop1, prop2];
|
||||
entity.props = [prop1, prop3];
|
||||
|
||||
assert.deepEqual(entity.diffFromBaseLine(baseLine), [prop3]);
|
||||
assert.deepEqual(entity.diffFromBaseLine([prop1, prop2]), [prop3]);
|
||||
});
|
||||
|
||||
test('baseLine diff player', () => {
|
||||
const baseLine = hydrateEntity(playerBaseLineData);
|
||||
const entity = hydrateEntity(playerEntityData);
|
||||
|
||||
assert.deepEqual(entity.diffFromBaseLine(baseLine).length, 75);
|
||||
assert.deepEqual(entity.diffFromBaseLine(baseLine.props).length, 75);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -148,13 +148,13 @@ suite('PacketEntities', () => {
|
|||
// }
|
||||
// });
|
||||
|
||||
// test('Encode packetEntities', () => {
|
||||
// const toEncode = {...expected};
|
||||
// const entity = toEncode.entities[1];
|
||||
// // entity.props = [entity.props[0]];
|
||||
// toEncode.entities = [entity];
|
||||
// assertEncoder(parse, encode, toEncode, 11266);
|
||||
// });
|
||||
test('Encode packetEntities', () => {
|
||||
const toEncode = {...expected};
|
||||
// entity.props.map(prop => console.log(`${prop.definition.fullName}: ${prop.value}`));
|
||||
// entity.props = [entity.props[0]];
|
||||
toEncode.entities = toEncode.entities.slice(281, 282);
|
||||
assertEncoder(parse, encode, toEncode, 0);
|
||||
});
|
||||
|
||||
|
||||
test('Encode small packetEntities', () => {
|
||||
|
|
@ -166,7 +166,7 @@ suite('PacketEntities', () => {
|
|||
delta: 0,
|
||||
maxEntries: 16,
|
||||
entities: [hydrateEntity(sunEntityData)]
|
||||
}, 202);
|
||||
}, 124);
|
||||
});
|
||||
|
||||
test('Encode small packetEntities with removed', () => {
|
||||
|
|
@ -178,7 +178,7 @@ suite('PacketEntities', () => {
|
|||
delta: 0,
|
||||
maxEntries: 16,
|
||||
entities: [hydrateEntity(sunEntityData)]
|
||||
}, 259);
|
||||
}, 181);
|
||||
});
|
||||
|
||||
test('Encode packetEntities only removed', () => {
|
||||
|
|
@ -204,7 +204,7 @@ suite('PacketEntities', () => {
|
|||
delta: 0,
|
||||
maxEntries: 16,
|
||||
entities: [hydrateEntity(sunEntityData), hydrateEntity(secondEntity)]
|
||||
}, 351);
|
||||
}, 195);
|
||||
});
|
||||
|
||||
test('Encode player packetEntities', () => {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function getStream(data: string | number[]) {
|
|||
export type Encoder = (data: any, stream: BitStream) => void;
|
||||
|
||||
export function assertEncoder(parser: Parser, encoder: Encoder, data: any, length: number = 0, message: string = '') {
|
||||
const stream = new BitStream(new ArrayBuffer(Math.max(64000, (length + 1) * 8)));
|
||||
const stream = new BitStream(new ArrayBuffer(length + 64000));
|
||||
|
||||
encoder(data as Packet, stream);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue