From 97776c168bf3e8a65918e3c8e0db771773829ad2 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 14 Mar 2015 10:48:53 +0100 Subject: [PATCH] use chemlights common parent class to reduce nearObjects calls --- .../mapfx/functions/fnc_determineMapLight.sqf | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/addons/mapfx/functions/fnc_determineMapLight.sqf b/addons/mapfx/functions/fnc_determineMapLight.sqf index 8c2e78f370..2307116b4e 100644 --- a/addons/mapfx/functions/fnc_determineMapLight.sqf +++ b/addons/mapfx/functions/fnc_determineMapLight.sqf @@ -100,17 +100,25 @@ if (vehicle ACE_player == ACE_player) then { TRACE_1("player near chemlight",""); }; - _nearObjects = [ACE_player nearObjects ["Chemlight_red", 4], {alive _this}] call EFUNC(common,filter); - [_nearObjects, [1,0,0,1]] call _fnc_chemLight; + // all chemlights inherit from SmokeShell, CfgAmmo + _nearObjects = [ACE_player nearObjects ["SmokeShell", 4], {alive _this}] call EFUNC(common,filter); - _nearObjects = [ACE_player nearObjects ["Chemlight_green", 4], {alive _this}] call EFUNC(common,filter); - [_nearObjects, [0,1,0,1]] call _fnc_chemLight; - - _nearObjects = [ACE_player nearObjects ["Chemlight_blue", 4], {alive _this}] call EFUNC(common,filter); - [_nearObjects, [0,0,1,1]] call _fnc_chemLight; - - _nearObjects = [ACE_player nearObjects ["Chemlight_yellow", 4], {alive _this}] call EFUNC(common,filter); - [_nearObjects, [1,1,0,1]] call _fnc_chemLight; + { + switch (toLower typeOf _x) do { + case ("chemlight_red"): { + [_nearObjects, [1,0,0,1]] call _fnc_chemLight; + }; + case ("chemlight_green"): { + [_nearObjects, [0,1,0,1]] call _fnc_chemLight; + }; + case ("chemlight_blue"): { + [_nearObjects, [0,0,1,1]] call _fnc_chemLight; + }; + case ("chemlight_yellow"): { + [_nearObjects, [1,1,0,1]] call _fnc_chemLight; + }; + }; + } forEach _nearObjects; // Gun with light if (_gunlight) then {