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 CBA_MiscItem to virtual arsenal #744

Merged
merged 4 commits into from
Sep 12, 2017
Merged

Add CBA_MiscItem to virtual arsenal #744

merged 4 commits into from
Sep 12, 2017

Conversation

PabstMirror
Copy link
Contributor

ACE and ACRE had been setting their items as minedetectors to show up in virtual arsenal.
With Arma 1.76 they now act as real mine detectors.

This PR adds a new base CfgWeapon CBA_MiscItem that will be manually added to the "Misc Items" tab in arsenal.

Example use:

class CfgWeapons {
    class CBA_MiscItem;
    class CBA_MiscItem_ItemInfo;

    class CBA_BananaA: CBA_MiscItem {
        displayName = "Banana A";
    };
    class CBA_BananaB: CBA_MiscItem {
        displayName = "Banana B";
        scope = 2;
        class ItemInfo: CBA_MiscItem_ItemInfo {
            mass = 2;
        };
    };
};

@PabstMirror PabstMirror added the WIP label Sep 8, 2017
@@ -8,4 +8,7 @@ if (hasInterface) then {
GVAR(actionListUpdated) = false; // Set true to force recreation of actions.
GVAR(nextActionIndex) = 0; // Next index that will be given out.
GVAR(actionListPFEH) = false;

// Add CBA_MiscItems to VirtualArsenal
[missionnamespace, "arsenalOpened", {call CBA_fnc_handleArsenalOpened}] call bis_fnc_addscriptedeventhandler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check camelCase capitalization in:
XEH_preClientInit - line 13.
fnc_handleArsenalOpened - lines 13, 19, 21, 30-44, 51-57 and 60.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[missionNamespace, "arsenalOpened", {call CBA_fnc_handleArsenalOpened}] call BIS_fnc_addScriptedEventHandler;

} forEach (configProperties [configFile >> "CfgWeapons", "(isClass _x) && {(configName _x) isKindOf ['CBA_MiscItem', configFile >> 'CfgWeapons']}"]);
TRACE_2("Items to add",count _cbaMiscItems,_cbaMiscItems);


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant whitespace?



// Much of this is from fn_arsenal.sqf -> "ListAdd"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same?

class InventoryItem_Base_F;
class CBA_MiscItem_ItemInfo: InventoryItem_Base_F {
type = 302; // "bipod"
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this class (CBA_MiscItem_ItemInfo) is really needed or if the modified entries couldn't just be put in CBA_MiscItem/ItemInfo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes configs easier IMHO because you just add the 2 parent defines instead of having to add the full inhertiance from the parent.
Also makes it a drop in replacement for our existing configs (just change InventoryItem_Base_F):

    class ACE_fieldDressing: ACE_ItemCore {
        class ItemInfo: InventoryItem_Base_F {
            mass = 1;
        };
    };


#define IDC_RSCDISPLAYARSENAL_LIST 960
#define IDC_RSCDISPLAYARSENAL_TAB_CARGOMISC 24
#define IDC_RSCDISPLAYARSENAL_SORT 800
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are already part of:

#include "\a3\ui_f\hpp\defineResinclDesign.inc"

But that file cannot be included in the components script_component.hpp, because it has a double define that crashes the binarizer. It can be included in this file though.

@commy2
Copy link
Contributor

commy2 commented Sep 9, 2017

It's not really a miscellaneous item, is it? Making that isn't hard. It's a base class that specifically makes the item appear in the Virtual Arsenal. CBA_Item(Virtual)Arsenal_base? Then the name would be descriptive.

@jonpas
Copy link
Member

jonpas commented Sep 9, 2017

Technically it's a miscellaneous item that supports Virtual Arsenal, I'd call it "inventory miscellaneous item".

Most of the commented code above is copied from arsenal.sqf as @PabstMirror noted, unsure if worth updating, makes it easier to diff with original like that?

@commy2
Copy link
Contributor

commy2 commented Sep 9, 2017

Agreed, except the line in preInitClient.sqf^^

@PabstMirror
Copy link
Contributor Author

We hook into arsenal when it calls events via:

with missionnamespace do {
    [missionnamespace,"arsenalOpened",[_display,_toggleSpace]] call bis_fnc_callscriptedeventhandler;
};

With ACE items our code takes ~15ms to finish and has no problems.
ACE adds 53 items to the list, but also has 1000 hidden dogtags, which explains why this takes some amount of time.
With debuging on, the execution time went up to 100ms and it randomly started to throw script errors.
It seems like it was getting kicked out of missionNamespace, which the command with says can happen:

https://community.bistudio.com/wiki/with

when used in a do-construct in scripts with allowed suspension, an unexpected namespace switch could happen (see note below)

Example:

missionNameSpace setVariable [QGVAR(arsenalDataModified), true];
TRACE_1("finished",GVAR(arsenalDataModified));

Reported:
TRACE: finished: cba_common_arsenalDataModified=any

Solution I came up with is to do

_this spawn {
    [{
        ...
    }, _this] call CBA_fnc_directCall;
};

Which isn't pretty, but does seem to prevent problems with with and namespaces.
This should also be safe if ACRE or other addons add thousands more items to filter and process.
I'm not real familiar with this aspect of sqf, if anyone has thoughts on this please let me know.

@@ -16,66 +16,73 @@ Author:


[missionNameSpace, "arsenalOpened", {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's missionNamespace I believe.

@Killswitch00 Killswitch00 merged commit 1fa4f28 into master Sep 12, 2017
@Killswitch00 Killswitch00 deleted the cba_miscItems branch September 12, 2017 17:58
@jonpas jonpas added this to the 3.4.1 milestone Sep 12, 2017
@jonpas jonpas changed the title Add CBA_miscItems to virtual arsenal Add CBA_MiscItem to virtual arsenal Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants