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

Improve removeXCargo functions to retain readded items properly #596

Merged
merged 14 commits into from
Mar 20, 2017
Merged

Improve removeXCargo functions to retain readded items properly #596

merged 14 commits into from
Mar 20, 2017

Conversation

jonpas
Copy link
Member

@jonpas jonpas commented Feb 19, 2017

When merged this pull request will:

  • Add CBA_fnc_getNoLinkedItemsClass - gets the first ancestor (or just passed class) that has no preset attachments (LinkedItems) or contents (TransportX)
  • Add tests for CBA_fnc_getNoLinkedItemsClass
  • Improve CBA_fnc_removeBackpackCargo - now retains all contents of other backpacks in container
  • Improve CBA_fnc_removeMagazineCargo - now retains ammo count of other magazines in container
  • Improve CBA_fnc_removeWeaponCargo - now retains all attachments and loaded magazines of other weapons in container
  • Add basic tests for removeXCargo functions
  • Fix indentation in all removeXCargo functions to 4 spaces
  • Remove "locally" note (which is not valid anymore) from examples of all removeXCargo functions
  • Fix CBA_fnc_weaponComponents caching (was caching the result instead of passed class)

The only issue remaining is with CBA_fnc_removeBackpackCargo and CBA_fnc_removeWeaponCargo.sqf, it is not possible to readd attachments and loaded magazines directly onto a weapon inside a container, or a weapon with already set attachments and loaded magazines. The current workaround used here adds those attachments and loaded magazines next to the weapon.

@jonpas jonpas changed the title Improve removeXCargo functions to retain as much items as possible Improve removeXCargo functions to retain readded items properly Feb 19, 2017
@commy2
Copy link
Contributor

commy2 commented Feb 19, 2017

"arifle_MX_ACO_pointer_F" call CBA_fnc_getNonPresetClass
"arifle_MX_F"
//0.362713 ms
"arifle_MX_ACO_pointer_F" call CBA_fnc_weaponComponents
["arifle_mx_f","optic_aco","acc_pointer_ir"]
//0.317662 ms

CBA_fnc_getNonPresetClass also seems to report a string no matter if the weapon actually exists or not. It should ideally report "" instead.

@commy2 commy2 added this to the 3.3 milestone Feb 19, 2017

// Check parent
private _parent = inheritsFrom _config;
if (_parent isEqualTo configNull) then {
Copy link
Contributor

Choose a reason for hiding this comment

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

isNull

@jonpas
Copy link
Member Author

jonpas commented Feb 19, 2017

"arifle_MX_ACO_pointer_F" call CBA_fnc_getNonPresetClass
-> "arifle_mx_f"
//0.0830 ms - first run (full caching - currently used)
//0.0215 ms - subsequent runs (full caching - currently used)
//0.0765 ms - first run (container-only caching)
//0.0315 ms - subsequent runs (container-only caching)
"arifle_MX_ACO_pointer_F" call CBA_fnc_weaponComponents
-> ["arifle_mx_f","optic_aco","acc_pointer_ir"]
//0.0560 ms - first run
//0.0160 ms - subsequent runs
["B_AssaultPack_mcamo_Ammo", "CfgVehicles"] call CBA_fnc_getNonPresetClass
-> "B_Carryall_mcamo"
//0.0425 ms - first run
//0.0170 ms - subsequent runs

@commy2
Copy link
Contributor

commy2 commented Mar 20, 2017

execVM "\x\cba\addons\common\test_config.sqf";

15:20:13 [CBA] (common) Test OK: (CBA_fnc_inheritsFrom is defined) x\cba\addons\common\test_config.sqf:11
15:20:13 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_config.sqf:18
15:20:13 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_config.sqf:23
15:20:13 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_config.sqf:28
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getMuzzles is defined) x\cba\addons\common\test_config.sqf:35
15:20:13 [CBA] (common) Test OK: (_result isEqualTo []) x\cba\addons\common\test_config.sqf:38
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["arifle_MX_F"]) x\cba\addons\common\test_config.sqf:41
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["arifle_MX_GL_F", "GL_3GL_F"]) x\cba\addons\common\test_config.sqf:44
15:20:13 [CBA] (common) Test OK: (_result isEqualTo []) x\cba\addons\common\test_config.sqf:47
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getWeaponModes is defined) x\cba\addons\common\test_config.sqf:54
15:20:13 [CBA] (common) Test OK: (_result isEqualTo []) x\cba\addons\common\test_config.sqf:57
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["Single", "FullAuto"]) x\cba\addons\common\test_config.sqf:60
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["Single", "FullAuto"]) x\cba\addons\common\test_config.sqf:63
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["Single", "FullAuto", "fullauto_medium", "single_medium_optics1", "single_far_optics2"]) x\cba\addons\common\test_config.sqf:66
15:20:13 [CBA] (common) Test OK: (_result isEqualTo ["FirstAidKit"]) x\cba\addons\common\test_config.sqf:69
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getItemConfig is defined) x\cba\addons\common\test_config.sqf:76
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:79
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgWeapons" >> "arifle_MX_F")) x\cba\addons\common\test_config.sqf:82
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgWeapons" >> "arifle_MX_GL_F")) x\cba\addons\common\test_config.sqf:85
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgWeapons" >> "FirstAidKit")) x\cba\addons\common\test_config.sqf:88
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgMagazines" >> "30Rnd_65x39_caseless_mag")) x\cba\addons\common\test_config.sqf:91
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgGlasses" >> "G_Shades_Black")) x\cba\addons\common\test_config.sqf:94
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:97
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getObjectConfig is defined) x\cba\addons\common\test_config.sqf:104
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:107
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:110
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_Soldier_F")) x\cba\addons\common\test_config.sqf:113
15:20:13 [CBA] (common) Test OK: (isNull player || !isNull _result) x\cba\addons\common\test_config.sqf:116
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgNonAIVehicles" >> "EmptyDetector")) x\cba\addons\common\test_config.sqf:119
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgAmmo" >> "B_65x39_Caseless")) x\cba\addons\common\test_config.sqf:122
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:125
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getTurret is defined) x\cba\addons\common\test_config.sqf:132
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:135
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:138
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_MBT_01_TUSK_F")) x\cba\addons\common\test_config.sqf:141
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_MBT_01_TUSK_F")) x\cba\addons\common\test_config.sqf:144
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_MBT_01_TUSK_F")) x\cba\addons\common\test_config.sqf:147
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_MBT_01_TUSK_F" >> "Turrets" >> "MainTurret")) x\cba\addons\common\test_config.sqf:150
15:20:13 [CBA] (common) Test OK: (_result isEqualTo (configFile >> "CfgVehicles" >> "B_MBT_01_TUSK_F" >> "Turrets" >> "MainTurret" >> "Turrets" >> "CommanderOptics")) x\cba\addons\common\test_config.sqf:153
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:156
15:20:13 [CBA] (common) Test OK: (isNull _result) x\cba\addons\common\test_config.sqf:159
15:20:13 [CBA] (common) Test OK: (CBA_fnc_getNonPresetClass is defined) x\cba\addons\common\test_config.sqf:172
15:20:13 [CBA] (common) Test OK: (_result isEqualTo "arifle_mx_f") x\cba\addons\common\test_config.sqf:175
15:20:13 [CBA] (common) Test OK: (_result isEqualTo "B_Carryall_mcamo") x\cba\addons\common\test_config.sqf:178

@commy2
Copy link
Contributor

commy2 commented Mar 20, 2017

execVM "\x\cba\addons\common\test_inventory.sqf";

15:21:24 [CBA] (common) Test OK: (CBA_fnc_addWeapon is defined) x\cba\addons\common\test_inventory.sqf:13
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:16
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:19
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:22
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:30
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:33
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:36
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:39
15:21:24 [CBA] (common) Test OK: (CBA_fnc_addMagazine is defined) x\cba\addons\common\test_inventory.sqf:46
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:49
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:52
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:55
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:63
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:66
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:69
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:74
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:89
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:93
15:21:24 [CBA] (common) Test OK: (count (backpackCargo _container) == 2) x\cba\addons\common\test_inventory.sqf:94
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:102
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:106
15:21:24 [CBA] (common) Test OK: (count (itemCargo _container) == 2) x\cba\addons\common\test_inventory.sqf:107
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:115
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:119
15:21:24 [CBA] (common) Test OK: (count (magazineCargo _container) == 2) x\cba\addons\common\test_inventory.sqf:120
15:21:24 [CBA] (common) Test OK: (not (_result)) x\cba\addons\common\test_inventory.sqf:128
15:21:24 [CBA] (common) Test OK: (_result) x\cba\addons\common\test_inventory.sqf:132
15:21:24 [CBA] (common) Test OK: (count (weaponCargo _container) == 2) x\cba\addons\common\test_inventory.sqf:133

@commy2
Copy link
Contributor

commy2 commented Mar 20, 2017

Very nice!

@commy2 commy2 merged commit b9d8e31 into CBATeam:master Mar 20, 2017
@jonpas jonpas deleted the removeMagazineCargoRetainAmmoCount branch March 20, 2017 15:04
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

2 participants