Skip to content

Commit 9dc777c

Browse files
authored
Intercom - Fix infantry phone not automatically disconnected when player enters a different vehicle (#1391)
* Add debugging info * Fix inf phone not disconnected when not on foot * Revert changes * Disconnect infantry phone when vehicle changes * Revert * Fix default
1 parent 7285893 commit 9dc777c

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

addons/sys_intercom/fnc_enterVehicle.sqf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
*/
1818

1919
params ["_vehicle", "_unit"];
20-
TRACE_2("enterVehicle",typeOf _vehicle,typeOf _unit);
20+
TRACE_2("enterVehicle",_vehicle,_unit);
21+
22+
(_unit getVariable [QGVAR(vehicleInfantryPhone), [objNull, INTERCOM_DISCONNECTED]]) params ["_vehicleInfantryPhone", "_infantryPhoneNetwork"];
23+
if (!isNull _vehicleInfantryPhone) then {
24+
// Disconnect infantry phone
25+
[_vehicleInfantryPhone, _unit, 0, _infantryPhoneNetwork] call FUNC(updateInfantryPhoneStatus);
26+
};
2127

2228
if ((_unit == _vehicle) || {GVAR(intercomPFH) > -1}) then {
2329
[GVAR(intercomPFH)] call CBA_fnc_removePerFrameHandler;

addons/sys_intercom/fnc_intercomPFH.sqf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ for "_i" from 0 to ((count _intercoms) - 1) do {
3636
_connectionStatus = [_vehicle, _player, _i, INTERCOM_STATIONSTATUS_CONNECTION] call FUNC(getStationConfiguration);
3737
};
3838

39+
TRACE_4("Intercom Frame",_vehicle,_player,_infantryPhoneNetwork,_i);
3940
if (_player == _unitInfantryPhone && {_infantryPhoneNetwork == _i}) then {
4041
(_vehicle getVariable [QGVAR(infantryPhoneInfo), [[0, 0, 0], 10]]) params ["_infantryPhonePosition", "_infantryPhoneMaxDistance"];
4142
_infantryPhonePosition = _vehicle modelToWorld _infantryPhonePosition;

addons/sys_intercom/fnc_updateInfantryPhoneStatus.sqf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ private _intercomText = format ["( %1 )", _intercomName];
2828

2929
switch (_action) do {
3030
case 0: {
31+
TRACE_3("Disconnect infantry phone",_vehicle,_unit,_intercomNetwork);
3132
// Stop using the intercom externally
3233
_vehicle setVariable [QGVAR(unitInfantryPhone), nil, true];
3334
_unit setVariable [QGVAR(vehicleInfantryPhone), nil, true];
@@ -40,6 +41,7 @@ switch (_action) do {
4041
[GVAR(intercomPFH)] call CBA_fnc_removePerFrameHandler;
4142
};
4243
case 1: {
44+
TRACE_3("Connect infantry phone",_vehicle,_unit,_intercomNetwork);
4345
// Start using the intercom externally
4446
_vehicle setVariable [QGVAR(unitInfantryPhone), [_unit, _intercomNetwork], true];
4547
_unit setVariable [QGVAR(vehicleInfantryPhone), [_vehicle, _intercomNetwork], true];
@@ -51,6 +53,7 @@ switch (_action) do {
5153
GVAR(intercomPFH) = [DFUNC(intercomPFH), 1.1, [acre_player, _vehicle]] call CBA_fnc_addPerFrameHandler;
5254
};
5355
case 2: {
56+
TRACE_4("Give infantry phone to another unit",_vehicle,_unit,_intercomNetwork,_givingUnit);
5457
// Give the intercom to another unit
5558
_givingUnit setVariable [QGVAR(vehicleInfantryPhone), nil, true];
5659
[GVAR(intercomPFH)] call CBA_fnc_removePerFrameHandler;
@@ -62,6 +65,7 @@ switch (_action) do {
6265
[QGVAR(giveInfantryPhone), [_vehicle, _unit, 1, _message, _intercomNetwork, _position], _unit] call CBA_fnc_targetEvent;
6366
};
6467
case 3: {
68+
TRACE_3("Update infantry phone vars",_vehicle,_unit,_intercomNetwork);
6569
_vehicle setVariable [QGVAR(unitInfantryPhone), [_unit, _intercomNetwork], true];
6670
_unit setVariable [QGVAR(vehicleInfantryPhone), [_vehicle, _intercomNetwork], true];
6771
};

0 commit comments

Comments
 (0)