mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
minor cleanup
This commit is contained in:
parent
a7911f2d3d
commit
2c8fe681d3
9 changed files with 93 additions and 54 deletions
|
|
@ -11,7 +11,7 @@ import {GameEventDefinition} from './GameEvent';
|
|||
import {EntityId, PacketEntity} from './PacketEntity';
|
||||
import {Player} from './Player';
|
||||
import {PlayerResource} from './PlayerResource';
|
||||
import {SendTable} from './SendTable';
|
||||
import {SendTable, SendTableName} from './SendTable';
|
||||
import {ServerClass} from './ServerClass';
|
||||
import {StringTable} from './StringTable';
|
||||
import {Team, TeamNumber} from './Team';
|
||||
|
|
@ -21,6 +21,7 @@ import {World} from './World';
|
|||
import {Round} from './Round';
|
||||
import {Chat} from './Chat';
|
||||
import {GameEvent} from './GameEventTypes';
|
||||
import {Packet} from './Packet';
|
||||
|
||||
export class Match {
|
||||
public tick: number = 0;
|
||||
|
|
@ -38,7 +39,7 @@ export class Match {
|
|||
};
|
||||
public playerEntityMap: Map<EntityId, Player> = new Map();
|
||||
public entityClasses: Map<EntityId, ServerClass> = new Map();
|
||||
public sendTables: Map<string, SendTable> = new Map();
|
||||
public sendTables: Map<SendTableName, SendTable> = new Map();
|
||||
public baseLineCache: Map<ServerClass, PacketEntity> = new Map();
|
||||
public weaponMap: Map<EntityId, Weapon> = new Map();
|
||||
public outerMap: Map<number, EntityId> = new Map();
|
||||
|
|
@ -91,7 +92,7 @@ export class Match {
|
|||
};
|
||||
}
|
||||
|
||||
public handlePacket(packet) {
|
||||
public handlePacket(packet: Packet) {
|
||||
switch (packet.packetType) {
|
||||
case 'packetEntities':
|
||||
handlePacketEntities(packet, this);
|
||||
|
|
|
|||
|
|
@ -270,7 +270,43 @@ export type Packet = BSPDecalPacket |
|
|||
PreFetchPacket |
|
||||
GetCvarValuePacket;
|
||||
|
||||
export enum PacketType {
|
||||
export type PacketType = Packet['packetType'];
|
||||
|
||||
export type PacketMapType = {
|
||||
bSPDecal: BSPDecalPacket;
|
||||
stringTable: StringTablePacket;
|
||||
createStringTable: CreateStringTablePacket;
|
||||
updateStringTable: UpdateStringTablePacket;
|
||||
dataTable: DataTablePacket;
|
||||
classInfo: ClassInfoPacket;
|
||||
entityMessage: EntityMessagePacket;
|
||||
gameEvent: GameEventPacket;
|
||||
gameEventList: GameEventListPacket;
|
||||
packetEntities: PacketEntitiesPacket;
|
||||
parseSounds: ParseSoundsPacket;
|
||||
setConVar: SetConVarPacket;
|
||||
tempEntities: TempEntitiesPacket;
|
||||
userMessage: UserMessagePacket;
|
||||
voiceInit: VoiceInitPacket;
|
||||
voiceData: VoiceDataPacket;
|
||||
menu: MenuPacket;
|
||||
consoleCmd: ConsoleCmdPacket;
|
||||
cmdKeyValues: CmdKeyValuesPacket;
|
||||
'void': VoidPacket;
|
||||
file: FilePacket;
|
||||
netTick: NetTickPacket;
|
||||
stringCmd: StringCmdPacket;
|
||||
sigOnState: SigOnStatePacket;
|
||||
print: PrintPacket;
|
||||
serverInfo: ServerInfoPacket;
|
||||
setPause: SetPausePacket;
|
||||
setView: SetViewPacket;
|
||||
fixAngle: FixAnglePacket;
|
||||
preFetch: PreFetchPacket;
|
||||
getCvarValue: GetCvarValuePacket;
|
||||
}
|
||||
|
||||
export enum PacketTypeId {
|
||||
file = 2,
|
||||
netTick = 3,
|
||||
stringCmd = 4,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
import {SendPropDefinition, SendPropFlag, SendPropType} from './SendPropDefinition';
|
||||
|
||||
export type SendTableName = string;
|
||||
|
||||
export class SendTable {
|
||||
public name: string;
|
||||
public name: SendTableName;
|
||||
public props: SendPropDefinition[];
|
||||
private cachedFlattenedProps: SendPropDefinition[];
|
||||
|
||||
constructor(name) {
|
||||
this.name = name;
|
||||
this.props = [];
|
||||
this.name = name;
|
||||
this.props = [];
|
||||
this.cachedFlattenedProps = [];
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +69,7 @@ export class SendTable {
|
|||
|
||||
private flatten() {
|
||||
const excludes: SendPropDefinition[] = this.excludes;
|
||||
const props: SendPropDefinition[] = [];
|
||||
const props: SendPropDefinition[] = [];
|
||||
this.getAllProps(excludes, props);
|
||||
|
||||
// sort often changed props before the others
|
||||
|
|
@ -75,8 +77,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++;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue