-
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
Improve removeXCargo functions to retain readded items properly #596
Merged
commy2
merged 14 commits into
CBATeam:master
from
jonpas:removeMagazineCargoRetainAmmoCount
Mar 20, 2017
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
49ace1b
Improve removeMagazineCargo, Correct indentation in removeXCargo
jonpas d2bce40
Improve
jonpas 4fc998d
Improve wording
jonpas 5663fcf
Add getNoLinkedItemsClass function, Improve removeBackpackCargo with …
jonpas ed86b0b
Improve removeWeaponCargo with content attachment/magazine keeping
jonpas 4a10c75
Improve getNoLinkedItemsClass header wording
jonpas 64df4a3
Streamline, Remove diag_log
jonpas 77f75c1
Add getNoLinkedItemsClass tests
jonpas f09c570
Rename getNoLinkedItemsClass function to getNonPresetClass
jonpas a562830
Add removeXCargo tests, Return empty string if invalid class, Use isN…
jonpas 5631ba3
Use CBA_fnc_weaponComponents and caching in CBA_fnc_getNonPresetClass…
jonpas 3ee210a
Fix CBA_fnc_weaponComponents caching, Improve CBA_fnc_getNonPresetCla…
jonpas 84aadef
Fix scope - preset backpacks are apparently scope = 1
jonpas dd78f4c
Cache all non-preset classes
jonpas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* ---------------------------------------------------------------------------- | ||
Function: CBA_fnc_getNonPresetClass | ||
|
||
Description: | ||
Get ancestor class of a weapon or container which has no preset attachments/contents. | ||
|
||
Parameters: | ||
_item - Classname of weapon/container <STRING> | ||
_configRoot - Root config ("CfgWeapons", "CfgVehicles", ...) <STRING> (Default: "CfgWeapons") | ||
|
||
Returns: | ||
Ancestor class without preset attachments/contents sub-class on success, "" otherwise <STRING> | ||
|
||
Examples: | ||
(begin example) | ||
// Get parent class without preset attachments of a weapon (returns "arifle_MX_F") | ||
_ancestorClass = ["arifle_MX_ACO_pointer_F"] call CBA_fnc_getNonPresetClass; | ||
(end) | ||
|
||
Author: | ||
Jonpas | ||
---------------------------------------------------------------------------- */ | ||
#include "script_component.hpp" | ||
SCRIPT(getNonPresetClass); | ||
|
||
params [["_class", "", [""]], ["_rootConfig", "CfgWeapons", [""]]]; | ||
|
||
private _config = configFile >> _rootConfig >> _class; | ||
|
||
// Invalid class/root config | ||
if (!isClass _config) exitWith { | ||
_class | ||
}; | ||
|
||
// Return current class - has no preset attachments/contents | ||
if ( | ||
// CfgWeapons | ||
(configProperties [_config >> "LinkedItems", "isClass _x", true] isEqualTo []) && | ||
// CfgVehicles | ||
{configProperties [_config >> "TransportItems", "isClass _x", true] isEqualTo []} && | ||
{configProperties [_config >> "TransportMagazines", "isClass _x", true] isEqualTo []} && | ||
{configProperties [_config >> "TransportWeapons", "isClass _x", true] isEqualTo []} | ||
) exitWith { | ||
_class | ||
}; | ||
|
||
// Check parent | ||
private _parent = inheritsFrom _config; | ||
if (_parent isEqualTo configNull) then { | ||
// We reached configNull, stuff must be invalid, return empty string | ||
"" | ||
} else { | ||
// Recursively search the ancestor tree | ||
[configName _parent, _rootConfig] call CBA_fnc_getNonPresetClass; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
isNull