From 98b088f26f717d172c3bdb5e1a0695412ce38c5a Mon Sep 17 00:00:00 2001 From: SilentSpike Date: Mon, 3 Aug 2015 00:24:36 +0100 Subject: [PATCH] Fix pre-spectator position saving When staging a spectator (physically applying the spectator state) the unit position is saved for potential later restoration. This shouldn't be done multiple times since the function can be called again to reset staged units. --- addons/spectator/functions/fnc_handleRespawn.sqf | 2 ++ addons/spectator/functions/fnc_stageSpectator.sqf | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/addons/spectator/functions/fnc_handleRespawn.sqf b/addons/spectator/functions/fnc_handleRespawn.sqf index 3e7dfa41f3..aa695dd553 100644 --- a/addons/spectator/functions/fnc_handleRespawn.sqf +++ b/addons/spectator/functions/fnc_handleRespawn.sqf @@ -15,4 +15,6 @@ #include "script_component.hpp" +params ["_unit","_oldUnit"]; + [_unit,false] call FUNC(setSpectator); diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 84bd6ffced..bac5174601 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -40,13 +40,16 @@ _unit enableSimulation !_set; [_unit, _set, QGVAR(isStaged), side group _unit] call EFUNC(common,switchToGroupSide); if (_set) then { - // Move and hide the player ASAP to avoid being seen - GVAR(oldPos) = getPosATL _unit; - _unit setPos (getMarkerPos QGVAR(respawn)); + // Position should only be saved on first entry + if !(GETVAR(_unit,GVAR(isStaged),false)) then { + GVAR(oldPos) = getPosATL _unit; + }; // Ghosts can't talk [_unit, QGVAR(isStaged)] call EFUNC(common,hideUnit); [_unit, QGVAR(isStaged)] call EFUNC(common,muteUnit); + + _unit setPos (getMarkerPos QGVAR(respawn)); } else { // Physical beings can talk [_unit, QGVAR(isStaged)] call EFUNC(common,unhideUnit);