mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
RAT v2.3.2
AIRBASE: - FindFreeParkikng: Added check that units of a group dont overlap with previous members of the same group. RAT: - Added check for all units of a group that did not move within a certain time.
This commit is contained in:
parent
2faf7631cb
commit
fdb1db6f85
@ -511,7 +511,7 @@ RAT.id="RAT | "
|
|||||||
--- RAT version.
|
--- RAT version.
|
||||||
-- @list version
|
-- @list version
|
||||||
RAT.version={
|
RAT.version={
|
||||||
version = "2.3.1",
|
version = "2.3.2",
|
||||||
print = true,
|
print = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2124,10 +2124,16 @@ function RAT:_SpawnWithRoute(_departure, _destination, _takeoff, _landing, _live
|
|||||||
if group:InAir() then
|
if group:InAir() then
|
||||||
self.ratcraft[self.SpawnIndex]["Tground"]=nil
|
self.ratcraft[self.SpawnIndex]["Tground"]=nil
|
||||||
self.ratcraft[self.SpawnIndex]["Pground"]=nil
|
self.ratcraft[self.SpawnIndex]["Pground"]=nil
|
||||||
|
self.ratcraft[self.SpawnIndex]["Uground"]=nil
|
||||||
self.ratcraft[self.SpawnIndex]["Tlastcheck"]=nil
|
self.ratcraft[self.SpawnIndex]["Tlastcheck"]=nil
|
||||||
else
|
else
|
||||||
self.ratcraft[self.SpawnIndex]["Tground"]=timer.getTime()
|
self.ratcraft[self.SpawnIndex]["Tground"]=timer.getTime()
|
||||||
self.ratcraft[self.SpawnIndex]["Pground"]=group:GetCoordinate()
|
self.ratcraft[self.SpawnIndex]["Pground"]=group:GetCoordinate()
|
||||||
|
self.ratcraft[self.SpawnIndex]["Uground"]={}
|
||||||
|
for _,_unit in pairs(group:GetUnits()) do
|
||||||
|
local _unitname=_unit:GetName()
|
||||||
|
self.ratcraft[self.SpawnIndex]["Uground"][_unitname]=_unit:GetCoordinate()
|
||||||
|
end
|
||||||
self.ratcraft[self.SpawnIndex]["Tlastcheck"]=timer.getTime()
|
self.ratcraft[self.SpawnIndex]["Tlastcheck"]=timer.getTime()
|
||||||
end
|
end
|
||||||
-- Initial and current position. For calculating the travelled distance.
|
-- Initial and current position. For calculating the travelled distance.
|
||||||
@ -3361,6 +3367,7 @@ function RAT:Status(message, forID)
|
|||||||
-- Aircraft is airborne.
|
-- Aircraft is airborne.
|
||||||
ratcraft["Tground"]=nil
|
ratcraft["Tground"]=nil
|
||||||
ratcraft["Pground"]=nil
|
ratcraft["Pground"]=nil
|
||||||
|
ratcraft["Uground"]=nil
|
||||||
ratcraft["Tlastcheck"]=nil
|
ratcraft["Tlastcheck"]=nil
|
||||||
else
|
else
|
||||||
--Aircraft is on ground.
|
--Aircraft is on ground.
|
||||||
@ -3377,13 +3384,36 @@ function RAT:Status(message, forID)
|
|||||||
-- If more than Tinactive seconds passed since last check ==> check how much we moved meanwhile.
|
-- If more than Tinactive seconds passed since last check ==> check how much we moved meanwhile.
|
||||||
if dTlast > self.Tinactive then
|
if dTlast > self.Tinactive then
|
||||||
|
|
||||||
|
--[[
|
||||||
|
if Dg<50 and active and status~=RAT.status.EventBirth then
|
||||||
|
stationary=true
|
||||||
|
end
|
||||||
|
]]
|
||||||
|
|
||||||
|
-- Loop over all units.
|
||||||
|
for _,_unit in pairs(group:GetUnits()) do
|
||||||
|
|
||||||
|
if _unit and _unit:IsAlive() then
|
||||||
|
|
||||||
|
-- Unit name, coord and distance since last check.
|
||||||
|
local unitname=_unit:GetName()
|
||||||
|
local unitcoord=_unit:GetCoordinate()
|
||||||
|
local Ug=unitcoord:Get2DDistance(ratcraft.Uground[unitname])
|
||||||
|
|
||||||
|
-- Debug info
|
||||||
|
self:T2(RAT.id..string.format("Unit %s travelled distance on ground %.1f m since %d seconds.", unitname, Ug, dTlast))
|
||||||
|
|
||||||
-- If aircraft did not move more than 50 m since last check, we call it stationary and despawn it.
|
-- If aircraft did not move more than 50 m since last check, we call it stationary and despawn it.
|
||||||
-- Aircraft which are spawned uncontrolled or starting their engines are not counted.
|
-- Aircraft which are spawned uncontrolled or starting their engines are not counted.
|
||||||
if Dg<50 and active and status~=RAT.status.EventBirth then
|
if Ug<50 and active and status~=RAT.status.EventBirth then
|
||||||
--if Dg<50 and active then
|
|
||||||
stationary=true
|
stationary=true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Update coords.
|
||||||
|
ratcraft["Uground"][unitname]=unitcoord
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Set the current time to know when the next check is necessary.
|
-- Set the current time to know when the next check is necessary.
|
||||||
ratcraft["Tlastcheck"]=Tnow
|
ratcraft["Tlastcheck"]=Tnow
|
||||||
ratcraft["Pground"]=coords
|
ratcraft["Pground"]=coords
|
||||||
@ -3394,6 +3424,11 @@ function RAT:Status(message, forID)
|
|||||||
ratcraft["Tground"]=Tnow
|
ratcraft["Tground"]=Tnow
|
||||||
ratcraft["Tlastcheck"]=Tnow
|
ratcraft["Tlastcheck"]=Tnow
|
||||||
ratcraft["Pground"]=coords
|
ratcraft["Pground"]=coords
|
||||||
|
ratcraft["Uground"]={}
|
||||||
|
for _,_unit in pairs(group:GetUnits()) do
|
||||||
|
local unitname=_unit:GetName()
|
||||||
|
ratcraft.Uground[unitname]=_unit:GetCoordinate()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -626,9 +626,9 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Function calculating the overlap of two (square) objects.
|
-- Function calculating the overlap of two (square) objects.
|
||||||
local function _overlap(mooseobject, dcsobject, dist)
|
local function _overlap(object1, mooseobject1, object2, mooseobject2, dist)
|
||||||
local l1=_GetObjectSize(mooseobject, true)
|
local l1=_GetObjectSize(object1, mooseobject1)
|
||||||
local l2=_GetObjectSize(dcsobject)
|
local l2=_GetObjectSize(object2, mooseobject2)
|
||||||
local safedist=(l1/2+l2/2)*1.1
|
local safedist=(l1/2+l2/2)*1.1
|
||||||
local safe = (dist > safedist)
|
local safe = (dist > safedist)
|
||||||
self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe)))
|
self:T3(string.format("l1=%.1f l2=%.1f s=%.1f d=%.1f ==> safe=%s", l1,l2,safedist,dist,tostring(safe)))
|
||||||
@ -676,10 +676,10 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
local _termid=parkingspot.TerminalID
|
local _termid=parkingspot.TerminalID
|
||||||
|
|
||||||
-- Very safe uses the DCS getParking() info to check if a spot is free. Unfortunately, the function returns free=false until the aircraft has actually taken-off.
|
-- Very safe uses the DCS getParking() info to check if a spot is free. Unfortunately, the function returns free=false until the aircraft has actually taken-off.
|
||||||
if verysafe and parkingspot.Free==false then
|
if verysafe and (parkingspot.Free==false or parkingspot.TOAC==true) then
|
||||||
|
|
||||||
-- DCS getParking() routine returned that spot is not free.
|
-- DCS getParking() routine returned that spot is not free.
|
||||||
self:T(string.format("%s: Parking spot id %d NOT free (or aircraft has not taken off yet).", airport, parkingspot.TerminalID))
|
self:E(string.format("%s: Parking spot id %d NOT free (or aircraft has not taken off yet). Free=%s, TOAC=%s.", airport, parkingspot.TerminalID, tostring(parkingspot.Free), tostring(parkingspot.TOAC)))
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -695,7 +695,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
local _vec3=unit:getPoint()
|
local _vec3=unit:getPoint()
|
||||||
local _coord=COORDINATE:NewFromVec3(_vec3)
|
local _coord=COORDINATE:NewFromVec3(_vec3)
|
||||||
local _dist=_coord:Get2DDistance(_spot)
|
local _dist=_coord:Get2DDistance(_spot)
|
||||||
local _safe=_overlap(aircraft, unit, _dist)
|
local _safe=_overlap(aircraft, true, unit, false,_dist)
|
||||||
|
|
||||||
if markobstacles then
|
if markobstacles then
|
||||||
local l,x,y,z=_GetObjectSize(unit)
|
local l,x,y,z=_GetObjectSize(unit)
|
||||||
@ -712,7 +712,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
local _vec3=static:getPoint()
|
local _vec3=static:getPoint()
|
||||||
local _coord=COORDINATE:NewFromVec3(_vec3)
|
local _coord=COORDINATE:NewFromVec3(_vec3)
|
||||||
local _dist=_coord:Get2DDistance(_spot)
|
local _dist=_coord:Get2DDistance(_spot)
|
||||||
local _safe=_overlap(aircraft, static, _dist)
|
local _safe=_overlap(aircraft, true, static, false,_dist)
|
||||||
|
|
||||||
if markobstacles then
|
if markobstacles then
|
||||||
local l,x,y,z=_GetObjectSize(static)
|
local l,x,y,z=_GetObjectSize(static)
|
||||||
@ -729,7 +729,7 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
local _vec3=scenery:getPoint()
|
local _vec3=scenery:getPoint()
|
||||||
local _coord=COORDINATE:NewFromVec3(_vec3)
|
local _coord=COORDINATE:NewFromVec3(_vec3)
|
||||||
local _dist=_coord:Get2DDistance(_spot)
|
local _dist=_coord:Get2DDistance(_spot)
|
||||||
local _safe=_overlap(aircraft, scenery, _dist)
|
local _safe=_overlap(aircraft, true, scenery, false,_dist)
|
||||||
|
|
||||||
if markobstacles then
|
if markobstacles then
|
||||||
local l,x,y,z=_GetObjectSize(scenery)
|
local l,x,y,z=_GetObjectSize(scenery)
|
||||||
@ -741,6 +741,15 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Now check the already given spots so that we do not put a large aircraft next to one we already assigned a nearby spot.
|
||||||
|
for _,_takenspot in pairs(validspots) do
|
||||||
|
local _dist=_takenspot.Coordinate:Get2DDistance(_spot)
|
||||||
|
local _safe=_overlap(aircraft, true, aircraft, true,_dist)
|
||||||
|
if not _safe then
|
||||||
|
occupied=true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--_spot:MarkToAll(string.format("Parking spot %d free=%s", parkingspot.TerminalID, tostring(not occupied)))
|
--_spot:MarkToAll(string.format("Parking spot %d free=%s", parkingspot.TerminalID, tostring(not occupied)))
|
||||||
if occupied then
|
if occupied then
|
||||||
self:T(string.format("%s: Parking spot id %d occupied.", airport, _termid))
|
self:T(string.format("%s: Parking spot id %d occupied.", airport, _termid))
|
||||||
@ -752,12 +761,13 @@ function AIRBASE:FindFreeParkingSpotForAircraft(group, terminaltype, scanradius,
|
|||||||
nvalid=nvalid+1
|
nvalid=nvalid+1
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end -- loop over units
|
||||||
|
|
||||||
-- We found enough spots.
|
-- We found enough spots.
|
||||||
if nvalid>=_nspots then
|
if nvalid>=_nspots then
|
||||||
return validspots
|
return validspots
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Retrun spots we found, even if there were not enough.
|
-- Retrun spots we found, even if there were not enough.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user