Check for dead & minor cleanup

This commit is contained in:
johnb432 2024-08-29 09:01:54 +02:00
parent cf89aade69
commit aae708ad00
4 changed files with 7 additions and 10 deletions

View File

@ -22,7 +22,7 @@
params [["_vehicle", objNull, [objNull]], ["_carryMag", "", [""]], ["_turretPath", [0], [[0]]], ["_instantReload", false, [false]], ["_clearForcedMag", true, [true]]]; params [["_vehicle", objNull, [objNull]], ["_carryMag", "", [""]], ["_turretPath", [0], [[0]]], ["_instantReload", false, [false]], ["_clearForcedMag", true, [true]]];
if !(alive _vehicle && {!isNull (_vehicle turretUnit _turretPath)}) exitWith {false}; if (!alive _vehicle || {!alive (_vehicle turretUnit _turretPath)}) exitWith {false};
// must be config case // must be config case
_carryMag = configName (configFile >> "CfgMagazines" >> _carryMag); _carryMag = configName (configFile >> "CfgMagazines" >> _carryMag);

View File

@ -26,11 +26,6 @@ if (!alive _vehicle) exitWith {createHashMap};
private _availableMagazines = createHashMap; private _availableMagazines = createHashMap;
private _fnc_addAmmo = {
params ["_magazine", "_ammo"];
_availableMagazines set [_magazine, (_availableMagazines getOrDefault [_magazine, 0]) + _ammo];
};
{ {
_x params ["_xMag", "", "_xAmmo"]; _x params ["_xMag", "", "_xAmmo"];
@ -39,7 +34,7 @@ private _fnc_addAmmo = {
private _carryMag = _xMag call FUNC(getCarryMagazine); private _carryMag = _xMag call FUNC(getCarryMagazine);
if (_carryMag isEqualTo "") then {continue}; if (_carryMag isEqualTo "") then {continue};
[_carryMag, _xAmmo] call _fnc_addAmmo _availableMagazines set [_carryMag, (_availableMagazines getOrDefault [_carryMag, 0]) + _xAmmo];
} forEach (magazinesAllTurrets _vehicle); } forEach (magazinesAllTurrets _vehicle);
if (_onlyLoaded) exitWith {_availableMagazines}; if (_onlyLoaded) exitWith {_availableMagazines};
@ -51,7 +46,9 @@ if (_sources isEqualTo []) exitWith {_availableMagazines};
{ {
private _source = _x; private _source = _x;
{ {
_x call _fnc_addAmmo _x params ["_xMag", "_xAmmo"];
_availableMagazines set [_xMag, (_availableMagazines getOrDefault [_xMag, 0]) + _xAmmo];
} forEach ([_source, _vehicle] call FUNC(getSourceCompatibleMagazines)); } forEach ([_source, _vehicle] call FUNC(getSourceCompatibleMagazines));
} forEach _sources; } forEach _sources;

View File

@ -20,7 +20,7 @@
params [["_source", objNull, [objNull]], ["_csw", objNull, [objNull]]]; params [["_source", objNull, [objNull]], ["_csw", objNull, [objNull]]];
if (isNull _source || {isNull _csw}) exitWith {[]}; if (isNull _source || {!alive _csw}) exitWith {[]};
if !(typeOf _csw in GVAR(initializedStaticTypes)) exitWith {[]}; if !(typeOf _csw in GVAR(initializedStaticTypes)) exitWith {[]};

View File

@ -18,7 +18,7 @@
params ["_vehicle"]; params ["_vehicle"];
if (!alive _vehicle) exitWith { WARNING_1("%1 not alive",_vehicle); }; if (!alive _vehicle) exitWith { WARNING_1("%1 not alive",_vehicle); };
if (!simulationEnabled _vehicle) exitWith { if (!simulationEnabled _vehicle) exitWith {
[{simulationEnabled _this}, FUNC(initVehicle), _vehicle] call CBA_fnc_waitUntilAndExecute; [{simulationEnabled _this}, LINKFUNC(initVehicle), _vehicle] call CBA_fnc_waitUntilAndExecute;
}; };
private _typeOf = typeOf _vehicle; private _typeOf = typeOf _vehicle;