diff --git a/Moose Development/Moose/Core/Point.lua b/Moose Development/Moose/Core/Point.lua index 7bf6003ee..65022dec4 100644 --- a/Moose Development/Moose/Core/Point.lua +++ b/Moose Development/Moose/Core/Point.lua @@ -1117,7 +1117,7 @@ do -- COORDINATE -- Airbase parameters for takeoff and landing points. if airbase then local AirbaseID = airbase:GetID() - local AirbaseCategory = airbase:GetDesc().category + local AirbaseCategory = airbase:GetAirbaseCategory() if AirbaseCategory == Airbase.Category.SHIP or AirbaseCategory == Airbase.Category.HELIPAD then RoutePoint.linkUnit = AirbaseID RoutePoint.helipadId = AirbaseID diff --git a/Moose Development/Moose/Core/Spawn.lua b/Moose Development/Moose/Core/Spawn.lua index 9c822777b..3634000fb 100644 --- a/Moose Development/Moose/Core/Spawn.lua +++ b/Moose Development/Moose/Core/Spawn.lua @@ -1983,7 +1983,7 @@ function SPAWN:ParkAircraft( SpawnAirbase, TerminalType, Parkingdata, SpawnIndex -- Get airbase ID and category. local AirbaseID = SpawnAirbase:GetID() - local AirbaseCategory = SpawnAirbase:GetDesc().category + local AirbaseCategory = SpawnAirbase:GetAirbaseCategory() self:F( { AirbaseCategory = AirbaseCategory } ) -- Set airdromeId. diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index 7492a5d4d..327e2e518 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -3416,7 +3416,7 @@ function RAT:_GetAirportsOfCoalition() for _,coalition in pairs(self.ctable) do for _,_airport in pairs(self.airports_map) do local airport=_airport --Wrapper.Airbase#AIRBASE - local category=airport:GetDesc().category + local category=airport:GetAirbaseCategory() if airport:GetCoalition()==coalition then -- Planes cannot land on FARPs. --local condition1=self.category==RAT.cat.plane and airport:GetTypeName()=="FARP" @@ -3847,7 +3847,7 @@ function RAT:_OnBirth(EventData) -- Check if any unit of the group was spawned on top of another unit in the MOOSE data base. local ontop=false - if self.checkontop and (_airbase and _airbase:GetDesc().category==Airbase.Category.AIRDROME) then + if self.checkontop and (_airbase and _airbase:GetAirbaseCategory()==Airbase.Category.AIRDROME) then ontop=self:_CheckOnTop(SpawnGroup, self.ontopradius) end @@ -4457,7 +4457,7 @@ function RAT:_Waypoint(index, description, Type, Coord, Speed, Altitude, Airport if (Airport~=nil) and (Type~=RAT.wp.air) then local AirbaseID = Airport:GetID() - local AirbaseCategory = Airport:GetDesc().category + local AirbaseCategory = Airport:GetAirbaseCategory() if AirbaseCategory == Airbase.Category.SHIP then RoutePoint.linkUnit = AirbaseID RoutePoint.helipadId = AirbaseID @@ -5141,7 +5141,7 @@ function RAT:_ModifySpawnTemplate(waypoints, livery, spawnplace, departure, take local spawnonrunway=false local spawnonairport=false if spawnonground then - local AirbaseCategory = departure:GetDesc().category + local AirbaseCategory = departure:GetAirbaseCategory() if AirbaseCategory == Airbase.Category.SHIP then spawnonship=true elseif AirbaseCategory == Airbase.Category.HELIPAD then diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 167532f4c..a41161291 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -3045,7 +3045,7 @@ end function WAREHOUSE:GetAirbaseCategory() local category=-1 if self.airbase then - category=self.airbase:GetDesc().category + category=self.airbase:GetAirbaseCategory() end return category end diff --git a/Moose Development/Moose/Utilities/Utils.lua b/Moose Development/Moose/Utilities/Utils.lua index d31ae647a..15ae1ac1b 100644 --- a/Moose Development/Moose/Utilities/Utils.lua +++ b/Moose Development/Moose/Utilities/Utils.lua @@ -471,15 +471,31 @@ end -- acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5. UTILS.tostringMGRS = function(MGRS, acc) --R2.1 + if acc == 0 then return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph else - --return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Easting/(10^(5-acc)), 0)) - -- .. ' ' .. string.format('%0' .. acc .. 'd', UTILS.Round(MGRS.Northing/(10^(5-acc)), 0)) + + -- Test if Easting/Northing have less than 4 digits. + --MGRS.Easting=123 -- should be 00123 + --MGRS.Northing=5432 -- should be 05432 - -- Truncate rather than round MGRS grid! - return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(tostring(MGRS.Easting), 1, acc), string.sub(tostring(MGRS.Northing), 1, acc)) + -- Truncate rather than round MGRS grid! + local Easting=tostring(MGRS.Easting) + local Northing=tostring(MGRS.Northing) + + -- Count number of missing digits. Easting/Northing should have 5 digits. However, it is passed as a number. Therefore, any leading zeros would not be displayed by lua. + local nE=5-string.len(Easting) + local nN=5-string.len(Northing) + + -- Get leading zeros (if any). + for i=1,nE do Easting="0"..Easting end + for i=1,nN do Northing="0"..Northing end + + -- Return MGRS string. + return string.format("%s %s %s %s", MGRS.UTMZone, MGRS.MGRSDigraph, string.sub(Easting, 1, acc), string.sub(Northing, 1, acc)) end + end diff --git a/Moose Development/Moose/Wrapper/Airbase.lua b/Moose Development/Moose/Wrapper/Airbase.lua index 22919628d..b6680f965 100644 --- a/Moose Development/Moose/Wrapper/Airbase.lua +++ b/Moose Development/Moose/Wrapper/Airbase.lua @@ -1003,7 +1003,7 @@ function AIRBASE:CheckOnRunWay(group, radius, despawn) radius=radius or 50 -- We only check at real airbases (not FARPS or ships). - if self:GetDesc().category~=Airbase.Category.AIRDROME then + if self:GetAirbaseCategory()~=Airbase.Category.AIRDROME then return false end diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 82616e283..3fc5e672a 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -1922,7 +1922,7 @@ function GROUP:RespawnAtCurrentAirbase(SpawnTemplate, Takeoff, Uncontrolled) -- -- Aibase id and category. local AirbaseID = airbase:GetID() - local AirbaseCategory = airbase:GetDesc().category + local AirbaseCategory = airbase:GetAirbaseCategory() if AirbaseCategory == Airbase.Category.SHIP or AirbaseCategory == Airbase.Category.HELIPAD then SpawnPoint.linkUnit = AirbaseID