mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
propper skipping of TempEntities
This commit is contained in:
parent
3b805be013
commit
1fbb61f252
11 changed files with 255 additions and 163 deletions
|
|
@ -17,22 +17,23 @@ export class Match {
|
|||
sendTables: SendTable[];
|
||||
instanceBaselines: SendProp[][][];
|
||||
staticBaseLines: any[];
|
||||
_classBits: number = 0
|
||||
|
||||
constructor() {
|
||||
this.tick = 0;
|
||||
this.chat = [];
|
||||
this.users = {};
|
||||
this.deaths = [];
|
||||
this.rounds = [];
|
||||
this.startTick = 0;
|
||||
this.intervalPerTick = 0;
|
||||
this.entities = [];
|
||||
this.stringTables = [];
|
||||
this.sendTables = [];
|
||||
this.serverClasses = [];
|
||||
this.entities = [];
|
||||
this.tick = 0;
|
||||
this.chat = [];
|
||||
this.users = {};
|
||||
this.deaths = [];
|
||||
this.rounds = [];
|
||||
this.startTick = 0;
|
||||
this.intervalPerTick = 0;
|
||||
this.entities = [];
|
||||
this.stringTables = [];
|
||||
this.sendTables = [];
|
||||
this.serverClasses = [];
|
||||
this.entities = [];
|
||||
this.instanceBaselines = [[], []];
|
||||
this.staticBaseLines = [];
|
||||
this.staticBaseLines = [];
|
||||
}
|
||||
|
||||
getSendTable(name) {
|
||||
|
|
@ -55,11 +56,11 @@ export class Match {
|
|||
|
||||
getState() {
|
||||
return {
|
||||
'chat': this.chat,
|
||||
'users': this.users,
|
||||
'deaths': this.deaths,
|
||||
'rounds': this.rounds,
|
||||
'startTick': this.startTick,
|
||||
'chat': this.chat,
|
||||
'users': this.users,
|
||||
'deaths': this.deaths,
|
||||
'rounds': this.rounds,
|
||||
'startTick': this.startTick,
|
||||
'intervalPerTick': this.intervalPerTick
|
||||
};
|
||||
}
|
||||
|
|
@ -88,11 +89,11 @@ export class Match {
|
|||
if (packet.tables.userinfo) {
|
||||
for (var j = 0; j < packet.tables.userinfo.length; j++) {
|
||||
if (packet.tables.userinfo[j].extraData) {
|
||||
var name = packet.tables.userinfo[j].extraData[0];
|
||||
var steamId = packet.tables.userinfo[j].extraData[2];
|
||||
var userId = packet.tables.userinfo[j].extraData[1].charCodeAt(0);
|
||||
userState = this.getUserState(userId);
|
||||
userState.name = name;
|
||||
var name = packet.tables.userinfo[j].extraData[0];
|
||||
var steamId = packet.tables.userinfo[j].extraData[2];
|
||||
var userId = packet.tables.userinfo[j].extraData[1].charCodeAt(0);
|
||||
userState = this.getUserState(userId);
|
||||
userState.name = name;
|
||||
userState.steamId = steamId;
|
||||
}
|
||||
}
|
||||
|
|
@ -113,24 +114,24 @@ export class Match {
|
|||
packet.event.values.userid -= 256;
|
||||
}
|
||||
this.deaths.push({
|
||||
killer: packet.event.values.attacker,
|
||||
killer: packet.event.values.attacker,
|
||||
assister: assister,
|
||||
victim: packet.event.values.userid,
|
||||
weapon: packet.event.values.weapon,
|
||||
tick: this.tick
|
||||
victim: packet.event.values.userid,
|
||||
weapon: packet.event.values.weapon,
|
||||
tick: this.tick
|
||||
});
|
||||
break;
|
||||
case 'teamplay_round_win':
|
||||
if (packet.event.values.winreason !== 6) {// 6 = timelimit
|
||||
this.rounds.push({
|
||||
winner: packet.event.values.team === 2 ? 'red' : 'blue',
|
||||
length: packet.event.values.round_time,
|
||||
winner: packet.event.values.team === 2 ? 'red' : 'blue',
|
||||
length: packet.event.values.round_time,
|
||||
end_tick: this.tick
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'player_spawn':
|
||||
userId = packet.event.values.userid;
|
||||
userId = packet.event.values.userid;
|
||||
userState = this.getUserState(userId);
|
||||
if (!userState.team) { //only register first spawn
|
||||
userState.team = packet.event.values.team === 2 ? 'red' : 'blue'
|
||||
|
|
@ -154,8 +155,8 @@ export class Match {
|
|||
}
|
||||
if (!this.users[userId]) {
|
||||
this.users[userId] = {
|
||||
name: null,
|
||||
userId: userId,
|
||||
name: null,
|
||||
userId: userId,
|
||||
steamId: null,
|
||||
classes: {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,20 @@ export class SendPropDefinition {
|
|||
table: SendTable|null;
|
||||
numElements: number|null;
|
||||
arrayProperty: SendPropDefinition|null;
|
||||
ownerTableName: string;
|
||||
|
||||
constructor(type, name, flags) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.flags = flags;
|
||||
this.excludeDTName = null;
|
||||
this.lowValue = 0;
|
||||
this.highValue = 0;
|
||||
this.bitCount = 0;
|
||||
this.table = null;
|
||||
this.numElements = null;
|
||||
this.arrayProperty = null;
|
||||
constructor(type, name, flags, ownerTableName) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.flags = flags;
|
||||
this.excludeDTName = null;
|
||||
this.lowValue = 0;
|
||||
this.highValue = 0;
|
||||
this.bitCount = 0;
|
||||
this.table = null;
|
||||
this.numElements = null;
|
||||
this.arrayProperty = null;
|
||||
this.ownerTableName = ownerTableName;
|
||||
}
|
||||
|
||||
hasFlag(flag: SendPropFlag) {
|
||||
|
|
@ -33,11 +35,22 @@ export class SendPropDefinition {
|
|||
}
|
||||
|
||||
inspect() {
|
||||
return {
|
||||
name: this.name,
|
||||
type: SendPropType[this.type],
|
||||
flags: SendPropDefinition.formatFlags(this.flags)
|
||||
let data: any = {
|
||||
fromTable: this.ownerTableName,
|
||||
name: this.name,
|
||||
type: SendPropType[this.type],
|
||||
flags: SendPropDefinition.formatFlags(this.flags),
|
||||
bitCount: this.bitCount
|
||||
};
|
||||
if (this.type === SendPropType.DPT_Float) {
|
||||
data.lowValue = this.lowValue;
|
||||
data.highValue = this.highValue;
|
||||
}
|
||||
if (this.type === SendPropType.DPT_DataTable && this.table) {
|
||||
data.tableName = this.table.name;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
static formatFlags(flags: number) {
|
||||
|
|
@ -67,27 +80,27 @@ export enum SendPropType {
|
|||
|
||||
|
||||
export enum SendPropFlag {
|
||||
SPROP_UNSIGNED = (1 << 0),// Unsigned integer data.
|
||||
SPROP_COORD = (1 << 1),// If this is set, the float/vector is treated like a world coordinate.
|
||||
// Note that the bit count is ignored in this case.
|
||||
SPROP_NOSCALE = (1 << 2),// For floating point, don't scale into range, just take value as is.
|
||||
SPROP_ROUNDDOWN = (1 << 3),// For floating point, limit high value to range minus one bit unit
|
||||
SPROP_ROUNDUP = (1 << 4),// For floating point, limit low value to range minus one bit unit
|
||||
SPROP_NORMAL = (1 << 5),// If this is set, the vector is treated like a normal (only valid for vectors)
|
||||
SPROP_EXCLUDE = (1 << 6),// This is an exclude prop (not excludED, but it points at another prop to be excluded).
|
||||
SPROP_XYZE = (1 << 7),// Use XYZ/Exponent encoding for vectors.
|
||||
SPROP_INSIDEARRAY = (1 << 8),// This tells us that the property is inside an array, so it shouldn't be put into the
|
||||
// flattened property list. Its array will point at it when it needs to.
|
||||
SPROP_PROXY_ALWAYS_YES = (1 << 9),// Set for datatable props using one of the default datatable proxies like
|
||||
// SendProxy_DataTableToDataTable that always send the data to all clients.
|
||||
SPROP_CHANGES_OFTEN = (1 << 10),// this is an often changed field, moved to head of sendtable so it gets a small index
|
||||
SPROP_IS_A_VECTOR_ELEM = (1 << 11),// Set automatically if SPROP_VECTORELEM is used.
|
||||
SPROP_COLLAPSIBLE = (1 << 12),// Set automatically if it's a datatable with an offset of 0 that doesn't change the pointer
|
||||
// (ie: for all automatically-chained base classes).
|
||||
// In this case, it can get rid of this SendPropDataTable altogether and spare the
|
||||
// trouble of walking the hierarchy more than necessary.
|
||||
SPROP_COORD_MP = (1 << 13),// Like SPROP_COORD, but special handling for multiplayer games
|
||||
SPROP_UNSIGNED = (1 << 0),// Unsigned integer data.
|
||||
SPROP_COORD = (1 << 1),// If this is set, the float/vector is treated like a world coordinate.
|
||||
// Note that the bit count is ignored in this case.
|
||||
SPROP_NOSCALE = (1 << 2),// For floating point, don't scale into range, just take value as is.
|
||||
SPROP_ROUNDDOWN = (1 << 3),// For floating point, limit high value to range minus one bit unit
|
||||
SPROP_ROUNDUP = (1 << 4),// For floating point, limit low value to range minus one bit unit
|
||||
SPROP_NORMAL = (1 << 5),// If this is set, the vector is treated like a normal (only valid for vectors)
|
||||
SPROP_EXCLUDE = (1 << 6),// This is an exclude prop (not excludED, but it points at another prop to be excluded).
|
||||
SPROP_XYZE = (1 << 7),// Use XYZ/Exponent encoding for vectors.
|
||||
SPROP_INSIDEARRAY = (1 << 8),// This tells us that the property is inside an array, so it shouldn't be put into the
|
||||
// flattened property list. Its array will point at it when it needs to.
|
||||
SPROP_PROXY_ALWAYS_YES = (1 << 9),// Set for datatable props using one of the default datatable proxies like
|
||||
// SendProxy_DataTableToDataTable that always send the data to all clients.
|
||||
SPROP_CHANGES_OFTEN = (1 << 10),// this is an often changed field, moved to head of sendtable so it gets a small index
|
||||
SPROP_IS_A_VECTOR_ELEM = (1 << 11),// Set automatically if SPROP_VECTORELEM is used.
|
||||
SPROP_COLLAPSIBLE = (1 << 12),// Set automatically if it's a datatable with an offset of 0 that doesn't change the pointer
|
||||
// (ie: for all automatically-chained base classes).
|
||||
// In this case, it can get rid of this SendPropDataTable altogether and spare the
|
||||
// trouble of walking the hierarchy more than necessary.
|
||||
SPROP_COORD_MP = (1 << 13),// Like SPROP_COORD, but special handling for multiplayer games
|
||||
SPROP_COORD_MP_LOWPRECISION = (1 << 14),// Like SPROP_COORD, but special handling for multiplayer games where the fractional component only gets a 3 bits instead of 5
|
||||
SPROP_COORD_MP_INTEGRAL = (1 << 15),// SPROP_COORD_MP, but coordinates are rounded to integral boundaries
|
||||
SPROP_VARINT = (1 << 5)
|
||||
SPROP_COORD_MP_INTEGRAL = (1 << 15),// SPROP_COORD_MP, but coordinates are rounded to integral boundaries
|
||||
SPROP_VARINT = (1 << 5)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ export class SendTable {
|
|||
private _flattenedProps: SendPropDefinition[];
|
||||
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.props = [];
|
||||
this.name = name;
|
||||
this.props = [];
|
||||
this._flattenedProps = [];
|
||||
}
|
||||
|
||||
|
|
@ -16,8 +16,8 @@ export class SendTable {
|
|||
}
|
||||
|
||||
flatten() {
|
||||
let excludes = [];
|
||||
let props: SendPropDefinition[] = [];
|
||||
let excludes: SendPropDefinition[] = [];
|
||||
let props: SendPropDefinition[] = [];
|
||||
this.getAllProps(excludes, props);
|
||||
|
||||
// sort often changed props before the others
|
||||
|
|
@ -25,8 +25,8 @@ export class SendTable {
|
|||
for (let i = 0; i < props.length; i++) {
|
||||
if (props[i].hasFlag(SendPropFlag.SPROP_CHANGES_OFTEN)) {
|
||||
if (i != start) {
|
||||
const temp = props[i];
|
||||
props[i] = props[start];
|
||||
const temp = props[i];
|
||||
props[i] = props[start];
|
||||
props[start] = temp;
|
||||
}
|
||||
start++;
|
||||
|
|
@ -35,7 +35,7 @@ export class SendTable {
|
|||
this._flattenedProps = props;
|
||||
}
|
||||
|
||||
getAllProps(excludes: SendTable[], props: SendPropDefinition[]) {
|
||||
getAllProps(excludes: SendPropDefinition[], props: SendPropDefinition[]) {
|
||||
let localProps = [];
|
||||
this.getAllPropsIteratorProps(excludes, localProps, props);
|
||||
for (let i = 0; i < localProps.length; i++) {
|
||||
|
|
@ -43,18 +43,23 @@ export class SendTable {
|
|||
}
|
||||
}
|
||||
|
||||
getAllPropsIteratorProps(excludes: SendTable[], props: SendPropDefinition[], childProps: SendPropDefinition[]) {
|
||||
getAllPropsIteratorProps(excludes: SendPropDefinition[], props: SendPropDefinition[], childProps: SendPropDefinition[]) {
|
||||
for (let i = 0; i < this.props.length; i++) {
|
||||
const prop = this.props[i];
|
||||
if (prop.hasFlag(SendPropFlag.SPROP_EXCLUDE) || excludes.indexOf(prop) !== -1) {
|
||||
continue;
|
||||
}
|
||||
if (excludes.filter((exclude) => {
|
||||
return prop.table && exclude.name == prop.name && exclude.excludeDTName == prop.table.name;
|
||||
}).length > 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prop.type === SendPropType.DPT_DataTable && prop.table) {
|
||||
if (prop.hasFlag(SendPropFlag.SPROP_EXCLUDE)) {
|
||||
excludes.push(prop.table);
|
||||
} else if (excludes.indexOf(this) === -1) {
|
||||
if (prop.hasFlag(SendPropFlag.SPROP_COLLAPSIBLE)) {
|
||||
prop.table.getAllPropsIteratorProps(excludes, props, childProps);
|
||||
} else {
|
||||
prop.table.getAllProps(excludes, childProps);
|
||||
}
|
||||
if (prop.hasFlag(SendPropFlag.SPROP_COLLAPSIBLE)) {
|
||||
prop.table.getAllPropsIteratorProps(excludes, props, childProps);
|
||||
} else {
|
||||
prop.table.getAllProps(excludes, childProps);
|
||||
}
|
||||
} else if (!prop.hasFlag(SendPropFlag.SPROP_EXCLUDE)) {
|
||||
props.push(prop);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue