Resync mine orientations in JIP. Fix #3317

This commit is contained in:
esteldunedain 2016-02-23 09:53:38 -03:00
parent e6af2864eb
commit 645ed3e63d
3 changed files with 34 additions and 10 deletions

View File

@ -36,16 +36,25 @@ GVAR(Setup) = objNull;
GVAR(pfeh_running) = false;
GVAR(CurrentSpeedDial) = 0;
// Properly angle preplaced bottom-attack SLAMs
{
if (local _x) then {
switch (typeOf _x) do {
case ("ACE_SLAMDirectionalMine_Magnetic_Ammo"): {
[_x, getDir _x, 90] call FUNC(setPosition);
};
};
};
} forEach allMines;
// In case we are a JIP client, ask the server for orientation of any previously
// placed mine.
if (isServer) then {
["clientRequestsOrientation", {
params ["_client"];
["serverSendsOrientations", _client, GVAR(explosivesOrientations)] call EFUNC(common,targetEvent);
}] call EFUNC(common,addEventHandler);
} else {
["serverSendsOrientations", {
params ["_explosivesOrientations"];
{
params ["_explosive","_direction","_pitch"];
[_explosive, _direction, _pitch] call FUNC(setPosition);
} forEach _explosivesOrientations;
}] call EFUNC(common,addEventHandler);
private _client = owner ACE_player;
["clientRequestsOrientations", [_client]] call EFUNC(common,serverEvent);
};
["interactMenuOpened", {
//Cancel placement if interact menu opened

View File

@ -19,4 +19,8 @@ ADDON = false;
#include "XEH_PREP.hpp"
if (isServer) then {
GVAR(explosivesOrientations) = []
};
ADDON = true;

View File

@ -29,3 +29,14 @@ if (isNull (attachedTo _explosive)) then {
//Attaching to a vehicle (dirAndUp based on vehicle)
_explosive setVectorDirAndUp [[0,0,1],[(sin _direction),(cos _direction),0]];
};
if (isServer) then {
// Store the orientation to broadcast it later to JIP players
GVAR(explosivesOrientations) pushBack [_explosive, _direction, _pitch];
// This is a good time to filter the array and remove explosives that no longer exist
GVAR(explosivesOrientations) = GVAR(explosivesOrientations) select {
params ["_explosive"];
(!isNull _explosive && {alive _explosive})
};
};