From b14829392045b0905b58d0b7a6148c66daccc085 Mon Sep 17 00:00:00 2001 From: ebaydayz Date: Sun, 22 Jan 2017 19:09:02 -0500 Subject: [PATCH] Move group icons to separate slower loop --- .../Configs/RscDisplay/RscPlayerUI.hpp | 4 +- SQF/dayz_code/configVariables.sqf | 2 +- SQF/dayz_code/groups/groupIcons.sqf | 42 ------- SQF/dayz_code/groups/groupMarkers.sqf | 111 +++++++++--------- SQF/dayz_code/groups/groupTags.sqf | 46 ++++++++ SQF/dayz_code/groups/init.sqf | 10 +- SQF/dayz_code/system/player_spawn_2.sqf | 2 - .../system/scheduler/sched_oneachframe.sqf | 2 - Server Files/Battleye/scripts.txt | 2 +- 9 files changed, 114 insertions(+), 107 deletions(-) delete mode 100644 SQF/dayz_code/groups/groupIcons.sqf create mode 100644 SQF/dayz_code/groups/groupTags.sqf diff --git a/SQF/dayz_code/Configs/RscDisplay/RscPlayerUI.hpp b/SQF/dayz_code/Configs/RscDisplay/RscPlayerUI.hpp index 4adf2116b..d15ec32c2 100644 --- a/SQF/dayz_code/Configs/RscDisplay/RscPlayerUI.hpp +++ b/SQF/dayz_code/Configs/RscDisplay/RscPlayerUI.hpp @@ -651,13 +651,13 @@ class RscTitles }; }; }; - class DZ_GroupIcons + class DZ_GroupTags { idd = -1; movingEnable = 1; enableSimulation = 1; enableDisplay = 1; - onLoad = "uiNamespace setVariable ['DZ_GroupIcons',_this select 0];"; + onLoad = "uiNamespace setVariable ['DZ_GroupTags',_this select 0];"; duration = 99999999999999999; fadein = 0; fadeout = 0; diff --git a/SQF/dayz_code/configVariables.sqf b/SQF/dayz_code/configVariables.sqf index cd8c3525a..327e13c10 100644 --- a/SQF/dayz_code/configVariables.sqf +++ b/SQF/dayz_code/configVariables.sqf @@ -98,7 +98,7 @@ DZE_doorManagementMaxFriends = 10; //Max friends allowed on a door. There is no DZE_doorManagementHarderPenalty = true; //Enforce an exponential wait on attempts between unlocking a door from a failed code. // Group System -dayz_groupSystem = true; // Enable group system +dayz_groupSystem = false; // Enable group system dayz_markGroup = 1; // Players can see their group members on the map 0=never, 1=always, 2=With GPS only dayz_markSelf = 0; // Players can see their own position on the map 0=never, 1=always, 2=With GPS only dayz_markBody = 0; // Players can see their corpse position on the map 0=never, 1=always, 2=With GPS only diff --git a/SQF/dayz_code/groups/groupIcons.sqf b/SQF/dayz_code/groups/groupIcons.sqf deleted file mode 100644 index e175fc9f1..000000000 --- a/SQF/dayz_code/groups/groupIcons.sqf +++ /dev/null @@ -1,42 +0,0 @@ -// OnEachFrame loop -private ["_display","_distance","_group","_icon","_index","_pos","_scale","_screen","_text"]; - -_group = player call dayz_filterGroup; -if (!visibleMap && count _group > 1 && cameraView in ["INTERNAL","EXTERNAL","GUNNER"]) then { - 80000 cutRsc ["DZ_GroupIcons","PLAIN"]; - - _display = uiNamespace getVariable "DZ_GroupIcons"; - _index = 0; - { - _pos = [_x] call FNC_GetPos; - _distance = _pos distance player; - _icon = _display displayCtrl (100 + _index); - if (_distance > 1 && _distance < 2500 && vehicle _x != vehicle player) then { - _pos set [2,(_pos select 2) + 1.5]; - _screen = worldToScreen _pos; - _text = composeText [image "\ca\ui\data\igui_side_unknown_ca.paa"," ",if (dayz_groupNameTags) then {name _x} else {""}]; - if (count _screen > 1) then { - _scale = if (_distance < 200) then {.3} else {1 min ((1 - (_distance - 3) / 15) max .3)}; - _icon ctrlSetStructuredText _text; - _icon ctrlSetPosition [(_screen select 0),(_screen select 1),.99,.65]; - _icon ctrlSetScale _scale; - _icon ctrlSetFade ((1 - _scale) / 2); - _icon ctrlCommit 0; - _icon ctrlShow true; - } else { - _icon ctrlShow false; - }; - } else { - _icon ctrlShow false; - }; - _index = _index + 1; - } count _group; - - if (dayz_oldGroupCount > count _group) then { - _display displayCtrl (100 + _index) ctrlShow false; - }; - - dayz_oldGroupCount = count _group; -} else { - 80000 cutText ["","PLAIN"]; -}; \ No newline at end of file diff --git a/SQF/dayz_code/groups/groupMarkers.sqf b/SQF/dayz_code/groups/groupMarkers.sqf index 1d411fd0d..60bfe97b6 100644 --- a/SQF/dayz_code/groups/groupMarkers.sqf +++ b/SQF/dayz_code/groups/groupMarkers.sqf @@ -1,60 +1,63 @@ -// Two second loop private ["_count","_found","_group","_hasGPS","_index","_marker","_markBody","_markGroup","_markSelf","_pos","_self","_vehicle"]; -_group = player call dayz_filterGroup; +while {true} do { + _group = player call dayz_filterGroup; -if (dayz_requireRadio && {count _group > 1} && {!("ItemRadio" in items player)}) exitWith { - [player] joinSilent grpNull; - _group = []; - if (!isNull findDisplay 80000) then {findDisplay 80000 closeDisplay 2;}; - localize "STR_EPOCH_RADIO_CONTACT_LOST" call dayz_rollingMessages; -}; - -if (visibleMap or !isNull findDisplay 88890) then { - _hasGPS = "ItemGPS" in items player; - _markBody = (dayz_markBody == 1 or (dayz_markBody == 2 && _hasGPS)); - _markGroup = (dayz_markGroup == 1 or (dayz_markGroup == 2 && _hasGPS)); - _markSelf = (dayz_markSelf == 1 or (dayz_markSelf == 2 && _hasGPS)); - - _index = 0; - { - _self = _x == player; - _vehicle = vehicle _x; - if ((_self or _markGroup) && (!_self or _markSelf) && (effectiveCommander _vehicle == _x)) then { - _pos = [_x] call FNC_GetPos; - deleteMarkerLocal format["groupMember%1",_index]; - _marker = createMarkerLocal [format["groupMember%1",_index],_pos]; - _marker setMarkerTypeLocal "DestroyedVehicle"; - _marker setMarkerTextLocal format ["%1",if (_vehicle == _x) then {name _x} else {_vehicle call dayz_getCrew}]; - _marker setMarkerColorLocal "ColorGreen"; - } else { - deleteMarkerLocal format["groupMember%1",_index]; - }; - _index = _index + 1; - } count _group; - - // Remove markers for group members that left - _count = count _group; - if (dayz_oldMemberCount > _count) then { - for "_i" from _count to dayz_oldMemberCount do {deleteMarkerLocal format["groupMember%1",_i];}; - }; - dayz_oldMemberCount = _count; - - if (_markBody) then { - _found = false; - { - if (_x getVariable["bodyName",""] == name player) exitWith { - _found = true; - _pos = [_x] call FNC_GetPos; - deleteMarkerLocal "MyBody"; - _marker = createMarkerLocal ["MyBody",_pos]; - _marker setMarkerTypeLocal "DestroyedVehicle"; - _marker setMarkerTextLocal localize "STR_EPOCH_RIP"; - _marker setMarkerColorLocal "ColorRed"; - }; - } count allDead; - if (!_found) then {deleteMarkerLocal "MyBody";}; //Body was deleted or hidden + if (dayz_requireRadio && {count _group > 1} && {!("ItemRadio" in items player)}) then { + [player] joinSilent grpNull; + _group = []; + if (!isNull findDisplay 80000) then {findDisplay 80000 closeDisplay 2;}; + localize "STR_EPOCH_RADIO_CONTACT_LOST" call dayz_rollingMessages; } else { - deleteMarkerLocal "MyBody"; + if (visibleMap or !isNull findDisplay 88890) then { + _hasGPS = "ItemGPS" in items player; + _markBody = (dayz_markBody == 1 or (dayz_markBody == 2 && _hasGPS)); + _markGroup = (dayz_markGroup == 1 or (dayz_markGroup == 2 && _hasGPS)); + _markSelf = (dayz_markSelf == 1 or (dayz_markSelf == 2 && _hasGPS)); + + _index = 0; + { + _self = _x == player; + _vehicle = vehicle _x; + if ((_self or _markGroup) && (!_self or _markSelf) && (effectiveCommander _vehicle == _x)) then { + _pos = [_x] call FNC_GetPos; + deleteMarkerLocal format["groupMember%1",_index]; + _marker = createMarkerLocal [format["groupMember%1",_index],_pos]; + _marker setMarkerTypeLocal "DestroyedVehicle"; + _marker setMarkerTextLocal format ["%1",if (_vehicle == _x) then {name _x} else {_vehicle call dayz_getCrew}]; + _marker setMarkerColorLocal "ColorGreen"; + } else { + deleteMarkerLocal format["groupMember%1",_index]; + }; + _index = _index + 1; + } count _group; + + // Remove markers for group members that left + _count = count _group; + if (dayz_oldMemberCount > _count) then { + for "_i" from _count to dayz_oldMemberCount do {deleteMarkerLocal format["groupMember%1",_i];}; + }; + dayz_oldMemberCount = _count; + + if (_markBody) then { + _found = false; + { + if (_x getVariable["bodyName",""] == name player) exitWith { + _found = true; + _pos = [_x] call FNC_GetPos; + deleteMarkerLocal "MyBody"; + _marker = createMarkerLocal ["MyBody",_pos]; + _marker setMarkerTypeLocal "DestroyedVehicle"; + _marker setMarkerTextLocal localize "STR_EPOCH_RIP"; + _marker setMarkerColorLocal "ColorRed"; + }; + } count allDead; + if (!_found) then {deleteMarkerLocal "MyBody";}; //Body was deleted or hidden + } else { + deleteMarkerLocal "MyBody"; + }; + }; }; + + uiSleep 1; }; \ No newline at end of file diff --git a/SQF/dayz_code/groups/groupTags.sqf b/SQF/dayz_code/groups/groupTags.sqf new file mode 100644 index 000000000..4964674cb --- /dev/null +++ b/SQF/dayz_code/groups/groupTags.sqf @@ -0,0 +1,46 @@ +private ["_display","_distance","_group","_icon","_index","_pos","_scale","_screen","_text"]; + +while {true} do { + _group = player call dayz_filterGroup; + + if (!visibleMap && count _group > 1 && cameraView in ["INTERNAL","EXTERNAL","GUNNER"]) then { + 80000 cutRsc ["DZ_GroupTags","PLAIN"]; + + _display = uiNamespace getVariable "DZ_GroupTags"; + _index = 0; + { + _pos = [_x] call FNC_GetPos; + _distance = _pos distance player; + _icon = _display displayCtrl (100 + _index); + if (_distance > 1 && _distance < 2500 && vehicle _x != vehicle player) then { + _pos set [2,(_pos select 2) + 1.5]; + _screen = worldToScreen _pos; + _text = composeText [image "\ca\ui\data\igui_side_unknown_ca.paa"," ",if (dayz_groupNameTags) then {name _x} else {""}]; + if (count _screen > 1) then { + _scale = if (_distance < 200) then {.3} else {1 min ((1 - (_distance - 3) / 15) max .3)}; + _icon ctrlSetStructuredText _text; + _icon ctrlSetPosition [(_screen select 0),(_screen select 1),.99,.65]; + _icon ctrlSetScale _scale; + _icon ctrlSetFade ((1 - _scale) / 2); + _icon ctrlCommit 0; + _icon ctrlShow true; + } else { + _icon ctrlShow false; + }; + } else { + _icon ctrlShow false; + }; + _index = _index + 1; + } count _group; + + if (dayz_oldGroupCount > count _group) then { + _display displayCtrl (100 + _index) ctrlShow false; + }; + + dayz_oldGroupCount = count _group; + } else { + 80000 cutText ["","PLAIN"]; + }; + + uiSleep 0.01; +}; \ No newline at end of file diff --git a/SQF/dayz_code/groups/init.sqf b/SQF/dayz_code/groups/init.sqf index 33cc6b8d1..813a45bf5 100644 --- a/SQF/dayz_code/groups/init.sqf +++ b/SQF/dayz_code/groups/init.sqf @@ -30,8 +30,6 @@ dayz_disbandGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\group dayz_filterGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\filter.sqf"; dayz_getCrew = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\getCrew.sqf"; dayz_getPlayer = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\getPlayer.sqf"; -dayz_groupIcons = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\groupIcons.sqf"; -dayz_groupMarkers = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\groupMarkers.sqf"; dayz_inviteToGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\invite.sqf"; dayz_joinGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\join.sqf"; dayz_kickFromGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\kick.sqf"; @@ -41,4 +39,10 @@ dayz_pickGroupMember = compile preprocessFileLineNumbers "\z\addons\dayz_code\gr dayz_pickPlayer = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\pickPlayer.sqf"; dayz_promotePlayer = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\promote.sqf"; dayz_rejectGroup = compile preprocessFileLineNumbers "\z\addons\dayz_code\groups\reject.sqf"; -dayz_groupInit = true; \ No newline at end of file +dayz_groupInit = true; + +execVM "\z\addons\dayz_code\groups\groupTags.sqf"; + +if (dayz_requireRadio or {dayz_markGroup > 0} or {dayz_markSelf > 0} or {dayz_markBody > 0}) then { + execVM "\z\addons\dayz_code\groups\groupMarkers.sqf"; +}; \ No newline at end of file diff --git a/SQF/dayz_code/system/player_spawn_2.sqf b/SQF/dayz_code/system/player_spawn_2.sqf index 7fca646e3..7bb1f0504 100644 --- a/SQF/dayz_code/system/player_spawn_2.sqf +++ b/SQF/dayz_code/system/player_spawn_2.sqf @@ -202,8 +202,6 @@ while {1 == 1} do { player setVariable["USEC_infected",true,true]; }; }; - - if (!isNil "dayz_groupInit") then {call dayz_groupMarkers;}; // Radiation zones rapid blood loss if (DZE_InRadiationZone) then { diff --git a/SQF/dayz_code/system/scheduler/sched_oneachframe.sqf b/SQF/dayz_code/system/scheduler/sched_oneachframe.sqf index e3bb8641d..5acc2f15d 100644 --- a/SQF/dayz_code/system/scheduler/sched_oneachframe.sqf +++ b/SQF/dayz_code/system/scheduler/sched_oneachframe.sqf @@ -30,8 +30,6 @@ sched_onEachFrame = { diag_log format [ "h1nt: LOW FPS (%1)", diag_fpsmin ]; }; }; - - if (!isNil "dayz_groupIcons") then {call dayz_groupIcons;}; _ret }; diff --git a/Server Files/Battleye/scripts.txt b/Server Files/Battleye/scripts.txt index 3efa4e2da..77ad10328 100644 --- a/Server Files/Battleye/scripts.txt +++ b/Server Files/Battleye/scripts.txt @@ -22,7 +22,7 @@ 5 displayRemoveAllEventHandlers 5 displaySetEventHandler 5 enableEnvironment -5 groupIcon !="uiNamespace setVariable ['DZ_GroupIcons',_this select 0];" !="80000 cutRsc [\"DZ_GroupIcons\",\"PLAIN\"];" !="_display = uiNamespace getVariable \"DZ_GroupIcons\";" !"if (!isNull (uiNamespace getVariable \"DZ_GroupIcons\")) then {" !"dayz_groupIcons = compile preprocessFileLineNumbers " !="if (!isNil \"dayz_groupIcons\") then {call dayz_groupIcons;};" +5 groupIcon 5 hideObject !"if (_VectorWorkAround) then {\n_object2 = _ghost2 createVehicleLocal [0,0,0];\nhideObject _object;\n};" !"\"setMarkerPosLocal\",\n\"hideObject\"\n];" !="rhideObject = 'hideObject'" !"rhideObjectcode" !"\"hideObject\", \"hint\"," 5 lbCurSel !="_selectedMissionIndex = lbCurSel _lbMissionsControl;" !="_selectedUserIndex = lbCurSel _lbUsersControl;" !="profileNamespace setVariable ['streamerMode',(lbCurSel (_this select 0))];" !="_index = lbCurSel _lbcontrol;" !="_selected = lbCurSel _list;" !="_friendName = _userList lbText (lbCurSel _userList);" !")] call Z_" !"(lbCurSel 7421) call Z_fillCategoryList" !"] call Door" !"] call Plot" !")] spawn TraderDialog" !="[(lbCurSel 21000), ((ctrlParent (_this select 0)) displayCtrl 21001)] spawn EpochDeathBoardClick;" !"((ctrlParent (_this select 0)) closeDisplay 2);" !="_uid = _playerList lbData (lbCurSel _playerList);" !"_myGroup lbData (lbCurSel _myGroup);" 5 lbSet !="_lbUsersControl lbSetColor [_x, [1,0,0,1]];" !="_lbUsersControl lbSetValue [_x, _rating];" !="_control lbSetColor [_x, _color];" !"_weaponsLBSetFocus" !="(_this select 0) displayCtrl 140 lbSetCurSel (profileNamespace getVariable ['streamerMode',0]);" !="(_display displayCtrl 105) lbSetColor [_i, [0.06, 0.05, 0.03, 1]];" !"[7421," !"lbSetPicture [7422, _index" !"lbSetPicture [7402, _index" !"lbSetPicture [7401, _index" !="_userList lbSetData [(lbSize _userList) -1,_friendUID];" !" [TraderDialogItemList, _index, " !"_myGroup lbSetData [_index,getPlayerUID _x];"