diff --git a/addons/advanced_ballistics/functions/fnc_handleFired.sqf b/addons/advanced_ballistics/functions/fnc_handleFired.sqf index 2c3488f92d..db0140756d 100644 --- a/addons/advanced_ballistics/functions/fnc_handleFired.sqf +++ b/addons/advanced_ballistics/functions/fnc_handleFired.sqf @@ -114,7 +114,7 @@ if (_caliber > 0 && _bulletLength > 0 && _bulletMass > 0 && _barrelTwist > 0) th GVAR(currentbulletID) = (GVAR(currentbulletID) + 1) % 10000; -"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _AmmoCacheEntry select 0, _AmmoCacheEntry select 6, _AmmoCacheEntry select 7, _AmmoCacheEntry select 8, _AmmoCacheEntry select 5, _stabilityFactor, _WeaponCacheEntry select 1, _muzzleVelocity, _AmmoCacheEntry select 4, getPosASL _bullet, EGVAR(weather,Latitude), EGVAR(weather,currentTemperature), EGVAR(weather,Altitude), EGVAR(weather,currentHumidity), overcast, floor(ACE_time), ACE_time - floor(ACE_time)]; +"ace_advanced_ballistics" callExtension format["new:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:%17:%18", GVAR(currentbulletID), _AmmoCacheEntry select 0, _AmmoCacheEntry select 6, _AmmoCacheEntry select 7, _AmmoCacheEntry select 8, _AmmoCacheEntry select 5, _stabilityFactor, _WeaponCacheEntry select 1, _muzzleVelocity, _AmmoCacheEntry select 4, getPosASL _bullet, EGVAR(common,mapLatitude), EGVAR(weather,currentTemperature), EGVAR(common,mapAltitude), EGVAR(weather,currentHumidity), overcast, floor(ACE_time), ACE_time - floor(ACE_time)]; [{ private ["_args", "_index", "_bullet", "_caliber", "_bulletTraceVisible", "_bulletVelocity", "_bulletPosition"]; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 3796a4fdc8..ce79c078ba 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -37,6 +37,14 @@ }; }] call FUNC(addEventhandler); +//~~~~~Get Map Data~~~~~ +//Find MGRS zone and 100km grid for current map +[] call FUNC(getMGRSdata); +//Prepare variables for FUNC(getMapGridFromPos)/FUNC(getMapPosFromGrid) +[] call FUNC(getMapGridData); + + + ["fixCollision", DFUNC(fixCollision)] call FUNC(addEventhandler); ["fixFloating", DFUNC(fixFloating)] call FUNC(addEventhandler); ["fixPosition", DFUNC(fixPosition)] call FUNC(addEventhandler); diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 72e85e4b6b..de9d0aa91a 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -69,7 +69,11 @@ PREP(getFirstTerrainIntersection); PREP(getForceWalkStatus); PREP(getGunner); PREP(getInPosition); +PREP(getMapGridData); +PREP(getMapGridFromPos); +PREP(getMapPosFromGrid); PREP(getMarkerType); +PREP(getMGRSdata); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getNumberMagazinesIn); diff --git a/addons/common/functions/fnc_getMGRSdata.sqf b/addons/common/functions/fnc_getMGRSdata.sqf new file mode 100644 index 0000000000..775f439174 --- /dev/null +++ b/addons/common/functions/fnc_getMGRSdata.sqf @@ -0,0 +1,165 @@ +/* + * Author: VKing + * Gets the current map's MGRS grid zone designator and 100km square. + * Also gets longitude, latitude and altitude offset for the map + * + * Argument: + * 0: Optional: Map name, if undefined the current map is used (String) + * + * Return value: + * 0: Grid zone designator (String) + * 1: 100km square (String) + * 2: GZD + 100km sq. as a single string (String) + * Writes return values to GVAR(MGRS_data) if run on the current map + */ + +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing", "_altitude"]; + +DEFAULT_PARAM(0,_map,worldName); + +_long = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "longitude"); +_lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude"); +_altitude = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "elevationOffset"); + +if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; _altitude = 0; }; +if (_map in ["Altis", "Stratis"]) then { _lat = 40; _altitude = 0; }; +if (_map in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; _altitude = 2000; }; +if (_map in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; _altitude = 100; }; +if (_map in ["fallujah"]) then { _lat = 33; _altitude = 0; }; +if (_map in ["fata", "Abbottabad"]) then { _lat = 30; _altitude = 1000; }; +if (_map in ["sfp_wamako"]) then { _lat = 14; _altitude = 0; }; +if (_map in ["sfp_sturko"]) then { _lat = 56; _altitude = 0; }; +if (_map in ["Bornholm"]) then { _lat = 55; _altitude = 0; }; +if (_map in ["Imrali"]) then { _lat = 40; _altitude = 0; }; +if (_map in ["Caribou"]) then { _lat = 68; _altitude = 0; }; +if (_map in ["Namalsk"]) then { _lat = 65; _altitude = 0; }; +if (_map in ["MCN_Aliabad"]) then { _lat = 36; _altitude = 0; }; +if (_map in ["Clafghan"]) then { _lat = 34; _altitude = 640; }; +if (_map in ["Sangin", "hellskitchen"]) then { _lat = 32; _altitude = 0; }; +if (_map in ["Sara"]) then { _lat = 40; _altitude = 0; }; +if (_map in ["reshmaan"]) then { _lat = 35; _altitude = 2000; }; +if (_map in ["Thirsk"]) then { _lat = 65; _altitude = 0; }; +if (_map in ["lingor"]) then { _lat = -4; _altitude = 0; }; +if (_map in ["Panthera3"]) then { _lat = 46; _altitude = 0; }; +if (_map in ["Kunduz"]) then { _lat = 37; _altitude = 400; }; + + +_UTM = [_long,_lat] call BIS_fnc_posDegToUTM; +_easting = _UTM select 0; +_northing = _UTM select 1; +// _zone = _UTM select 2; +TRACE_4("",_UTM,_easting,_northing,_zone); + +/* +_band = switch (true) do { + case (_lat<-72): {"C"}; + case (_lat<-64): {"D"}; + case (_lat<-56): {"E"}; + case (_lat<-48): {"F"}; + case (_lat<-40): {"G"}; + case (_lat<-32): {"H"}; + case (_lat<-24): {"J"}; + case (_lat<-16): {"K"}; + case (_lat<-8): {"L"}; + case (_lat<0): {"M"}; + case (_lat>72): {"X"}; + case (_lat>64): {"W"}; + case (_lat>56): {"V"}; + case (_lat>48): {"U"}; + case (_lat>40): {"T"}; + case (_lat>32): {"S"}; + case (_lat>24): {"R"}; + case (_lat>16): {"Q"}; + case (_lat>8): {"P"}; + case (_lat>=0): {"N"}; +}; + */ +_zone = 1 + (floor ((_long + 180) / 6)); +_band = "Z"; +if (_lat <= -80) then { + _band = "A"; +} else { + if (_lat < 84) then { + _band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1]; + }; +}; +if (_map == "VR") then {_zone = 0; _band = "RV";}; + +_GZD = format ["%1%2",_zone,_band]; +TRACE_3("",_zone,_band,_GZD); + + +private ["_set1","_set2","_set3","_set4","_set5","_set6","_metaE","_metaN","_letterE","_letterN","_grid100km"]; + +_set1 = [1,7,13,19,25,31,37,43,49,55]; +_set2 = [2,8,14,20,26,32,38,44,50,56]; +_set3 = [3,9,15,21,27,33,39,45,51,57]; +_set4 = [4,10,16,22,28,34,40,46,52,58]; +_set5 = [5,11,17,23,29,35,41,47,53,59]; +_set6 = [6,12,18,24,30,36,42,48,54,60]; + +switch (true) do { +case (_zone in _set1): {_metaE = 1; _metaN = 1;}; +case (_zone in _set2): {_metaE = 2; _metaN = 2;}; +case (_zone in _set3): {_metaE = 3; _metaN = 1;}; +case (_zone in _set4): {_metaE = 1; _metaN = 2;}; +case (_zone in _set5): {_metaE = 2; _metaN = 1;}; +case (_zone in _set6): {_metaE = 3; _metaN = 2;}; +}; +TRACE_2("",_metaE,_metaN); + +switch (true) do { +case (_zone == 0): {_letterE = "E"}; +case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; }; +case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; }; +case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; }; +case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; }; +case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; }; +case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; }; +case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; }; +case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; }; + default {_letterE="@"}; +}; +TRACE_1("",_letterE); + +_northing = _northing mod 2000000; +TRACE_1("",_northing); + +switch (true) do { +case (_zone == 0): {_letterN = "N"}; +case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; }; +case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; }; +case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; }; +case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; }; +case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; }; +case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; }; +case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; }; +case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; }; +case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; }; +case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; }; +case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; }; +case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; }; +case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; }; +case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; }; +case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; }; +case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; }; +case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; }; +case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; }; +case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; }; +case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; }; +}; +TRACE_1("",_letterN); + +_grid100km = _letterE+_letterN; +TRACE_1("",_grid100km); + +if (_map == worldName) then { + GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km]; + GVAR(mapAltitude) = _altitude; + GVAR(mapLatitude) = _lat; + GVAR(mapLongitude) = _long; +}; +[_GZD,_grid100km,_GZD+_grid100km] \ No newline at end of file diff --git a/addons/map/functions/fnc_prepareMapGrid.sqf b/addons/common/functions/fnc_getMapGridData.sqf similarity index 88% rename from addons/map/functions/fnc_prepareMapGrid.sqf rename to addons/common/functions/fnc_getMapGridData.sqf index efa917cd2e..308772bfff 100644 --- a/addons/map/functions/fnc_prepareMapGrid.sqf +++ b/addons/common/functions/fnc_getMapGridData.sqf @@ -1,3 +1,19 @@ +/* + * Author: PabstMirror (ideas from Nou's mapGridToPos and BIS_fnc_gridToPos) + * Finds real x/y offset and map step for a 10 digit grid + * Save time by preparing data one time at startup + * + * Argument: + * None + * + * Return values: + * None + * + * Example: + * [] call ace_map_fnc_getMapGridData + * + * Public: No + */ #include "script_component.hpp" private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"]; diff --git a/addons/map/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf similarity index 92% rename from addons/map/functions/fnc_getMapGridFromPos.sqf rename to addons/common/functions/fnc_getMapGridFromPos.sqf index 2b971b14ee..983b78ffff 100644 --- a/addons/map/functions/fnc_getMapGridFromPos.sqf +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -1,64 +1,63 @@ -/* - * Author: VKing - * Gets a 10-digit map grid for the given world position - * - * Argument: - * 0: Position (2D Position) - * 1: Return type; false for array of easting and northing, true for single string - * - * Return values: - * 0: Easting - * 1: Northing - * - * Example: - * [(getPos player)] call ace_map_fnc_getMapGridFromPos; - * - * Public: Yes - */ - -// #define DEBUG_MODE_FULL -#include "script_component.hpp" - -PARAMS_1(_pos); -DEFAULT_PARAM(1,_returnSingleString,false); - -private["_count", "_easting", "_nativeGrid", "_northing"]; - -//Fallback, when map data is weird (letters) -if ((count GVAR(mapGridData)) == 0) exitWith { - _nativeGrid = mapGridPosition _pos; - if (_returnSingleString) then { - _nativeGrid - } else { - _count = floor ((count _nativeGrid) / 2); - [(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])] - }; -}; - -EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); -_easting = floor (((_pos select 0) - _offsetX) / _stepXat5); -_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5); - -//Attempt to handle negative east/north (e.g.: moving west of map bounds) -if (_easting > 0) then { - _easting = str _easting; - while {count _easting < 5} do {_easting = "0" + _easting;}; -} else { - _easting = str abs _easting; - while {count _easting < 4} do {_easting = "0" + _easting;}; - _easting = "-" + _easting; -}; -if (_northing > 0) then { - _northing = str _northing; - while {count _northing < 5} do {_northing = "0" + _northing;}; -} else { - _northing = str abs _northing; - while {count _northing < 4} do {_northing = "0" + _northing;}; - _northing = "-" + _northing; -}; - -if (_returnSingleString) then { - _easting + _northing -} else { - [_easting, _northing] -}; +/* + * Author: VKing, PabstMirror + * Gets a 10-digit map grid for the given world position + * + * Argument: + * 0: Position (2D Position) + * 1: Return type; false for array of easting and northing, true for single string + * + * Return values: + * 0: Easting + * 1: Northing + * + * Example: + * [(getPos player)] call ace_common_fnc_getMapGridFromPos; + * + * Public: Yes + */ +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +PARAMS_1(_pos); +DEFAULT_PARAM(1,_returnSingleString,false); + +private["_count", "_easting", "_nativeGrid", "_northing"]; + +//Fallback, when map data is weird (letters) +if ((count GVAR(mapGridData)) == 0) exitWith { + _nativeGrid = mapGridPosition _pos; + if (_returnSingleString) then { + _nativeGrid + } else { + _count = floor ((count _nativeGrid) / 2); + [(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])] + }; +}; + +EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); +_easting = floor (((_pos select 0) - _offsetX) / _stepXat5); +_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5); + +//Attempt to handle negative east/north (e.g.: moving west of map bounds) +if (_easting > 0) then { + _easting = str _easting; + while {count _easting < 5} do {_easting = "0" + _easting;}; +} else { + _easting = str abs _easting; + while {count _easting < 4} do {_easting = "0" + _easting;}; + _easting = "-" + _easting; +}; +if (_northing > 0) then { + _northing = str _northing; + while {count _northing < 5} do {_northing = "0" + _northing;}; +} else { + _northing = str abs _northing; + while {count _northing < 4} do {_northing = "0" + _northing;}; + _northing = "-" + _northing; +}; + +if (_returnSingleString) then { + _easting + _northing +} else { + [_easting, _northing] +}; diff --git a/addons/map/functions/fnc_getMapPosFromGrid.sqf b/addons/common/functions/fnc_getMapPosFromGrid.sqf similarity index 95% rename from addons/map/functions/fnc_getMapPosFromGrid.sqf rename to addons/common/functions/fnc_getMapPosFromGrid.sqf index 2daa9c63ee..20194df88a 100644 --- a/addons/map/functions/fnc_getMapPosFromGrid.sqf +++ b/addons/common/functions/fnc_getMapPosFromGrid.sqf @@ -10,7 +10,7 @@ * Position * * Example: - * ["6900080085"] call ace_map_fnc_getMapPosFromGrid + * ["6900080085"] call ace_common_fnc_getMapPosFromGrid * * Public: Yes */ diff --git a/addons/dagr/functions/fnc_outputData.sqf b/addons/dagr/functions/fnc_outputData.sqf index ff7429fa0a..0825814d31 100644 --- a/addons/dagr/functions/fnc_outputData.sqf +++ b/addons/dagr/functions/fnc_outputData.sqf @@ -97,7 +97,7 @@ GVAR(outputPFH) = [{ // Elevation _elevation = getPosASL ACE_player; - _elevation = floor ((_elevation select 2) + EGVAR(weather,altitude)); + _elevation = floor ((_elevation select 2) + EGVAR(common,mapAltitude)); _dagrElevation = str _elevation + "m"; // Heading diff --git a/addons/dagr/functions/fnc_outputVector.sqf b/addons/dagr/functions/fnc_outputVector.sqf index 660e678a82..ad9068344f 100644 --- a/addons/dagr/functions/fnc_outputVector.sqf +++ b/addons/dagr/functions/fnc_outputVector.sqf @@ -72,7 +72,7 @@ _yCoord = switch true do { _dagrGrid = _xCoord + " " + _yCoord; // Find target elevation -_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(weather,altitude)); +_elevation = floor ((GVAR(LAZPOS) select 2) + EGVAR(common,mapAltitude)); _dagrElevation = str _elevation + "m"; // Time diff --git a/addons/kestrel4500/functions/fnc_collectData.sqf b/addons/kestrel4500/functions/fnc_collectData.sqf index 4858ad80b2..244e719b37 100644 --- a/addons/kestrel4500/functions/fnc_collectData.sqf +++ b/addons/kestrel4500/functions/fnc_collectData.sqf @@ -20,7 +20,7 @@ _playerAltitude = (getPosASL ACE_player) select 2; _temperature = _playerAltitude call EFUNC(weather,calculateTemperatureAtHeight); _humidity = EGVAR(weather,currentHumidity); _barometricPressure = _playerAltitude call EFUNC(weather,calculateBarometricPressure); -_altitude = EGVAR(weather,Altitude) + _playerAltitude; +_altitude = EGVAR(common,mapAltitude) + _playerAltitude; _airDensity = [_temperature, _barometricPressure, _humidity] call EFUNC(weather,calculateAirDensity); _densityAltitude = _airDensity call EFUNC(weather,calculateDensityAltitude); _chill = [_temperature, _humidity] call EFUNC(weather,calculateWindChill); diff --git a/addons/kestrel4500/functions/fnc_generateOutputData.sqf b/addons/kestrel4500/functions/fnc_generateOutputData.sqf index fce359de6f..d61a1f48e4 100644 --- a/addons/kestrel4500/functions/fnc_generateOutputData.sqf +++ b/addons/kestrel4500/functions/fnc_generateOutputData.sqf @@ -276,7 +276,7 @@ if (GVAR(referenceHeadingMenu) == 0) then { }; case 12: { // ALTITUDE if (!GVAR(MinAvgMax)) then { - _textCenterBig = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); + _textCenterBig = Str(round(EGVAR(common,mapAltitude) + _playerAltitude)); } else { _textCenterLine1Left = "Min"; _textCenterLine2Left = "Avg"; @@ -300,7 +300,7 @@ if (GVAR(referenceHeadingMenu) == 0) then { }; case 14: { // User Screen 1 _textCenterLine1Left = Str(round(_playerDir)); - _textCenterLine2Left = Str(round(EGVAR(weather,Altitude) + _playerAltitude)); + _textCenterLine2Left = Str(round(EGVAR(common,mapAltitude) + _playerAltitude)); _textCenterLine3Left = Str(round(abs(_windSpeed) * 10) / 10); _textCenterLine1Right = GVAR(Directions) select GVAR(Direction); _textCenterLine2Right = "m"; diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index c0aad301b7..a3f377544b 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -8,9 +8,6 @@ LOG(MSG_INIT); // Calculate the maximum zoom allowed for this map call FUNC(determineZoom); -// Find MGRS zone and 100km grid for current map -[] call FUNC(getMGRSdata); - // This spawn is probably worth keeping, as pfh don't work natively on the briefing screen and IDK how reliable the hack we implemented for them is. // The thread dies as soon as the mission start, so it's not really compiting for scheduler space. [] spawn { diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index 1f1131eb9f..c5645a52e7 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -7,15 +7,8 @@ PREP(blueForceTrackingModule); PREP(blueForceTrackingUpdate); PREP(determineMapLight); PREP(determineZoom); -PREP(getMapGridFromPos); -PREP(getMapPosFromGrid); -PREP(getMGRSdata); PREP(moduleMap); PREP(onDrawMap); -PREP(prepareMapGrid); PREP(updateMapEffects); -//Prepare variables for FUNC(getMapGridFromPos): -[] call FUNC(prepareMapGrid); - ADDON = true; diff --git a/addons/map/functions/fnc_getMGRSdata.sqf b/addons/map/functions/fnc_getMGRSdata.sqf deleted file mode 100644 index 02097b4c83..0000000000 --- a/addons/map/functions/fnc_getMGRSdata.sqf +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Author: VKing - * - * Gets the current map's MGRS grid zone designator and 100km square. - * - * Argument: - * 0: Optional: Map name, if undefined the current map is used (String) - * - * Return value: - * 0: Grid zone designator (String) - * 1: 100km square (String) - * 2: GZD + 100km sq. as a single string (String) - * Writes return values to GVAR(MGRS_data) if run on the current map - */ - -// #define DEBUG_MODE_FULL -#include "script_component.hpp" - -private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing"]; - -DEFAULT_PARAM(0,_map,worldName); - -_long = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "longitude"); -_lat = getNumber (ConfigFile >> "CfgWorlds" >> _map >> "latitude"); - -// if (!isNil QEGVAR(weather,Latitude)) then {_lat = EGVAR(weather,Latitude)}; - -if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; }; -if (_map in ["Altis", "Stratis"]) then { _lat = 35; }; -if (_map in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; }; -if (_map in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; }; -if (_map in ["fallujah"]) then { _lat = 33; }; -if (_map in ["fata", "Abbottabad"]) then { _lat = 30; }; -if (_map in ["sfp_wamako"]) then { _lat = 14; }; -if (_map in ["sfp_sturko"]) then { _lat = 56; }; -if (_map in ["Bornholm"]) then { _lat = 55; }; -if (_map in ["Imrali"]) then { _lat = 40; }; -if (_map in ["Caribou"]) then { _lat = 68; }; -if (_map in ["Namalsk"]) then { _lat = 65; }; -if (_map in ["MCN_Aliabad"]) then { _lat = 36; }; -if (_map in ["Clafghan"]) then { _lat = 34; }; -if (_map in ["Sangin", "hellskitchen"]) then { _lat = 32; }; -if (_map in ["Sara"]) then { _lat = 40; }; -if (_map in ["reshmaan"]) then { _lat = 35; }; -if (_map in ["Thirsk"]) then { _lat = 65; }; -if (_map in ["lingor"]) then { _lat = -4; }; -if (_map in ["Panthera3"]) then { _lat = 46; }; -if (_map in ["Kunduz"]) then { _lat = 37; }; - - -_UTM = [_long,_lat] call BIS_fnc_posDegToUTM; -_easting = _UTM select 0; -_northing = _UTM select 1; -// _zone = _UTM select 2; -TRACE_4("",_UTM,_easting,_northing,_zone); - -/* -_band = switch (true) do { - case (_lat<-72): {"C"}; - case (_lat<-64): {"D"}; - case (_lat<-56): {"E"}; - case (_lat<-48): {"F"}; - case (_lat<-40): {"G"}; - case (_lat<-32): {"H"}; - case (_lat<-24): {"J"}; - case (_lat<-16): {"K"}; - case (_lat<-8): {"L"}; - case (_lat<0): {"M"}; - case (_lat>72): {"X"}; - case (_lat>64): {"W"}; - case (_lat>56): {"V"}; - case (_lat>48): {"U"}; - case (_lat>40): {"T"}; - case (_lat>32): {"S"}; - case (_lat>24): {"R"}; - case (_lat>16): {"Q"}; - case (_lat>8): {"P"}; - case (_lat>=0): {"N"}; -}; -*/ -_zone = 1 + (floor ((_long + 180) / 6)); -_band = "Z"; -if (_lat <= -80) then { - _band = "A"; -} else { - if (_lat < 84) then { - _band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_lat / 8) + 10)), 1]; - }; -}; -if (_map == "VR") then {_zone = 0; _band = "RV";}; - -_GZD = format ["%1%2",_zone,_band]; -TRACE_3("",_zone,_band,_GZD); - - -private ["_set1","_set2","_set3","_set4","_set5","_set6","_metaE","_metaN","_letterE","_letterN","_grid100km"]; - -_set1 = [1,7,13,19,25,31,37,43,49,55]; -_set2 = [2,8,14,20,26,32,38,44,50,56]; -_set3 = [3,9,15,21,27,33,39,45,51,57]; -_set4 = [4,10,16,22,28,34,40,46,52,58]; -_set5 = [5,11,17,23,29,35,41,47,53,59]; -_set6 = [6,12,18,24,30,36,42,48,54,60]; - -switch (true) do { - case (_zone in _set1): {_metaE = 1; _metaN = 1;}; - case (_zone in _set2): {_metaE = 2; _metaN = 2;}; - case (_zone in _set3): {_metaE = 3; _metaN = 1;}; - case (_zone in _set4): {_metaE = 1; _metaN = 2;}; - case (_zone in _set5): {_metaE = 2; _metaN = 1;}; - case (_zone in _set6): {_metaE = 3; _metaN = 2;}; -}; -TRACE_2("",_metaE,_metaN); - -switch (true) do { - case (_zone == 0): {_letterE = "E"}; - case (_easting > 800000): {LOG("E8"); switch (_metaE) do {case 1: {_letterE="H"}; case 2: {_letterE="R"}; case 3: {_letterE="Z"}; }; }; - case (_easting > 700000): {LOG("E7"); switch (_metaE) do {case 1: {_letterE="G"}; case 2: {_letterE="Q"}; case 3: {_letterE="Y"}; }; }; - case (_easting > 600000): {LOG("E6"); switch (_metaE) do {case 1: {_letterE="F"}; case 2: {_letterE="P"}; case 3: {_letterE="X"}; }; }; - case (_easting > 500000): {LOG("E5"); switch (_metaE) do {case 1: {_letterE="E"}; case 2: {_letterE="N"}; case 3: {_letterE="W"}; }; }; - case (_easting > 400000): {LOG("E4"); switch (_metaE) do {case 1: {_letterE="D"}; case 2: {_letterE="M"}; case 3: {_letterE="V"}; }; }; - case (_easting > 300000): {LOG("E3"); switch (_metaE) do {case 1: {_letterE="C"}; case 2: {_letterE="L"}; case 3: {_letterE="U"}; }; }; - case (_easting > 200000): {LOG("E2"); switch (_metaE) do {case 1: {_letterE="B"}; case 2: {_letterE="K"}; case 3: {_letterE="T"}; }; }; - case (_easting > 100000): {LOG("E1"); switch (_metaE) do {case 1: {_letterE="A"}; case 2: {_letterE="J"}; case 3: {_letterE="S"}; }; }; - default {_letterE="@"}; -}; -TRACE_1("",_letterE); - -_northing = _northing mod 2000000; -TRACE_1("",_northing); - -switch (true) do { - case (_zone == 0): {_letterN = "N"}; - case (_northing > 1900000): {LOG("N19"); switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; }; - case (_northing > 1800000): {LOG("N18"); switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; }; - case (_northing > 1700000): {LOG("N17"); switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; }; - case (_northing > 1600000): {LOG("N16"); switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; }; - case (_northing > 1500000): {LOG("N15"); switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; }; - case (_northing > 1400000): {LOG("N14"); switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; }; - case (_northing > 1300000): {LOG("N13"); switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; }; - case (_northing > 1200000): {LOG("N12"); switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; }; - case (_northing > 1100000): {LOG("N11"); switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; }; - case (_northing > 1000000): {LOG("N10"); switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; }; - case (_northing > 900000): {LOG("N09"); switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; }; - case (_northing > 800000): {LOG("N08"); switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; }; - case (_northing > 700000): {LOG("N07"); switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; }; - case (_northing > 600000): {LOG("N06"); switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; }; - case (_northing > 500000): {LOG("N05"); switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; }; - case (_northing > 400000): {LOG("N04"); switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; }; - case (_northing > 300000): {LOG("N03"); switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; }; - case (_northing > 200000): {LOG("N02"); switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; }; - case (_northing > 100000): {LOG("N01"); switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; }; - case (_northing > 0): {LOG("N00"); switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; }; -}; -TRACE_1("",_letterN); - -_grid100km = _letterE+_letterN; -TRACE_1("",_grid100km); - -if (_map == worldName) then { - GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km]; -}; -[_GZD,_grid100km,_GZD+_grid100km] \ No newline at end of file diff --git a/addons/microdagr/XEH_clientInit.sqf b/addons/microdagr/XEH_clientInit.sqf index 3484073e57..c918bcf454 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -39,8 +39,4 @@ GVAR(newWaypointPosition) = []; GVAR(currentWaypoint) = -1; GVAR(rangeFinderPositionASL) = []; - -GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset"); - -GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(map,MGRS_data) select 0, EGVAR(map,MGRS_data) select 1]; - +GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(common,MGRS_data) select 0, EGVAR(common,MGRS_data) select 1]; diff --git a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf index 97229355dd..0822bdf310 100644 --- a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf +++ b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf @@ -34,7 +34,7 @@ _editText = ctrlText (_display displayCtrl IDC_MODEMARK_CORDSEDIT); switch (_keypadButton) do { case ("ok"): { if ((count GVAR(newWaypointPosition)) == 0) then { - _actualPos = [_editText, true] call EFUNC(map,getMapPosFromGrid); + _actualPos = [_editText, true] call EFUNC(common,getMapPosFromGrid); _actualPos set [2, (getTerrainHeightASL _actualPos)]; GVAR(newWaypointPosition) = _actualPos; [APP_MODE_MARK] call FUNC(saveCurrentAndSetNewMode); diff --git a/addons/microdagr/functions/fnc_updateDisplay.sqf b/addons/microdagr/functions/fnc_updateDisplay.sqf index f0b48751db..910f422c75 100644 --- a/addons/microdagr/functions/fnc_updateDisplay.sqf +++ b/addons/microdagr/functions/fnc_updateDisplay.sqf @@ -37,14 +37,14 @@ _waypoints = [] call FUNC(deviceGetWaypoints); switch (GVAR(currentApplicationPage)) do { case (APP_MODE_INFODISPLAY): { //Easting/Northing: - _posString = [getPos ACE_player] call EFUNC(map,getMapGridFromPos); + _posString = [getPos ACE_player] call EFUNC(common,getMapGridFromPos); _eastingText = (_posString select 0) + "e"; _northingText = (_posString select 1) + "n"; (_display displayCtrl IDC_MODEDISPLAY_EASTING) ctrlSetText _eastingText; (_display displayCtrl IDC_MODEDISPLAY_NORTHING) ctrlSetText _northingText; //Elevation: - _numASL = ((getPosASL ace_player) select 2) + GVAR(mapAltitude); + _numASL = ((getPosASL ace_player) select 2) + EGVAR(common,mapAltitude); _aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber; _aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"}; (_display displayCtrl IDC_MODEDISPLAY_ELEVATIONNUM) ctrlSetText _aboveSeaLevelText; @@ -78,8 +78,8 @@ case (APP_MODE_INFODISPLAY): { if (GVAR(currentWaypoint) == -2) then { if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then { - _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(map,getMapGridFromPos); - _targetPosName = format ["[%1 %2 %3]", EGVAR(map,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; + _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos); + _targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { @@ -97,7 +97,7 @@ case (APP_MODE_INFODISPLAY): { }; _2dDistanceKm = (((getPosASL ace_player) select [0,2]) distance (_targetPosLocationASL select [0,2])) / 1000; _rangeText = format ["%1km", ([_2dDistanceKm, 1, 1] call CBA_fnc_formatNumber)]; - _numASL = (_targetPosLocationASL select 2) + GVAR(mapAltitude); + _numASL = (_targetPosLocationASL select 2) + EGVAR(common,mapAltitude); _aboveSeaLevelText = [_numASL, 5, 0] call CBA_fnc_formatNumber; _aboveSeaLevelText = if (_numASL > 0) then {"+" + _aboveSeaLevelText + " MSL"} else {_aboveSeaLevelText + " MSL"}; }; @@ -133,8 +133,8 @@ case (APP_MODE_COMPASS): { if (GVAR(currentWaypoint) == -2) then { if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then { - _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(map,getMapGridFromPos); - _targetPosName = format ["[%1 %2 %3]", EGVAR(map,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; + _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(common,getMapGridFromPos); + _targetPosName = format ["[%1 %2 %3]", EGVAR(common,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { diff --git a/addons/rangecard/functions/fnc_updateRangeCard.sqf b/addons/rangecard/functions/fnc_updateRangeCard.sqf index b5ec9683f4..04317d46d7 100644 --- a/addons/rangecard/functions/fnc_updateRangeCard.sqf +++ b/addons/rangecard/functions/fnc_updateRangeCard.sqf @@ -149,7 +149,7 @@ if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) t _barometricPressure = 1013.25; if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then { - _barometricPressure = 1013.25 * (1 - (0.0065 * EGVAR(weather,altitude)) / 288.15) ^ 5.255754495; + _barometricPressure = 1013.25 * (1 - (0.0065 * EGVAR(common,mapAltitude)) / 288.15) ^ 5.255754495; }; _relativeHumidity = 0.5; diff --git a/addons/weather/functions/fnc_calculateBarometricPressure.sqf b/addons/weather/functions/fnc_calculateBarometricPressure.sqf index e0d8e8f878..869deb93cb 100644 --- a/addons/weather/functions/fnc_calculateBarometricPressure.sqf +++ b/addons/weather/functions/fnc_calculateBarometricPressure.sqf @@ -14,4 +14,4 @@ */ #include "script_component.hpp" -((1013.25 - 10 * overcast) * (1 - (0.0065 * (GVAR(Altitude) + _this)) / (KELVIN(GVAR(currentTemperature)) + 0.0065 * GVAR(Altitude))) ^ 5.255754495); \ No newline at end of file +((1013.25 - 10 * overcast) * (1 - (0.0065 * (EGVAR(common,mapAltitude) + _this)) / (KELVIN(GVAR(currentTemperature)) + 0.0065 * EGVAR(common,mapAltitude))) ^ 5.255754495); diff --git a/addons/weather/functions/fnc_getMapData.sqf b/addons/weather/functions/fnc_getMapData.sqf index 55c6e9c3c0..2e39f80764 100644 --- a/addons/weather/functions/fnc_getMapData.sqf +++ b/addons/weather/functions/fnc_getMapData.sqf @@ -11,31 +11,6 @@ */ #include "script_component.hpp" -GVAR(Altitude) = getNumber(configFile >> "CfgWorlds" >> worldName >> "elevationOffset"); -GVAR(Latitude) = getNumber(configFile >> "CfgWorlds" >> worldName >> "latitude"); - -if (worldName in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { GVAR(Latitude) = 50; GVAR(Altitude) = 0; }; -if (worldName in ["Altis", "Stratis"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; }; -if (worldName in ["Takistan", "Zargabad", "Mountains_ACR"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 2000; }; -if (worldName in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 100; }; -if (worldName in ["fallujah"]) then { GVAR(Latitude) = 33; GVAR(Altitude) = 0; }; -if (worldName in ["fata", "Abbottabad"]) then { GVAR(Latitude) = 30; GVAR(Altitude) = 1000; }; -if (worldName in ["sfp_wamako"]) then { GVAR(Latitude) = 14; GVAR(Altitude) = 0; }; -if (worldName in ["sfp_sturko"]) then { GVAR(Latitude) = 56; GVAR(Altitude) = 0; }; -if (worldName in ["Bornholm"]) then { GVAR(Latitude) = 55; GVAR(Altitude) = 0; }; -if (worldName in ["Imrali"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; }; -if (worldName in ["Caribou"]) then { GVAR(Latitude) = 68; GVAR(Altitude) = 0; }; -if (worldName in ["Namalsk"]) then { GVAR(Latitude) = 65; GVAR(Altitude) = 0; }; -if (worldName in ["MCN_Aliabad"]) then { GVAR(Latitude) = 36; GVAR(Altitude) = 0; }; -if (worldName in ["Clafghan"]) then { GVAR(Latitude) = 34; GVAR(Altitude) = 640; }; -if (worldName in ["Sangin", "hellskitchen"]) then { GVAR(Latitude) = 32; GVAR(Altitude) = 0; }; -if (worldName in ["Sara"]) then { GVAR(Latitude) = 40; GVAR(Altitude) = 0; }; -if (worldName in ["reshmaan"]) then { GVAR(Latitude) = 35; GVAR(Altitude) = 2000; }; -if (worldName in ["Thirsk"]) then { GVAR(Latitude) = 65; GVAR(Altitude) = 0; }; -if (worldName in ["lingor"]) then { GVAR(Latitude) = -4; GVAR(Altitude) = 0; }; -if (worldName in ["Panthera3"]) then { GVAR(Latitude) = 46; GVAR(Altitude) = 0; }; -if (worldName in ["Kunduz"]) then { GVAR(Latitude) = 37; GVAR(Altitude) = 400; }; - // Assume default wind values // Source: https://weatherspark.com/averages/32194/Lemnos-Limnos-North-Aegean-Islands-Greece GVAR(WindSpeedMax) = [[8.8, 5.5], [8.8, 5], [8.6, 4.8], [7.6, 3.4], [7.0, 3.0], [7.1, 3.0], [7.5, 3.1], [8.0, 3.2], [7.6, 3.5], [7.8, 4.6], [7.9, 5.0], [8.2, 5.5]];