mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
schema
This commit is contained in:
parent
00610a9a95
commit
e7dec55453
4 changed files with 2934 additions and 2984 deletions
|
|
@ -264,7 +264,7 @@ pub fn generate_game_events(demo: Demo) -> TokenStream {
|
||||||
};
|
};
|
||||||
|
|
||||||
quote!(
|
quote!(
|
||||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
#[derive(Debug, BitWrite, PartialEq, Serialize, Deserialize, Clone)]
|
#[derive(Debug, BitWrite, PartialEq, Serialize, Deserialize, Clone)]
|
||||||
pub struct #name {
|
pub struct #name {
|
||||||
#(#fields)*
|
#(#fields)*
|
||||||
|
|
@ -381,7 +381,7 @@ pub fn generate_game_events(demo: Demo) -> TokenStream {
|
||||||
#(#event_definitions)*
|
#(#event_definitions)*
|
||||||
|
|
||||||
|
|
||||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
pub enum GameEvent {
|
pub enum GameEvent {
|
||||||
|
|
@ -389,7 +389,7 @@ pub fn generate_game_events(demo: Demo) -> TokenStream {
|
||||||
Unknown(RawGameEvent),
|
Unknown(RawGameEvent),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
pub enum GameEventType {
|
pub enum GameEventType {
|
||||||
#(#event_types)*
|
#(#event_types)*
|
||||||
|
|
|
||||||
64
schema.json
64
schema.json
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"title": "Packet",
|
"title": "Packet",
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -365,7 +365,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GameEvent": {
|
"GameEvent": {
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -10818,7 +10818,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GameEventType": {
|
"GameEventType": {
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
@ -11245,7 +11245,7 @@
|
||||||
"minimum": 0.0
|
"minimum": 0.0
|
||||||
},
|
},
|
||||||
"GameEventValue": {
|
"GameEventValue": {
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
|
@ -11356,7 +11356,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Message": {
|
"Message": {
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -11490,9 +11490,7 @@
|
||||||
"minimum": 0.0
|
"minimum": 0.0
|
||||||
},
|
},
|
||||||
"state": {
|
"state": {
|
||||||
"type": "integer",
|
"$ref": "#/definitions/SignOnState"
|
||||||
"format": "uint8",
|
|
||||||
"minimum": 0.0
|
|
||||||
},
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|
@ -11922,7 +11920,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"anyOf": [
|
"oneOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -12419,26 +12417,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PVS": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"Preserve",
|
|
||||||
"Leave",
|
|
||||||
"Enter",
|
|
||||||
"Delete"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"PacketEntity": {
|
"PacketEntity": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
"baseline_props",
|
||||||
"entity_index",
|
"entity_index",
|
||||||
"in_pvs",
|
"in_pvs",
|
||||||
"props",
|
"props",
|
||||||
"pvs",
|
|
||||||
"serial_number",
|
"serial_number",
|
||||||
"server_class"
|
"server_class",
|
||||||
|
"update_type"
|
||||||
],
|
],
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"baseline_props": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/SendProp"
|
||||||
|
}
|
||||||
|
},
|
||||||
"delay": {
|
"delay": {
|
||||||
"type": [
|
"type": [
|
||||||
"number",
|
"number",
|
||||||
|
|
@ -12458,9 +12454,6 @@
|
||||||
"$ref": "#/definitions/SendProp"
|
"$ref": "#/definitions/SendProp"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"pvs": {
|
|
||||||
"$ref": "#/definitions/PVS"
|
|
||||||
},
|
|
||||||
"serial_number": {
|
"serial_number": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"format": "uint32",
|
"format": "uint32",
|
||||||
|
|
@ -12468,6 +12461,9 @@
|
||||||
},
|
},
|
||||||
"server_class": {
|
"server_class": {
|
||||||
"$ref": "#/definitions/ClassId"
|
"$ref": "#/definitions/ClassId"
|
||||||
|
},
|
||||||
|
"update_type": {
|
||||||
|
"$ref": "#/definitions/UpdateType"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -12673,6 +12669,19 @@
|
||||||
"ServerClassName": {
|
"ServerClassName": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"SignOnState": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"None",
|
||||||
|
"Challenge",
|
||||||
|
"Connected",
|
||||||
|
"New",
|
||||||
|
"PreSpawn",
|
||||||
|
"Spawn",
|
||||||
|
"Full",
|
||||||
|
"ChangeLevel"
|
||||||
|
]
|
||||||
|
},
|
||||||
"StringTable": {
|
"StringTable": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
@ -12753,6 +12762,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"UpdateType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Preserve",
|
||||||
|
"Leave",
|
||||||
|
"Enter",
|
||||||
|
"Delete"
|
||||||
|
]
|
||||||
|
},
|
||||||
"UserCmd": {
|
"UserCmd": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -162,6 +162,13 @@ impl<'a> ExtraData<'a> {
|
||||||
let byte_len = (data.bit_len() / 8) as u16;
|
let byte_len = (data.bit_len() / 8) as u16;
|
||||||
ExtraData { byte_len, data }
|
ExtraData { byte_len, data }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_owned(&self) -> ExtraData<'static> {
|
||||||
|
ExtraData {
|
||||||
|
byte_len: self.byte_len,
|
||||||
|
data: self.data.to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||||
|
|
@ -179,6 +186,13 @@ impl StringTableEntry<'_> {
|
||||||
.map(|text| text.borrow())
|
.map(|text| text.borrow())
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn to_owned(&self) -> StringTableEntry<'static> {
|
||||||
|
StringTableEntry {
|
||||||
|
text: self.text.as_deref().map(|text| Cow::Owned(text.into())),
|
||||||
|
extra_data: self.extra_data.as_ref().map(|data| data.to_owned()),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BitRead<'a, LittleEndian> for StringTableEntry<'a> {
|
impl<'a> BitRead<'a, LittleEndian> for StringTableEntry<'a> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue