Skip to content

Commit

Permalink
Unclaim, then claim
Browse files Browse the repository at this point in the history
  • Loading branch information
johnb432 committed Jan 12, 2025
1 parent c49a82a commit befdcc2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions addons/sitting/functions/fnc_sit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ private _seatDistOrig = (getPosASL _player) distance _seat;
_seatsClaimed set [_seatPos, objNull];
_seat setVariable [QGVAR(seatsClaimed), _seatsClaimed, true];

// Unclaim if no one else sitting on it, but pass ownership if someone remains
private _newOwner = _seatsClaimed param [_seatsClaimed findIf {!isNull _x}, objNull];
[_newOwner, _seat] call EFUNC(common,claim);
// Unclaim...
[objNull, _seat] call EFUNC(common,claim);

// ...but have a remaining unit reclaim ownership immediately
private _index = _seatsClaimed findIf {!isNull _x};

if (_index == -1) exitWith {};

[_seatsClaimed select _index, _seat] call EFUNC(common,claim);
};

// Stand up if chair gets deleted or moved
Expand Down
12 changes: 9 additions & 3 deletions addons/sitting/functions/fnc_stand.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ private _seatsClaimed = _seat getVariable [QGVAR(seatsClaimed), []];
_seatsClaimed set [_seatPos, objNull];
_seat setVariable [QGVAR(seatsClaimed), _seatsClaimed, true];

// Unclaim if no one else sitting on it, but pass ownership if someone remains
private _newOwner = _seatsClaimed param [_seatsClaimed findIf {!isNull _x}, objNull];
[_newOwner, _seat] call EFUNC(common,claim);
// Unclaim...
[objNull, _seat] call EFUNC(common,claim);

// ...but have a remaining unit reclaim ownership immediately
private _index = _seatsClaimed findIf {!isNull _x};

if (_index == -1) exitWith {};

[_seatsClaimed select _index, _seat] call EFUNC(common,claim);

0 comments on commit befdcc2

Please sign in to comment.