Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PREP(getCargoPositionsCount);
PREP(getDefaultInventory);
PREP(getDLC);
PREP(getEffectiveGunner);
PREP(getFewestGroupsHC);
PREP(getGunnerName);
PREP(getLightingSelections);
PREP(getPhoneticName);
Expand Down
1 change: 1 addition & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion addons/common/functions/fnc_deserializeObjects.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* 1: Center Position <ARRAY>
* 2: Make Editable <BOOL> (default: true)
* 3: Randomization <BOOL> (default: false)
* 4: Use Headless Client <BOOL> (default: true)
Comment thread
ampersand38 marked this conversation as resolved.
*
* Return Value:
* Created Objects <ARRAY>
Expand All @@ -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]]];
Comment thread
ampersand38 marked this conversation as resolved.
_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];
Expand Down
51 changes: 51 additions & 0 deletions addons/common/functions/fnc_getFewestGroupsHC.sqf
Original file line number Diff line number Diff line change
@@ -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 <OBJECT>
*
* 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)
};
};
2 changes: 1 addition & 1 deletion addons/editor/initKeybinds.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
9 changes: 9 additions & 0 deletions addons/editor/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions addons/editor/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,18 @@
<French>Oblige les unités IA sélectionnées à surveiller la position de la caméra Zeus.</French>
<Chinesesimp>让选定的AI单位看向宙斯镜头所在位置</Chinesesimp>
</Key>
<Key ID="STR_ZEN_Editor_DeepPasteHC">
<English>Deep Paste On Headless Client</English>
</Key>
<Key ID="STR_ZEN_Editor_DeepPasteHC_Description">
<English>Deep-copied entities will be sent to headless client(s) if available, avoiding subsequent transfer.</English>
</Key>
<Key ID="STR_ZEN_Editor_FocusSearchBar">
<English>Focus Search Bar</English>
<German>Suchfeld fokussieren</German>
<Polish>Skieruj na wyszukiwarke</Polish>
<Japanese>検索バーにフォーカス</Japanese>
</Key>
<Key ID="STR_ZEN_Editor_ForceFire">
<English>Force Fire</English>
<Japanese>強制射撃</Japanese>
Expand Down
Loading