diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 339b180ce..36d16aa23 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -26,6 +26,7 @@ PREP(getCargoPositionsCount); PREP(getDefaultInventory); PREP(getDLC); PREP(getEffectiveGunner); +PREP(getFewestGroupsHC); PREP(getGunnerName); PREP(getLightingSelections); PREP(getPhoneticName); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 8e4053dee..b2436af82 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -358,6 +358,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(fireWeapon), LINKFUNC(fireWeapon)] call CBA_fnc_addEventHandler; diff --git a/addons/common/functions/fnc_deserializeObjects.sqf b/addons/common/functions/fnc_deserializeObjects.sqf index cbc0e84f7..c5e579977 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.inc.sqf b/addons/editor/initKeybinds.inc.sqf index 34ec3f46d..17930ea22 100644 --- a/addons/editor/initKeybinds.inc.sqf +++ b/addons/editor/initKeybinds.inc.sqf @@ -39,7 +39,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.inc.sqf b/addons/editor/initSettings.inc.sqf index 1952d007e..cc2a34f5d 100644 --- a/addons/editor/initSettings.inc.sqf +++ b/addons/editor/initSettings.inc.sqf @@ -61,6 +61,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 3acefb41a..d72df460a 100644 --- a/addons/editor/stringtable.xml +++ b/addons/editor/stringtable.xml @@ -446,6 +446,18 @@ Oblige les unités IA sélectionnées à surveiller la position de la caméra Zeus. 让选定的AI单位看向宙斯镜头所在位置 + + 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 + Skieruj na wyszukiwarke + 検索バーにフォーカス + Force Fire 強制射撃