mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-04 02:24:12 +02:00
wip
This commit is contained in:
parent
45e9df31e5
commit
43b7270fcd
29 changed files with 3818 additions and 76 deletions
|
|
@ -1,7 +1,13 @@
|
|||
use crate::{ReadResult, Stream};
|
||||
use bitbuffer::{BitRead, BitWrite, LittleEndian};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ConsoleCmdPacket {
|
||||
pub tick: u32,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@ use serde::{Deserialize, Serialize};
|
|||
use std::cmp::min;
|
||||
use std::convert::TryFrom;
|
||||
use std::iter::once;
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(
|
||||
BitRead,
|
||||
BitWrite,
|
||||
|
|
@ -46,6 +52,10 @@ impl From<ClassId> for u16 {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, Display)]
|
||||
pub struct ServerClassName(String);
|
||||
|
||||
|
|
@ -67,6 +77,10 @@ impl From<&str> for ServerClassName {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ServerClass {
|
||||
pub id: ClassId,
|
||||
|
|
@ -74,6 +88,10 @@ pub struct ServerClass {
|
|||
pub data_table: SendTableName,
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(
|
||||
BitRead,
|
||||
BitWrite,
|
||||
|
|
@ -109,6 +127,10 @@ impl From<&str> for SendTableName {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ParseSendTable {
|
||||
pub name: SendTableName,
|
||||
|
|
@ -331,6 +353,10 @@ impl ParseSendTable {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct SendTable {
|
||||
pub name: SendTableName,
|
||||
|
|
@ -339,6 +365,10 @@ pub struct SendTable {
|
|||
pub flattened_props: Vec<SendPropDefinition>,
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct DataTablePacket {
|
||||
pub tick: u32,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@ use crate::demo::message::{Message, MessageType};
|
|||
use crate::demo::parser::Encode;
|
||||
use crate::demo::vector::Vector;
|
||||
use crate::{Parse, ParserState, ReadResult, Result, Stream};
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, BitRead, BitWrite, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MessagePacketMeta {
|
||||
pub flags: u32, // TODO
|
||||
|
|
@ -14,6 +20,10 @@ pub struct MessagePacketMeta {
|
|||
pub sequence_out: u32,
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
pub struct MessagePacket<'a> {
|
||||
|
|
@ -22,6 +32,10 @@ pub struct MessagePacket<'a> {
|
|||
pub meta: MessagePacketMeta,
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct ViewAngles {
|
||||
pub origin: (Vector, Vector),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ pub mod stop;
|
|||
pub mod stringtable;
|
||||
pub mod synctick;
|
||||
pub mod usercmd;
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
pub enum Packet<'a> {
|
||||
|
|
@ -48,6 +54,10 @@ impl Packet<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, Debug, Clone, Copy, Eq, PartialEq)]
|
||||
#[discriminant_bits = 8]
|
||||
#[repr(u8)]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
use bitbuffer::{BitRead, BitWrite};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, BitRead, BitWrite, PartialEq, Serialize, Deserialize)]
|
||||
pub struct StopPacket {
|
||||
#[size = 24]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,13 @@ use crate::demo::parser::Encode;
|
|||
use crate::{Parse, ParseError, ParserState, ReadResult, Result, Stream};
|
||||
use std::borrow::{Borrow, Cow};
|
||||
use std::cmp::min;
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct FixedUserDataSize {
|
||||
#[size = 12]
|
||||
|
|
@ -16,6 +22,10 @@ pub struct FixedUserDataSize {
|
|||
pub bits: u8,
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
pub struct StringTable<'a> {
|
||||
|
|
@ -145,6 +155,10 @@ fn test_string_table_roundtrip() {
|
|||
});
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[endianness = "LittleEndian"]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
|
|
@ -161,6 +175,10 @@ impl<'a> ExtraData<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Clone, Default, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
pub struct StringTableEntry<'a> {
|
||||
|
|
@ -211,6 +229,10 @@ impl fmt::Debug for StringTableEntry<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(bound(deserialize = "'a: 'static"))]
|
||||
pub struct StringTablePacket<'a> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
use bitbuffer::{BitRead, BitWrite};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(BitRead, BitWrite, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SyncTickPacket {
|
||||
pub tick: u32,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
use bitbuffer::{BitRead, BitReadStream, BitWrite, BitWriteStream, LittleEndian};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "wasm")]
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct UserCmdPacket {
|
||||
pub tick: u32,
|
||||
|
|
@ -31,6 +37,10 @@ impl BitWrite<LittleEndian> for UserCmdPacket {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(
|
||||
feature = "wasm",
|
||||
derive(wasm_typescript_definition::TypescriptDefinition)
|
||||
)]
|
||||
#[derive(Debug, PartialEq, BitRead, BitWrite, Serialize, Deserialize)]
|
||||
pub struct UserCmd {
|
||||
command_number: Option<u32>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue