Checking worn items for flag

I’ve just started trying to fiddle with the code to contribute to github rather than just pointing out issues and hoping someone both agrees with me and gets around to coding a fix. I’m currently trying to find a way to code something that checks if all items worn on a specific body part have a certain flag. I’ve been looking through the code for hours trying to find an existing example, but have not found any. I’m not overly familiar with the game’s code so I most likely missed it, I was hoping there would be a simple single function with both a body part and flag argument but it seems I am not in luck.

Could any of you more code-savvy people show me some example code that makes sure every piece of armor on a specific body part, for example bp_torso has a specified flag, for example OVERSIZE?

player::exclusive_flag_coverage does that for the entire body at once (returns a bitset).
You can use it like:

const auto coverage = g->u.exclusive_flag_coverage( "FLAG_HERE" );
bool torso_covered = coverage[bp_torso];

It would be quite easy to copy it and simplify the copy to just return “false” if any item without flag exists a given body part (or set of body parts).

[quote=“Coolthulhu, post:2, topic:10929”]player::exclusive_flag_coverage does that for the entire body at once (returns a bitset).
You can use it like:

const auto coverage = g->u.exclusive_flag_coverage( "FLAG_HERE" );
bool torso_covered = coverage[bp_torso];

It would be quite easy to copy it and simplify the copy to just return “false” if any item without flag exists a given body part (or set of body parts).[/quote]

Thanks, took some time and a bunch of fiddling since this is my first time doing this, but I’ve got it compiled and working.