mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 18:24:05 +02:00
make game event definitions sortable
This commit is contained in:
parent
2da874da18
commit
faf205c9da
2 changed files with 28 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ use crate::{MalformedDemoError, ParseError, Result};
|
||||||
|
|
||||||
pub use super::gameevent_gen::{GameEvent, GameEventType};
|
pub use super::gameevent_gen::{GameEvent, GameEventType};
|
||||||
use crate::demo::message::gameevent::GameEventTypeId;
|
use crate::demo::message::gameevent::GameEventTypeId;
|
||||||
|
use std::cmp::Ordering;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -14,6 +15,26 @@ pub struct GameEventDefinition {
|
||||||
pub entries: Vec<GameEventEntry>,
|
pub entries: Vec<GameEventEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PartialEq<GameEventDefinition> for GameEventDefinition {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.id.eq(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Eq for GameEventDefinition {}
|
||||||
|
|
||||||
|
impl PartialOrd for GameEventDefinition {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
self.id.partial_cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for GameEventDefinition {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
|
self.id.cmp(&other.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GameEventEntry {
|
pub struct GameEventEntry {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ impl ParseBitSkip for GameEventMessage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||||
pub struct GameEventTypeId(u16);
|
pub struct GameEventTypeId(u16);
|
||||||
|
|
||||||
impl BitRead<LittleEndian> for GameEventTypeId {
|
impl BitRead<LittleEndian> for GameEventTypeId {
|
||||||
|
|
@ -75,6 +75,12 @@ impl BitRead<LittleEndian> for GameEventTypeId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<GameEventTypeId> for u16 {
|
||||||
|
fn from(id: GameEventTypeId) -> Self {
|
||||||
|
id.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GameEventListMessage {
|
pub struct GameEventListMessage {
|
||||||
pub event_list: HashMap<GameEventTypeId, GameEventDefinition>,
|
pub event_list: HashMap<GameEventTypeId, GameEventDefinition>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue