-
Notifications
You must be signed in to change notification settings - Fork 149
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
Joint Rails - Optimize CBA_fnc_compatibleItems
#1558
Joint Rails - Optimize CBA_fnc_compatibleItems
#1558
Conversation
Current implementation reports config case of the items. What case does this return? All lower? Config? Whatever is listed inside This must not change for sake of bwc. |
This still returns config case (as far as my testing has shown). It's much the same case as for |
Dedmen was able to confirm that both |
Someone who knows how to set up a config with broken case should test that. Otherwise, this PR may silently break a ton of stuff in ACE and other places. |
I don't quite know what you mean by broken case, but I have tried the following:
I will gladly test broken case configs, but I need to know how to create one. |
seems like we could use the alt syntax to do the filtering as well?
|
On my big modset
but
|
class CfgMagazines {
class RPG32_F;
class CBA_TestMagazine: RPG32_F {};
};
class CfgWeapons {
class CBA_MiscItem;
class CBA_MiscItem_ItemInfo;
class CBA_TestOptic: CBA_MiscItem {
class ItemInfo: CBA_MiscItem_ItemInfo {};
};
class Launcher;
class Launcher_Base_F: Launcher {
class WeaponSlotsInfo;
};
class CBA_TestLauncher: Launcher_Base_F {
magazines[] = {"CBA_TESTmagazine"};
class WeaponSlotsInfo: WeaponSlotsInfo {
allowedSlots[] = {};
class CowsSlot {
compatibleItems[] = {"CBA_TESToptic"};
};
class MuzzleSlot {};
class PointerSlot {};
};
};
}; From memory: CBA_fnc_compatibleMagazines must report CBA_TestMagazine. CBA_fnc_compatibleItems must report CBA_TestOptic. Please double check that case does not change before and after the PR. Duplicates should be fine I guess. To complete this, would also need time comparisions between both versions. |
Well.. I managed to break I used the following config and packed it into a PBO: class CfgWeapons {
class rhs_weap_ak74m_Base_F;
class rhs_weap_ak74m: rhs_weap_ak74m_Base_F {
class WeaponSlotsInfo;
};
class rhs_weap_ak74m_zenitco01: rhs_weap_ak74m {
class WeaponSlotsInfo: WeaponSlotsInfo {};
};
class rhs_weap_ak74m_zenitco01_b33: rhs_weap_ak74m_zenitco01 {
class WeaponSlotsInfo: WeaponSlotsInfo {};
};
}; This gave compatibleItems[] = {"rhs_acc_npz"}; The game does not allow you to equip In some cases, |
Unfortunately not, because of broken configs. This can be tested by anyone fairly easily: |
compatibleItems "CBA_TestLauncher" // returns ["CBA_TestOptic"], 0.0009 ms
"CBA_TestLauncher" call CBA_fnc_compatibleItems // returns ["CBA_TestOptic"], 0.0046 ms (old)
compatibleMagazines "CBA_TestLauncher" // returns ["CBA_TestMagazine"], 0.0009 ms
"CBA_TestLauncher" call CBA_fnc_compatibleMagazines // returns ["CBA_TestMagazine"], 0.0054 ms (old) I'll add the new compile versions shortly. |
When running (the proposed changed one) "CBA_TestLauncher" call CBA_fnc_compatibleItems it throws errors:
It returns the correct answer, but given the errors - I doubt this will be accepted as it is at the moment. However, if wanted, I still suggest:
So, if you guys give me the green light, I will apply the above mentioned suggestions to the original function in this PR. |
Please send that bug report to me, at best via Discord there I won't miss it. Add scope=1 or scope=2 to the config (like every usable weapon has) and the warnings go away |
The more I try to figure out a more robust way to select which slot to pick, the more I realise the current CBA_fnc_compatibleItems filter is also not reliable. |
So the duplicate items issue is related to wrong configs, where a weapon has multiple slots defined that have similar compatible items. So the |
As for the type filter, the most reliable method I can think of so far (although it is still a config thing that could be changed by someone) is checking which These are the There could be multiple slots defined for each slot type, as there is a limit of 5 slots in the engine. (Not sure what the fifth is supposed to be used for normally) |
That's not how any of this works lol ^ |
Enlighten me how it does work then? Because I spent quite a bit of time looking at the engine code and at several mods to see how it works and how they are configured... |
My project was to improve
This PR with commit e703926 addresses or incorporates all of the points above. However, there is a small cost to pay: As it is now in CBA:
As suggested with e703926:
The proposed option is faster (sometimes much faster) in nearly every case, except the first one - which is probably the most common use case. Slower by 3 ns, due to more checks for the type filter. My question is: Is this acceptable? |
|
CBA_fnc_compatibleItems
For updated information, see #1558 (comment).
When merged this pull request will:
- Uses 2.10 command (compatibleItems)When 2.12 is released, the following (or similar) can probably replace everything after and including line 44 (if it's same or faster):