mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
initial handling of hl2dm
This commit is contained in:
parent
5aa5fe95fd
commit
04fc9b1f76
9 changed files with 730 additions and 479 deletions
|
|
@ -102,6 +102,9 @@ export class Match {
|
|||
userId -= 256;
|
||||
}
|
||||
const user = this.users.get(userId);
|
||||
if (user && user.userId !== userId) {
|
||||
throw new Error(`Invalid user info id`);
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
const entityInfo = this.parserState.getUserEntityInfo(userId);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
UserMessageType, UserMessageTypeMap, VoiceSubtitlePacket
|
||||
} from './UserMessage';
|
||||
import {Vector} from './Vector';
|
||||
import {Game} from './ParserState';
|
||||
|
||||
export interface StringTablePacket {
|
||||
packetType: 'stringTable';
|
||||
|
|
@ -179,7 +180,7 @@ export interface ServerInfoPacket {
|
|||
maxPlayerCount: number;
|
||||
intervalPerTick: number;
|
||||
platform: string;
|
||||
game: string;
|
||||
game: Game;
|
||||
skybox: string;
|
||||
serverName: string;
|
||||
replay: boolean;
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import {ServerClass, ServerClassId} from './ServerClass';
|
|||
import {StringTable} from './StringTable';
|
||||
import {UserEntityInfo, UserId} from './UserInfo';
|
||||
|
||||
export type Game = 'tf' | 'hl2mp';
|
||||
|
||||
export class ParserState {
|
||||
public version: number = 0;
|
||||
public staticBaseLines: Map<ServerClassId, BitStream> = new Map();
|
||||
|
|
@ -30,6 +32,7 @@ export class ParserState {
|
|||
public skippedPackets: PacketTypeId[] = [];
|
||||
public userInfo: Map<UserId, UserEntityInfo> = new Map();
|
||||
public tick: number = 0;
|
||||
public game: Game;
|
||||
|
||||
public handlePacket(packet: Packet) {
|
||||
switch (packet.packetType) {
|
||||
|
|
@ -38,6 +41,7 @@ export class ParserState {
|
|||
break;
|
||||
case 'serverInfo':
|
||||
this.version = packet.version;
|
||||
this.game = packet.game;
|
||||
break;
|
||||
case 'stringTable':
|
||||
handleStringTables(packet, this);
|
||||
|
|
@ -77,7 +81,7 @@ export class ParserState {
|
|||
}
|
||||
|
||||
public getUserEntityInfo(userId: number): UserEntityInfo {
|
||||
const info = this.userInfo.get(userId);
|
||||
const info = this.userInfo.get(JSON.parse(JSON.stringify(userId)));
|
||||
if (info) {
|
||||
return info;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue