mirror of
https://github.com/demostf/demo.js
synced 2026-06-04 00:54:14 +02:00
dont modify match state in gameevent packet handler
This commit is contained in:
parent
7cb74d93de
commit
95b9fb55c7
4 changed files with 18 additions and 5 deletions
|
|
@ -13,6 +13,7 @@ import {handleStringTable} from "../PacketHandler/StringTable";
|
|||
import {handleSayText2} from "../PacketHandler/SayText2";
|
||||
import {handleGameEvent} from "../PacketHandler/GameEvent";
|
||||
import {handlePacketEntities} from "../PacketHandler/PacketEntities";
|
||||
import {handleGameEventList} from "../PacketHandler/GameEventList";
|
||||
|
||||
export class Match {
|
||||
tick: number;
|
||||
|
|
@ -122,6 +123,9 @@ export class Match {
|
|||
case 'stringTable':
|
||||
handleStringTable(packet, this);
|
||||
break;
|
||||
case 'gameEventList':
|
||||
handleGameEventList(packet, this);
|
||||
break;
|
||||
case 'gameEvent':
|
||||
handleGameEvent(packet, this);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {StringTable} from "./StringTable";
|
||||
import {Vector} from "./Vector";
|
||||
import {GameEvent} from "./GameEvent";
|
||||
import {GameEvent, GameEventDefinitionMap} from "./GameEvent";
|
||||
import {PacketEntity} from "./PacketEntity";
|
||||
|
||||
export interface StringTablePacket {
|
||||
|
|
@ -42,6 +42,7 @@ export interface GameEventPacket {
|
|||
|
||||
export interface GameEventListPacket {
|
||||
packetType: 'gameEventList';
|
||||
eventList: GameEventDefinitionMap;
|
||||
}
|
||||
|
||||
export interface PacketEntitiesPacket {
|
||||
|
|
|
|||
6
src/PacketHandler/GameEventList.ts
Normal file
6
src/PacketHandler/GameEventList.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import {GameEventListPacket} from "../Data/Packet";
|
||||
import {Match} from "../Data/Match";
|
||||
|
||||
export function handleGameEventList(packet: GameEventListPacket, match: Match) {
|
||||
match.eventDefinitions = packet.eventList;
|
||||
}
|
||||
|
|
@ -5,8 +5,9 @@ import {Match} from "../../Data/Match";
|
|||
|
||||
export function GameEventList(stream: BitStream, match: Match): GameEventListPacket { // 30: gameEventList
|
||||
// list of game events and parameters
|
||||
const numEvents = stream.readBits(9);
|
||||
const length = stream.readBits(20);
|
||||
const numEvents = stream.readBits(9);
|
||||
const length = stream.readBits(20);
|
||||
const eventList: GameEventDefinitionMap = {};
|
||||
for (let i = 0; i < numEvents; i++) {
|
||||
const id = stream.readBits(9);
|
||||
const name = stream.readASCIIString();
|
||||
|
|
@ -19,13 +20,14 @@ export function GameEventList(stream: BitStream, match: Match): GameEventListPac
|
|||
});
|
||||
type = stream.readBits(3);
|
||||
}
|
||||
match.eventDefinitions[id] = {
|
||||
eventList[id] = {
|
||||
id: id,
|
||||
name: name,
|
||||
entries: entries
|
||||
};
|
||||
}
|
||||
return {
|
||||
packetType: 'gameEventList'
|
||||
packetType: 'gameEventList',
|
||||
eventList: eventList
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue