mirror of
https://codeberg.org/demostf/tf-demos-viewer.git
synced 2026-06-03 18:14:11 +02:00
cleanup
This commit is contained in:
parent
0d382e1541
commit
cf385c207d
4 changed files with 10 additions and 20 deletions
12
js/parser.ts
12
js/parser.ts
|
|
@ -4,8 +4,8 @@ export async function parseDemo(bytes: Uint8Array): Promise<ParsedDemo> {
|
||||||
let m = await import("../pkg/index.js");
|
let m = await import("../pkg/index.js");
|
||||||
const state = m.parse_demo(bytes);
|
const state = m.parse_demo(bytes);
|
||||||
|
|
||||||
let playerCount = m.get_player_count(state);
|
let playerCount = state.player_count;
|
||||||
let boundaries = m.get_boundaries(state);
|
let boundaries = state.boundaries;
|
||||||
let data = m.get_data(state);
|
let data = m.get_data(state);
|
||||||
|
|
||||||
return new ParsedDemo(playerCount, {
|
return new ParsedDemo(playerCount, {
|
||||||
|
|
@ -73,10 +73,10 @@ function unpack_angle(val: number): number {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ParsedDemo {
|
export class ParsedDemo {
|
||||||
private playerCount: number;
|
private readonly playerCount: number;
|
||||||
private world: WorldBoundaries;
|
private readonly world: WorldBoundaries;
|
||||||
private data: Uint8Array;
|
private readonly data: Uint8Array;
|
||||||
private tickCount: number;
|
private readonly tickCount: number;
|
||||||
|
|
||||||
constructor(playerCount: number, world: WorldBoundaries, data: Uint8Array) {
|
constructor(playerCount: number, world: WorldBoundaries, data: Uint8Array) {
|
||||||
this.playerCount = playerCount;
|
this.playerCount = playerCount;
|
||||||
|
|
|
||||||
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "tf-demos-viewer",
|
"name": "@demostf/parser",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"author": "Robin Appelman <robin@icewind.nl>",
|
"author": "Robin Appelman <robin@icewind.nl>",
|
||||||
"name": "tf-demos-viewer",
|
"name": "@demostf/parser",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rimraf dist pkg && webpack",
|
"build": "rimraf dist pkg && webpack",
|
||||||
|
|
|
||||||
14
src/lib.rs
14
src/lib.rs
|
|
@ -45,9 +45,9 @@ impl From<World> for WorldBoundaries {
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub struct FlatState {
|
pub struct FlatState {
|
||||||
player_count: usize,
|
pub player_count: usize,
|
||||||
|
pub boundaries: WorldBoundaries,
|
||||||
data: Box<[u8]>,
|
data: Box<[u8]>,
|
||||||
boundaries: WorldBoundaries,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FlatState {
|
impl FlatState {
|
||||||
|
|
@ -70,16 +70,6 @@ pub fn parse_demo(buffer: Box<[u8]>) -> Result<FlatState, JsValue> {
|
||||||
Ok(FlatState::new(parsed, world))
|
Ok(FlatState::new(parsed, world))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn get_boundaries(state: &FlatState) -> WorldBoundaries {
|
|
||||||
state.boundaries.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn get_player_count(state: &FlatState) -> usize {
|
|
||||||
state.player_count
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn get_data(state: FlatState) -> Box<[u8]> {
|
pub fn get_data(state: FlatState) -> Box<[u8]> {
|
||||||
state.data
|
state.data
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue