diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 771245431..968a132f1 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -20,6 +20,7 @@ PREP(getArtilleryETA); PREP(getCargoPositionsCount); PREP(getDefaultInventory); PREP(getDLC); +PREP(getFewestGroupsHC); PREP(getLightingSelections); PREP(getPhoneticName); PREP(getPlayers); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 7ceb451f0..81a996fa1 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -302,6 +302,7 @@ _unit setNameSound _nameSound; }] call CBA_fnc_addEventHandler; +[QGVAR(deserializeObjects), LINKFUNC(deserializeObjects)] call CBA_fnc_addEventHandler; [QGVAR(earthquake), LINKFUNC(earthquake)] call CBA_fnc_addEventHandler; [QGVAR(fireArtillery), LINKFUNC(fireArtillery)] call CBA_fnc_addEventHandler; [QGVAR(setLampState), LINKFUNC(setLampState)] call CBA_fnc_addEventHandler; @@ -392,5 +393,4 @@ if (isServer) then { } call FUNC(runAfterSettingsInit); [QGVAR(createZeus), LINKFUNC(createZeus)] call CBA_fnc_addEventHandler; - [QGVAR(deserializeObjects), LINKFUNC(deserializeObjects)] call CBA_fnc_addEventHandler; }; diff --git a/addons/common/functions/fnc_deserializeObjects.sqf b/addons/common/functions/fnc_deserializeObjects.sqf index 32c6cfc26..b619f5ce8 100644 --- a/addons/common/functions/fnc_deserializeObjects.sqf +++ b/addons/common/functions/fnc_deserializeObjects.sqf @@ -9,6 +9,7 @@ * 1: Center Position * 2: Make Editable (default: true) * 3: Randomization (default: false) + * 4: Use Headless Client (default: true) * * Return Value: * Created Objects @@ -19,9 +20,15 @@ * Public: No */ -params [["_serializedData", [], [[]]], ["_centerPos", [0, 0, 0], [[]], [2, 3]], ["_makeEditable", true, [true]], ["_enableRandomization", false, [true]]]; +params [["_serializedData", [], [[]]], ["_centerPos", [0, 0, 0], [[]], [2, 3]], ["_makeEditable", true, [true]], ["_enableRandomization", false, [true]], ["_useHC", true, [true]]]; _serializedData params [["_objectData", [], [[]]], ["_groupData", [], [[]]]]; +// Check for suitable Headless Client +private _hc = [] call FUNC(getFewestGroupsHC); +if (isServer && {_useHC} && {!isNull _hc}) exitWith { + [QEGVAR(common,deserializeObjects), _this, _hc] call CBA_fnc_targetEvent; +}; + // Set center position to ground level over land and water level over the ocean // Serialized object data offsets are relative to AGL height 0 _centerPos set [2, 0]; diff --git a/addons/common/functions/fnc_getFewestGroupsHC.sqf b/addons/common/functions/fnc_getFewestGroupsHC.sqf new file mode 100644 index 000000000..2ac025da1 --- /dev/null +++ b/addons/common/functions/fnc_getFewestGroupsHC.sqf @@ -0,0 +1,51 @@ +#include "script_component.hpp" +/* + * Author: Ampersand + * Returns the headless client with the fewest local groups. objNull if none are available. + * + * Arguments: + * None + * + * Return Value: + * Headless Client + * + * Example: + * [] call zen_common_fnc_getFewestGroupsHC + * + * Public: No + */ + +if (!isServer) exitWith {objNull}; + +private _hcs = []; +private _hcIDs = []; +private _hcLoad = []; + +{ + if (_x isKindOf "HeadlessClient_F") then { + _hcs pushBack _x; + _hcIDs pushBack owner _x; + _hcLoad pushBack 0; + }; +} forEach allPlayers; + +switch (count _hcIDs) do { + case 0: { + objNull + }; + case 1: { + _hcs select 0 + }; + default { + // Count local groups for each HC + { + private _hcIndex = _hcIDs find groupOwner _x; + if (_hcIndex != -1) then { + private _groupCount = _hcLoad select _hcIndex; + _hcLoad set [_hcIndex, _groupCount + 1]; + }; + } forEach allGroups; + + _hcs select (_hcLoad find selectMin _hcLoad) + }; +}; diff --git a/addons/editor/initKeybinds.sqf b/addons/editor/initKeybinds.sqf index a8a751a12..a91979111 100644 --- a/addons/editor/initKeybinds.sqf +++ b/addons/editor/initKeybinds.sqf @@ -59,7 +59,7 @@ [ELSTRING(main,DisplayName), QGVAR(deepPaste), [LSTRING(DeepPaste), LSTRING(DeepPaste_Description)], { if (!isNull curatorCamera && {!GETMVAR(RscDisplayCurator_search,false)}) then { private _position = [nil, false] call EFUNC(common,getPosFromScreen); - [QEGVAR(common,deserializeObjects), [GVAR(clipboard), _position, true, GVAR(randomizeCopyPaste)]] call CBA_fnc_serverEvent; + [QEGVAR(common,deserializeObjects), [GVAR(clipboard), _position, true, GVAR(randomizeCopyPaste), EGVAR(editor,deepPasteHC)]] call CBA_fnc_serverEvent; playSound ["RscDisplayCurator_error01", true]; diff --git a/addons/editor/initSettings.sqf b/addons/editor/initSettings.sqf index 82e980d64..595844126 100644 --- a/addons/editor/initSettings.sqf +++ b/addons/editor/initSettings.sqf @@ -52,6 +52,15 @@ false ] call CBA_fnc_addSetting; +[ + QGVAR(deepPasteHC), + "CHECKBOX", + [LSTRING(DeepPasteHC), LSTRING(DeepPasteHC_Description)], + [ELSTRING(main,DisplayName), LSTRING(DisplayName)], + true, + false +] call CBA_fnc_addSetting; + [ QGVAR(unitRadioMessages), "LIST", diff --git a/addons/editor/stringtable.xml b/addons/editor/stringtable.xml index c725dc5db..038da6ea2 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -208,6 +208,12 @@ Wkleja z schowka obiekty które zostały głęboko skopiowane. 深コピーによってコピーしたオブジェクト データを貼り付けできます。 + + Deep Paste On Headless Client + + + Deep-copied entities will be sent to headless client(s) if available, avoiding subsequent transfer. + Focus Search Bar Suchfeld fokussieren