mirror of
https://github.com/demostf/demo.js
synced 2026-06-03 16:44:12 +02:00
save baseline in packet handler instead of parser
This commit is contained in:
parent
fc6d758a31
commit
5fcbbe540e
2 changed files with 15 additions and 16 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import {StringTablePacket} from "../Data/Packet";
|
||||
import {Match} from "../Data/Match";
|
||||
import {StringTableEntry} from "../Data/StringTable";
|
||||
|
||||
export function handleStringTable(packet: StringTablePacket, match: Match) {
|
||||
for (const table of packet.tables) {
|
||||
|
|
@ -20,5 +21,18 @@ export function handleStringTable(packet: StringTablePacket, match: Match) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (table.name === 'instancebaseline') {
|
||||
for (const instanceBaseLine of table.entries) {
|
||||
saveInstanceBaseLine(instanceBaseLine, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveInstanceBaseLine(entry: StringTableEntry, match: Match) {
|
||||
if (entry.extraData) {
|
||||
match.staticBaseLines[parseInt(entry.text, 10)] = entry.extraData;
|
||||
} else {
|
||||
throw new Error('Missing baseline');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,23 +55,16 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
|
|||
if (userData) {
|
||||
existingEntry.extraData = userData;
|
||||
}
|
||||
if (table.name === 'instancebaseline') {
|
||||
saveInstanceBaseLine(existingEntry, match);
|
||||
}
|
||||
history.push(existingEntry);
|
||||
|
||||
if (value) {
|
||||
existingEntry.text = value;
|
||||
}
|
||||
} else {
|
||||
const entry = {
|
||||
table.entries[entryIndex] = {
|
||||
text: value,
|
||||
extraData: userData
|
||||
};
|
||||
if (table.name === 'instancebaseline') {
|
||||
saveInstanceBaseLine(entry, match);
|
||||
}
|
||||
table.entries[entryIndex] = entry;
|
||||
history.push(table.entries[entryIndex]);
|
||||
}
|
||||
if (history.length > 32) {
|
||||
|
|
@ -79,11 +72,3 @@ export function parseStringTable(stream: BitStream, table: StringTable, entries:
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveInstanceBaseLine(entry: StringTableEntry, match: Match) {
|
||||
if (entry.extraData) {
|
||||
match.staticBaseLines[parseInt(entry.text, 10)] = entry.extraData;
|
||||
} else {
|
||||
throw new Error('Missing baseline');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue