mirror of
https://codeberg.org/demostf/frontend.git
synced 2026-06-04 02:34:13 +02:00
kill search
This commit is contained in:
parent
78d8d4eb9f
commit
72c4b6ee08
10 changed files with 413 additions and 117 deletions
|
|
@ -1,4 +1,13 @@
|
|||
import {BuildingState, Kill, ParsedDemo, PlayerState, ProjectileState, ProjectileType, WorldBoundaries} from "./Parser";
|
||||
import {
|
||||
BuildingState,
|
||||
Event,
|
||||
Kill,
|
||||
ParsedDemo,
|
||||
PlayerState,
|
||||
ProjectileState,
|
||||
ProjectileType,
|
||||
WorldBoundaries
|
||||
} from "./Parser";
|
||||
|
||||
function getCacheBuster(): string {
|
||||
const url = document.querySelector('script[src*="viewer"]').attributes.src.value;
|
||||
|
|
@ -33,7 +42,18 @@ export class AsyncParser {
|
|||
const cachedData: ParsedDemo = event.data.demo;
|
||||
console.log(`packed data: ${(cachedData.data.length / (1024 * 1024)).toFixed(1)}MB`);
|
||||
this.world = cachedData.world;
|
||||
this.demo = new ParsedDemo(cachedData.playerCount, cachedData.buildingCount, cachedData.projectileCount, cachedData.world, cachedData.header, cachedData.data, cachedData.kills, cachedData.playerInfo, cachedData.tickCount);
|
||||
this.demo = new ParsedDemo(
|
||||
cachedData.playerCount,
|
||||
cachedData.buildingCount,
|
||||
cachedData.projectileCount,
|
||||
cachedData.world,
|
||||
cachedData.header,
|
||||
cachedData.data,
|
||||
cachedData.kills,
|
||||
cachedData.playerInfo,
|
||||
cachedData.events,
|
||||
cachedData.tickCount
|
||||
);
|
||||
resolve(this.demo);
|
||||
}
|
||||
}
|
||||
|
|
@ -76,4 +96,8 @@ export class AsyncParser {
|
|||
getKills(): Kill[] {
|
||||
return this.demo.kills
|
||||
}
|
||||
|
||||
getEvents(): Event[] {
|
||||
return this.demo.events
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,6 +54,14 @@ export async function parseDemo(bytes: Uint8Array, progressCallback: (progress:
|
|||
let map = get_map(state);
|
||||
let data = get_data(state);
|
||||
|
||||
let events = kills.map((kill: Kill) => {
|
||||
return {
|
||||
tick: kill.tick,
|
||||
type: "kill",
|
||||
kill
|
||||
} as Event
|
||||
});
|
||||
|
||||
return new ParsedDemo(
|
||||
playerCount,
|
||||
buildingCount,
|
||||
|
|
@ -75,6 +83,7 @@ export async function parseDemo(bytes: Uint8Array, progressCallback: (progress:
|
|||
data,
|
||||
kills,
|
||||
playerInfo,
|
||||
events,
|
||||
tickCount,
|
||||
);
|
||||
}
|
||||
|
|
@ -206,8 +215,20 @@ export class ParsedDemo {
|
|||
public readonly tickCount: number;
|
||||
public readonly kills: Kill[];
|
||||
public readonly playerInfo: PlayerInfo[];
|
||||
public readonly events: Event[];
|
||||
|
||||
constructor(playerCount: number, buildingCount: number, projectileCount: number, world: WorldBoundaries, header: Header, data: Uint8Array, kills: Kill[], playerInfo: PlayerInfo[], tickCount: number) {
|
||||
constructor(
|
||||
playerCount: number,
|
||||
buildingCount: number,
|
||||
projectileCount: number,
|
||||
world: WorldBoundaries,
|
||||
header: Header,
|
||||
data: Uint8Array,
|
||||
kills: Kill[],
|
||||
playerInfo: PlayerInfo[],
|
||||
events: Event[],
|
||||
tickCount: number
|
||||
) {
|
||||
this.playerCount = playerCount;
|
||||
this.buildingCount = buildingCount;
|
||||
this.projectileCount = projectileCount;
|
||||
|
|
@ -216,6 +237,7 @@ export class ParsedDemo {
|
|||
this.data = data;
|
||||
this.kills = kills;
|
||||
this.playerInfo = playerInfo;
|
||||
this.events = events;
|
||||
this.tickCount = tickCount;
|
||||
}
|
||||
|
||||
|
|
@ -309,3 +331,11 @@ function unpackProjectile(bytes: Uint8Array, base: number, world: WorldBoundarie
|
|||
projectileType,
|
||||
}
|
||||
}
|
||||
|
||||
export type KillEvent = {
|
||||
type: "kill";
|
||||
tick: number,
|
||||
kill: Kill,
|
||||
}
|
||||
|
||||
export type Event = KillEvent;
|
||||
Loading…
Add table
Add a link
Reference in a new issue