From f0468fa7c8102d733a7b4e6bed25654e89bc324a Mon Sep 17 00:00:00 2001 From: Niko Lehtovirta Date: Fri, 10 Apr 2015 14:21:52 +0300 Subject: [PATCH 1/3] Changed spawn code on respawn to PFH format --- addons/respawn/functions/fnc_module.sqf | 18 +++-- .../respawn/functions/fnc_moveRallypoint.sqf | 65 ++++++++++--------- addons/respawn/functions/fnc_removeBody.sqf | 25 +++---- 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 6d03c1eda3..391209009f 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -33,15 +33,19 @@ GVAR(Module) = true; if (isServer) then { if (GVAR(RemoveDeadBodiesDisconnected)) then { _fnc_deleteDisconnected = { - _this spawn { - _unit = _this select 0; + [ + { + _unit = (_this select 0) select 0; - sleep 4; - - if (!alive _unit) then { + if (!alive _unit) then { deleteVehicle _unit; - }; - }; + + [_this select 0] call CBA_fnc_removePerFrameHandler; + }; + }, + 4, + [_this] + ] call CBA_fnc_addPerFrameHandler false }; diff --git a/addons/respawn/functions/fnc_moveRallypoint.sqf b/addons/respawn/functions/fnc_moveRallypoint.sqf index dcd4810844..28dcc54326 100644 --- a/addons/respawn/functions/fnc_moveRallypoint.sqf +++ b/addons/respawn/functions/fnc_moveRallypoint.sqf @@ -1,54 +1,59 @@ /* Name: ACE_Respawn_fnc_moveRallypoint - + Author(s): commy2 - + Description: Moves a rallypoint to the player's location - + Parameters: 0: OBJECT - unit 1: OBJECT - side - + Returns: VOID */ #include "script_component.hpp" -_this spawn { - _unit = _this select 0; - _side = _this select 1; +_unit = _this select 0; +_side = _this select 1; - // rallypoint names are defined in CfgVehicles.hpp +// rallypoint names are defined in CfgVehicles.hpp - _rallypoint = [ - objNull, - missionNamespace getVariable ["ACE_Rallypoint_West", objNull], - missionNamespace getVariable ["ACE_RallypointExit_East", objNull], - missionNamespace getVariable ["ACE_RallypointExit_Independent", objNull] - ] select ([west, east, independent] find _side) + 1; +_rallypoint = [ + objNull, + missionNamespace getVariable ["ACE_Rallypoint_West", objNull], + missionNamespace getVariable ["ACE_RallypointExit_East", objNull], + missionNamespace getVariable ["ACE_RallypointExit_Independent", objNull] +] select ([west, east, independent] find _side) + 1; - if (isNull _rallypoint) exitWith {}; +if (isNull _rallypoint) exitWith {}; - _position = getPosATL _unit; - _position = _position findEmptyPosition [0, 2, typeOf _rallypoint]; - if (count _position == 0) then {_position = getPosATL _unit}; +_position = getPosATL _unit; +_position = _position findEmptyPosition [0, 2, typeOf _rallypoint]; +if (count _position == 0) then {_position = getPosATL _unit}; - _position set [2, 0]; +_position set [2, 0]; - [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); +[localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); - sleep 5; - _rallypoint setPosATL _position; - _unit reveal _rallypoint; +[{ + _args = _this select 0; + _rallypoint = _args select 0; + _unit = _args select 1; + _position = _args select 2; + _rallypoint = _args select 3; - /* - _marker = format ["AGM_RallyPoint_%1", _side]; - _marker setMarkerPos _position; - _marker setMarkerTextLocal format ["%1:%2", [date select 3, 2, 0] call CBA_fnc_FORMATNumber, [date select 4, 2, 0] call CBA_fnc_FORMATNumber]; - */ + _rallypoint setPosATL _position; + _unit reveal _rallypoint; - [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); -}; + /* + _marker = format ["AGM_RallyPoint_%1", _side]; + _marker setMarkerPos _position; + _marker setMarkerTextLocal format ["%1:%2", [date select 3, 2, 0] call CBA_fnc_FORMATNumber, [date select 4, 2, 0] call CBA_fnc_FORMATNumber]; + */ + + [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); +}, 5, [_rallypoint, _unit, _position, _rallypoint]] diff --git a/addons/respawn/functions/fnc_removeBody.sqf b/addons/respawn/functions/fnc_removeBody.sqf index 5c3ed14988..a17193aa1a 100644 --- a/addons/respawn/functions/fnc_removeBody.sqf +++ b/addons/respawn/functions/fnc_removeBody.sqf @@ -1,22 +1,22 @@ /* Name: ACE_Respawn_fnc_removeBody - + Author(s): bux578 - + Description: removes a given body - + Parameters: 0: OBJECT - body 1: BOOLEAN - forceRemove // not used atm - + Returns: VOID */ #include "script_component.hpp" - + private ["_body", "_forceRemove", "_bodyRemoveTimer"]; _body = _this select 0; @@ -29,9 +29,12 @@ if (_forceRemove) then { _bodyRemoveTimer = 2; }; -[_body, _bodyRemoveTimer] spawn { - sleep (_this select 1); - // hideBody takes ~20s till body is fully underground - // a better hideBody would make this more aesthetic - deleteVehicle (_this select 0); -}; +[{ + + _unit = (_this select 1) select 0; + // hideBody takes ~20s till body is fully underground + // a better hideBody would make this more aesthetic + deleteVehicle _unit; +}, +_bodyRemoveTime, +[_body]] call CBA_fnc_addPerFrameHandler \ No newline at end of file From 9f2f660b89aec6c342cb429643deba54b7d6dce3 Mon Sep 17 00:00:00 2001 From: Niko Lehtovirta Date: Fri, 10 Apr 2015 16:23:27 +0300 Subject: [PATCH 2/3] fixed PFH to use EFUNC(common,waitAndExecute) --- addons/respawn/functions/fnc_module.sqf | 33 +++++++++-------- .../respawn/functions/fnc_moveRallypoint.sqf | 36 ++++++++++--------- addons/respawn/functions/fnc_removeBody.sqf | 19 +++++----- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 391209009f..57ebb91615 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -32,24 +32,23 @@ GVAR(Module) = true; if (isServer) then { if (GVAR(RemoveDeadBodiesDisconnected)) then { - _fnc_deleteDisconnected = { - [ - { - _unit = (_this select 0) select 0; + addMissionEventHandler ["HandleDisconnect", + { + [ + { + _unit = _this select 0; - if (!alive _unit) then { - deleteVehicle _unit; - - [_this select 0] call CBA_fnc_removePerFrameHandler; - }; - }, - 4, - [_this] - ] call CBA_fnc_addPerFrameHandler - false - }; - - addMissionEventHandler ["HandleDisconnect", _fnc_deleteDisconnected]; + if (!alive _unit) then { + deleteVehicle _unit; + }; + }, + _this, + 4, + 1 + ] call EFUNC(common,waitAndExecute); + false + } + ]; }; }; diff --git a/addons/respawn/functions/fnc_moveRallypoint.sqf b/addons/respawn/functions/fnc_moveRallypoint.sqf index 28dcc54326..96672fecd6 100644 --- a/addons/respawn/functions/fnc_moveRallypoint.sqf +++ b/addons/respawn/functions/fnc_moveRallypoint.sqf @@ -37,23 +37,25 @@ if (count _position == 0) then {_position = getPosATL _unit}; _position set [2, 0]; -[localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); +[ + { + _rallypoint = _this select 0; + _unit = _this select 1; + _position = _this select 2; + _rallypoint = _this select 3; -[{ - _args = _this select 0; - _rallypoint = _args select 0; - _unit = _args select 1; - _position = _args select 2; - _rallypoint = _args select 3; + _rallypoint setPosATL _position; + _unit reveal _rallypoint; - _rallypoint setPosATL _position; - _unit reveal _rallypoint; + /* + _marker = format ["AGM_RallyPoint_%1", _side]; + _marker setMarkerPos _position; + _marker setMarkerTextLocal format ["%1:%2", [date select 3, 2, 0] call CBA_fnc_FORMATNumber, [date select 4, 2, 0] call CBA_fnc_FORMATNumber]; + */ - /* - _marker = format ["AGM_RallyPoint_%1", _side]; - _marker setMarkerPos _position; - _marker setMarkerTextLocal format ["%1:%2", [date select 3, 2, 0] call CBA_fnc_FORMATNumber, [date select 4, 2, 0] call CBA_fnc_FORMATNumber]; - */ - - [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); -}, 5, [_rallypoint, _unit, _position, _rallypoint]] + [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); + }, + [_rallypoint, _unit, _position, _rallypoint], + 5, + 1 +] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeBody.sqf b/addons/respawn/functions/fnc_removeBody.sqf index a17193aa1a..4b7deaa6ce 100644 --- a/addons/respawn/functions/fnc_removeBody.sqf +++ b/addons/respawn/functions/fnc_removeBody.sqf @@ -29,12 +29,13 @@ if (_forceRemove) then { _bodyRemoveTimer = 2; }; -[{ - - _unit = (_this select 1) select 0; - // hideBody takes ~20s till body is fully underground - // a better hideBody would make this more aesthetic - deleteVehicle _unit; -}, -_bodyRemoveTime, -[_body]] call CBA_fnc_addPerFrameHandler \ No newline at end of file +[ + { + // hideBody takes ~20s till body is fully underground + // a better hideBody would make this more aesthetic + deleteVehicle _this; + }, + _body, + _bodyRemoveTimer, + 1 +] call EFUNC(common,waitAndExecute); From 4b50d760e9ed90a257cad4379329db478d9d39dd Mon Sep 17 00:00:00 2001 From: Niko Lehtovirta Date: Sat, 11 Apr 2015 20:36:38 +0300 Subject: [PATCH 3/3] fixed to use proper 4-space tabbing --- addons/respawn/functions/fnc_module.sqf | 24 +++++++------------ .../respawn/functions/fnc_moveRallypoint.sqf | 10 +++----- addons/respawn/functions/fnc_removeBody.sqf | 9 ++----- 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 57ebb91615..77e435349f 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -32,23 +32,17 @@ GVAR(Module) = true; if (isServer) then { if (GVAR(RemoveDeadBodiesDisconnected)) then { - addMissionEventHandler ["HandleDisconnect", - { - [ - { - _unit = _this select 0; + addMissionEventHandler ["HandleDisconnect", { + [{ + _unit = _this select 0; - if (!alive _unit) then { - deleteVehicle _unit; - }; + if (!alive _unit) then { + deleteVehicle _unit; + }; }, - _this, - 4, - 1 - ] call EFUNC(common,waitAndExecute); - false - } - ]; + _this, 4, 1] call EFUNC(common,waitAndExecute); + false + }]; }; }; diff --git a/addons/respawn/functions/fnc_moveRallypoint.sqf b/addons/respawn/functions/fnc_moveRallypoint.sqf index 96672fecd6..30802c5de2 100644 --- a/addons/respawn/functions/fnc_moveRallypoint.sqf +++ b/addons/respawn/functions/fnc_moveRallypoint.sqf @@ -37,8 +37,7 @@ if (count _position == 0) then {_position = getPosATL _unit}; _position set [2, 0]; -[ - { +[{ _rallypoint = _this select 0; _unit = _this select 1; _position = _this select 2; @@ -54,8 +53,5 @@ _position set [2, 0]; */ [localize "STR_ACE_Respawn_Deploy"] call EFUNC(common,displayTextStructured); - }, - [_rallypoint, _unit, _position, _rallypoint], - 5, - 1 -] call EFUNC(common,waitAndExecute); +}, +[_rallypoint, _unit, _position, _rallypoint], 5, 1] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeBody.sqf b/addons/respawn/functions/fnc_removeBody.sqf index 4b7deaa6ce..e00f633e6c 100644 --- a/addons/respawn/functions/fnc_removeBody.sqf +++ b/addons/respawn/functions/fnc_removeBody.sqf @@ -29,13 +29,8 @@ if (_forceRemove) then { _bodyRemoveTimer = 2; }; -[ - { +[{ // hideBody takes ~20s till body is fully underground // a better hideBody would make this more aesthetic deleteVehicle _this; - }, - _body, - _bodyRemoveTimer, - 1 -] call EFUNC(common,waitAndExecute); +}, _body, _bodyRemoveTimer, 1] call EFUNC(common,waitAndExecute);