Minor cleanup

This commit is contained in:
johnb432 2024-02-12 12:59:59 +01:00
parent b5dfe0a346
commit 70b21f6cec
2 changed files with 68 additions and 65 deletions

View File

@ -14,77 +14,77 @@
_source say3D _scream; _source say3D _scream;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
if (isServer) then { if (!isServer) exitWith {};
["CBA_settingsInitialized", {
TRACE_1("settingsInit",GVAR(enabled));
if (!GVAR(enabled)) exitWith {}; ["CBA_settingsInitialized", {
TRACE_1("settingsInit",GVAR(enabled));
GVAR(fireSources) = createHashMap; if (!GVAR(enabled)) exitWith {};
[QGVAR(addFireSource), { GVAR(fireSources) = createHashMap;
params [
["_source", objNull, [objNull, []]],
["_radius", 0, [0]],
["_intensity", 0, [0]],
["_key", ""],
["_condition", {true}],
["_conditionArgs", []]
];
private _isObject = _source isEqualType objNull; [QGVAR(addFireSource), {
params [
["_source", objNull, [objNull, []]],
["_radius", 0, [0]],
["_intensity", 0, [0]],
["_key", ""],
["_condition", {true}],
["_conditionArgs", []]
];
// Check if the source is valid private _isObject = _source isEqualType objNull;
if !(_isObject || {_source isEqualTypeParams [0, 0, 0]}) exitWith {};
if (_isObject && {isNull _source}) exitWith {}; // Check if the source is valid
if (_radius == 0 || _intensity == 0) exitWith {}; if !(_isObject || {_source isEqualTypeParams [0, 0, 0]}) exitWith {};
if (_key isEqualTo "") exitWith {}; // key can be many types
// If a position is passed, create a static object at said position if (_isObject && {isNull _source}) exitWith {};
private _sourcePos = if (_isObject) then { if (_radius == 0 || _intensity == 0) exitWith {};
getPosATL _source if (_key isEqualTo "") exitWith {}; // key can be many types
} else {
ASLToATL _source
};
private _fireLogic = createVehicle [QGVAR(logic), _sourcePos, [], 0, "CAN_COLLIDE"]; // If a position is passed, create a static object at said position
private _sourcePos = if (_isObject) then {
getPosATL _source
} else {
ASLToATL _source
};
// If an object was passed, attach logic to the object private _fireLogic = createVehicle [QGVAR(logic), _sourcePos, [], 0, "CAN_COLLIDE"];
if (_isObject) then {
_fireLogic attachTo [_source];
};
// hashValue supports more types than hashmaps do by default, but not all (e.g. locations) // If an object was passed, attach logic to the object
private _hashedKey = hashValue _key; if (_isObject) then {
_fireLogic attachTo [_source];
};
if (isNil "_hashedKey") exitWith { // hashValue supports more types than hashmaps do by default, but not all (e.g. locations)
ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key); private _hashedKey = hashValue _key;
};
// To avoid issues, remove existing entries first before overwriting if (isNil "_hashedKey") exitWith {
if (_hashedKey in GVAR(fireSources)) then { ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key);
[QGVAR(removeFireSource), _key] call CBA_fnc_localEvent; };
};
GVAR(fireSources) set [_hashedKey, [_fireLogic, _radius, _intensity, _condition, _conditionArgs]]; // To avoid issues, remove existing entries first before overwriting
}] call CBA_fnc_addEventHandler; if (_hashedKey in GVAR(fireSources)) then {
[QGVAR(removeFireSource), _key] call CBA_fnc_localEvent;
};
[QGVAR(removeFireSource), { GVAR(fireSources) set [_hashedKey, [_fireLogic, _radius, _intensity, _condition, _conditionArgs]];
params ["_key"];
private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith {
ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key);
};
(GVAR(fireSources) deleteAt _hashedKey) params [["_fireLogic", objNull]];
detach _fireLogic;
deleteVehicle _fireLogic;
}] call CBA_fnc_addEventHandler;
[LINKFUNC(fireManagerPFH), FIRE_MANAGER_PFH_DELAY, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler; }] call CBA_fnc_addEventHandler;
};
[QGVAR(removeFireSource), {
params ["_key"];
private _hashedKey = hashValue _key;
if (isNil "_hashedKey") exitWith {
ERROR_3("Unsupported key type used: %1 - %2 - %3",_key,typeName _key,typeOf _key);
};
(GVAR(fireSources) deleteAt _hashedKey) params [["_fireLogic", objNull]];
detach _fireLogic;
deleteVehicle _fireLogic;
}] call CBA_fnc_addEventHandler;
[LINKFUNC(fireManagerPFH), FIRE_MANAGER_PFH_DELAY, []] call CBA_fnc_addPerFrameHandler;
}] call CBA_fnc_addEventHandler;

View File

@ -1,5 +1,6 @@
[ [
QGVAR(enabled), "CHECKBOX", QGVAR(enabled),
"CHECKBOX",
[ELSTRING(common,Enabled), LSTRING(Setting_Description)], [ELSTRING(common,Enabled), LSTRING(Setting_Description)],
LSTRING(Category_DisplayName), LSTRING(Category_DisplayName),
true, true,
@ -9,17 +10,18 @@
] call CBA_fnc_addSetting; ] call CBA_fnc_addSetting;
[ [
QGVAR(enableFlare), "CHECKBOX", QGVAR(enableFlare),
"CHECKBOX",
[LSTRING(Setting_FlareEnable), LSTRING(Setting_FlareDescription)], [LSTRING(Setting_FlareEnable), LSTRING(Setting_FlareDescription)],
LSTRING(Category_DisplayName), LSTRING(Category_DisplayName),
false, false,
1, 1,
{[QGVAR(flareEnabled), _this] call EFUNC(common,cbaSettings_settingChanged)}, {[QGVAR(flareEnabled), _this] call EFUNC(common,cbaSettings_settingChanged)}
true
] call CBA_fnc_addSetting; ] call CBA_fnc_addSetting;
[ [
QGVAR(dropWeapon), "LIST", QGVAR(dropWeapon),
"LIST",
[LSTRING(Setting_DropWeapon), LSTRING(Setting_DropWeapon_Description)], [LSTRING(Setting_DropWeapon), LSTRING(Setting_DropWeapon_Description)],
LSTRING(Category_DisplayName), LSTRING(Category_DisplayName),
[ [
@ -31,7 +33,8 @@
] call CBA_fnc_addSetting; ] call CBA_fnc_addSetting;
[ [
QGVAR(enableScreams), "CHECKBOX", QGVAR(enableScreams),
"CHECKBOX",
[LSTRING(Setting_EnableScreams), LSTRING(Setting_EnableScreams_Description)], [LSTRING(Setting_EnableScreams), LSTRING(Setting_EnableScreams_Description)],
LSTRING(Category_DisplayName), LSTRING(Category_DisplayName),
true true