2015-06-30 17:26:51 +00:00
|
|
|
/*
|
2015-09-21 11:53:12 +00:00
|
|
|
* Author: PabstMirror
|
2015-06-30 17:26:51 +00:00
|
|
|
* Finds real x/y offset and map step for a 10 digit grid
|
|
|
|
* Save time by preparing data one time at startup
|
2015-09-21 11:53:12 +00:00
|
|
|
* Ideas from Nou's mapGridToPos and BIS_fnc_gridToPos
|
2015-06-30 17:26:51 +00:00
|
|
|
*
|
2015-09-21 11:53:12 +00:00
|
|
|
* Arguments:
|
2015-06-30 17:26:51 +00:00
|
|
|
* None
|
|
|
|
*
|
2015-09-21 11:53:12 +00:00
|
|
|
* Return Value:
|
2015-06-30 17:26:51 +00:00
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_map_fnc_getMapGridData
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-06-30 02:18:21 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-06-30 16:11:53 +00:00
|
|
|
GVAR(mapGridData) = [];
|
|
|
|
|
2015-06-30 02:18:21 +00:00
|
|
|
//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos)
|
2015-12-12 15:48:54 +00:00
|
|
|
private _cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid";
|
|
|
|
private _offsetX = getNumber (_cfgGrid >> "offsetX");
|
|
|
|
private _offsetY = getNumber (_cfgGrid >> "offsetY");
|
|
|
|
private _zoomMax = 1e99;
|
|
|
|
private _formatX = "";
|
|
|
|
private _formatY = "";
|
|
|
|
private _stepX = 1e10;
|
|
|
|
private _stepY = 1e10;
|
2015-09-21 11:53:12 +00:00
|
|
|
|
2015-06-30 02:18:21 +00:00
|
|
|
{
|
2015-12-12 15:48:54 +00:00
|
|
|
private _zoom = getnumber (_x >> "zoomMax");
|
2015-06-30 02:18:21 +00:00
|
|
|
if (_zoom < _zoomMax) then {
|
|
|
|
_zoomMax = _zoom;
|
2015-06-30 16:11:53 +00:00
|
|
|
_formatX = getText (_x >> "formatX");
|
|
|
|
_formatY = getText (_x >> "formatY");
|
|
|
|
_stepX = getNumber (_x >> "stepX");
|
|
|
|
_stepY = getNumber (_x >> "stepY");
|
2015-06-30 02:18:21 +00:00
|
|
|
};
|
2015-09-21 11:53:12 +00:00
|
|
|
false
|
|
|
|
} count configProperties [_cfgGrid, "isClass _x", false];
|
2015-06-30 16:11:53 +00:00
|
|
|
|
2015-12-12 15:48:54 +00:00
|
|
|
private _letterGrid = false;
|
2015-09-21 11:53:12 +00:00
|
|
|
|
|
|
|
if (toLower _formatX find "a" != -1) then {_letterGrid = true};
|
|
|
|
if (toLower _formatY find "a" != -1) then {_letterGrid = true};
|
|
|
|
|
2015-06-30 16:11:53 +00:00
|
|
|
if (_letterGrid) exitWith {
|
2016-10-02 10:55:31 +00:00
|
|
|
WARNING_3("Map Grid Warning (%1) - Map uses letter grids [%2, %3]",worldName,_formatX,_formatY);
|
2015-06-30 16:11:53 +00:00
|
|
|
};
|
2015-06-30 02:18:21 +00:00
|
|
|
|
2015-07-16 23:10:10 +00:00
|
|
|
//Start at [0, 500] and move north until we get a change in grid
|
2015-12-12 15:48:54 +00:00
|
|
|
private _heightOffset = 500;
|
|
|
|
private _startGrid = mapGridPosition [0, _heightOffset];
|
|
|
|
private _originGrid = _startGrid;
|
2015-09-21 11:53:12 +00:00
|
|
|
|
2015-07-16 23:10:10 +00:00
|
|
|
while {_startGrid == _originGrid} do {
|
|
|
|
_heightOffset = _heightOffset + 1;
|
|
|
|
_originGrid = mapGridPosition [0, _heightOffset];
|
|
|
|
};
|
|
|
|
|
2015-06-30 16:11:53 +00:00
|
|
|
//Calculate the real y offset
|
2015-12-12 15:48:54 +00:00
|
|
|
private _realOffsetY = (parseNumber (_originGrid select [count _formatX, count _formatY])) * _stepY + _heightOffset - 1;
|
2015-06-30 02:18:21 +00:00
|
|
|
|
2015-06-30 16:11:53 +00:00
|
|
|
//Calculate MGRS 10digit step - they should both be 1 meter:
|
2017-05-14 19:48:05 +00:00
|
|
|
private _stepXat5 = _stepX * 10 ^ ((count _formatX) - 5);
|
|
|
|
private _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
|
2015-06-30 02:18:21 +00:00
|
|
|
|
2015-06-30 16:11:53 +00:00
|
|
|
if (_stepYat5 < 0) then {
|
2017-08-22 21:21:41 +00:00
|
|
|
TRACE_1("Northing is reversed",worldName);
|
2015-06-30 16:11:53 +00:00
|
|
|
};
|
|
|
|
if (_stepXat5 != 1) then {
|
2017-08-22 21:21:41 +00:00
|
|
|
TRACE_2("MGRS 10 digit grid does not equal 1 meter",_stepXat5,worldName);
|
2015-06-30 16:11:53 +00:00
|
|
|
};
|
2015-09-21 11:53:12 +00:00
|
|
|
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {
|
2017-08-22 21:21:41 +00:00
|
|
|
TRACE_2("MGRS 10 digit grid does not equal 1 meter",_stepYat5,worldName);
|
2015-06-30 16:11:53 +00:00
|
|
|
};
|
|
|
|
|
2015-06-30 02:18:21 +00:00
|
|
|
GVAR(mapGridData) = [_offsetX, _realOffsetY, _stepXat5, _stepYat5];
|