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

feat: query for info only from ticks that satisfy specific prop states conditions #209

Merged
merged 16 commits into from
Sep 17, 2024

Conversation

dankotov
Copy link
Contributor

bar the translation of user input into PropInfo vector

bar the translation of user input into PropInfo vector
@LaihoE
Copy link
Owner

LaihoE commented Aug 22, 2024

looks good so far, check discord for some more info

@dankotov
Copy link
Contributor Author

dankotov commented Aug 22, 2024

@LaihoE tested to work with basic condition like

let wanted_props = vec!["X".to_string()];
let mut wanted_prop_states: AHashMap<String, Variant> = AHashMap::new();
wanted_prop_states.insert(
    "CCSGameRulesProxy.CCSGameRules.m_bBombPlanted".to_string(),
    Variant::Bool(false),
);

let huf = create_huffman_lookup_table();
let settings = ParserInputs {
    wanted_players: vec![],
    real_name_to_og_name: AHashMap::default(),
    wanted_player_props: wanted_props.clone(),
    wanted_events: vec![],
    wanted_other_props: vec![],
    parse_ents: true,
    wanted_ticks: vec![],
    parse_projectiles: true,
    only_header: false,
    count_props: false,
    only_convars: false,
    huffman_lookup_table: &huf,
    order_by_steamid: false,
    wanted_prop_states: wanted_prop_states,
};
let mut ds = Parser::new(settings, ParsingMode::Normal);
let file = File::open(path_to_demo).unwrap();
let mmap = unsafe { MmapOptions::new().map(&file).unwrap() };
let _output = ds.parse_demo(&mmap).unwrap();

@dankotov dankotov changed the title feat: wanted prop states check skeleton feat: query for info only from ticks that satisfy specific wanted prop states Aug 23, 2024
@dankotov dankotov changed the title feat: query for info only from ticks that satisfy specific wanted prop states feat: query for info only from ticks that satisfy specific prop states conditions Aug 23, 2024
@LaihoE
Copy link
Owner

LaihoE commented Aug 23, 2024

Sorry for the late reply.

Yes prop_controller is some horrible code that needs to be refactored. And very much true that the if statements were already getting quite ridiculous, and now double the amount is maybe a little too much. If you want to try to simplify it then that would be great.

As for "is_player_prop" it is used in game events for something. I think it is to know where to look for the value (from the perspective of the player or something i don't quite remember) but maybe this could also be implemented in some other way.

@dankotov
Copy link
Contributor Author

dankotov commented Aug 23, 2024

@LaihoE no worries on the late reply

Yeah, I can refactor those if statements. I just have a few more questions to better understand the set_custom_propinfos function.

If I interpret it correctly, it sets PropInfo for A) Buttons B) Ticks, SteamID, Name C) Props that are of type PropType::Custom. The reason for it setting those separately is because those props have specific unique ids. The A and B part I think are fine, the wealth of the code is caused by C. I see that there is a TYPEHM map in maps.rs which maps prop string names to corresponding PropType. My initial idea was to retrieve all keys from that map, for which the value is PropType::Custom, and iterate over the keys, and doing the if check for each key. However, I noticed that not all prop names referenced in the if statements were present in TYPEHM, for example velocity_X/Y/Z or weapon_skin(_id). Is that by design? Or were they just missed accidentally? If I could add the missing prop names to TYPEHM I think this refactor would be elegant and quick.

As for the is_player_prop, at the moment, I believe, whether a prop is a player prop is derived by which parser input array it was put into by the end user - wanted_player_props or wanted_other_props. Is there a reason why we dont hardcode (using some kind of a map, perhaps just a name to boolean) to whether a prop is a player prop or not?

@LaihoE
Copy link
Owner

LaihoE commented Aug 23, 2024

You can just add all the A) Buttons B) Ticks, SteamID, Name C) as PropType::Custom 👍

You are probably right about the is_player_prop. I don't really remember much about its role.

@dankotov dankotov force-pushed the feat/game-state-condition-queries branch from eb3c7c6 to 2917165 Compare August 28, 2024 21:27
@dankotov dankotov force-pushed the feat/game-state-condition-queries branch 12 times, most recently from 7c05bb2 to ee75355 Compare August 29, 2024 15:31
@dankotov dankotov force-pushed the feat/game-state-condition-queries branch from ee75355 to 0177420 Compare August 29, 2024 15:52
@dankotov dankotov force-pushed the feat/game-state-condition-queries branch 3 times, most recently from 0f67ee2 to 5f0a5c7 Compare August 29, 2024 21:58
@dankotov dankotov force-pushed the feat/game-state-condition-queries branch 3 times, most recently from 2e41b95 to 16c4cc5 Compare August 29, 2024 23:10
@dankotov dankotov force-pushed the feat/game-state-condition-queries branch from 16c4cc5 to bdb2a1a Compare August 29, 2024 23:17
@LaihoE
Copy link
Owner

LaihoE commented Aug 31, 2024

Are we ready to merge?

@dankotov
Copy link
Contributor Author

Not yet. Need to add 1 more Rust test case and JS bindings.

@dankotov
Copy link
Contributor Author

dankotov commented Sep 1, 2024

^ Had to remove other wanted states as querying for prop states while parsing event(s) not yet implemented and "other" props do not work when parsing ticks.

Will probably implement querying for prop states while parsing event(s) in another PR down the line.

@dankotov dankotov force-pushed the feat/game-state-condition-queries branch from ddd568e to db81084 Compare September 13, 2024 05:21
@dankotov dankotov marked this pull request as ready for review September 17, 2024 13:47
@LaihoE LaihoE merged commit 2354809 into LaihoE:main Sep 17, 2024
6 checks passed
@LaihoE
Copy link
Owner

LaihoE commented Sep 17, 2024

LGTM. Will create a new release soon.

@dankotov dankotov deleted the feat/game-state-condition-queries branch September 17, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants