mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +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};
|
||||
use crate::demo::message::gameevent::GameEventTypeId;
|
||||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -14,6 +15,26 @@ pub struct GameEventDefinition {
|
|||
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)]
|
||||
pub struct GameEventEntry {
|
||||
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);
|
||||
|
||||
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)]
|
||||
pub struct GameEventListMessage {
|
||||
pub event_list: HashMap<GameEventTypeId, GameEventDefinition>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue