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

Fix flattening of prop definitions

This commit is contained in:
Robin Appelman 2017-02-11 15:21:07 +01:00
commit a5bfe128ed
4 changed files with 36 additions and 24 deletions

View file

@ -12,11 +12,12 @@ export function applyEntityUpdate(entity: Entity, stream: BitStream): Entity {
throw new Error('prop index out of bounds while applying update for ' + entity.sendTable.name + ' got ' + index
+ ' proptype only has ' + allProps.length + ' properties');
}
const propDefinition = allProps[index];
const existingProp = entity.getPropByDefinition(propDefinition);
const prop = existingProp ? existingProp : new SendProp(propDefinition);
prop.value = SendPropParser.decode(propDefinition, stream);
console.log(prop);
if (!existingProp) {
entity.props.push(prop);

View file

@ -60,7 +60,7 @@ function readEnterPVS(stream: BitStream, entityId: number, match: Match, baseLin
if (staticBaseLine) {
staticBaseLine.index = 0;
applyEntityUpdate(entity, staticBaseLine);
if(staticBaseLine.bitsLeft > 7) {
if (staticBaseLine.bitsLeft > 7) {
console.log(staticBaseLine.length, staticBaseLine.index);
throw new Error('Unexpected data left at the end of staticBaseline, ' + stream.bitsLeft + ' bits left');
}
@ -127,7 +127,7 @@ export function PacketEntities(stream: BitStream, match: Match): Packet { //26:
if (entity) {
applyEntityUpdate(entity, stream);
} else {
console.log( entityId, match.entities.length);
console.log(entityId, match.entities.length);
throw new Error("unknown entity");
}
} else {

View file

@ -56,12 +56,7 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
existingEntry.extraData = userData;
}
if (table.name === 'instancebaseline') {
console.log('updating instancebaseline');
if (userData) {
match.staticBaseLines[parseInt(existingEntry.text, 10)] = userData;
} else {
throw new Error('Missing baseline');
}
saveInstanceBaseLine(existingEntry, match);
}
history.push(existingEntry);
@ -69,17 +64,14 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
existingEntry.text = value;
}
} else {
if (table.name === 'instancebaseline') {
if (userData) {
match.staticBaseLines[parseInt(value, 10)] = userData;
} else {
throw new Error('Missing baseline');
}
}
table.entries[entryIndex] = {
const entry = {
text: value,
extraData: userData
};
if (table.name === 'instancebaseline') {
saveInstanceBaseLine(entry, match);
}
table.entries[entryIndex] = entry;
history.push(table.entries[entryIndex]);
}
if (history.length > 32) {
@ -87,3 +79,11 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
}
}
}
function saveInstanceBaseLine(entry: StringTableEntry, match: Match) {
if (entry.extraData) {
match.staticBaseLines[parseInt(entry.text, 10)] = entry.extraData;
} else {
throw new Error('Missing baseline');
}
}