1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

Change UserId to use u16

This commit is contained in:
Narcha 2023-01-07 01:32:48 +01:00
commit 256ab3760a
No known key found for this signature in database
GPG key ID: D8A068FBD60270D2
2 changed files with 11 additions and 11 deletions

View file

@ -216,7 +216,7 @@ impl From<HashMap<Class, u8>> for ClassList {
#[derive(
Debug, Clone, Serialize, Deserialize, Copy, PartialEq, Eq, Hash, Ord, PartialOrd, Default,
)]
pub struct UserId(pub u8);
pub struct UserId(pub u16);
impl<E: Endianness> BitWrite<E> for UserId {
fn write(&self, stream: &mut BitWriteStream<E>) -> ReadResult<()> {
@ -226,23 +226,23 @@ impl<E: Endianness> BitWrite<E> for UserId {
impl From<u32> for UserId {
fn from(int: u32) -> Self {
UserId((int & 255) as u8)
UserId(int as u16)
}
}
impl From<u16> for UserId {
fn from(int: u16) -> Self {
UserId((int & 255) as u8)
UserId(int)
}
}
impl From<u8> for UserId {
fn from(int: u8) -> Self {
UserId(int)
UserId(int as u16)
}
}
impl From<UserId> for u8 {
impl From<UserId> for u16 {
fn from(id: UserId) -> Self {
id.0
}
@ -254,8 +254,8 @@ impl From<UserId> for u32 {
}
}
impl PartialEq<u8> for UserId {
fn eq(&self, other: &u8) -> bool {
impl PartialEq<u16> for UserId {
fn eq(&self, other: &u16) -> bool {
self.0 == *other
}
}
@ -296,7 +296,7 @@ impl From<crate::demo::data::UserInfo> for UserInfo {
UserInfo {
classes: ClassList::default(),
name: info.player_info.name,
user_id: info.player_info.user_id.into(),
user_id: info.player_info.user_id,
steam_id: info.player_info.steam_id,
entity_id: info.entity_id,
team: Team::default(),

View file

@ -566,7 +566,7 @@ impl GameStateAnalyser {
}
TARGET => {
sentry.auto_aim_target =
UserId::from(i64::try_from(&prop.value).unwrap_or_default() as u8)
UserId::from(i64::try_from(&prop.value).unwrap_or_default() as u16)
}
SHELLS => {
sentry.shells = i64::try_from(&prop.value).unwrap_or_default() as u16
@ -676,7 +676,7 @@ impl GameStateAnalyser {
dispenser.healing = values
.iter()
.map(|val| {
UserId::from(i64::try_from(val).unwrap_or_default() as u8)
UserId::from(i64::try_from(val).unwrap_or_default() as u16)
})
.collect()
}
@ -761,7 +761,7 @@ impl GameStateAnalyser {
LEVEL => *level = i64::try_from(&prop.value).unwrap_or_default() as u8,
BUILDER => {
*builder =
UserId::from(i64::try_from(&prop.value).unwrap_or_default() as u8)
UserId::from(i64::try_from(&prop.value).unwrap_or_default() as u16)
}
MAX_HEALTH => {
*max_health = i64::try_from(&prop.value).unwrap_or_default() as u16