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:
parent
5b1b11220d
commit
a5bfe128ed
4 changed files with 36 additions and 24 deletions
|
|
@ -16,7 +16,7 @@ export class SendTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private flatten() {
|
private flatten() {
|
||||||
let excludes: SendPropDefinition[] = [];
|
let excludes: SendPropDefinition[] = this.excludes;
|
||||||
let props: SendPropDefinition[] = [];
|
let props: SendPropDefinition[] = [];
|
||||||
this.getAllProps(excludes, props);
|
this.getAllProps(excludes, props);
|
||||||
|
|
||||||
|
|
@ -38,19 +38,18 @@ export class SendTable {
|
||||||
getAllProps(excludes: SendPropDefinition[], props: SendPropDefinition[]) {
|
getAllProps(excludes: SendPropDefinition[], props: SendPropDefinition[]) {
|
||||||
let localProps = [];
|
let localProps = [];
|
||||||
this.getAllPropsIteratorProps(excludes, localProps, props);
|
this.getAllPropsIteratorProps(excludes, localProps, props);
|
||||||
for (let i = 0; i < localProps.length; i++) {
|
for (const localProp of localProps) {
|
||||||
props.push(localProps[i]);
|
props.push(localProp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllPropsIteratorProps(excludes: SendPropDefinition[], props: SendPropDefinition[], childProps: SendPropDefinition[]) {
|
getAllPropsIteratorProps(excludes: SendPropDefinition[], props: SendPropDefinition[], childProps: SendPropDefinition[]) {
|
||||||
for (let i = 0; i < this.props.length; i++) {
|
for (const prop of this.props) {
|
||||||
const prop = this.props[i];
|
|
||||||
if (prop.hasFlag(SendPropFlag.SPROP_EXCLUDE) || excludes.indexOf(prop) !== -1) {
|
if (prop.hasFlag(SendPropFlag.SPROP_EXCLUDE) || excludes.indexOf(prop) !== -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (excludes.filter((exclude) => {
|
if (excludes.filter((exclude) => {
|
||||||
return prop.table && exclude.name == prop.name && exclude.excludeDTName == prop.table.name;
|
return exclude.name == prop.name && exclude.excludeDTName == prop.ownerTableName;
|
||||||
}).length > 0) {
|
}).length > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +60,7 @@ export class SendTable {
|
||||||
} else {
|
} else {
|
||||||
prop.table.getAllProps(excludes, childProps);
|
prop.table.getAllProps(excludes, childProps);
|
||||||
}
|
}
|
||||||
} else if (!prop.hasFlag(SendPropFlag.SPROP_EXCLUDE)) {
|
} else {
|
||||||
props.push(prop);
|
props.push(prop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -73,6 +72,18 @@ export class SendTable {
|
||||||
}
|
}
|
||||||
return this._flattenedProps;
|
return this._flattenedProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get excludes() {
|
||||||
|
let result: SendPropDefinition[] = [];
|
||||||
|
for (const prop of this.props) {
|
||||||
|
if (prop.hasFlag(SendPropFlag.SPROP_EXCLUDE)) {
|
||||||
|
result.push(prop);
|
||||||
|
} else if (prop.type === SendPropType.DPT_DataTable && prop.table) {
|
||||||
|
result = result.concat(prop.table.excludes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
throw new Error('prop index out of bounds while applying update for ' + entity.sendTable.name + ' got ' + index
|
||||||
+ ' proptype only has ' + allProps.length + ' properties');
|
+ ' proptype only has ' + allProps.length + ' properties');
|
||||||
}
|
}
|
||||||
|
|
||||||
const propDefinition = allProps[index];
|
const propDefinition = allProps[index];
|
||||||
const existingProp = entity.getPropByDefinition(propDefinition);
|
const existingProp = entity.getPropByDefinition(propDefinition);
|
||||||
|
|
||||||
const prop = existingProp ? existingProp : new SendProp(propDefinition);
|
const prop = existingProp ? existingProp : new SendProp(propDefinition);
|
||||||
prop.value = SendPropParser.decode(propDefinition, stream);
|
prop.value = SendPropParser.decode(propDefinition, stream);
|
||||||
console.log(prop);
|
|
||||||
|
|
||||||
if (!existingProp) {
|
if (!existingProp) {
|
||||||
entity.props.push(prop);
|
entity.props.push(prop);
|
||||||
|
|
|
||||||
|
|
@ -56,12 +56,7 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
|
||||||
existingEntry.extraData = userData;
|
existingEntry.extraData = userData;
|
||||||
}
|
}
|
||||||
if (table.name === 'instancebaseline') {
|
if (table.name === 'instancebaseline') {
|
||||||
console.log('updating instancebaseline');
|
saveInstanceBaseLine(existingEntry, match);
|
||||||
if (userData) {
|
|
||||||
match.staticBaseLines[parseInt(existingEntry.text, 10)] = userData;
|
|
||||||
} else {
|
|
||||||
throw new Error('Missing baseline');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
history.push(existingEntry);
|
history.push(existingEntry);
|
||||||
|
|
||||||
|
|
@ -69,17 +64,14 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
|
||||||
existingEntry.text = value;
|
existingEntry.text = value;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (table.name === 'instancebaseline') {
|
const entry = {
|
||||||
if (userData) {
|
|
||||||
match.staticBaseLines[parseInt(value, 10)] = userData;
|
|
||||||
} else {
|
|
||||||
throw new Error('Missing baseline');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
table.entries[entryIndex] = {
|
|
||||||
text: value,
|
text: value,
|
||||||
extraData: userData
|
extraData: userData
|
||||||
};
|
};
|
||||||
|
if (table.name === 'instancebaseline') {
|
||||||
|
saveInstanceBaseLine(entry, match);
|
||||||
|
}
|
||||||
|
table.entries[entryIndex] = entry;
|
||||||
history.push(table.entries[entryIndex]);
|
history.push(table.entries[entryIndex]);
|
||||||
}
|
}
|
||||||
if (history.length > 32) {
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue