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

go trough an entire demo without errors

seemingly working entity parsing
This commit is contained in:
Robin Appelman 2017-02-11 16:47:19 +01:00
commit 1c33058cb4
4 changed files with 19 additions and 17 deletions

View file

@ -35,17 +35,16 @@ function readPVSType(stream: BitStream): PVS {
function readEnterPVS(stream: BitStream, entityId: number, match: Match, baseLine: number): Entity {
// https://github.com/PazerOP/DemoLib/blob/5f9467650f942a4a70f9ec689eadcd3e0a051956/TF2Net/NetMessages/NetPacketEntitiesMessage.cs#L198
const serverClass = match.serverClasses[stream.readBits(match.classBits)];
// console.log(serverClass);
const sendTable = match.getSendTable(serverClass.dataTable);
const serialNumber = stream.readBits(10);
if (!sendTable) {
throw new Error('Unknown SendTable for serverclass');
}
let entity = match.entities[entityId];
if (!entity) {
entity = new Entity(serverClass, sendTable, entityId, serialNumber);
}
// if (match.entities[entityId]) {
// console.log('overwriting entity');
// }
const entity = new Entity(serverClass, sendTable, entityId, serialNumber);
const decodedBaseLine = match.instanceBaselines[baseLine][entityId];
if (decodedBaseLine) {
@ -59,9 +58,9 @@ function readEnterPVS(stream: BitStream, entityId: number, match: Match, baseLin
const staticBaseLine = match.staticBaseLines[serverClass.id];
if (staticBaseLine) {
staticBaseLine.index = 0;
applyEntityUpdate(entity, staticBaseLine);
applyEntityUpdate(entity, staticBaseLine, sendTable);
if (staticBaseLine.bitsLeft > 7) {
console.log(staticBaseLine.length, staticBaseLine.index);
// console.log(staticBaseLine.length, staticBaseLine.index);
// throw new Error('Unexpected data left at the end of staticBaseline, ' + staticBaseLine.bitsLeft + ' bits left');
}
}
@ -109,10 +108,8 @@ export function PacketEntities(stream: BitStream, match: Match): Packet { //26:
const diff = readUBitVar(stream);
entityId += 1 + diff;
const pvs = readPVSType(stream);
console.log("entity: " + entityId, ", pvs " + PVS[pvs]);
if (pvs === PVS.ENTER) {
const entity = readEnterPVS(stream, entityId, match, baseLine);
console.log('got entity');
applyEntityUpdate(entity, stream);
match.entities[entityId] = entity;

View file

@ -18,7 +18,6 @@ export function UpdateStringTable(stream: BitStream, match: Match): Packet { //
}
const table = match.stringTables[tableId];
console.log('update table ' + table.name);
parseStringTable(data, table, changedEntries, match);
return {