Move carry mag getting code to function (#8888)

This commit is contained in:
Dystopian 2022-05-03 03:54:04 +04:00 committed by GitHub
parent 70641c39a1
commit 54c13c5f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 29 deletions

View File

@ -19,6 +19,7 @@ PREP(assemble_pickupWeapon);
PREP(canGetIn); PREP(canGetIn);
PREP(getIn); PREP(getIn);
PREP(getCarryMagazine);
PREP(proxyWeapon); PREP(proxyWeapon);
PREP(reload_actionsLoad); PREP(reload_actionsLoad);

View File

@ -31,13 +31,7 @@ private _allCarryMags = [];
private _weapon = _x; private _weapon = _x;
{ {
private _xMag = _x; private _xMag = _x;
private _carryMag = GVAR(vehicleMagCache) get _xMag; private _carryMag = _xMag call FUNC(getCarryMagazine);
if (isNil "_carryMag") then {
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
_carryMag = configName (_groups param [0, configNull]);
GVAR(vehicleMagCache) set [_x, _carryMag];
TRACE_2("setting cache",_xMag,_carryMag);
};
if (_carryMag != "") then { if (_carryMag != "") then {
_turretMagsCSW pushBackUnique _xMag; _turretMagsCSW pushBackUnique _xMag;
_allCarryMags pushBackUnique _carryMag; _allCarryMags pushBackUnique _carryMag;

View File

@ -41,13 +41,7 @@
{ {
_x params ["_xMag", "", "_xAmmo"]; _x params ["_xMag", "", "_xAmmo"];
private _carryMag = GVAR(vehicleMagCache) get _xMag; private _carryMag = _xMag call FUNC(getCarryMagazine);
if (isNil "_carryMag") then {
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
_carryMag = configName (_groups param [0, configNull]);
GVAR(vehicleMagCache) set [_xMag, _carryMag];
TRACE_2("setting cache",_xMag,_carryMag);
};
if ((_xAmmo > 0) && {_carryMag != ""}) then { if ((_xAmmo > 0) && {_carryMag != ""}) then {
TRACE_2("Removing ammo",_xMag,_carryMag); TRACE_2("Removing ammo",_xMag,_carryMag);
[_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo); [_player, _carryMag, _xAmmo] call FUNC(reload_handleReturnAmmo);

View File

@ -0,0 +1,28 @@
#include "script_component.hpp"
/*
* Author: PabstMirror, Dystopian
* Gets magazine that the player can carry, suitable to vehicle magazine
*
* Arguments:
* 0: Vehicle Magazine <STRING>
*
* Return Value:
* Carry Magazine <STRING>
*
* Example:
* "1Rnd_GAT_missiles" call ace_csw_fnc_getCarryMagazine
*
* Public: No
*/
params ["_vehicleMag"];
private _carryMag = GVAR(vehicleMagCache) get _vehicleMag;
if (isNil "_carryMag") then {
private _groups = "getNumber (_x >> _vehicleMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
_carryMag = configName (_groups param [0, configNull]);
GVAR(vehicleMagCache) set [_vehicleMag, _carryMag];
TRACE_2("setting cache",_vehicleMag,_carryMag);
};
_carryMag

View File

@ -60,14 +60,7 @@ private _cfgMagazines = configFile >> "CfgMagazines";
if ((_xAmmo > 0) && {!(_xMag in _handeledMagTypes)}) then { if ((_xAmmo > 0) && {!(_xMag in _handeledMagTypes)}) then {
_handeledMagTypes pushBack _xMag; _handeledMagTypes pushBack _xMag;
private _carryMag = GVAR(vehicleMagCache) get _xMag; private _carryMag = _xMag call FUNC(getCarryMagazine);
if (isNil "_carryMag") then {
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
_carryMag = configName (_groups param [0, configNull]);
GVAR(vehicleMagCache) set [_xMag, _carryMag];
TRACE_2("setting cache",_xMag,_carryMag);
};
if (_carryMag == "") exitWith {}; if (_carryMag == "") exitWith {};
private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName"); private _displayName = getText (_cfgMagazines >> _carryMag >> "displayName");

View File

@ -36,13 +36,7 @@ private _containerMagazineCount = [];
{ {
_x params ["_xMag", "_xTurret", "_xAmmo"]; _x params ["_xMag", "_xTurret", "_xAmmo"];
private _carryMag = GVAR(vehicleMagCache) get _xMag; private _carryMag = _xMag call FUNC(getCarryMagazine);
if (isNil "_carryMag") then {
private _groups = "getNumber (_x >> _xMag) == 1 && {isClass (configFile >> 'CfgMagazines' >> configName _x)}" configClasses (configFile >> QGVAR(groups));
_carryMag = configName (_groups param [0, configNull]);
GVAR(vehicleMagCache) set [_xMag, _carryMag];
TRACE_2("setting cache",_xMag,_carryMag);
};
if (_carryMag != "") then { if (_carryMag != "") then {
if ((_desiredAmmo > 0) && {_loadedMagazineInfo isEqualTo []}) then { if ((_desiredAmmo > 0) && {_loadedMagazineInfo isEqualTo []}) then {
private _loadedMagAmmo = _desiredAmmo min _xAmmo; private _loadedMagAmmo = _desiredAmmo min _xAmmo;