mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-06-03 18:24:09 +02:00
btreemap
This commit is contained in:
parent
9c63c8b658
commit
eba1c81126
4 changed files with 23 additions and 10 deletions
|
|
@ -2,6 +2,7 @@ use crate::raw_event::RawSubject;
|
||||||
use enum_iterator::IntoEnumIterator;
|
use enum_iterator::IntoEnumIterator;
|
||||||
use serde::ser::SerializeMap;
|
use serde::ser::SerializeMap;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
|
use std::cmp::Ordering;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::ops::{Index, IndexMut};
|
use std::ops::{Index, IndexMut};
|
||||||
|
|
@ -249,6 +250,18 @@ impl TryFrom<&RawSubject<'_>> for SubjectData {
|
||||||
#[derive(Debug, Hash, Eq, PartialEq)]
|
#[derive(Debug, Hash, Eq, PartialEq)]
|
||||||
pub struct SteamId3(pub SteamID);
|
pub struct SteamId3(pub SteamID);
|
||||||
|
|
||||||
|
impl PartialOrd<Self> for SteamId3 {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
(u64::from(self.0)).partial_cmp(&u64::from(other.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Ord for SteamId3 {
|
||||||
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
|
(u64::from(self.0)).cmp(&u64::from(other.0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<SteamID> for SteamId3 {
|
impl From<SteamID> for SteamId3 {
|
||||||
fn from(id: SteamID) -> Self {
|
fn from(id: SteamID) -> Self {
|
||||||
SteamId3(id)
|
SteamId3(id)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::module::EventHandler;
|
||||||
use crate::raw_event::{RawEventType, RawSubject};
|
use crate::raw_event::{RawEventType, RawSubject};
|
||||||
use crate::SubjectMap;
|
use crate::SubjectMap;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ops::{Add, AddAssign};
|
use std::ops::{Add, AddAssign};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Default, PartialEq)]
|
#[derive(Debug, Serialize, Default, PartialEq)]
|
||||||
|
|
@ -40,8 +40,8 @@ impl AddAssign for ClassStat {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ClassStatsHandler {
|
pub struct ClassStatsHandler {
|
||||||
active: bool,
|
active: bool,
|
||||||
classes: HashMap<SubjectId, Class>,
|
classes: BTreeMap<SubjectId, Class>,
|
||||||
stats: HashMap<SteamId3, ClassMap<ClassStat>>,
|
stats: BTreeMap<SteamId3, ClassMap<ClassStat>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClassStatsHandler {
|
impl ClassStatsHandler {
|
||||||
|
|
@ -65,7 +65,7 @@ impl ClassStatsHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventHandler for ClassStatsHandler {
|
impl EventHandler for ClassStatsHandler {
|
||||||
type Output = HashMap<SteamId3, ClassMap<ClassStat>>;
|
type Output = BTreeMap<SteamId3, ClassMap<ClassStat>>;
|
||||||
|
|
||||||
fn does_handle(&self, ty: RawEventType) -> bool {
|
fn does_handle(&self, ty: RawEventType) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@ use crate::event::GameEvent;
|
||||||
use crate::module::EventHandler;
|
use crate::module::EventHandler;
|
||||||
use crate::raw_event::RawEventType;
|
use crate::raw_event::RawEventType;
|
||||||
use crate::SubjectMap;
|
use crate::SubjectMap;
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct HealSpreadHandler(HashMap<SteamId3, HashMap<SteamId3, u32>>);
|
pub struct HealSpreadHandler(BTreeMap<SteamId3, BTreeMap<SteamId3, u32>>);
|
||||||
|
|
||||||
impl EventHandler for HealSpreadHandler {
|
impl EventHandler for HealSpreadHandler {
|
||||||
type Output = HashMap<SteamId3, HashMap<SteamId3, u32>>;
|
type Output = BTreeMap<SteamId3, BTreeMap<SteamId3, u32>>;
|
||||||
|
|
||||||
fn does_handle(&self, ty: RawEventType) -> bool {
|
fn does_handle(&self, ty: RawEventType) -> bool {
|
||||||
matches!(ty, RawEventType::Healed)
|
matches!(ty, RawEventType::Healed)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::module::EventHandler;
|
||||||
use crate::raw_event::RawEventType;
|
use crate::raw_event::RawEventType;
|
||||||
use crate::SubjectMap;
|
use crate::SubjectMap;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -62,10 +62,10 @@ impl From<MedicStatsBuilder> for MedicStats {
|
||||||
pub struct InvalidMedicEvent(String);
|
pub struct InvalidMedicEvent(String);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct MedicStatsHandler(HashMap<SteamId3, MedicStatsBuilder>);
|
pub struct MedicStatsHandler(BTreeMap<SteamId3, MedicStatsBuilder>);
|
||||||
|
|
||||||
impl EventHandler for MedicStatsHandler {
|
impl EventHandler for MedicStatsHandler {
|
||||||
type Output = HashMap<SteamId3, MedicStats>;
|
type Output = BTreeMap<SteamId3, MedicStats>;
|
||||||
|
|
||||||
fn does_handle(&self, ty: RawEventType) -> bool {
|
fn does_handle(&self, ty: RawEventType) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue