mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +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!(
|
||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
#[derive(Debug, BitWrite, PartialEq, Serialize, Deserialize, Clone)]
|
||||
pub struct #name {
|
||||
#(#fields)*
|
||||
|
|
@ -381,7 +381,7 @@ pub fn generate_game_events(demo: Demo) -> TokenStream {
|
|||
#(#event_definitions)*
|
||||
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[serde(tag = "type")]
|
||||
pub enum GameEvent {
|
||||
|
|
@ -389,7 +389,7 @@ pub fn generate_game_events(demo: Demo) -> TokenStream {
|
|||
Unknown(RawGameEvent),
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", derive(schemars::JsonSchema))]
|
||||
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum GameEventType {
|
||||
#(#event_types)*
|
||||
|
|
|
|||
64
schema.json
64
schema.json
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Packet",
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -365,7 +365,7 @@
|
|||
}
|
||||
},
|
||||
"GameEvent": {
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -10818,7 +10818,7 @@
|
|||
}
|
||||
},
|
||||
"GameEventType": {
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
@ -11245,7 +11245,7 @@
|
|||
"minimum": 0.0
|
||||
},
|
||||
"GameEventValue": {
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
|
|
@ -11356,7 +11356,7 @@
|
|||
]
|
||||
},
|
||||
"Message": {
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -11490,9 +11490,7 @@
|
|||
"minimum": 0.0
|
||||
},
|
||||
"state": {
|
||||
"type": "integer",
|
||||
"format": "uint8",
|
||||
"minimum": 0.0
|
||||
"$ref": "#/definitions/SignOnState"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
|
|
@ -11922,7 +11920,7 @@
|
|||
},
|
||||
{
|
||||
"type": "object",
|
||||
"anyOf": [
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -12419,26 +12417,24 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"PVS": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Preserve",
|
||||
"Leave",
|
||||
"Enter",
|
||||
"Delete"
|
||||
]
|
||||
},
|
||||
"PacketEntity": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"baseline_props",
|
||||
"entity_index",
|
||||
"in_pvs",
|
||||
"props",
|
||||
"pvs",
|
||||
"serial_number",
|
||||
"server_class"
|
||||
"server_class",
|
||||
"update_type"
|
||||
],
|
||||
"properties": {
|
||||
"baseline_props": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/SendProp"
|
||||
}
|
||||
},
|
||||
"delay": {
|
||||
"type": [
|
||||
"number",
|
||||
|
|
@ -12458,9 +12454,6 @@
|
|||
"$ref": "#/definitions/SendProp"
|
||||
}
|
||||
},
|
||||
"pvs": {
|
||||
"$ref": "#/definitions/PVS"
|
||||
},
|
||||
"serial_number": {
|
||||
"type": "integer",
|
||||
"format": "uint32",
|
||||
|
|
@ -12468,6 +12461,9 @@
|
|||
},
|
||||
"server_class": {
|
||||
"$ref": "#/definitions/ClassId"
|
||||
},
|
||||
"update_type": {
|
||||
"$ref": "#/definitions/UpdateType"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -12673,6 +12669,19 @@
|
|||
"ServerClassName": {
|
||||
"type": "string"
|
||||
},
|
||||
"SignOnState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"None",
|
||||
"Challenge",
|
||||
"Connected",
|
||||
"New",
|
||||
"PreSpawn",
|
||||
"Spawn",
|
||||
"Full",
|
||||
"ChangeLevel"
|
||||
]
|
||||
},
|
||||
"StringTable": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -12753,6 +12762,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"UpdateType": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Preserve",
|
||||
"Leave",
|
||||
"Enter",
|
||||
"Delete"
|
||||
]
|
||||
},
|
||||
"UserCmd": {
|
||||
"type": "object",
|
||||
"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;
|
||||
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))]
|
||||
|
|
@ -179,6 +186,13 @@ impl StringTableEntry<'_> {
|
|||
.map(|text| text.borrow())
|
||||
.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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue