Skip to content

Commit

Permalink
Optimize CBA_fnc_getActiveFeatureCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Sep 14, 2018
1 parent 99f32e7 commit 9e07b1c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
25 changes: 17 additions & 8 deletions addons/common/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,23 @@ GVAR(delayless_loop) = QUOTE(PATHTOF(delayless_loop.fsm));

// Initialize Components
GVAR(groups) = [grpNull, grpNull, grpNull, grpNull, grpNull];
GVAR(featureCameras) = [
["curator", {!isNull curatorCamera}], // Curator
["nexus", {!isNull (missionNamespace getVariable ["BIS_EGSpectatorCamera_camera", objNull])}], // BIS Nexus Spectator
["arsenal", {!isNull (uiNamespace getVariable ["BIS_fnc_arsenal_cam", objNull])}], // Arsenal camera
["establishing", {!isNull (missionNamespace getVariable ["BIS_fnc_establishingShot_fakeUAV", objNull])}], // Establishing shot camera
["splendid", {!isNull (missionNamespace getVariable ["BIS_fnc_camera_cam", objNull])}], // Splendid camera
["animViewer", {!isNull (uiNamespace getVariable ["BIS_fnc_animViewer_cam", objNull])}], // Animation viewer camera
["classic", {!isNull (missionNamespace getVariable ["BIS_DEBUG_CAM", objNull])}] // Classic camera
GVAR(featureCamerasCode) = [
{!isNull curatorCamera}, // Curator
{!isNull (missionNamespace getVariable ["BIS_EGSpectatorCamera_camera", objNull])}, // BIS Nexus Spectator
{!isNull (uiNamespace getVariable ["BIS_fnc_arsenal_cam", objNull])}, // Arsenal camera
{!isNull (missionNamespace getVariable ["BIS_fnc_establishingShot_fakeUAV", objNull])}, // Establishing shot camera
{!isNull (missionNamespace getVariable ["BIS_fnc_camera_cam", objNull])}, // Splendid camera
{!isNull (uiNamespace getVariable ["BIS_fnc_animViewer_cam", objNull])}, // Animation viewer camera
{!isNull (missionNamespace getVariable ["BIS_DEBUG_CAM", objNull])} // Classic camera
];
GVAR(featureCamerasNames) = [
"curator", // Curator
"nexus", // BIS Nexus Spectator
"arsenal", // Arsenal camera
"establishing", // Establishing shot camera
"splendid", // Splendid camera
"animViewer", // Animation viewer camera
"classic" // Classic camera
];

call COMPILE_FILE(init_gauss);
Expand Down
7 changes: 1 addition & 6 deletions addons/common/fnc_getActiveFeatureCamera.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,4 @@ Author:
---------------------------------------------------------------------------- */
SCRIPT(getActiveFeatureCamera);

{
_x params ["_name", "_callback"];

if (call _callback) exitWith {_name};
""
} forEach GVAR(featureCameras);
GVAR(featureCamerasNames) param [GVAR(featureCamerasCode) findIf {call _x}, "none"]

This comment has been minimized.

Copy link
@jonpas

jonpas Sep 14, 2018

Member

Would prefer to leave none as "", easier and shorter to check in user's code.

5 changes: 4 additions & 1 deletion addons/common/fnc_registerFeatureCamera.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ if (_callback isEqualTo false) exitWith {
false
};

(GVAR(featureCameras) pushBackUnique _this) != -1 // return
GVAR(featureCamerasNames) pushBack _name;
GVAR(featureCamerasCode) pushBack _callback;

This comment has been minimized.

Copy link
@jonpas

jonpas Sep 14, 2018

Member

pushBackUnique and don't pushback name if return is -1. That way you can add multiple checks separately (for whatever reason) for same name, but code can't be the same (automatically avoids duplicate checks).


true

0 comments on commit 9e07b1c

Please sign in to comment.