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

Vehicle Lock - Enable for planes #6646

Merged
merged 7 commits into from
Oct 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 0 additions & 18 deletions addons/vehiclelock/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,3 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};

class Extended_InitPost_EventHandlers {
class Car {
class ADDON {
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
};
};
class Tank {
class ADDON {
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
};
};
class Helicopter {
class ADDON {
serverInit = QUOTE(_this call FUNC(handleVehicleInitPost));
};
};
};
3 changes: 3 additions & 0 deletions addons/vehiclelock/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class CfgVehicles {
class Helicopter: Air {
MACRO_LOCK_ACTIONS
};
class Plane: Air {
MACRO_LOCK_ACTIONS
};
class Motorcycle: LandVehicle {
MACRO_LOCK_ACTIONS
};
Expand Down
14 changes: 10 additions & 4 deletions addons/vehiclelock/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
[QGVAR(setupCustomKey), {_this call FUNC(serverSetupCustomKeyEH)}] call CBA_fnc_addEventHandler;
[QGVAR(setVehicleLock), {_this call FUNC(setVehicleLockEH)}] call CBA_fnc_addEventHandler;

if (!hasInterface) exitwith {};

["ace_settingsInitialized", {
TRACE_1("SettingsInitialized eh",GVAR(LockVehicleInventory));
TRACE_2("SettingsInitialized eh",GVAR(LockVehicleInventory),GVAR(VehicleStartingLockState));

if (GVAR(LockVehicleInventory)) then {
if (hasInterface && {GVAR(LockVehicleInventory)}) then {
["CAManBase", "InventoryOpened", {_this call FUNC(onOpenInventory)}] call CBA_fnc_addClassEventHandler;
};
if (isServer && {GVAR(VehicleStartingLockState) != -1}) then {
[{
TRACE_1("adding lock handler",GVAR(VehicleStartingLockState));
{
[_x, "initpost", LINKFUNC(handleVehicleInitPost), true, [], true] call CBA_fnc_addClassEventHandler;
} forEach ["Car", "Tank", "Air"];
}, [], 0.25] call CBA_fnc_waitAndExecute;
};
}] call CBA_fnc_addEventHandler;
36 changes: 13 additions & 23 deletions addons/vehiclelock/functions/fnc_handleVehicleInitPost.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Author: PabstMirror
* For every lockable vehicle, sets the starting lock state to a sane value.
* Only run if the InitModule is placed.
* Only run if the enabled via settings
*
* Arguments:
* 0: Vehicle <OBJECT>
Expand All @@ -16,28 +16,18 @@
* Public: No
*/

if (!isServer) exitWith {};

params ["_vehicle"];
TRACE_1("params",_vehicle);

[{
//If the module wasn't placed, just exit (needs to be in wait because objectInitEH is before moduleInit)
if (GVAR(VehicleStartingLockState) == -1) exitWith {};
TRACE_1("handleVehicleInitPost",_vehicle);

params ["_vehicle"];

if ((_vehicle isKindOf "Car") || {_vehicle isKindOf "Tank"} || {_vehicle isKindOf "Helicopter"}) then {
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states)
private _lock = switch (GVAR(VehicleStartingLockState)) do {
case (0): { (locked _vehicle) in [2, 3] };
case (1): { true };
case (2): { false };
};
if ((_lock && {(locked _vehicle) != 2}) || {!_lock && {(locked _vehicle) != 0}}) then {
TRACE_3("Setting Lock State",_lock,(typeOf _vehicle),_vehicle);
[QGVAR(SetVehicleLock), [_vehicle, _lock], [_vehicle]] call CBA_fnc_targetEvent;
};
if (alive _vehicle) then {
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states)
private _lock = switch (GVAR(VehicleStartingLockState)) do {
case 0: {locked _vehicle in [2, 3]};
case 1: {true};
case 2: {false};
};
if ((_lock && {locked _vehicle != 2}) || {!_lock && {locked _vehicle != 0}}) then {
TRACE_3("Setting Lock State",_lock,typeOf _vehicle,_vehicle);
[QGVAR(SetVehicleLock), [_vehicle, _lock], [_vehicle]] call CBA_fnc_targetEvent;
};
//Delay call until mission start (so everyone has the eventHandler's installed)
}, [_vehicle], 0.25] call CBA_fnc_waitAndExecute;
};
4 changes: 3 additions & 1 deletion addons/vehiclelock/functions/fnc_moduleSync.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not ac
params ["_syncedObjects"];

private _listOfVehicles = _syncedObjects select {
(_x isKindOf "Car") || {(_x isKindOf "Tank") || {_x isKindOf "Helicopter"}}
private _object = _x;
#define CLASSNAMES ["Car", "Tank", "Air"]
Copy link
Contributor

Choose a reason for hiding this comment

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

macro is useless here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Commas break the args in a macro, because the preprocessor cannot handle the parentheses syntax. You'd have to use the ARR_3 macro which is ugly.

IS_KIND_OF_ANY(_object,CLASSNAMES)
};

if (_listOfVehicles isEqualTo []) exitWith { //Verbose error for mission makers (only shows on server)
Expand Down
2 changes: 2 additions & 0 deletions addons/vehiclelock/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
#endif

#include "\z\ace\addons\main\script_macros.hpp"

#define IS_KIND_OF_ANY(object,classnames) ((classnames) findIf {(object) isKindOf _x} > -1)