From 236ae767b50f74f366ac55254feb360559f98a14 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 28 May 2015 00:18:45 -0500 Subject: [PATCH] Goggles - Cache Surface Dust --- addons/goggles/XEH_postInit.sqf | 2 ++ addons/goggles/functions/fnc_dustHandler.sqf | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/addons/goggles/XEH_postInit.sqf b/addons/goggles/XEH_postInit.sqf index a6fe7c415f..a63004083d 100644 --- a/addons/goggles/XEH_postInit.sqf +++ b/addons/goggles/XEH_postInit.sqf @@ -47,6 +47,8 @@ GVAR(DustHandler) = -1; GVAR(RainDrops) = objNull; GVAR(RainActive) = false; GVAR(RainLastLevel) = 0; +GVAR(surfaceCache) = ""; +GVAR(surfaceCacheIsDust) = false; FUNC(CheckGlasses) = { if (GVAR(Current) != (goggles ace_player)) then { diff --git a/addons/goggles/functions/fnc_dustHandler.sqf b/addons/goggles/functions/fnc_dustHandler.sqf index af3c084e63..44475d1acc 100644 --- a/addons/goggles/functions/fnc_dustHandler.sqf +++ b/addons/goggles/functions/fnc_dustHandler.sqf @@ -15,7 +15,7 @@ * Public: No */ #include "script_component.hpp" -private ["_bullets", "_position", "_surface", "_found", "_weapon", "_cloudType", "_unit"]; +private ["_bullets", "_position", "_surface", "_weapon", "_cloudType", "_unit"]; EXPLODE_2_PVT(_this,_unit,_weapon); if (_unit != ace_player) exitWith {true}; _cloudType = ""; @@ -39,12 +39,14 @@ if (surfaceIsWater _position) exitWith {}; if ((_position select 2) > 0.2) exitWith {}; _surface = surfaceType _position; -_surface = ([_surface, "#"] call CBA_fnc_split) select 1; -_found = false; -_found = getNumber (ConfigFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1; +if (_surface != GVAR(surfaceCache)) then { + GVAR(surfaceCache) = _surface; + _surface = ([_surface, "#"] call CBA_fnc_split) select 1; + GVAR(surfaceCacheIsDust) = getNumber (ConfigFile >> "CfgSurfaces" >> _surface >> "dust") >= 0.1; +}; -if (!_found) exitWith {}; +if (!GVAR(surfaceCacheIsDust)) exitWith {}; _bullets = GETDUSTT(DBULLETS);