Merge pull request #134 from KoffeinFlummi/switchUnits_codecleanup

SwitchUnits: remove PFH and code cleanup
This commit is contained in:
bux578 2015-03-01 14:11:01 +01:00
commit e3db1466f5
9 changed files with 53 additions and 31 deletions

View File

@ -9,3 +9,4 @@ class Extended_PostInit_EventHandlers {
clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) );
};
};

View File

@ -16,24 +16,13 @@
#include "script_component.hpp"
DFUNC(pfhClientInit) = {
if (GVAR(EnableSwitchUnits)) exitWith {
private ["_sides"];
_sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (player getVariable ["ACE_CanSwitchUnits", false]) then {
[player, _sides] call FUNC(initPlayer);
if (missionNamespace getVariable [QGVAR(EnableSwitchUnits), false]) then {
[player] call FUNC(startSwitchUnits);
} else {
["SettingChanged", {
PARAMS_2(_name,_value);
if ((_name == QGVAR(EnableSwitchUnits)) && {_value}) then {
[player] call FUNC(startSwitchUnits);
};
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}] call EFUNC(common,addEventhandler);
};
[FUNC(pfhClientInit), 0.5, []] call cba_fnc_addPerFrameHandler;

View File

@ -9,6 +9,7 @@ PREP(isValidAi);
PREP(markAiOnMap);
PREP(module);
PREP(nearestPlayers);
PREP(startSwitchUnits);
PREP(switchBack);
PREP(switchUnit);

View File

@ -16,10 +16,6 @@ class CfgPatches {
#include "CfgVehicles.hpp"
class ACE_Settings {
class GVAR(SafeZoneRadius) {
value = 100;
typeName = "SCALAR";
};
class GVAR(EnableSwitchUnits) {
value = 0;
typeName = "BOOL";
@ -44,4 +40,8 @@ class ACE_Settings {
value = 1;
typeName = "BOOL";
};
class GVAR(SafeZoneRadius) {
value = 100;
typeName = "SCALAR";
};
};

View File

@ -40,9 +40,6 @@ DFUNC(pfhMarkAiOnMap) = {
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
private ["_markerName", "_marker", "_markerColor"];
hint format ["marker. %1", time];
//_markerName = format ["%1", [_x] call EFUNC(common,getName)];
_markerName = str _x;
_marker = createMarkerLocal [_markerName, position _x];

View File

@ -20,8 +20,7 @@
if !(isServer) exitWith {};
_logic = _this select 0;
_activated = _this select 2;
EXPLODE_3_PVT(_this,_logic,_units,_activated);
if !(_activated) exitWith {};

View File

@ -0,0 +1,36 @@
/*
* Author: bux578
* Starts the SwitchUnits functionality
*
* Arguments:
* 0: player <OBJECT>
*
* Return Value:
* None
*
* Example:
* [_player] call FUNC(startSwitchUnits)
*
* Public: No
*/
#include "script_component.hpp"
private "_player";
_player = _this select 0;
if (GVAR(EnableSwitchUnits)) then {
private ["_sides"];
_sides = [];
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
if(GVAR(SwitchToIndependent)) then {_sides pushBack independent;};
if(GVAR(SwitchToCivilian)) then {_sides pushBack civilian;};
if (_player getVariable ["ACE_CanSwitchUnits", false]) then {
[_player, _sides] call FUNC(initPlayer);
};
};

View File

@ -2,11 +2,11 @@
#include "\z\ace\addons\main\script_mod.hpp"
#ifdef DEBUG_ENABLED_SWITCHUNITS
#define DEBUG_MODE_FULL
#define DEBUG_MODE_FULL
#endif
#ifdef DEBUG_SETTINGS_SWITCHUNITS
#define DEBUG_SETTINGS DEBUG_SETTINGS_SwitchUnits
#define DEBUG_SETTINGS DEBUG_SETTINGS_SwitchUnits
#endif
#include "\z\ace\addons\main\script_macros.hpp"

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited with tabler - 2014-12-20 -->
<Project name="ACE">
<Package name="SwitchUnits">
<Key ID="STR_ACE_SwitchUnits_SwitchedUnit">