1
0
Fork 0
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:
Robin Appelman 2017-02-14 20:51:04 +01:00
commit 95b9fb55c7
4 changed files with 18 additions and 5 deletions

View file

@ -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;

View file

@ -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 {

View 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;
}

View file

@ -7,6 +7,7 @@ export function GameEventList(stream: BitStream, match: Match): GameEventListPac
// list of game events and parameters
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
}
}