mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
more common code cleanup
This commit is contained in:
@ -1,12 +1,13 @@
|
||||
/*
|
||||
* Author: PabstMirror (ideas from Nou's mapGridToPos and BIS_fnc_gridToPos)
|
||||
* Author: PabstMirror
|
||||
* Finds real x/y offset and map step for a 10 digit grid
|
||||
* Save time by preparing data one time at startup
|
||||
* Ideas from Nou's mapGridToPos and BIS_fnc_gridToPos
|
||||
*
|
||||
* Argument:
|
||||
* Arguments:
|
||||
* None
|
||||
*
|
||||
* Return values:
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
@ -16,10 +17,10 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
private["_cfgGrid", "_formatX", "_formatY", "_heightOffset", "_offsetX", "_offsetY", "_originGrid", "_realOffsetY", "_startGrid", "_stepX", "_stepY", "_zoom", "_zoomMax", "_letterGrid"];
|
||||
|
||||
GVAR(mapGridData) = [];
|
||||
|
||||
private ["_cfgGrid", "_offsetX", "_offsetY", "_zoomMax", "_formatX", "_formatY", "_stepX", "_stepY", "_zoom", "_letterGrid", "_heightOffset", "_startGrid", "_originGrid", "_realOffsetY"];
|
||||
|
||||
//--- Extract grid values from world config (Borrowed from BIS_fnc_gridToPos)
|
||||
_cfgGrid = configFile >> "CfgWorlds" >> worldName >> "Grid";
|
||||
_offsetX = getNumber (_cfgGrid >> "offsetX");
|
||||
@ -29,6 +30,7 @@ _formatX = "";
|
||||
_formatY = "";
|
||||
_stepX = 1e10;
|
||||
_stepY = 1e10;
|
||||
|
||||
{
|
||||
_zoom = getnumber (_x >> "zoomMax");
|
||||
if (_zoom < _zoomMax) then {
|
||||
@ -38,11 +40,14 @@ _stepY = 1e10;
|
||||
_stepX = getNumber (_x >> "stepX");
|
||||
_stepY = getNumber (_x >> "stepY");
|
||||
};
|
||||
} foreach configProperties [_cfgGrid, "isClass _x", false];
|
||||
false
|
||||
} count 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 (toLower _formatX find "a" != -1) then {_letterGrid = true};
|
||||
if (toLower _formatY find "a" != -1) then {_letterGrid = true};
|
||||
|
||||
if (_letterGrid) exitWith {
|
||||
ACE_LOGWARNING_3("Map Grid Warning (%1) - Map uses letter grids [%2, %3]",worldName,_formatX,_formatY);
|
||||
};
|
||||
@ -51,13 +56,14 @@ if (_letterGrid) exitWith {
|
||||
_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 = (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);
|
||||
@ -66,10 +72,12 @@ _stepYat5 = -1 * _stepY * 10 ^ ((count _formatY) - 5);
|
||||
if (_stepYat5 < 0) then {
|
||||
ACE_LOGWARNING_1("Map Grid Warning (%1) - Northing is reversed.",worldName);
|
||||
};
|
||||
|
||||
if (_stepXat5 != 1) then {
|
||||
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for x.",worldName,_stepXat5);
|
||||
};
|
||||
if ((_stepYat5 != 1) && {_stepYat5 != -1}) then {
|
||||
|
||||
if (_stepYat5 != 1 && {_stepYat5 != -1}) then {
|
||||
ACE_LOGWARNING_2("Map Grid Warning (%1) - MGRS 10 digit grid does not equal 1 meter: (%2) for y.",worldName,_stepXat5);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user