Merge pull request #3398 from acemod/fix3317

Resync mine orientations in JIP.
This commit is contained in:
commy2 2016-02-27 16:52:53 +01:00
commit a7ec4d9d2f
6 changed files with 58 additions and 16 deletions

View File

@ -36,16 +36,40 @@ 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);
};
// In case we are a JIP client, ask the server for orientation of any previously
// placed mine.
if (isServer) then {
["clientRequestsOrientations", {
params ["_logic"];
TRACE_1("clientRequestsOrientations received:",_logic);
// Filter the array before sending it
GVAR(explosivesOrientations) = GVAR(explosivesOrientations) select {
_x params ["_explosive"];
(!isNull _explosive && {alive _explosive})
};
};
} forEach allMines;
TRACE_1("serverSendsOrientations sent:",GVAR(explosivesOrientations));
["serverSendsOrientations", _logic, [GVAR(explosivesOrientations)]] call EFUNC(common,targetEvent);
}] call EFUNC(common,addEventHandler);
} else {
["serverSendsOrientations", {
params ["_explosivesOrientations"];
TRACE_1("serverSendsOrientations received:",_explosivesOrientations);
{
_x params ["_explosive","_direction","_pitch"];
TRACE_3("orientation set:",_explosive,_direction,_pitch);
[_explosive, _direction, _pitch] call FUNC(setPosition);
} forEach _explosivesOrientations;
private _group = group GVAR(localLogic);
deleteVehicle GVAR(localLogic);
GVAR(localLogic) = nil;
deleteGroup _group;
}] call EFUNC(common,addEventHandler);
// Create a logic to get the client ID
GVAR(localLogic) = (createGroup sideLogic) createUnit ["Logic", [0,0,0], [], 0, "NONE"];
TRACE_1("clientRequestsOrientations sent:",GVAR(localLogic));
["clientRequestsOrientations", [GVAR(localLogic)]] 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,15 @@ 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 {
_x params ["_explosive"];
(!isNull _explosive && {alive _explosive})
};
TRACE_1("setPosition",GVAR(explosivesOrientations));
};

View File

@ -9,9 +9,8 @@
// request marker data for JIP
if (isMultiplayer && {!isServer} && {hasInterface}) then {
private _logic = createGroup sideLogic createUnit ["Logic", [0,0,0], [], 0, "NONE"];
[QGVAR(sendMarkersJIP), [_logic]] call EFUNC(common,serverEvent);
GVAR(localLogic) = (createGroup sideLogic) createUnit ["Logic", [0,0,0], [], 0, "NONE"];
[QGVAR(sendMarkersJIP), [GVAR(localLogic)]] call EFUNC(common,serverEvent);
};
GVAR(mapDisplaysWithDrawEHs) = [];

View File

@ -21,5 +21,5 @@ TRACE_1("params",_logic);
[
QGVAR(setMarkerJIP),
[_logic],
[GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[]), _logic]
[GETGVAR(allMapMarkers,[]), GETGVAR(allMapMarkersProperties,[])]
] call EFUNC(common,targetEvent);

View File

@ -17,8 +17,8 @@
*/
#include "script_component.hpp"
params ["_allMapMarkers", "_allMapMarkersProperties", "_logic"];
TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic);
params ["_allMapMarkers", "_allMapMarkersProperties"];
TRACE_3("params",_allMapMarkers,_allMapMarkersProperties);
{
private _index = _allMapMarkers find _x;
@ -51,4 +51,7 @@ TRACE_3("params",_allMapMarkers,_allMapMarkersProperties,_logic);
false
} count allMapMarkers;
deleteVehicle _logic;
private _group = group GVAR(localLogic);
deleteVehicle GVAR(localLogic);
GVAR(localLogic) = nil;
deleteGroup _group;