-
Notifications
You must be signed in to change notification settings - Fork 148
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 CBA_fnc_compatibleMagazines that supports mag wells #965
Conversation
For consistency with compatibleItems, I would change the name to compatibleMagazines (remove "get"). I think it would be worth it to implement caching: |
The function should also report all entries lower case. |
I thought it would be harder to cache because I wanted to support sub-muzzles like I like config capitalization because you can use edit, also should this go in addons/jr, next to fnc_compatibleItems? It's not really JR related. |
I guess the JAM component, but that doesn't exist yet. Common is fine for now imo. |
All lower case means |
Config case would simplify a func like this |
Whatever we go with, it should be clarified in the function header. |
ACE Arsenal would prefer configCase I think. |
Function: CBA_fnc_compatibleMagazines | ||
|
||
Description: | ||
Retrievs a list of magazines that are compatible with a weapon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retrieves
|
||
private _returnMags = GVAR(magNamespace) getVariable _cacheKey; | ||
|
||
if (isNil "_returnMags") then { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be replaced with early return
if (!isNil "_returnMags") exitWith {_returnMags};
if (!isNil "_returnMags") exitWith {+_returnMags};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget to copy the returned array, otherwise someone will mess up the cache by editing it by reference.
Because of mag wells it's no longer safe to do simple code like
private _weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
The filtering gets expensive, and might not always be needed, so I added a param for it
rhs_weap_m27iar_grip
with 57 filtered entries is 0.26 msfast way is 0.028 ms but produces 69 entries because of duplicates and no guarantees that
in
is safe to use