Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist 2023-12-23 14:53:36 +01:00
commit e82e4f7dd7
2 changed files with 12 additions and 10 deletions

View File

@ -170,7 +170,7 @@
-- --
-- * A specific departure and/or destination airport can be chosen. -- * A specific departure and/or destination airport can be chosen.
-- * Valid coalitions can be set, e.g. only red, blue or neutral, all three "colours". -- * Valid coalitions can be set, e.g. only red, blue or neutral, all three "colours".
-- * It is possible to start in air within a zone defined in the mission editor or within a zone above an airport of the map. -- * It is possible to start in air within a zone or within a zone above an airport of the map.
-- --
-- ## Flight Plan -- ## Flight Plan
-- --
@ -1179,13 +1179,13 @@ function RAT:SetTakeoffAir()
return self return self
end end
--- Set possible departure ports. This can be an airport or a zone defined in the mission editor. --- Set possible departure ports. This can be an airport or a zone.
-- @param #RAT self -- @param #RAT self
-- @param #string departurenames Name or table of names of departure airports or zones. -- @param #string departurenames Name or table of names of departure airports or zones.
-- @return #RAT RAT self object. -- @return #RAT RAT self object.
-- @usage RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport. -- @usage RAT:SetDeparture("Sochi-Adler") will spawn RAT objects at Sochi-Adler airport.
-- @usage RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport. -- @usage RAT:SetDeparture({"Sochi-Adler", "Gudauta"}) will spawn RAT aircraft radomly at Sochi-Adler or Gudauta airport.
-- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, which has to be defined in the mission editor, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set. -- @usage RAT:SetDeparture({"Zone A", "Gudauta"}) will spawn RAT aircraft in air randomly within Zone A, or within a zone around Gudauta airport. Note that this also requires RAT:takeoff("air") to be set.
function RAT:SetDeparture(departurenames) function RAT:SetDeparture(departurenames)
self:F2(departurenames) self:F2(departurenames)
@ -2537,7 +2537,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
end end
elseif self:_ZoneExists(_departure) then elseif self:_ZoneExists(_departure) then
-- If it's not an airport, check whether it's a zone. -- If it's not an airport, check whether it's a zone.
departure=ZONE:New(_departure) departure=ZONE:FindByName(_departure)
else else
local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias) local text=string.format("ERROR! Specified departure airport %s does not exist for %s.", _departure, self.alias)
self:E(RAT.id..text) self:E(RAT.id..text)
@ -2635,7 +2635,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
end end
elseif self:_ZoneExists(_destination) then elseif self:_ZoneExists(_destination) then
destination=ZONE:New(_destination) destination=ZONE:FindByName(_destination)
else else
local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias) local text=string.format("ERROR: Specified destination airport/zone %s does not exist for %s!", _destination, self.alias)
self:E(RAT.id.."ERROR: "..text) self:E(RAT.id.."ERROR: "..text)
@ -3142,7 +3142,7 @@ function RAT:_PickDeparture(takeoff)
end end
elseif self:_ZoneExists(name) then elseif self:_ZoneExists(name) then
if takeoff==RAT.wp.air then if takeoff==RAT.wp.air then
dep=ZONE:New(name) dep=ZONE:FindByName(name)
else else
self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name)) self:E(RAT.id..string.format("ERROR! Takeoff is not in air. Cannot use %s as departure.", name))
end end
@ -3254,7 +3254,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
end end
elseif self:_ZoneExists(name) then elseif self:_ZoneExists(name) then
if landing==RAT.wp.air then if landing==RAT.wp.air then
dest=ZONE:New(name) dest=ZONE:FindByName(name)
else else
self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name)) self:E(RAT.id..string.format("ERROR! Landing is not in air. Cannot use zone %s as destination!", name))
end end
@ -4930,12 +4930,12 @@ function RAT:_AirportExists(name)
return false return false
end end
--- Test if a trigger zone defined in the mission editor exists. --- Test if a zone exists.
-- @param #RAT self -- @param #RAT self
-- @param #string name -- @param #string name
-- @return #boolean True if zone exsits, false otherwise. -- @return #boolean True if zone exsits, false otherwise.
function RAT:_ZoneExists(name) function RAT:_ZoneExists(name)
local z=trigger.misc.getZone(name) local z=ZONE:FindByName(name) --trigger.misc.getZone(name) as suggested by @Viking on MOOSE discord #rat
if z then if z then
return true return true
end end

View File

@ -1738,6 +1738,8 @@ end
function RANGE:OnEventBirth( EventData ) function RANGE:OnEventBirth( EventData )
self:F( { eventbirth = EventData } ) self:F( { eventbirth = EventData } )
if not EventData.IniPlayerName then return end
local _unitName = EventData.IniUnitName local _unitName = EventData.IniUnitName
local _unit, _playername = self:_GetPlayerUnitAndName( _unitName ) local _unit, _playername = self:_GetPlayerUnitAndName( _unitName )