mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-04 02:24:12 +02:00
134 lines
4.1 KiB
Rust
134 lines
4.1 KiB
Rust
/// Messages that consists only of primitives and string and can be derived
|
|
use crate::demo::data::{MaybeUtf8String, ServerTick};
|
|
use crate::Stream;
|
|
#[cfg(feature = "write")]
|
|
use bitbuffer::BitWrite;
|
|
use bitbuffer::{BitRead, LittleEndian};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct FileMessage {
|
|
pub transfer_id: u32,
|
|
pub file_name: String,
|
|
pub requested: bool,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct NetTickMessage {
|
|
pub tick: ServerTick,
|
|
pub frame_time: u16,
|
|
pub std_dev: u16,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct StringCmdMessage {
|
|
pub command: String,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
#[discriminant_bits = 8]
|
|
pub enum SignOnState {
|
|
None = 0,
|
|
Challenge,
|
|
Connected,
|
|
New,
|
|
PreSpawn,
|
|
Spawn,
|
|
Full,
|
|
ChangeLevel,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct SignOnStateMessage {
|
|
pub state: SignOnState,
|
|
pub count: u32,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct PrintMessage {
|
|
pub value: MaybeUtf8String,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct SetPauseMessage {
|
|
pub pause: bool,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct SetViewMessage {
|
|
#[size = 11]
|
|
pub index: u16,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct FixAngleMessage {
|
|
pub relative: bool,
|
|
pub x: u16,
|
|
pub y: u16,
|
|
pub z: u16,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
#[endianness = "LittleEndian"]
|
|
#[serde(bound(deserialize = "'a: 'static"))]
|
|
pub struct EntityMessage<'a> {
|
|
#[size = 11]
|
|
pub index: u16,
|
|
#[size = 9]
|
|
pub class_id: u16,
|
|
#[size = 11]
|
|
pub length: u16,
|
|
#[size = "length"]
|
|
pub data: Stream<'a>,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
#[endianness = "LittleEndian"]
|
|
#[serde(bound(deserialize = "'a: 'static"))]
|
|
pub struct MenuMessage<'a> {
|
|
pub kind: u16,
|
|
pub length: u16,
|
|
#[size = "length.saturating_mul(8)"]
|
|
pub index: Stream<'a>,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
pub struct GetCvarValueMessage {
|
|
pub cookie: u32,
|
|
pub value: String,
|
|
}
|
|
|
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
|
#[derive(BitRead, Debug, PartialEq, Serialize, Deserialize, Clone)]
|
|
#[cfg_attr(feature = "write", derive(BitWrite))]
|
|
#[endianness = "LittleEndian"]
|
|
#[serde(bound(deserialize = "'a: 'static"))]
|
|
pub struct CmdKeyValuesMessage<'a> {
|
|
pub length: u32,
|
|
#[size = "length.saturating_mul(8)"]
|
|
pub data: Stream<'a>,
|
|
}
|