mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +02:00
add test for new celt codec
This commit is contained in:
parent
c2e79f552a
commit
1ef9fe444b
7 changed files with 2043 additions and 27 deletions
|
|
@ -1,4 +1,5 @@
|
|||
src
|
||||
typings
|
||||
build/tests
|
||||
*.dem
|
||||
*.txt
|
||||
|
|
|
|||
|
|
@ -33,28 +33,30 @@ export class Match {
|
|||
playerMap: {[entityId: number]: Player};
|
||||
entityClasses: {[entityId: string]: ServerClass};
|
||||
sendTableMap: {[name: string]: SendTable};
|
||||
baseLineCache: {[serverClass: string]: PacketEntity};
|
||||
|
||||
constructor() {
|
||||
this.tick = 0;
|
||||
this.chat = [];
|
||||
this.users = {};
|
||||
this.deaths = [];
|
||||
this.rounds = [];
|
||||
this.startTick = 0;
|
||||
this.intervalPerTick = 0;
|
||||
this.stringTables = [];
|
||||
this.sendTables = [];
|
||||
this.serverClasses = [];
|
||||
this.staticBaseLines = [];
|
||||
this.eventDefinitions = {};
|
||||
this.players = [];
|
||||
this.playerMap = {};
|
||||
this.world = {
|
||||
this.tick = 0;
|
||||
this.chat = [];
|
||||
this.users = {};
|
||||
this.deaths = [];
|
||||
this.rounds = [];
|
||||
this.startTick = 0;
|
||||
this.intervalPerTick = 0;
|
||||
this.stringTables = [];
|
||||
this.sendTables = [];
|
||||
this.serverClasses = [];
|
||||
this.staticBaseLines = [];
|
||||
this.eventDefinitions = {};
|
||||
this.players = [];
|
||||
this.playerMap = {};
|
||||
this.world = {
|
||||
boundaryMin: {x: 0, y: 0, z: 0},
|
||||
boundaryMax: {x: 0, y: 0, z: 0}
|
||||
};
|
||||
this.entityClasses = {};
|
||||
this.sendTableMap = {};
|
||||
this.entityClasses = {};
|
||||
this.sendTableMap = {};
|
||||
this.baseLineCache = {};
|
||||
}
|
||||
|
||||
getSendTable(name) {
|
||||
|
|
|
|||
|
|
@ -23,15 +23,13 @@ function readPVSType(stream: BitStream): PVS {
|
|||
return pvs;
|
||||
}
|
||||
|
||||
const baseLineCache: {[serverClass: string]: PacketEntity} = {};
|
||||
|
||||
function readEnterPVS(stream: BitStream, entityId: number, match: Match): PacketEntity {
|
||||
// https://github.com/PazerOP/DemoLib/blob/5f9467650f942a4a70f9ec689eadcd3e0a051956/TF2Net/NetMessages/NetPacketEntitiesMessage.cs#L198
|
||||
const serverClass = match.serverClasses[stream.readBits(match.classBits)];
|
||||
stream.readBits(10); // unused serial number
|
||||
|
||||
if (baseLineCache[serverClass.id]) {
|
||||
const result = baseLineCache[serverClass.id].clone();
|
||||
if (match.baseLineCache[serverClass.id]) {
|
||||
const result = match.baseLineCache[serverClass.id].clone();
|
||||
result.entityIndex = entityId;
|
||||
return result;
|
||||
} else {
|
||||
|
|
@ -44,7 +42,7 @@ function readEnterPVS(stream: BitStream, entityId: number, match: Match): Packet
|
|||
if (staticBaseLine) {
|
||||
staticBaseLine.index = 0;
|
||||
applyEntityUpdate(entity, sendTable, staticBaseLine);
|
||||
baseLineCache[serverClass.id] = entity.clone();
|
||||
match.baseLineCache[serverClass.id] = entity.clone();
|
||||
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');
|
||||
|
|
@ -56,7 +54,7 @@ function readEnterPVS(stream: BitStream, entityId: number, match: Match): Packet
|
|||
|
||||
function getPacketEntityForExisting(entityId: number, match: Match, pvs: PVS) {
|
||||
if (!match.entityClasses[entityId]) {
|
||||
throw new Error("unknown entity");
|
||||
throw new Error("unknown entity " + entityId + " for " + PVS[pvs]);
|
||||
}
|
||||
const serverClass = match.entityClasses[entityId];
|
||||
return new PacketEntity(serverClass, entityId, pvs);
|
||||
|
|
@ -89,7 +87,7 @@ export function PacketEntities(stream: BitStream, match: Match): PacketEntitiesP
|
|||
if (updatedBaseLine) {
|
||||
const newBaseLine: SendProp[] = [];
|
||||
newBaseLine.concat(packetEntity.props);
|
||||
baseLineCache[packetEntity.serverClass.id] = packetEntity.clone();
|
||||
match.baseLineCache[packetEntity.serverClass.id] = packetEntity.clone();
|
||||
}
|
||||
packetEntity.inPVS = true;
|
||||
receivedEntities.push(packetEntity);
|
||||
|
|
|
|||
BIN
src/tests/data/celt.dem
Normal file
BIN
src/tests/data/celt.dem
Normal file
Binary file not shown.
2011
src/tests/data/celt.json
Normal file
2011
src/tests/data/celt.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -17,4 +17,8 @@ suite('Parse basic demo info', () => {
|
|||
test('Parse snakewater.dem', () => {
|
||||
testDemo('snakewater');
|
||||
});
|
||||
|
||||
test('Parse demo with new celt voice codec', () => {
|
||||
testDemo('celt');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
"lib": [
|
||||
"dom",
|
||||
"es2015.promise",
|
||||
"es6"
|
||||
"es5"
|
||||
],
|
||||
"module": "ES6",
|
||||
"target": "ES6",
|
||||
"module": "commonjs",
|
||||
"target": "ES5",
|
||||
"outDir": "build",
|
||||
"rootDir": "src",
|
||||
"declaration": true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue