2015-05-10 10:20:42 +00:00
|
|
|
/*
|
|
|
|
* Author: VKing
|
|
|
|
* Gets a 10-digit map grid for the given world position
|
|
|
|
*
|
|
|
|
* Argument:
|
2015-06-23 01:36:37 +00:00
|
|
|
* 0: Position (2D Position) <ARRAY>
|
|
|
|
* 1: Return type; false for array of easting and northing, true for single string <Bool>
|
2015-05-10 10:20:42 +00:00
|
|
|
*
|
2015-05-10 15:26:28 +00:00
|
|
|
* Return values:
|
2015-06-23 01:36:37 +00:00
|
|
|
* 0: Easting <String>
|
|
|
|
* 1: Northing <String>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [(getPos player)] call ace_map_fnc_getMapGridFromPos;
|
|
|
|
*
|
|
|
|
* Public: Yes
|
2015-05-10 10:20:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// #define DEBUG_MODE_FULL
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-05-10 10:36:44 +00:00
|
|
|
PARAMS_1(_pos);
|
2015-06-23 01:36:37 +00:00
|
|
|
DEFAULT_PARAM(1,_returnSingleString,false);
|
2015-05-10 10:20:42 +00:00
|
|
|
|
2015-06-23 01:36:37 +00:00
|
|
|
private["_posX", "_posY"];
|
2015-05-10 10:20:42 +00:00
|
|
|
|
|
|
|
TRACE_2("",_pos select 0, _pos select 1);
|
|
|
|
|
2015-06-23 01:36:37 +00:00
|
|
|
_posX = GVAR(gridOffsetX) + floor (_pos select 0);
|
2015-05-10 10:20:42 +00:00
|
|
|
TRACE_1("",_posX);
|
2015-06-23 01:36:37 +00:00
|
|
|
_posX = str ((100000 + _posX) % 100000);
|
|
|
|
|
|
|
|
if (cba_common_mapReversed) then {
|
|
|
|
_posY = GVAR(gridOffsetY) - ceil(_pos select 1);
|
2015-05-10 10:20:42 +00:00
|
|
|
} else {
|
2015-06-23 01:36:37 +00:00
|
|
|
_posY = GVAR(gridOffsetY) + floor(_pos select 1);
|
2015-05-10 10:20:42 +00:00
|
|
|
};
|
|
|
|
TRACE_1("",_posY);
|
2015-06-23 01:36:37 +00:00
|
|
|
_posY = str ((100000 + _posY) % 100000);
|
|
|
|
|
2015-05-10 10:20:42 +00:00
|
|
|
TRACE_2("",_posX,_posY);
|
|
|
|
|
2015-05-10 10:36:44 +00:00
|
|
|
_posX = switch (count _posX) do {
|
|
|
|
case 1: {"0000"+_posX};
|
|
|
|
case 2: {"000"+_posX};
|
|
|
|
case 3: {"00"+_posX};
|
|
|
|
case 4: {"0"+_posX};
|
|
|
|
default {_posX};
|
2015-05-10 10:20:42 +00:00
|
|
|
};
|
2015-05-10 10:36:44 +00:00
|
|
|
_posY = switch (count _posY) do {
|
|
|
|
case 1: {"0000"+_posY};
|
|
|
|
case 2: {"000"+_posY};
|
|
|
|
case 3: {"00"+_posY};
|
|
|
|
case 4: {"0"+_posY};
|
|
|
|
default {_posY};
|
2015-05-10 10:20:42 +00:00
|
|
|
};
|
|
|
|
TRACE_3("",mapGridPosition _pos,_posX,_posY);
|
|
|
|
|
2015-06-23 01:36:37 +00:00
|
|
|
if (_returnSingleString) then {
|
2015-05-10 16:05:28 +00:00
|
|
|
_posX+_posY
|
|
|
|
} else {
|
|
|
|
[_posX,_posY]
|
2015-06-23 01:36:37 +00:00
|
|
|
};
|