From 9d527bf6d25aa89c0890322a161389a670856cfd Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 12:20:42 +0200 Subject: [PATCH 01/19] Added function that gets 10 digit grids from a position --- addons/common/XEH_preInit.sqf | 1 + .../functions/fnc_getMapGridFromPos.sqf | 91 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 addons/common/functions/fnc_getMapGridFromPos.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 5c2ad1e592..118a2eb5b7 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -66,6 +66,7 @@ PREP(getFirstTerrainIntersection); PREP(getForceWalkStatus); PREP(getGunner); PREP(getInPosition); +PREP(getMapGridFromPos); PREP(getMarkerType); PREP(getName); PREP(getNumberFromMissionSQM); diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf new file mode 100644 index 0000000000..14fccba2d4 --- /dev/null +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -0,0 +1,91 @@ +/* + * Author: VKing + * + * Gets a 10-digit map grid for the given world position + * + * Argument: + * 0: Position (2D Position) + * + * Return value: + * Easting and Northing as strings (Array) + */ + +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +private "_pos"; +_pos = getPos player; +TRACE_1("",_pos); +// PARAMS_1(_pos); + +private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originArray","_length","_offsetX","_offsetY","_gridX","_gridY"]; + +// _northingReversed = [] call CBA_fnc_northingReversed; +_northingReversed = false; +if(isNil "cba_common_mapReversed") then { + _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); + if(_test > 0) then { + _northingReversed = true; + }; + cba_common_mapReversed = _northingReversed; +} else { + _northingReversed = cba_common_mapReversed; +}; + +_mapsize = [] call bis_fnc_mapSize; +TRACE_2("",_northingReversed,_mapsize); + +if (_northingReversed) then { + _originGrid = mapGridPosition [0,_mapsize,0]; +} else { + _originGrid = mapGridPosition [0,0,0]; +}; +// _originGrid = "1234567890"; +TRACE_1("",_originGrid); + +if (count _originGrid == 10) exitWith { + TRACE_1("",mapGridPosition _pos); + [mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] +}; + +_originArray = toArray _originGrid; +_length = (count _originArray); +_length = _length/2; + +_offsetX = parseNumber (toString (_originArray select [0,_length])); +_offsetY = parseNumber (toString (_originArray select [_length,_length])); +TRACE_2("",_offsetX,_offsetY); + +TRACE_2("",_pos select 0, _pos select 1); + +_posX = ceil(_pos select 0) + _offsetX; +if (_posX < 0) then {_posX = 100000 + _posX}; +TRACE_1("",_posX); +_posX = format ["%1",_posX]; +if (_northingReversed) then { + _posY = _mapSize - ceil(_pos select 1) + _offsetY -100; +} else { + _posY = ceil(_pos select 1) + _offsetY; +}; +TRACE_1("",_posY); +if (_posY < 0) then {_posY = 100000 + _posY}; +_posY = format["%1",_posY]; +TRACE_2("",_posX,_posY); + +switch (count _posX) do { + case 1: {_posX = "0000"+_posX}; + case 2: {_posX = "000"+_posX}; + case 3: {_posX = "00"+_posX}; + case 4: {_posX = "0"+_posX}; + default {}; +}; +switch (count _posY) do { + case 1: {_posY = "0000"+_posY}; + case 2: {_posY = "000"+_posY}; + case 3: {_posY = "00"+_posY}; + case 4: {_posY = "0"+_posY}; + default {}; +}; +TRACE_3("",mapGridPosition _pos,_posX,_posY); + +[_posX,_posY] \ No newline at end of file From e6f27f961205aaa4b26110e8bd98f6024ec54c36 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 12:36:44 +0200 Subject: [PATCH 02/19] Fix offset, remove debug --- .../functions/fnc_getMapGridFromPos.sqf | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf index 14fccba2d4..963a95ba0c 100644 --- a/addons/common/functions/fnc_getMapGridFromPos.sqf +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -13,12 +13,12 @@ // #define DEBUG_MODE_FULL #include "script_component.hpp" -private "_pos"; -_pos = getPos player; -TRACE_1("",_pos); -// PARAMS_1(_pos); +// private "_pos"; +// _pos = getPos player; +// TRACE_1("",_pos); +PARAMS_1(_pos); -private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originArray","_length","_offsetX","_offsetY","_gridX","_gridY"]; +private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originArray","_length","_offsetX","_offsetY","_offsetPadding","_gridX","_gridY"]; // _northingReversed = [] call CBA_fnc_northingReversed; _northingReversed = false; @@ -40,7 +40,7 @@ if (_northingReversed) then { } else { _originGrid = mapGridPosition [0,0,0]; }; -// _originGrid = "1234567890"; +// _originGrid = "123456"; TRACE_1("",_originGrid); if (count _originGrid == 10) exitWith { @@ -51,9 +51,15 @@ if (count _originGrid == 10) exitWith { _originArray = toArray _originGrid; _length = (count _originArray); _length = _length/2; - -_offsetX = parseNumber (toString (_originArray select [0,_length])); -_offsetY = parseNumber (toString (_originArray select [_length,_length])); +_offsetPadding = switch (_length) do { + case 1: {"0000"}; + case 2: {"000"}; + case 3: {"00"}; + case 4: {"0"}; + default {}; +}; +_offsetX = parseNumber (toString (_originArray select [0,_length]) + _offsetPadding); +_offsetY = parseNumber (toString (_originArray select [_length,_length]) + _offsetPadding); TRACE_2("",_offsetX,_offsetY); TRACE_2("",_pos select 0, _pos select 1); @@ -72,19 +78,19 @@ if (_posY < 0) then {_posY = 100000 + _posY}; _posY = format["%1",_posY]; TRACE_2("",_posX,_posY); -switch (count _posX) do { - case 1: {_posX = "0000"+_posX}; - case 2: {_posX = "000"+_posX}; - case 3: {_posX = "00"+_posX}; - case 4: {_posX = "0"+_posX}; - default {}; +_posX = switch (count _posX) do { + case 1: {"0000"+_posX}; + case 2: {"000"+_posX}; + case 3: {"00"+_posX}; + case 4: {"0"+_posX}; + default {_posX}; }; -switch (count _posY) do { - case 1: {_posY = "0000"+_posY}; - case 2: {_posY = "000"+_posY}; - case 3: {_posY = "00"+_posY}; - case 4: {_posY = "0"+_posY}; - default {}; +_posY = switch (count _posY) do { + case 1: {"0000"+_posY}; + case 2: {"000"+_posY}; + case 3: {"00"+_posY}; + case 4: {"0"+_posY}; + default {_posY}; }; TRACE_3("",mapGridPosition _pos,_posX,_posY); From c6dbe6d39d7bb1f3d4de0d4fd344edb09cead0fe Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 12:51:18 +0200 Subject: [PATCH 03/19] tabs to space --- addons/common/functions/fnc_getMapGridFromPos.sqf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf index 963a95ba0c..a649c5125e 100644 --- a/addons/common/functions/fnc_getMapGridFromPos.sqf +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -23,13 +23,13 @@ private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originAr // _northingReversed = [] call CBA_fnc_northingReversed; _northingReversed = false; if(isNil "cba_common_mapReversed") then { - _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); - if(_test > 0) then { - _northingReversed = true; - }; - cba_common_mapReversed = _northingReversed; + _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); + if(_test > 0) then { + _northingReversed = true; + }; + cba_common_mapReversed = _northingReversed; } else { - _northingReversed = cba_common_mapReversed; + _northingReversed = cba_common_mapReversed; }; _mapsize = [] call bis_fnc_mapSize; From 39e851df03c3f61cab969218f57a7c7fe7495f82 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 17:26:28 +0200 Subject: [PATCH 04/19] Added functions to create MGRS grid zone designator and 100km grid for given world. *probably* not very accurate, but it should be close enough for fluff --- addons/common/XEH_preInit.sqf | 1 + addons/common/functions/fnc_getMGRSzone.sqf | 142 ++++++++++++++++++ .../functions/fnc_getMapGridFromPos.sqf | 5 +- 3 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 addons/common/functions/fnc_getMGRSzone.sqf diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 118a2eb5b7..e44b034416 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -68,6 +68,7 @@ PREP(getGunner); PREP(getInPosition); PREP(getMapGridFromPos); PREP(getMarkerType); +PREP(getMGRSzone); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getNumberMagazinesIn); diff --git a/addons/common/functions/fnc_getMGRSzone.sqf b/addons/common/functions/fnc_getMGRSzone.sqf new file mode 100644 index 0000000000..00d11d4877 --- /dev/null +++ b/addons/common/functions/fnc_getMGRSzone.sqf @@ -0,0 +1,142 @@ +/* + * Author: VKing + * + * Gets the current map's MGRS grid zone designator and 100km square. + * + * Argument: + * None + * + * Return value: + * 0: Grid zone designator (String) + * 1: 100km square (String) + */ + +#define DEBUG_MODE_FULL +#include "script_component.hpp" + +private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing"]; + +_long = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "longitude"); +_lat = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "latitude"); + +// if (!isNil QEGVAR(weather,Latitude)) then {_lat = EGVAR(weather,Latitude)}; + +if (worldName in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; }; +if (worldName in ["Altis", "Stratis"]) then { _lat = 40; }; +if (worldName in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; }; +if (worldName in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; }; +if (worldName in ["fallujah"]) then { _lat = 33; }; +if (worldName in ["fata", "Abbottabad"]) then { _lat = 30; }; +if (worldName in ["sfp_wamako"]) then { _lat = 14; }; +if (worldName in ["sfp_sturko"]) then { _lat = 56; }; +if (worldName in ["Bornholm"]) then { _lat = 55; }; +if (worldName in ["Imrali"]) then { _lat = 40; }; +if (worldName in ["Caribou"]) then { _lat = 68; }; +if (worldName in ["Namalsk"]) then { _lat = 65; }; +if (worldName in ["MCN_Aliabad"]) then { _lat = 36; }; +if (worldName in ["Clafghan"]) then { _lat = 34; }; +if (worldName in ["Sangin", "hellskitchen"]) then { _lat = 32; }; +if (worldName in ["Sara"]) then { _lat = 40; }; +if (worldName in ["reshmaan"]) then { _lat = 35; }; +if (worldName in ["Thirsk"]) then { _lat = 65; }; +if (worldName in ["lingor"]) then { _lat = -4; }; +if (worldName in ["Panthera3"]) then { _lat = 46; }; +if (worldName 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"}; +}; +if (worldName == "VR") then {_zone = 0; _band = "VR";}; + +_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;}; +}; + +switch (true) do { + 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 (_northing > 1900000): {switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; }; + case (_northing > 1800000): {switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; }; + case (_northing > 1700000): {switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; }; + case (_northing > 1600000): {switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; }; + case (_northing > 1500000): {switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; }; + case (_northing > 1400000): {switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; }; + case (_northing > 1300000): {switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; }; + case (_northing > 1200000): {switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; }; + case (_northing > 1100000): {switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; }; + case (_northing > 1000000): {switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; }; + case (_northing > 900000): {switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; }; + case (_northing > 800000): {switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; }; + case (_northing > 700000): {switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; }; + case (_northing > 600000): {switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; }; + case (_northing > 500000): {switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; }; + case (_northing > 400000): {switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; }; + case (_northing > 300000): {switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; }; + case (_northing > 200000): {switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; }; + case (_northing > 100000): {switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; }; + case (_northing > 0): {switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; }; +}; +TRACE_1("",_letterN); + +_grid100km = _letterE+_letterN; +TRACE_1("",_grid100km); + +[_GZD,_grid100km] diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf index a649c5125e..dfbde32388 100644 --- a/addons/common/functions/fnc_getMapGridFromPos.sqf +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -6,8 +6,9 @@ * Argument: * 0: Position (2D Position) * - * Return value: - * Easting and Northing as strings (Array) + * Return values: + * 0: Easting (String) + * 1: Northing (String) */ // #define DEBUG_MODE_FULL From 5f809476c336df0048e35bd7d0ea9aaaf322e2ef Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 17:35:40 +0200 Subject: [PATCH 05/19] VR is a special place --- addons/common/functions/fnc_getMGRSzone.sqf | 45 +++++++++++---------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/addons/common/functions/fnc_getMGRSzone.sqf b/addons/common/functions/fnc_getMGRSzone.sqf index 00d11d4877..ef3d7ea6c5 100644 --- a/addons/common/functions/fnc_getMGRSzone.sqf +++ b/addons/common/functions/fnc_getMGRSzone.sqf @@ -72,7 +72,7 @@ _band = switch (true) do { case (_lat>8): {"P"}; case (_lat>=0): {"N"}; }; -if (worldName == "VR") then {_zone = 0; _band = "VR";}; +if (worldName == "VR") then {_zone = 0; _band = "RV";}; _GZD = format ["%1%2",_zone,_band]; TRACE_3("",_zone,_band,_GZD); @@ -95,8 +95,10 @@ switch (true) do { 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"}; }; }; @@ -113,26 +115,27 @@ _northing = _northing mod 2000000; TRACE_1("",_northing); switch (true) do { - case (_northing > 1900000): {switch (_metaN) do {case 1: {_letterN = "V"}; case 2: {_letterN = "E"}; }; }; - case (_northing > 1800000): {switch (_metaN) do {case 1: {_letterN = "U"}; case 2: {_letterN = "D"}; }; }; - case (_northing > 1700000): {switch (_metaN) do {case 1: {_letterN = "T"}; case 2: {_letterN = "C"}; }; }; - case (_northing > 1600000): {switch (_metaN) do {case 1: {_letterN = "S"}; case 2: {_letterN = "B"}; }; }; - case (_northing > 1500000): {switch (_metaN) do {case 1: {_letterN = "R"}; case 2: {_letterN = "A"}; }; }; - case (_northing > 1400000): {switch (_metaN) do {case 1: {_letterN = "Q"}; case 2: {_letterN = "V"}; }; }; - case (_northing > 1300000): {switch (_metaN) do {case 1: {_letterN = "P"}; case 2: {_letterN = "U"}; }; }; - case (_northing > 1200000): {switch (_metaN) do {case 1: {_letterN = "N"}; case 2: {_letterN = "T"}; }; }; - case (_northing > 1100000): {switch (_metaN) do {case 1: {_letterN = "M"}; case 2: {_letterN = "S"}; }; }; - case (_northing > 1000000): {switch (_metaN) do {case 1: {_letterN = "L"}; case 2: {_letterN = "R"}; }; }; - case (_northing > 900000): {switch (_metaN) do {case 1: {_letterN = "K"}; case 2: {_letterN = "Q"}; }; }; - case (_northing > 800000): {switch (_metaN) do {case 1: {_letterN = "J"}; case 2: {_letterN = "P"}; }; }; - case (_northing > 700000): {switch (_metaN) do {case 1: {_letterN = "H"}; case 2: {_letterN = "N"}; }; }; - case (_northing > 600000): {switch (_metaN) do {case 1: {_letterN = "G"}; case 2: {_letterN = "M"}; }; }; - case (_northing > 500000): {switch (_metaN) do {case 1: {_letterN = "F"}; case 2: {_letterN = "L"}; }; }; - case (_northing > 400000): {switch (_metaN) do {case 1: {_letterN = "E"}; case 2: {_letterN = "K"}; }; }; - case (_northing > 300000): {switch (_metaN) do {case 1: {_letterN = "D"}; case 2: {_letterN = "J"}; }; }; - case (_northing > 200000): {switch (_metaN) do {case 1: {_letterN = "C"}; case 2: {_letterN = "H"}; }; }; - case (_northing > 100000): {switch (_metaN) do {case 1: {_letterN = "B"}; case 2: {_letterN = "G"}; }; }; - case (_northing > 0): {switch (_metaN) do {case 1: {_letterN = "A"}; case 2: {_letterN = "F"}; }; }; + 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); From 4cf54799aba6ef7c6717f071994612605e0e75d0 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 18:05:28 +0200 Subject: [PATCH 06/19] Optional parameter to select return value; array or string --- .../common/functions/fnc_getMapGridFromPos.sqf | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/common/functions/fnc_getMapGridFromPos.sqf index dfbde32388..2a9453b0a1 100644 --- a/addons/common/functions/fnc_getMapGridFromPos.sqf +++ b/addons/common/functions/fnc_getMapGridFromPos.sqf @@ -5,6 +5,7 @@ * * Argument: * 0: Position (2D Position) + * 1: Return type; false for array of easting and northing, true for single string (Bool) * * Return values: * 0: Easting (String) @@ -18,6 +19,7 @@ // _pos = getPos player; // TRACE_1("",_pos); PARAMS_1(_pos); +DEFAULT_PARAM(1,_return,false); private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originArray","_length","_offsetX","_offsetY","_offsetPadding","_gridX","_gridY"]; @@ -33,7 +35,7 @@ if(isNil "cba_common_mapReversed") then { _northingReversed = cba_common_mapReversed; }; -_mapsize = [] call bis_fnc_mapSize; +_mapsize = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "mapSize"); TRACE_2("",_northingReversed,_mapsize); if (_northingReversed) then { @@ -46,7 +48,11 @@ TRACE_1("",_originGrid); if (count _originGrid == 10) exitWith { TRACE_1("",mapGridPosition _pos); - [mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] + if (_return) then { + format ["%1%2",mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] + } else { + [mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] + }; }; _originArray = toArray _originGrid; @@ -95,4 +101,8 @@ _posY = switch (count _posY) do { }; TRACE_3("",mapGridPosition _pos,_posX,_posY); -[_posX,_posY] \ No newline at end of file +if (_return) then { + _posX+_posY +} else { + [_posX,_posY] +}; \ No newline at end of file From fe40452c8e9132a82adf4814e546b2fd8bf794a6 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 18:06:37 +0200 Subject: [PATCH 07/19] Added optional parameter to run for any map. Writes information for current map to GVAR in prep for postinit runs --- addons/common/functions/fnc_getMGRSzone.sqf | 58 ++++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/addons/common/functions/fnc_getMGRSzone.sqf b/addons/common/functions/fnc_getMGRSzone.sqf index ef3d7ea6c5..34ba25be84 100644 --- a/addons/common/functions/fnc_getMGRSzone.sqf +++ b/addons/common/functions/fnc_getMGRSzone.sqf @@ -4,11 +4,12 @@ * Gets the current map's MGRS grid zone designator and 100km square. * * Argument: - * None + * 0: Optional: Map name, if undefined the current map is used (String) * * Return value: * 0: Grid zone designator (String) * 1: 100km square (String) + * Writes return values to GVAR(MGRS_data) if run on the current map */ #define DEBUG_MODE_FULL @@ -16,32 +17,34 @@ private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing"]; -_long = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "longitude"); -_lat = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "latitude"); +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 (worldName in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; }; -if (worldName in ["Altis", "Stratis"]) then { _lat = 40; }; -if (worldName in ["Takistan", "Zargabad", "Mountains_ACR"]) then { _lat = 35; }; -if (worldName in ["Shapur_BAF", "ProvingGrounds_PMC"]) then { _lat = 35; }; -if (worldName in ["fallujah"]) then { _lat = 33; }; -if (worldName in ["fata", "Abbottabad"]) then { _lat = 30; }; -if (worldName in ["sfp_wamako"]) then { _lat = 14; }; -if (worldName in ["sfp_sturko"]) then { _lat = 56; }; -if (worldName in ["Bornholm"]) then { _lat = 55; }; -if (worldName in ["Imrali"]) then { _lat = 40; }; -if (worldName in ["Caribou"]) then { _lat = 68; }; -if (worldName in ["Namalsk"]) then { _lat = 65; }; -if (worldName in ["MCN_Aliabad"]) then { _lat = 36; }; -if (worldName in ["Clafghan"]) then { _lat = 34; }; -if (worldName in ["Sangin", "hellskitchen"]) then { _lat = 32; }; -if (worldName in ["Sara"]) then { _lat = 40; }; -if (worldName in ["reshmaan"]) then { _lat = 35; }; -if (worldName in ["Thirsk"]) then { _lat = 65; }; -if (worldName in ["lingor"]) then { _lat = -4; }; -if (worldName in ["Panthera3"]) then { _lat = 46; }; -if (worldName in ["Kunduz"]) then { _lat = 37; }; +if (_map in ["Chernarus", "Bootcamp_ACR", "Woodland_ACR", "utes"]) then { _lat = 50; }; +if (_map in ["Altis", "Stratis"]) then { _lat = 40; }; +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; @@ -72,7 +75,7 @@ _band = switch (true) do { case (_lat>8): {"P"}; case (_lat>=0): {"N"}; }; -if (worldName == "VR") then {_zone = 0; _band = "RV";}; +if (_map == "VR") then {_zone = 0; _band = "RV";}; _GZD = format ["%1%2",_zone,_band]; TRACE_3("",_zone,_band,_GZD); @@ -142,4 +145,7 @@ TRACE_1("",_letterN); _grid100km = _letterE+_letterN; TRACE_1("",_grid100km); -[_GZD,_grid100km] +if (_map == worldName) then { + GVAR(MGRS_data) = [_GZD,_grid100km]; +}; +[_GZD,_grid100km] \ No newline at end of file From 4e09681c9edb5774036d94356bf59ec9b63d2070 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 18:10:03 +0200 Subject: [PATCH 08/19] Added getMGRSdata to PostInit --- addons/common/XEH_postInit.sqf | 3 +++ addons/common/XEH_preInit.sqf | 2 +- .../functions/{fnc_getMGRSzone.sqf => fnc_getMGRSdata.sqf} | 0 3 files changed, 4 insertions(+), 1 deletion(-) rename addons/common/functions/{fnc_getMGRSzone.sqf => fnc_getMGRSdata.sqf} (100%) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 696aa16f9b..3eda03b4a7 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -238,6 +238,9 @@ GVAR(OldIsCamera) = false; {!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}} }] call FUNC(addCanInteractWithCondition); +// Find MGRS zone and 100km grid for current map +[] call FUNC(getMGRSdata); + // Lastly, do JIP events // JIP Detection and event trigger. Run this at the very end, just in case anything uses it if(isMultiplayer && { time > 0 || isNull player } ) then { diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index e44b034416..9de99b9ea6 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -68,7 +68,7 @@ PREP(getGunner); PREP(getInPosition); PREP(getMapGridFromPos); PREP(getMarkerType); -PREP(getMGRSzone); +PREP(getMGRSdata); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getNumberMagazinesIn); diff --git a/addons/common/functions/fnc_getMGRSzone.sqf b/addons/common/functions/fnc_getMGRSdata.sqf similarity index 100% rename from addons/common/functions/fnc_getMGRSzone.sqf rename to addons/common/functions/fnc_getMGRSdata.sqf From bcac56874b35057c407682d7f5daae1b34b5602c Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 19:58:09 +0200 Subject: [PATCH 09/19] Moved functions to ace_map --- addons/common/XEH_postInit.sqf | 3 --- addons/common/XEH_preInit.sqf | 2 -- addons/map/XEH_postInitClient.sqf | 3 +++ addons/map/XEH_preInit.sqf | 2 ++ addons/{common => map}/functions/fnc_getMGRSdata.sqf | 0 addons/{common => map}/functions/fnc_getMapGridFromPos.sqf | 0 6 files changed, 5 insertions(+), 5 deletions(-) rename addons/{common => map}/functions/fnc_getMGRSdata.sqf (100%) rename addons/{common => map}/functions/fnc_getMapGridFromPos.sqf (100%) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 3eda03b4a7..696aa16f9b 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -238,9 +238,6 @@ GVAR(OldIsCamera) = false; {!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}} }] call FUNC(addCanInteractWithCondition); -// Find MGRS zone and 100km grid for current map -[] call FUNC(getMGRSdata); - // Lastly, do JIP events // JIP Detection and event trigger. Run this at the very end, just in case anything uses it if(isMultiplayer && { time > 0 || isNull player } ) then { diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 9de99b9ea6..5c2ad1e592 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -66,9 +66,7 @@ PREP(getFirstTerrainIntersection); PREP(getForceWalkStatus); PREP(getGunner); PREP(getInPosition); -PREP(getMapGridFromPos); PREP(getMarkerType); -PREP(getMGRSdata); PREP(getName); PREP(getNumberFromMissionSQM); PREP(getNumberMagazinesIn); diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index ccaf9041ab..98216ef93c 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -6,6 +6,9 @@ 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 c5645a52e7..20d89b193d 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -7,6 +7,8 @@ PREP(blueForceTrackingModule); PREP(blueForceTrackingUpdate); PREP(determineMapLight); PREP(determineZoom); +PREP(getMapGridFromPos); +PREP(getMGRSdata); PREP(moduleMap); PREP(onDrawMap); PREP(updateMapEffects); diff --git a/addons/common/functions/fnc_getMGRSdata.sqf b/addons/map/functions/fnc_getMGRSdata.sqf similarity index 100% rename from addons/common/functions/fnc_getMGRSdata.sqf rename to addons/map/functions/fnc_getMGRSdata.sqf diff --git a/addons/common/functions/fnc_getMapGridFromPos.sqf b/addons/map/functions/fnc_getMapGridFromPos.sqf similarity index 100% rename from addons/common/functions/fnc_getMapGridFromPos.sqf rename to addons/map/functions/fnc_getMapGridFromPos.sqf From 2dd42f828dd4f1a603ec8c075dbbfd9d6970a3c3 Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 21:45:49 +0200 Subject: [PATCH 10/19] "Borrowed" pabst's UTM zone/band function and moved it from microdagr to map --- addons/map/functions/fnc_getMGRSdata.sqf | 22 +++++++++++++++++----- addons/microdagr/XEH_clientInit.sqf | 19 +------------------ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/addons/map/functions/fnc_getMGRSdata.sqf b/addons/map/functions/fnc_getMGRSdata.sqf index 34ba25be84..02097b4c83 100644 --- a/addons/map/functions/fnc_getMGRSdata.sqf +++ b/addons/map/functions/fnc_getMGRSdata.sqf @@ -9,10 +9,11 @@ * 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 +// #define DEBUG_MODE_FULL #include "script_component.hpp" private ["_zone","_band","_GZD","_long","_lat","_UTM","_easting","_northing"]; @@ -25,7 +26,7 @@ _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 = 40; }; +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; }; @@ -50,9 +51,10 @@ 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; +// _zone = _UTM select 2; TRACE_4("",_UTM,_easting,_northing,_zone); +/* _band = switch (true) do { case (_lat<-72): {"C"}; case (_lat<-64): {"D"}; @@ -75,6 +77,16 @@ _band = switch (true) do { 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]; @@ -146,6 +158,6 @@ _grid100km = _letterE+_letterN; TRACE_1("",_grid100km); if (_map == worldName) then { - GVAR(MGRS_data) = [_GZD,_grid100km]; + GVAR(MGRS_data) = [_GZD,_grid100km,_GZD+_grid100km]; }; -[_GZD,_grid100km] \ No newline at end of file +[_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 587bf85ef5..89f9d7a4a5 100644 --- a/addons/microdagr/XEH_clientInit.sqf +++ b/addons/microdagr/XEH_clientInit.sqf @@ -54,22 +54,5 @@ GVAR(rangeFinderPositionASL) = []; GVAR(mapAltitude) = getNumber (configFile >> "CfgWorlds" >> worldName >> "elevationOffset"); -private ["_worldMapLong", "_worldMapLat", "_zone", "_band", "_squareID"]; - -//Calculate the map's MGRS: -_worldMapLong = getNumber (configFile >> "CfgWorlds" >> worldName >> "longitude"); -_worldMapLat = getNumber (configFile >> "CfgWorlds" >> worldName >> "latitude"); -//Pull UTM grid from world's long/lat -_zone = 1 + (floor ((_worldMapLong + 180) / 6)); -_band = "Z"; -if (_worldMapLat <= -80) then { - _band = "A"; -} else { - if (_worldMapLat < 84) then { - _band = "CDEFGHJKLMNPQRSTUVWXX" select [(floor ((_worldMapLat / 8) + 10)), 1]; - }; -}; -//calculating square ID from long/lat is a pain in the ass, just fake it unless someone wants to actualy do this -_squareID = if ((count worldName) > 2) then {toUpper(worldName select [0,2])} else {"XG"}; -GVAR(mgrsGridZoneDesignator) = format ["%1%2 %3", _zone, _band, _squareID]; +GVAR(mgrsGridZoneDesignator) = format ["%1 %2",EGVAR(map,MGRS_data) select 0, EGVAR(map,MGRS_data) select 1]; From 8d61b42e879afd2e28e04d28f556b8885401f28c Mon Sep 17 00:00:00 2001 From: VKing Date: Sun, 10 May 2015 21:47:05 +0200 Subject: [PATCH 11/19] Changed MicroDAGR position and target display to 10-digit grids --- .../microdagr/functions/fnc_updateDisplay.sqf | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/addons/microdagr/functions/fnc_updateDisplay.sqf b/addons/microdagr/functions/fnc_updateDisplay.sqf index 26e5ef8638..7ea9a69846 100644 --- a/addons/microdagr/functions/fnc_updateDisplay.sqf +++ b/addons/microdagr/functions/fnc_updateDisplay.sqf @@ -15,7 +15,7 @@ */ #include "script_component.hpp" -private ["_display", "_waypoints", "_posString", "_eastingText", "_northingText", "_numASL", "_aboveSeaLevelText", "_compassAngleText", "_targetPosName", "_targetPosLocationASL", "_bearingText", "_rangeText", "_targetName", "_bearing", "_2dDistanceKm", "_SpeedText", "_playerPos2d", "_wpListBox", "_currentIndex", "_wpName", "_wpPos", "_settingListBox", "_yearString", "_monthSring", "_dayString"]; +private ["_display", "_waypoints", "_posString", "_eastingText", "_northingText", "_numASL", "_aboveSeaLevelText", "_compassAngleText", "_targetPos", "_targetPosName", "_targetPosLocationASL", "_bearingText", "_rangeText", "_targetName", "_bearing", "_2dDistanceKm", "_SpeedText", "_playerPos2d", "_wpListBox", "_currentIndex", "_wpName", "_wpPos", "_settingListBox", "_yearString", "_monthSring", "_dayString"]; disableSerialization; _display = displayNull; @@ -33,13 +33,9 @@ _waypoints = [] call FUNC(deviceGetWaypoints); switch (GVAR(currentApplicationPage)) do { case (APP_MODE_INFODISPLAY): { //Easting/Northing: - _posString = mapGridPosition ACE_player; - _eastingText = ""; - _northingText = ""; - if (count _posString > 0) then { - _eastingText = (_posString select [0, ((count _posString)/2)]) + "e"; - _northingText = (_posString select [(count _posString)/2, (count _posString - 1)]) + "n"; - }; + _posString = [getPos ACE_player] call EFUNC(map,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; @@ -78,7 +74,8 @@ case (APP_MODE_INFODISPLAY): { if (GVAR(currentWaypoint) == -2) then { if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then { - _targetPosName = format ["[%1]", (mapGridPosition GVAR(rangeFinderPositionASL))]; + _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(map,getMapGridFromPos); + _targetPosName = format ["[%1 %2 %3]", EGVAR(map,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { @@ -132,7 +129,8 @@ case (APP_MODE_COMPASS): { if (GVAR(currentWaypoint) == -2) then { if (!(GVAR(rangeFinderPositionASL) isEqualTo [])) then { - _targetPosName = format ["[%1]", (mapGridPosition GVAR(rangeFinderPositionASL))]; + _targetPos = [GVAR(rangeFinderPositionASL)] call EFUNC(map,getMapGridFromPos); + _targetPosName = format ["[%1 %2 %3]", EGVAR(map,MGRS_data) select 1, _targetPos select 0, _targetPos select 1]; _targetPosLocationASL = GVAR(rangeFinderPositionASL); }; } else { From d5757c090a0e59b5acaf0146c124b31bc2bb7ef1 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 22 Jun 2015 20:36:37 -0500 Subject: [PATCH 12/19] Calc gridOffsets at mission start. --- addons/map/XEH_preInit.sqf | 26 ++++++ .../map/functions/fnc_getMapGridFromPos.sqf | 87 +++++-------------- 2 files changed, 47 insertions(+), 66 deletions(-) diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index 20d89b193d..15799001de 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -13,4 +13,30 @@ PREP(moduleMap); PREP(onDrawMap); PREP(updateMapEffects); +//Prepare variables for FUNC(getMapGridFromPos): +private["_length", "_mapSize", "_northingReversed", "_offsetPadding", "_originGrid"]; +_northingReversed = [] call CBA_fnc_northingReversed; +_mapsize = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "mapSize"); + +_originGrid = if (_northingReversed) then { + mapGridPosition [0,_mapsize,0]; +} else { + mapGridPosition [0,0,0]; +}; + +_length = (count _originGrid) / 2; +_offsetPadding = switch (_length) do { + case 1: {"0000"}; + case 2: {"000"}; + case 3: {"00"}; + case 4: {"0"}; + default {""}; +}; + +GVAR(gridOffsetX) = parseNumber ((_originGrid select [0,_length]) + _offsetPadding); +GVAR(gridOffsetY) = parseNumber ((_originGrid select [_length,_length]) + _offsetPadding); +if (_northingReversed) then { + GVAR(gridOffsetY) = GVAR(gridOffsetY) + _mapSize; +}; + ADDON = true; diff --git a/addons/map/functions/fnc_getMapGridFromPos.sqf b/addons/map/functions/fnc_getMapGridFromPos.sqf index 2a9453b0a1..f505fb8372 100644 --- a/addons/map/functions/fnc_getMapGridFromPos.sqf +++ b/addons/map/functions/fnc_getMapGridFromPos.sqf @@ -1,88 +1,43 @@ /* * 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 (Bool) + * 0: Position (2D Position) + * 1: Return type; false for array of easting and northing, true for single string * * Return values: - * 0: Easting (String) - * 1: Northing (String) + * 0: Easting + * 1: Northing + * + * Example: + * [(getPos player)] call ace_map_fnc_getMapGridFromPos; + * + * Public: Yes */ // #define DEBUG_MODE_FULL #include "script_component.hpp" -// private "_pos"; -// _pos = getPos player; -// TRACE_1("",_pos); PARAMS_1(_pos); -DEFAULT_PARAM(1,_return,false); +DEFAULT_PARAM(1,_returnSingleString,false); -private ["_posX","_posY","_northingReversed","_mapsize","_originGrid","_originArray","_length","_offsetX","_offsetY","_offsetPadding","_gridX","_gridY"]; - -// _northingReversed = [] call CBA_fnc_northingReversed; -_northingReversed = false; -if(isNil "cba_common_mapReversed") then { - _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); - if(_test > 0) then { - _northingReversed = true; - }; - cba_common_mapReversed = _northingReversed; -} else { - _northingReversed = cba_common_mapReversed; -}; - -_mapsize = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "mapSize"); -TRACE_2("",_northingReversed,_mapsize); - -if (_northingReversed) then { - _originGrid = mapGridPosition [0,_mapsize,0]; -} else { - _originGrid = mapGridPosition [0,0,0]; -}; -// _originGrid = "123456"; -TRACE_1("",_originGrid); - -if (count _originGrid == 10) exitWith { - TRACE_1("",mapGridPosition _pos); - if (_return) then { - format ["%1%2",mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] - } else { - [mapGridPosition _pos select [0,5], mapGridPosition _pos select [5,5]] - }; -}; - -_originArray = toArray _originGrid; -_length = (count _originArray); -_length = _length/2; -_offsetPadding = switch (_length) do { - case 1: {"0000"}; - case 2: {"000"}; - case 3: {"00"}; - case 4: {"0"}; - default {}; -}; -_offsetX = parseNumber (toString (_originArray select [0,_length]) + _offsetPadding); -_offsetY = parseNumber (toString (_originArray select [_length,_length]) + _offsetPadding); -TRACE_2("",_offsetX,_offsetY); +private["_posX", "_posY"]; TRACE_2("",_pos select 0, _pos select 1); -_posX = ceil(_pos select 0) + _offsetX; -if (_posX < 0) then {_posX = 100000 + _posX}; +_posX = GVAR(gridOffsetX) + floor (_pos select 0); TRACE_1("",_posX); -_posX = format ["%1",_posX]; -if (_northingReversed) then { - _posY = _mapSize - ceil(_pos select 1) + _offsetY -100; +_posX = str ((100000 + _posX) % 100000); + +if (cba_common_mapReversed) then { + _posY = GVAR(gridOffsetY) - ceil(_pos select 1); } else { - _posY = ceil(_pos select 1) + _offsetY; + _posY = GVAR(gridOffsetY) + floor(_pos select 1); }; TRACE_1("",_posY); -if (_posY < 0) then {_posY = 100000 + _posY}; -_posY = format["%1",_posY]; +_posY = str ((100000 + _posY) % 100000); + TRACE_2("",_posX,_posY); _posX = switch (count _posX) do { @@ -101,8 +56,8 @@ _posY = switch (count _posY) do { }; TRACE_3("",mapGridPosition _pos,_posX,_posY); -if (_return) then { +if (_returnSingleString) then { _posX+_posY } else { [_posX,_posY] -}; \ No newline at end of file +}; From 1f7994e10fa71cbe87f20dcd292664c5fd76b881 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Mon, 29 Jun 2015 21:18:21 -0500 Subject: [PATCH 13/19] Calc real X and Y offsets --- addons/map/XEH_preInit.sqf | 27 ++--------- .../map/functions/fnc_getMapGridFromPos.sqf | 45 ++++++------------- .../map/functions/fnc_getMapPosFromGrid.sqf | 40 +++++++++++++++++ addons/map/functions/fnc_prepareMapGrid.sqf | 39 ++++++++++++++++ 4 files changed, 95 insertions(+), 56 deletions(-) create mode 100644 addons/map/functions/fnc_getMapPosFromGrid.sqf create mode 100644 addons/map/functions/fnc_prepareMapGrid.sqf diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index 15799001de..1f1131eb9f 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -8,35 +8,14 @@ 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): -private["_length", "_mapSize", "_northingReversed", "_offsetPadding", "_originGrid"]; -_northingReversed = [] call CBA_fnc_northingReversed; -_mapsize = getNumber (ConfigFile >> "CfgWorlds" >> worldName >> "mapSize"); - -_originGrid = if (_northingReversed) then { - mapGridPosition [0,_mapsize,0]; -} else { - mapGridPosition [0,0,0]; -}; - -_length = (count _originGrid) / 2; -_offsetPadding = switch (_length) do { - case 1: {"0000"}; - case 2: {"000"}; - case 3: {"00"}; - case 4: {"0"}; - default {""}; -}; - -GVAR(gridOffsetX) = parseNumber ((_originGrid select [0,_length]) + _offsetPadding); -GVAR(gridOffsetY) = parseNumber ((_originGrid select [_length,_length]) + _offsetPadding); -if (_northingReversed) then { - GVAR(gridOffsetY) = GVAR(gridOffsetY) + _mapSize; -}; +[] call FUNC(prepareMapGrid); ADDON = true; diff --git a/addons/map/functions/fnc_getMapGridFromPos.sqf b/addons/map/functions/fnc_getMapGridFromPos.sqf index f505fb8372..e520654e9b 100644 --- a/addons/map/functions/fnc_getMapGridFromPos.sqf +++ b/addons/map/functions/fnc_getMapGridFromPos.sqf @@ -22,42 +22,23 @@ PARAMS_1(_pos); DEFAULT_PARAM(1,_returnSingleString,false); -private["_posX", "_posY"]; - -TRACE_2("",_pos select 0, _pos select 1); - -_posX = GVAR(gridOffsetX) + floor (_pos select 0); -TRACE_1("",_posX); -_posX = str ((100000 + _posX) % 100000); - -if (cba_common_mapReversed) then { - _posY = GVAR(gridOffsetY) - ceil(_pos select 1); -} else { - _posY = GVAR(gridOffsetY) + floor(_pos select 1); +if ((count GVAR(mapGridData)) == 0) exitWith { + if (_returnSingleString) then { + mapGridPosition _pos + } else { + [(mapGridPosition _pos) select [0,5], (mapGridPosition _pos) select [5,5]] + }; }; -TRACE_1("",_posY); -_posY = str ((100000 + _posY) % 100000); -TRACE_2("",_posX,_posY); +EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); +_easting = str floor (((_pos select 0) - _offsetX) / _stepXat5); +_northing = str floor (((_pos select 1) - _realOffsetY) / _stepYat5); -_posX = switch (count _posX) do { - case 1: {"0000"+_posX}; - case 2: {"000"+_posX}; - case 3: {"00"+_posX}; - case 4: {"0"+_posX}; - default {_posX}; -}; -_posY = switch (count _posY) do { - case 1: {"0000"+_posY}; - case 2: {"000"+_posY}; - case 3: {"00"+_posY}; - case 4: {"0"+_posY}; - default {_posY}; -}; -TRACE_3("",mapGridPosition _pos,_posX,_posY); +while {count _easting < 5} do {_easting = "0" + _easting;}; +while {count _northing < 5} do {_northing = "0" + _northing;}; if (_returnSingleString) then { - _posX+_posY + _easting+_northing } else { - [_posX,_posY] + [_easting, _northing] }; diff --git a/addons/map/functions/fnc_getMapPosFromGrid.sqf b/addons/map/functions/fnc_getMapPosFromGrid.sqf new file mode 100644 index 0000000000..16324383bc --- /dev/null +++ b/addons/map/functions/fnc_getMapPosFromGrid.sqf @@ -0,0 +1,40 @@ +/* + * Author: PabstMirror + * Gets position from grid cords + * + * Argument: + * 0: Grid Cords + * + * Return values: + * 0: Position + * + * Example: + * ["6900080085"] call ace_map_fnc_getMapPosFromGrid + * + * Public: Yes + */ + +// #define DEBUG_MODE_FULL +#include "script_component.hpp" + +PARAMS_1(_inputString); +DEFAULT_PARAM(1,_getCenterOfGrid,true); + +EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); + +_countInput = count _inputString; +_countInputHalf = floor (_countInput / 2); + +//Split string, ignoring middle +_xPart = _inputString select [0, _countInputHalf]; +_yPart = _inputString select [(ceil (_countInput / 2)), _countInputHalf]; + +_xPos = ((parseNumber _xPart) * _stepXat5 * 10 ^ (5 - _countInputHalf)) + _offsetX; +_yPos = ((parseNumber _yPart) * _stepYat5 * 10 ^ (5 - _countInputHalf)) + _realOffsetY; + +if (_getCenterOfGrid) then { + _xPos = _xPos + 0.5 * _stepXat5 * 10 ^ (5 - _countInputHalf); + _yPos = _yPos + 0.5 * _stepYat5 * 10 ^ (5 - _countInputHalf); +}; + +[_xPos, _yPos, 0]; diff --git a/addons/map/functions/fnc_prepareMapGrid.sqf b/addons/map/functions/fnc_prepareMapGrid.sqf new file mode 100644 index 0000000000..3c82ef0758 --- /dev/null +++ b/addons/map/functions/fnc_prepareMapGrid.sqf @@ -0,0 +1,39 @@ +#include "script_component.hpp" + +//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos) +// +_cfgGrid = configfile >> "CfgWorlds" >> worldname >> "Grid"; +_offsetX = getnumber (_cfgGrid >> "offsetX"); +_offsetY = getnumber (_cfgGrid >> "offsetY"); +_zoomMax = 1e99; +_format = ""; +_formatX = ""; +_formatY = ""; +_stepX = 1e10; +_stepY = 1e10; +{ + _zoom = getnumber (_x >> "zoomMax"); + if (_zoom < _zoomMax) then { + _zoomMax = _zoom; + _format = gettext (_x >> "format"); + _formatX = gettext (_x >> "formatX"); + _formatY = gettext (_x >> "formatY"); + _stepX = getnumber (_x >> "stepX"); + _stepY = getnumber (_x >> "stepY"); + }; +} foreach configproperties [_cfgGrid,"isclass _x",false]; + +_heightOffset = 500; +_startGrid = mapGridPosition [0, _heightOffset]; +_originGrid = _startGrid; +while {_startGrid == _originGrid} do { + _heightOffset = _heightOffset + 1; + _originGrid = mapGridPosition [0, _heightOffset]; +}; + +_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1; + +_stepXat5 = _stepX * 10 ^ ((count _formatX) - 5); +_stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5); + +GVAR(mapGridData) = [_offsetX, _realOffsetY, _stepXat5, _stepYat5]; From 1f47ffc5de8786250013861aefebf0d8e6ecab82 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jun 2015 11:11:53 -0500 Subject: [PATCH 14/19] Error checking, handle out of bounds grids --- .../map/functions/fnc_getMapGridFromPos.sqf | 34 ++++++++++++--- .../map/functions/fnc_getMapPosFromGrid.sqf | 12 ++++-- addons/map/functions/fnc_prepareMapGrid.sqf | 43 ++++++++++++++----- 3 files changed, 68 insertions(+), 21 deletions(-) diff --git a/addons/map/functions/fnc_getMapGridFromPos.sqf b/addons/map/functions/fnc_getMapGridFromPos.sqf index e520654e9b..2b971b14ee 100644 --- a/addons/map/functions/fnc_getMapGridFromPos.sqf +++ b/addons/map/functions/fnc_getMapGridFromPos.sqf @@ -22,23 +22,43 @@ 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 { - mapGridPosition _pos + _nativeGrid } else { - [(mapGridPosition _pos) select [0,5], (mapGridPosition _pos) select [5,5]] + _count = floor ((count _nativeGrid) / 2); + [(_nativeGrid select [0, _count]), (_nativeGrid select [_count, _count])] }; }; EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); -_easting = str floor (((_pos select 0) - _offsetX) / _stepXat5); -_northing = str floor (((_pos select 1) - _realOffsetY) / _stepYat5); +_easting = floor (((_pos select 0) - _offsetX) / _stepXat5); +_northing = floor (((_pos select 1) - _realOffsetY) / _stepYat5); -while {count _easting < 5} do {_easting = "0" + _easting;}; -while {count _northing < 5} do {_northing = "0" + _northing;}; +//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 + _easting + _northing } else { [_easting, _northing] }; diff --git a/addons/map/functions/fnc_getMapPosFromGrid.sqf b/addons/map/functions/fnc_getMapPosFromGrid.sqf index 16324383bc..2daa9c63ee 100644 --- a/addons/map/functions/fnc_getMapPosFromGrid.sqf +++ b/addons/map/functions/fnc_getMapPosFromGrid.sqf @@ -4,22 +4,28 @@ * * Argument: * 0: Grid Cords + * 1: Get Center or bottom right * * Return values: - * 0: Position + * Position * * Example: * ["6900080085"] call ace_map_fnc_getMapPosFromGrid * * Public: Yes */ - -// #define DEBUG_MODE_FULL #include "script_component.hpp" PARAMS_1(_inputString); DEFAULT_PARAM(1,_getCenterOfGrid,true); +private["_countInput", "_countInputHalf", "_xPart", "_xPos", "_yPart", "_yPos"]; + +if ((count GVAR(mapGridData)) == 0) exitWith { + ERROR("Map has bad data, falling back to BIS_fnc_gridToPos"); + (_this call BIS_fnc_gridToPos) select 0 +}; + EXPLODE_4_PVT(GVAR(mapGridData),_offsetX,_realOffsetY,_stepXat5,_stepYat5); _countInput = count _inputString; diff --git a/addons/map/functions/fnc_prepareMapGrid.sqf b/addons/map/functions/fnc_prepareMapGrid.sqf index 3c82ef0758..efa917cd2e 100644 --- a/addons/map/functions/fnc_prepareMapGrid.sqf +++ b/addons/map/functions/fnc_prepareMapGrid.sqf @@ -1,12 +1,14 @@ #include "script_component.hpp" +private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"]; + +GVAR(mapGridData) = []; + //--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos) -// -_cfgGrid = configfile >> "CfgWorlds" >> worldname >> "Grid"; -_offsetX = getnumber (_cfgGrid >> "offsetX"); -_offsetY = getnumber (_cfgGrid >> "offsetY"); +_cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid"; +_offsetX = getNumber (_cfgGrid >> "offsetX"); +_offsetY = getNumber (_cfgGrid >> "offsetY"); _zoomMax = 1e99; -_format = ""; _formatX = ""; _formatY = ""; _stepX = 1e10; @@ -15,14 +17,21 @@ _stepY = 1e10; _zoom = getnumber (_x >> "zoomMax"); if (_zoom < _zoomMax) then { _zoomMax = _zoom; - _format = gettext (_x >> "format"); - _formatX = gettext (_x >> "formatX"); - _formatY = gettext (_x >> "formatY"); - _stepX = getnumber (_x >> "stepX"); - _stepY = getnumber (_x >> "stepY"); + _formatX = getText (_x >> "formatX"); + _formatY = getText (_x >> "formatY"); + _stepX = getNumber (_x >> "stepX"); + _stepY = getNumber (_x >> "stepY"); }; -} foreach configproperties [_cfgGrid,"isclass _x",false]; +} foreach configProperties [_cfgGrid, "isClass _x", false]; +_letterGrid = false; +if (((toLower _formatX) find "a") != -1) then {_letterGrid = true}; +if (((toLower _formatY) find "a") != -1) then {_letterGrid = true}; +if (_letterGrid) exitWith { + diag_log text format ["[ACE] Map Grid Warning (%1) - Map uses letter grids [%2,%3]", worldName, _formatX, _formatY]; +}; + +//Start at [0, 500] and move north until we get a change in grid _heightOffset = 500; _startGrid = mapGridPosition [0, _heightOffset]; _originGrid = _startGrid; @@ -31,9 +40,21 @@ while {_startGrid == _originGrid} do { _originGrid = mapGridPosition [0, _heightOffset]; }; +//Calculate the real y offset _realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1; +//Calculate MGRS 10digit step - they should both be 1 meter: _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5); _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5); +if (_stepYat5 < 0) then { + diag_log text format ["[ACE] Map Grid Warning (%1) - Northing is reversed", worldName]; +}; +if (_stepXat5 != 1) then { + diag_log text format ["[ACE] Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x", worldName, _stepXat5]; +}; +if ((_stepYat5 != 1) && {_stepYat5 != -1}) then { + diag_log text format ["[ACE] Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y", worldName, _stepXat5]; +}; + GVAR(mapGridData) = [_offsetX, _realOffsetY, _stepXat5, _stepYat5]; From 923018a9f63d2cd1c373eca53792d0d2a3f5a4ed Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jun 2015 11:18:47 -0500 Subject: [PATCH 15/19] mdagr use getMapPosFromGrid --- addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf index 066b44508d..97229355dd 100644 --- a/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf +++ b/addons/microdagr/functions/fnc_appMarkKeypadEntry.sqf @@ -15,7 +15,7 @@ */ #include "script_component.hpp" -private ["_display", "_editText", "_gridPosTuple", "_actualPos"]; +private ["_display", "_editText", "_actualPos"]; PARAMS_1(_keypadButton); disableSerialization; @@ -34,8 +34,7 @@ _editText = ctrlText (_display displayCtrl IDC_MODEMARK_CORDSEDIT); switch (_keypadButton) do { case ("ok"): { if ((count GVAR(newWaypointPosition)) == 0) then { - _gridPosTuple = [_editText] call BIS_fnc_gridToPos; - _actualPos = [(((_gridPosTuple select 0) select 0) + 0.5 * ((_gridPosTuple select 1) select 0)), (((_gridPosTuple select 0) select 1) + 0.5 * ((_gridPosTuple select 1) select 1))]; + _actualPos = [_editText, true] call EFUNC(map,getMapPosFromGrid); _actualPos set [2, (getTerrainHeightASL _actualPos)]; GVAR(newWaypointPosition) = _actualPos; [APP_MODE_MARK] call FUNC(saveCurrentAndSetNewMode); From c1dd2df57a174dd2d793a71915c7b0f413cd4597 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 30 Jun 2015 12:26:51 -0500 Subject: [PATCH 16/19] Move grid funcs and map long,lat,altitude to common --- .../functions/fnc_handleFired.sqf | 2 +- addons/common/XEH_postInit.sqf | 8 + addons/common/XEH_preInit.sqf | 4 + addons/common/functions/fnc_getMGRSdata.sqf | 165 ++++++++++++++++++ .../functions/fnc_getMapGridData.sqf} | 16 ++ .../functions/fnc_getMapGridFromPos.sqf | 127 +++++++------- .../functions/fnc_getMapPosFromGrid.sqf | 2 +- addons/dagr/functions/fnc_outputData.sqf | 2 +- addons/dagr/functions/fnc_outputVector.sqf | 2 +- .../kestrel4500/functions/fnc_collectData.sqf | 2 +- .../functions/fnc_generateOutputData.sqf | 4 +- addons/map/XEH_postInitClient.sqf | 3 - addons/map/XEH_preInit.sqf | 7 - addons/map/functions/fnc_getMGRSdata.sqf | 163 ----------------- addons/microdagr/XEH_clientInit.sqf | 6 +- .../functions/fnc_appMarkKeypadEntry.sqf | 2 +- .../microdagr/functions/fnc_updateDisplay.sqf | 14 +- .../functions/fnc_updateRangeCard.sqf | 2 +- .../fnc_calculateBarometricPressure.sqf | 2 +- addons/weather/functions/fnc_getMapData.sqf | 25 --- 20 files changed, 274 insertions(+), 284 deletions(-) create mode 100644 addons/common/functions/fnc_getMGRSdata.sqf rename addons/{map/functions/fnc_prepareMapGrid.sqf => common/functions/fnc_getMapGridData.sqf} (88%) rename addons/{map => common}/functions/fnc_getMapGridFromPos.sqf (92%) rename addons/{map => common}/functions/fnc_getMapPosFromGrid.sqf (95%) delete mode 100644 addons/map/functions/fnc_getMGRSdata.sqf 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]]; From 7d26519b2eeec41f417071d32e853f9e8b40669b Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 16 Jul 2015 17:47:39 -0500 Subject: [PATCH 17/19] Use new worldSize command instead of whileLoop --- addons/common/functions/fnc_getMapGridData.sqf | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/addons/common/functions/fnc_getMapGridData.sqf b/addons/common/functions/fnc_getMapGridData.sqf index 308772bfff..e542c9d818 100644 --- a/addons/common/functions/fnc_getMapGridData.sqf +++ b/addons/common/functions/fnc_getMapGridData.sqf @@ -47,17 +47,8 @@ if (_letterGrid) exitWith { diag_log text format ["[ACE] Map Grid Warning (%1) - Map uses letter grids [%2,%3]", worldName, _formatX, _formatY]; }; -//Start at [0, 500] and move north until we get a change in grid -_heightOffset = 500; -_startGrid = mapGridPosition [0, _heightOffset]; -_originGrid = _startGrid; -while {_startGrid == _originGrid} do { - _heightOffset = _heightOffset + 1; - _originGrid = mapGridPosition [0, _heightOffset]; -}; - //Calculate the real y offset -_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1; +_realOffsetY = worldSize - _stepY - 1; //Calculate MGRS 10digit step - they should both be 1 meter: _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5); From f438c6d0c5100b3a9943268b2e734380b9e61dd5 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 16 Jul 2015 18:10:10 -0500 Subject: [PATCH 18/19] Revert "Use new worldSize command instead of whileLoop" This reverts commit 7d26519b2eeec41f417071d32e853f9e8b40669b. --- addons/common/functions/fnc_getMapGridData.sqf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/addons/common/functions/fnc_getMapGridData.sqf b/addons/common/functions/fnc_getMapGridData.sqf index e542c9d818..308772bfff 100644 --- a/addons/common/functions/fnc_getMapGridData.sqf +++ b/addons/common/functions/fnc_getMapGridData.sqf @@ -47,8 +47,17 @@ if (_letterGrid) exitWith { diag_log text format ["[ACE] Map Grid Warning (%1) - Map uses letter grids [%2,%3]", worldName, _formatX, _formatY]; }; +//Start at [0, 500] and move north until we get a change in grid +_heightOffset = 500; +_startGrid = mapGridPosition [0, _heightOffset]; +_originGrid = _startGrid; +while {_startGrid == _originGrid} do { + _heightOffset = _heightOffset + 1; + _originGrid = mapGridPosition [0, _heightOffset]; +}; + //Calculate the real y offset -_realOffsetY = worldSize - _stepY - 1; +_realOffsetY = parseNumber (_originGrid select [(count _formatX), (count _formatY)]) * _stepY + _heightOffset - 1; //Calculate MGRS 10digit step - they should both be 1 meter: _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5); From f845d54290533f9b4852798b6c9f9f208434f1dc Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 16 Jul 2015 18:35:38 -0500 Subject: [PATCH 19/19] #1634 - Integrate with DAGR --- addons/dagr/functions/fnc_outputData.sqf | 52 ++-------------------- addons/dagr/functions/fnc_outputWP.sqf | 56 +++--------------------- 2 files changed, 8 insertions(+), 100 deletions(-) diff --git a/addons/dagr/functions/fnc_outputData.sqf b/addons/dagr/functions/fnc_outputData.sqf index 0825814d31..9bcf244fbc 100644 --- a/addons/dagr/functions/fnc_outputData.sqf +++ b/addons/dagr/functions/fnc_outputData.sqf @@ -30,7 +30,7 @@ __background ctrlSetText QUOTE(PATHTOF(UI\dagr_gps.paa)); if (GVAR(outputPFH) != -1) exitWith {}; GVAR(outputPFH) = [{ - private ["_pos", "_mapSize", "_gridConfig", "_offsetX", "_offsetY", "_stepX", "_stepY", "_xgrid", "_ygrid", "_xcoord", "_ycoord", "_speed", "_dagrHeading", "_dagrGrid", "_dagrElevation", "_dagrSpeed", "_dagrTime", "_elevation"]; + private["_dagrElevation", "_dagrGrid", "_dagrHeading", "_dagrSpeed", "_dagrTime", "_elevation", "_gridArray", "_speed"]; // Abort Condition if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith { @@ -40,54 +40,8 @@ GVAR(outputPFH) = [{ }; // GRID - _pos = getPosASL ACE_player; - - _mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize"); - _gridConfig = (configFile >> "CfgWorlds" >> worldName >> "Grid"); - _offsetX = getNumber (_gridConfig >> "offsetX"); - _offsetY = getNumber (_gridConfig >> "offsetY"); - _stepX = getNumber (_gridConfig >> "Zoom1" >> "stepX"); - _stepY = getNumber (_gridConfig >> "Zoom1" >> "stepY"); - - if (_stepY >= 0) then { - _pos set [1, (_mapSize - 100) - (_pos select 1) - _offsetY]; - }; - - // Incase grids go neg due to 99-00 boundry - if (_pos select 0 < 0) then {_pos set [0, (_pos select 0) + 99999];}; - if (_pos select 1 < 0) then {_pos set [1, (_pos select 1) + 99999];}; - - _xGrid = toArray Str(round(_pos select 0)); - while {count _xGrid < 5} do { - _xGrid = [48] + _xGrid; - }; - _xGrid resize 4; - _xGrid = toString _xGrid; - _xGrid = parseNumber _xGrid; - - _yGrid = toArray Str(round(_pos select 1)); - while {count _yGrid < 5} do { - _yGrid = [48] + _yGrid; - }; - _yGrid resize 4; - _yGrid = toString _yGrid; - _yGrid = parseNumber _yGrid; - - _xCoord = switch true do { - case (_xGrid >= 1000): { "" + Str(_xGrid) }; - case (_xGrid >= 100): { "0" + Str(_xGrid) }; - case (_xGrid >= 10): { "00" + Str(_xGrid) }; - default { "000" + Str(_xGrid) }; - }; - - _yCoord = switch true do { - case (_yGrid >= 1000): { "" + Str(_yGrid) }; - case (_yGrid >= 100): { "0" + Str(_yGrid) }; - case (_yGrid >= 10): { "00" + Str(_yGrid) }; - default { "000" + Str(_yGrid) }; - }; - - _dagrGrid = _xcoord + " " + _ycoord; + _gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos); + _dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])]; // SPEED _speed = speed (vehicle ACE_player); diff --git a/addons/dagr/functions/fnc_outputWP.sqf b/addons/dagr/functions/fnc_outputWP.sqf index d1fc2a47f2..71c3e7c1a7 100644 --- a/addons/dagr/functions/fnc_outputWP.sqf +++ b/addons/dagr/functions/fnc_outputWP.sqf @@ -30,7 +30,7 @@ __background ctrlSetText QUOTE(PATHTOF(UI\dagr_wp.paa)); if (GVAR(outputPFH) != -1) exitWith {}; GVAR(outputPFH) = [{ - private ["_pos", "_mapSize", "_gridConfig", "_offsetX", "_offsetY", "_stepX", "_stepY", "_xGrid", "_yGrid", "_xCoord", "_yCoord", "_dagrHeading", "_dagrGrid", "_bearing", "_MYpos", "_WPpos", "_dagrDistance", "_distance"]; + private["_MYpos", "_WPpos", "_bearing", "_dagrDistance", "_dagrGrid", "_dagrHeading", "_distance", "_gridArray"]; // Abort Condition if !(GVAR(run) && [ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)) exitWith { @@ -40,54 +40,8 @@ GVAR(outputPFH) = [{ }; // GRID - _pos = getPosASL ACE_player; - - _mapSize = getNumber (configFile >> "CfgWorlds" >> worldName >> "MapSize"); - _gridConfig = (configFile >> "CfgWorlds" >> worldName >> "Grid"); - _offsetX = getNumber (_gridConfig >> "offsetX"); - _offsetY = getNumber (_gridConfig >> "offsetY"); - _stepX = getNumber (_gridConfig >> "Zoom1" >> "stepX"); - _stepY = getNumber (_gridConfig >> "Zoom1" >> "stepY"); - - if (_stepY >= 0) then { - _pos set [1, (_mapSize - 100) - (_pos select 1) - _offsetY]; - }; - - // Incase grids go neg due to 99-00 boundry - if (_pos select 0 < 0) then {_pos set [0, (_pos select 0) + 99999];}; - if (_pos select 1 < 0) then {_pos set [1, (_pos select 1) + 99999];}; - - _xGrid = toArray Str(round(_pos select 0)); - while {count _xGrid < 5} do { - _xGrid = [48] + _xGrid; - }; - _xGrid resize 4; - _xGrid = toString _xGrid; - _xGrid = parseNumber _xGrid; - - _yGrid = toArray Str(round(_pos select 1)); - while {count _yGrid < 5} do { - _yGrid = [48] + _yGrid; - }; - _yGrid resize 4; - _yGrid = toString _yGrid; - _yGrid = parseNumber _yGrid; - - _xCoord = switch true do { - case (_xGrid >= 1000): { "" + Str(_xGrid) }; - case (_xGrid >= 100): { "0" + Str(_xGrid) }; - case (_xGrid >= 10): { "00" + Str(_xGrid) }; - default { "000" + Str(_xGrid) }; - }; - - _yCoord = switch true do { - case (_yGrid >= 1000): { "" + Str(_yGrid) }; - case (_yGrid >= 100): { "0" + Str(_yGrid) }; - case (_yGrid >= 10): { "00" + Str(_yGrid) }; - default { "000" + Str(_yGrid) }; - }; - - _dagrGrid = _xCoord + " " + _yCoord; + _gridArray = [(getPos ACE_player), false] call EFUNC(common,getMapGridFromPos); + _dagrGrid = format ["%1 %2", ((_gridArray select 0) select [0,4]), ((_gridArray select 1) select [0,4])]; // WP Grid _xGrid2 = floor (DAGR_WP_INFO / 10000); @@ -110,8 +64,8 @@ GVAR(outputPFH) = [{ _dagrGrid2 = _xCoord2 + " " + _yCoord2; // Distance - _WPpos = [[_xCoord2, _yCoord2], true] call CBA_fnc_mapGridToPos; - _MYpos = [[_xCoord, _yCoord], true] call CBA_fnc_mapGridToPos; + _WPpos = [_dagrGrid2, true] call EFUNC(common,getMapPosFromGrid); + _MYpos = [_dagrGrid, true] call EFUNC(common,getMapPosFromGrid); _distance = _MYpos distance _WPpos; _distance = floor (_distance * 10) / 10; _dagrDistance = str _distance + "m";