Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skin paint seed, float and stickers props #144

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 175 additions & 2 deletions src/parser/src/e2e_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ pub fn _create_tests() {
custom.insert(TICK_ID, "tick");
custom.insert(STEAMID_ID, "steamid");
custom.insert(NAME_ID, "name");
custom.insert(WEAPON_STICKERS_ID, "weapon_stickers");

for (k, v) in d.df {
if let Some(real_name) = d.prop_controller.id_to_name.get(&k) {
Expand Down Expand Up @@ -1019,6 +1020,9 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap<String, Vec<GameEvent>
"is_alive".to_string(),
"user_id".to_string(),
"agent_skin".to_string(),
"weapon_stickers".to_string(),
"weapon_float".to_string(),
"weapon_paint_seed".to_string(),
];

let wanted_events = vec![];
Expand All @@ -1040,8 +1044,6 @@ fn create_data() -> (DemoOutput, PropController, BTreeMap<String, Vec<GameEvent>
};

let mut ds = Parser::new(settings, true);
// ds.is_multithreadable = false;

let file = File::open("test_demo.dem".to_string()).unwrap();
let mmap = unsafe { MmapOptions::new().map(&file).unwrap() };
let out1 = ds.parse_demo(&mmap).unwrap();
Expand Down Expand Up @@ -1142,6 +1144,7 @@ mod tests {
use crate::second_pass::game_events::EventField;
use crate::second_pass::game_events::GameEvent;
use crate::second_pass::variants::PropColumn;
use crate::second_pass::variants::Sticker;
use crate::second_pass::variants::VarVec::String;
use crate::second_pass::variants::VarVec::*;
use lazy_static::lazy_static;
Expand Down Expand Up @@ -2129,6 +2132,176 @@ mod tests {
let prop_id = out.1.name_to_id[prop.0];
assert_eq!(out.0.df[&prop_id], prop.1);
}
#[test]
fn weapon_stickers() {
let prop = (
"weapon_stickers",
PropColumn {
data: Some(Stickers(vec![
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![Sticker {
name: "eslcologne2015_signature_taz_foil".to_string(),
wear: 0.0,
id: 477,
x: 6.711e-42,
y: 6.711e-42,
}],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![Sticker {
name: "eslcologne2015_signature_taz_gold".to_string(),
wear: 0.0,
id: 478,
x: 6.711e-42,
y: 6.711e-42,
}],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
vec![],
])),
num_nones: 0,
},
);
assert_eq!(out.0.df[&WEAPON_STICKERS_ID], prop.1);
}
#[test]
fn weapon_float() {
let prop = (
"weapon_float",
PropColumn {
data: Some(F32(vec![
None,
Some(0.98352885),
None,
None,
None,
None,
Some(0.3540078),
None,
None,
None,
Some(0.43085524),
Some(0.6917364),
None,
Some(0.7812842),
None,
Some(0.25730723),
None,
Some(0.7812842),
None,
Some(0.6907767),
Some(0.43085524),
Some(0.3268206),
None,
None,
Some(0.12372956),
None,
None,
None,
Some(0.07466238),
Some(0.6907767),
None,
Some(0.12372956),
None,
None,
None,
Some(0.09038387),
Some(0.3540078),
None,
None,
Some(0.41596374),
])),
num_nones: 0,
},
);
assert_eq!(out.0.df[&WEAPON_FLOAT], prop.1);
}

#[test]
fn weapon_paint_seed() {
let prop = (
"weapon_paint_seed",
PropColumn {
data: Some(F32(vec![
None,
Some(647.8849),
None,
None,
None,
None,
Some(201.31105),
None,
None,
None,
Some(762.7262),
Some(804.3764),
None,
Some(760.18475),
None,
Some(16.234646),
None,
Some(760.18475),
None,
Some(711.0891),
Some(762.7262),
Some(377.8302),
None,
None,
Some(410.4961),
None,
None,
None,
Some(528.8964),
Some(711.0891),
None,
Some(410.4961),
None,
None,
None,
Some(976.17224),
Some(201.31105),
None,
None,
Some(362.73822),
])),
num_nones: 0,
},
);
assert_eq!(out.0.df[&WEAPON_PAINT_SEED], prop.1);
}

#[test]
fn m_nEntityId() {
let prop = (
Expand Down
33 changes: 32 additions & 1 deletion src/parser/src/first_pass/prop_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub const SPECTATOR_TEAM_NUM: u32 = 1;
pub const BUTTONS_BASEID: u32 = 100000;
pub const NORMAL_PROP_BASEID: u32 = 1000;
pub const WEAPON_SKIN_NAME: u32 = 420420420;
pub const WEAPON_SKIN_ID: u32 = 42042069;
pub const WEAPON_ORIGINGAL_OWNER_ID: u32 = 6942000;
pub const MY_WEAPONS_OFFSET: u32 = 500000;
pub const GRENADE_AMMO_ID: u32 = 1111111;
Expand All @@ -35,6 +34,11 @@ pub const NAME_ID: u32 = 100000015;
pub const PLAYER_X_ID: u32 = 100000016;
pub const PLAYER_Y_ID: u32 = 100000017;
pub const PLAYER_Z_ID: u32 = 100000018;
pub const WEAPON_STICKERS_ID: u32 = 100000019;

pub const WEAPON_SKIN_ID: u32 = 10000000;
pub const WEAPON_PAINT_SEED: u32 = 10000001;
pub const WEAPON_FLOAT: u32 = 10000002;

#[derive(Clone, Debug)]
pub struct PropController {
Expand Down Expand Up @@ -227,6 +231,33 @@ impl PropController {
is_player_prop: true,
});
}
if self.wanted_player_props.contains(&("weapon_paint_seed".to_string())) {
self.prop_infos.push(PropInfo {
id: WEAPON_PAINT_SEED,
prop_type: PropType::Custom,
prop_name: "weapon_paint_seed".to_string(),
prop_friendly_name: "weapon_paint_seed".to_string(),
is_player_prop: true,
});
}
if self.wanted_player_props.contains(&("weapon_float".to_string())) {
self.prop_infos.push(PropInfo {
id: WEAPON_FLOAT,
prop_type: PropType::Custom,
prop_name: "weapon_float".to_string(),
prop_friendly_name: "weapon_float".to_string(),
is_player_prop: true,
});
}
if self.wanted_player_props.contains(&("weapon_stickers".to_string())) {
self.prop_infos.push(PropInfo {
id: WEAPON_STICKERS_ID,
prop_type: PropType::Custom,
prop_name: "weapon_stickers".to_string(),
prop_friendly_name: "weapon_stickers".to_string(),
is_player_prop: true,
});
}
if self.wanted_player_props.contains(&("weapon_name".to_string())) {
self.prop_infos.push(PropInfo {
id: WEAPON_NAME_ID,
Expand Down
9 changes: 7 additions & 2 deletions src/parser/src/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ pub static ROUND_WIN_REASON_TO_WINNER: phf::Map<i32, &'static str> = phf_map! {
20_i32 => "CT",
};


pub static BASETYPE_DECODERS: phf::Map<&'static str, Decoder> = phf_map! {
"bool" => BooleanDecoder,
"char" => StringDecoder,
Expand Down Expand Up @@ -2388,6 +2387,9 @@ pub static TYPEHM: phf::Map<&'static str, PropType> = phf_map! {
"CCSPlayerPawn.m_bSpottedByMask" => PropType::Custom,
"agent_skin" => PropType::Custom,
"is_alive" => PropType::Custom,
"weapon_paint_seed" => PropType::Custom,
"weapon_float" => PropType::Custom,
"weapon_stickers" => PropType::Custom,
// Weapon
"m_flAnimTime" => PropType::Weapon,
"m_flSimulationTime"=> PropType::Weapon,
Expand Down Expand Up @@ -2789,6 +2791,9 @@ pub static FRIENDLY_NAMES_MAPPING: phf::Map<&'static str, &'static str> = phf_ma
"time" => "CCSPlayerPawn.m_flSimulationTime",
"health" => "CCSPlayerPawn.m_iHealth",
"life_state" => "CCSPlayerPawn.m_lifeState",
"weapon_paint_seed" => "weapon_paint_seed",
"weapon_float" => "weapon_float",
"weapon_stickers" => "weapon_stickers",
"X"=> "X",
"Y"=> "Y",
"Z"=> "Z",
Expand Down Expand Up @@ -9911,5 +9916,5 @@ pub static STICKER_ID_TO_NAME: phf::Map<u32, &'static str> = phf_map! {
6604_u32=>"community2022_ninja_smokes_foil",
6605_u32=>"community2022_old_eye_foil",
6606_u32=>"community2022_peek_foil",

};
Loading
Loading