Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for non local Zeus RC in common-isPlayer #3052

Merged
merged 2 commits into from
Dec 31, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions addons/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@
// Eventhandlers
//////////////////////////////////////////////////

//Add a fix for BIS's zeus remoteControl module not reseting variables on DC when RC a unit
//This variable is used for isPlayer checks
if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {
params ["_dcPlayer"];
private _zeusLogic = getAssignedCuratorLogic _dcPlayer;
if ((!isNil "_zeusLogic") && {!isNull _zeusLogic}) then {
{
if ((_x getvariable ["bis_fnc_moduleRemoteControl_owner", objnull]) isEqualTo _dcPlayer) exitWith {
ACE_LOGINFO_3("[%1] DC - Was Zeus [%2] while controlling unit [%3] - manually clearing `bis_fnc_moduleRemoteControl_owner`", [_x] call FUNC(getName), _dcPlayer, _x);
_x setVariable ["bis_fnc_moduleRemoteControl_owner", nil, true];
};
} count (curatorEditableObjects _zeusLogic);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc there has been a discussion in slack that we always should return something in count loops. nil, false etc...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will implicitly return nil, though it is probably good practise to do that explicitly

};
}];
};

// Listens for global "SettingChanged" events, to update the force status locally
["SettingChanged", {
params ["_name", "_value", "_force"];
Expand Down
7 changes: 5 additions & 2 deletions addons/common/functions/fnc_isPlayer.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Author: bux578, commy2, akalegman
* Checks if a unit is a player / curator controlled unit.
* Currently returns false for non-local remote controlled zeus units. (Remotes from another zeus machine)
* This now includes both local and non-local remote controlled zeus units. (Remotes from another zeus machine)
*
* Arguments:
* 0: unit to be checked <OBJECT>
Expand All @@ -10,10 +10,13 @@
* Return Value:
* Is unit a player? <BOOL>
*
* Example:
* [cursorTarget, false] call ace_common_fnc_isPlayer;
*
* Public: Yes
*/
#include "script_component.hpp"

params ["_unit", ["_excludeRemoteControlled", false]];

isPlayer _unit || (!_excludeRemoteControlled && {_unit == call FUNC(player)}) // return
(isPlayer _unit) || {(!_excludeRemoteControlled) && {!isNull (_unit getVariable ["bis_fnc_moduleRemoteControl_owner", objNull])}}