mirror of
https://codeberg.org/icewind/tf-log-parser.git
synced 2026-11-30 04:40:47 +01:00
fixes
This commit is contained in:
parent
8d17b30682
commit
95119b9347
13 changed files with 157 additions and 161 deletions
|
|
@ -14,21 +14,16 @@ use std::ops::{Index, IndexMut};
|
|||
use std::str::FromStr;
|
||||
use steamid_ng::{AccountType, Instance, SteamID, Universe};
|
||||
|
||||
#[derive(Serialize, Copy, Clone, Eq, PartialEq, Debug, Ord, PartialOrd, Hash)]
|
||||
#[derive(Serialize, Copy, Clone, Eq, PartialEq, Debug, Ord, PartialOrd, Hash, Default)]
|
||||
pub enum Team {
|
||||
Red,
|
||||
Blue,
|
||||
#[default]
|
||||
Spectator,
|
||||
}
|
||||
|
||||
impl EventFieldFromStr for Team {}
|
||||
|
||||
impl Default for Team {
|
||||
fn default() -> Self {
|
||||
Team::Spectator
|
||||
}
|
||||
}
|
||||
|
||||
impl Team {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
|
|
@ -58,7 +53,9 @@ impl FromStr for Team {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Sequence, Serialize)]
|
||||
#[derive(
|
||||
Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Sequence, Serialize, Default,
|
||||
)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Class {
|
||||
Scout,
|
||||
|
|
@ -70,6 +67,7 @@ pub enum Class {
|
|||
Medic,
|
||||
Sniper,
|
||||
Spy,
|
||||
#[default]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
|
|
@ -92,12 +90,6 @@ impl Class {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for Class {
|
||||
fn default() -> Self {
|
||||
Class::Unknown
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Class {
|
||||
type Err = ();
|
||||
|
||||
|
|
@ -242,7 +234,7 @@ impl TryFrom<&RawSubject<'_>> for SubjectId {
|
|||
}
|
||||
}
|
||||
let Ok((_, user_id, steam_id, _)) = split_player_subject(raw) else {
|
||||
return Ok(SubjectId::MalformedPlayer(hash_player_str(*raw)));
|
||||
return Ok(SubjectId::MalformedPlayer(hash_player_str(raw)));
|
||||
};
|
||||
if let Ok(steam_id) = SteamID::from_steam2(steam_id) {
|
||||
SubjectId::Player(steam_id.account_id())
|
||||
|
|
@ -250,7 +242,7 @@ impl TryFrom<&RawSubject<'_>> for SubjectId {
|
|||
user_id
|
||||
.parse()
|
||||
.map(SubjectId::Bot)
|
||||
.unwrap_or_else(|_| SubjectId::MalformedPlayer(hash_player_str(*raw)))
|
||||
.unwrap_or_else(|_| SubjectId::MalformedPlayer(hash_player_str(raw)))
|
||||
}
|
||||
}
|
||||
RawSubject::Team(team) => SubjectId::Team(*team),
|
||||
|
|
@ -290,7 +282,7 @@ impl SubjectData {
|
|||
SubjectData::Bot { user_id, .. } => SubjectId::Bot(*user_id),
|
||||
SubjectData::Console => SubjectId::Console,
|
||||
SubjectData::World => SubjectId::World,
|
||||
SubjectData::MalformedPlayer(raw) => SubjectId::MalformedPlayer(hash_player_str(&raw)),
|
||||
SubjectData::MalformedPlayer(raw) => SubjectId::MalformedPlayer(hash_player_str(raw)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -347,7 +339,7 @@ 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))
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue