aboutsummaryrefslogtreecommitdiff
path: root/client/src/world/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/world/mod.rs')
-rw-r--r--client/src/world/mod.rs36
1 files changed, 29 insertions, 7 deletions
diff --git a/client/src/world/mod.rs b/client/src/world/mod.rs
index ae985a6..bbc505c 100644
--- a/client/src/world/mod.rs
+++ b/client/src/world/mod.rs
@@ -1,10 +1,9 @@
+use self::map::Map;
+use crate::client::{helper::get_map_path, ClientMesgOut};
use gamenet::{
enums::{Emote, Team, Weapon},
SnapObj,
};
-
-use self::map::Map;
-use crate::client::{helper::get_map_path, ClientMesgOut};
use std::{collections::BTreeMap, fs::File};
pub mod map;
@@ -13,6 +12,10 @@ pub use gamenet::enums;
#[derive(Debug)]
pub struct Tee {
+ pub name: String,
+ pub skin: String,
+ pub clan: String,
+
pub local: bool,
pub latency: i32,
pub score: i32,
@@ -62,6 +65,9 @@ impl Default for Tee {
hook_dy: Default::default(),
hook_player: Default::default(),
hook_state: Default::default(),
+ name: Default::default(),
+ skin: Default::default(),
+ clan: Default::default(),
}
}
}
@@ -88,19 +94,20 @@ impl World {
ClientMesgOut::Snaps(s) => {
self.tees.clear();
for (id, o) in s {
+ let e = self.tees.entry(*id).or_default();
match o {
- SnapObj::ClientInfo(_o) => {
- // TODO
+ SnapObj::ClientInfo(o) => {
+ e.name = i32_to_string(o.name);
+ e.skin = i32_to_string(o.skin);
+ e.clan = i32_to_string(o.clan);
}
SnapObj::PlayerInfo(o) => {
- let e = self.tees.entry(*id).or_default();
e.local = o.local == 1;
e.team = o.team;
e.latency = o.latency;
e.score = o.score;
}
SnapObj::Character(c) => {
- let e = self.tees.entry(*id).or_default();
e.ammo = c.ammo_count;
e.weapon = c.weapon;
e.emote = c.emote;
@@ -130,3 +137,18 @@ impl World {
self.tees.values().find(|e| e.local)
}
}
+
+fn i32_to_string<const S: usize>(k: [i32; S]) -> String {
+ let mut bytes = vec![];
+ for i in 0..S {
+ bytes.push(((((k[i]) >> 24) & 0xff) - 128) as u8);
+ bytes.push(((((k[i]) >> 16) & 0xff) - 128) as u8);
+ bytes.push(((((k[i]) >> 8) & 0xff) - 128) as u8);
+ bytes.push((((k[i]) & 0xff) - 128) as u8);
+ }
+ let len = bytes.iter().position(|e| *e == 0).unwrap_or(S);
+ while bytes.len() > len {
+ bytes.pop();
+ }
+ String::from_utf8(bytes).unwrap()
+}