2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2022-02-17 20:03:12 +00:00
|
|
|
/*
|
|
|
|
* Author: Pterolatypus
|
2024-08-11 23:28:51 +00:00
|
|
|
* Read a list of wound handler entries from config, accounting for inheritance.
|
2022-02-17 20:03:12 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: The config class containing the entries <CONFIG>
|
|
|
|
*
|
|
|
|
* ReturnValue:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2024-08-11 23:28:51 +00:00
|
|
|
* [configFile >> "ace_medical_injuries" >> "damageTypes" >> "woundHandlers"] call ace_medical_damage_fnc_parseWoundHandlersCfg
|
2022-02-17 20:03:12 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2024-08-11 23:28:51 +00:00
|
|
|
|
2022-02-17 20:03:12 +00:00
|
|
|
params ["_config"];
|
|
|
|
|
2024-08-11 23:28:51 +00:00
|
|
|
// Read all valid entries from config and store
|
2022-02-17 20:03:12 +00:00
|
|
|
private _entries = [];
|
2024-08-11 23:28:51 +00:00
|
|
|
|
2022-02-17 20:03:12 +00:00
|
|
|
{
|
2024-08-11 23:28:51 +00:00
|
|
|
private _entryResult = getText _x;
|
|
|
|
|
|
|
|
if (_entryResult != "") then {
|
|
|
|
if (ADDON) then {
|
|
|
|
// Runs in postInit
|
|
|
|
_entryResult = call compile _entryResult;
|
|
|
|
|
|
|
|
if (!isNil "_entryResult") then {
|
|
|
|
if (_entryResult isEqualType {}) then {
|
|
|
|
_entries pushBack _entryResult;
|
|
|
|
} else {
|
|
|
|
ERROR_2("Wound handler '%1' needs to be a function, but is of type %2.",configName _x,toLowerANSI typeName _entryResult);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// Runs in preInit
|
|
|
|
// In case function doesn't exist yet, wrap in extra layer
|
|
|
|
_entries pushBack (compile format ["call %1", _entryResult]);
|
|
|
|
};
|
|
|
|
};
|
2022-02-17 20:03:12 +00:00
|
|
|
} forEach configProperties [_config, "isText _x", false];
|
|
|
|
|
|
|
|
private _parent = inheritsFrom _config;
|
2024-08-11 23:28:51 +00:00
|
|
|
|
2022-02-17 20:03:12 +00:00
|
|
|
if (isNull _parent) exitWith {_entries};
|
|
|
|
|
2024-08-11 23:28:51 +00:00
|
|
|
// Recursive call for parent
|
|
|
|
// Can't use configProperties for inheritance since it returns entries in the wrong order
|
|
|
|
([_parent] call FUNC(parseWoundHandlersCfg)) + _entries // return
|