CombinedArmsGaming / CAFE3

F3_CA but bouncier.
2 stars 3 forks source link

[Change] Refactor function overrides for external addons. #166

Closed Bubbus closed 7 months ago

Bubbus commented 1 year ago

By Cre, from https://github.com/CombinedArmsGaming/CAFE3/pull/162

As discussed, I'd modify the ACRE override to use two distinct functions: your override, and the original function (compiled in the traditional way in CfgFunctions. but using a soft-dependency). The functions config would then become

#if __has_include("\idi\acre\addons\main\stringtable.xml")
    class acre_ace_interact
    {
        class overrides
        {
            file = "components\radio\acre";
            class radioListChildrenActions{};
            class radioListChildrenActions_original
            {
                file = "idi\acre\addons\ace_interact\fnc_radioListChildrenActions.sqf";
            };
        }
    }
#endif

Then we can omit lines 5-12 of your override:

if (isNil "f_var_originalFunction_addRadioActionsToClass") then
{
    // Why isn't this easier to do in SQF?  Why does it have to be so brittle?  thanks lads
    f_var_originalFunction_addRadioActionsToClass = compile preprocessFileLineNumbers "idi\acre\addons\ace_interact\fnc_radioListChildrenActions.sqf";
};

private _children = _this call f_var_originalFunction_addRadioActionsToClass;

and just do:

private _children = _this call acre_ace_interact_fnc_radioListChildrenActions_original;

Originally posted by @Cre8or in https://github.com/CombinedArmsGaming/CAFE3/issues/162#issuecomment-1591118556