mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed bugs with new option table.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
__Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Routines.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Routines.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
|
||||||
|
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
|
||||||
|
|
||||||
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/Base.lua' )
|
||||||
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
__Moose.Include( 'Scripts/Moose/Core/UserFlag.lua' )
|
||||||
|
|||||||
@@ -1392,8 +1392,8 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
if self.ai then
|
if self.ai then
|
||||||
|
|
||||||
-- Set default ROE and ROT options.
|
-- Set default ROE and ROT options.
|
||||||
self:SetOptionROE(self.roe)
|
self:SwitchROE(self.option.ROE)
|
||||||
self:SetOptionROT(self.rot)
|
self:SwitchROT(self.option.ROT)
|
||||||
|
|
||||||
-- TODO: make this input.
|
-- TODO: make this input.
|
||||||
self.group:SetOption(AI.Option.Air.id.PROHIBIT_JETT, true)
|
self.group:SetOption(AI.Option.Air.id.PROHIBIT_JETT, true)
|
||||||
@@ -1402,18 +1402,19 @@ function FLIGHTGROUP:onafterSpawned(From, Event, To)
|
|||||||
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
--self.group:SetOption(AI.Option.Air.id.RADAR_USING, AI.Option.Air.val.RADAR_USING.FOR_CONTINUOUS_SEARCH)
|
||||||
|
|
||||||
-- Turn TACAN beacon on.
|
-- Turn TACAN beacon on.
|
||||||
if self.tacanChannelDefault then
|
if self.tacanDefault.Channel then
|
||||||
self:SwitchTACANOn(self.tacanChannelDefault, self.tacanMorseDefault)
|
self:SwitchTACAN(self.tacanDefault.Channel, self.tacanDefault.Morse)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Turn on the radio.
|
-- Turn on the radio.
|
||||||
if self.radioFreqDefault then
|
if self.radioDefault.Freq then
|
||||||
self:SwitchRadioOn(self.radioFreqDefault, self.radioModuDefault)
|
self:SwitchRadio(self.radioDefault.Freq, self.radioDefault.Modu)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set callsign.
|
-- Set callsign.
|
||||||
if self.callsignNameDefault then
|
if self.callsignDefault.Name then
|
||||||
self:SwitchCallsign(self.callsignNameDefault, self.callsignNumberDefault)
|
self:SwitchCallsign(self.callsignNameDefault, self.callsignNumberDefault)
|
||||||
|
else
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
@@ -2510,36 +2511,28 @@ function FLIGHTGROUP:_InitGroup()
|
|||||||
|
|
||||||
-- Radio parameters from template.
|
-- Radio parameters from template.
|
||||||
self.radioOn=self.template.communication
|
self.radioOn=self.template.communication
|
||||||
self.radioFreq=self.template.frequency
|
self.radio.Freq=self.template.frequency
|
||||||
self.radioModu=self.template.modulation
|
self.radio.Modu=self.template.modulation
|
||||||
|
self.radioDefault.Freq=self.radio.Freq
|
||||||
-- If not set by the use explicitly yet, we take the template values as defaults.
|
self.radioDefault.Modu=self.radio.Modu
|
||||||
if not self.radioFreqDefault then
|
|
||||||
self.radioFreqDefault=self.radioFreq
|
|
||||||
self.radioModuDefault=self.radioModu
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set default formation.
|
-- Set default formation.
|
||||||
if not self.formationDefault then
|
if self.ishelo then
|
||||||
if self.ishelo then
|
self.optionDefault.Formation=ENUMS.Formation.RotaryWing.EchelonLeft.D300
|
||||||
self.formationDefault=ENUMS.Formation.RotaryWing.EchelonLeft.D300
|
else
|
||||||
else
|
self.optionDefault.Formation=ENUMS.Formation.FixedWing.EchelonLeft.Group
|
||||||
self.formationDefault=ENUMS.Formation.FixedWing.EchelonLeft.Group
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Is this purely AI?
|
||||||
self.ai=not self:_IsHuman(self.group)
|
self.ai=not self:_IsHuman(self.group)
|
||||||
|
|
||||||
|
-- Create Menu.
|
||||||
if not self.ai then
|
if not self.ai then
|
||||||
self.menu=self.menu or {}
|
self.menu=self.menu or {}
|
||||||
self.menu.atc=self.menu.atc or {}
|
self.menu.atc=self.menu.atc or {}
|
||||||
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC")
|
self.menu.atc.root=self.menu.atc.root or MENU_GROUP:New(self.group, "ATC")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Switch to default formation.
|
|
||||||
-- TODO: Should this be moved to onafterspawned?
|
|
||||||
self:SwitchFormation(self.formationDefault)
|
|
||||||
|
|
||||||
-- Add elemets.
|
-- Add elemets.
|
||||||
for _,unit in pairs(self.group:GetUnits()) do
|
for _,unit in pairs(self.group:GetUnits()) do
|
||||||
local element=self:AddElementByName(unit:GetName())
|
local element=self:AddElementByName(unit:GetName())
|
||||||
@@ -2573,7 +2566,7 @@ function FLIGHTGROUP:_InitGroup()
|
|||||||
text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter()))
|
text=text..string.format("Helicopter = %s\n", tostring(self.group:IsHelicopter()))
|
||||||
text=text..string.format("Elements = %d\n", #self.elements)
|
text=text..string.format("Elements = %d\n", #self.elements)
|
||||||
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
text=text..string.format("Waypoints = %d\n", #self.waypoints)
|
||||||
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radioFreq, UTILS.GetModulationName(self.radioModu), tostring(self.radioOn))
|
text=text..string.format("Radio = %.1f MHz %s %s\n", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu), tostring(self.radioOn))
|
||||||
text=text..string.format("Ammo = %d (G=%d/R=%d/B=%d/M=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Bombs, self.ammo.Missiles)
|
text=text..string.format("Ammo = %d (G=%d/R=%d/B=%d/M=%d)\n", self.ammo.Total, self.ammo.Guns, self.ammo.Rockets, self.ammo.Bombs, self.ammo.Missiles)
|
||||||
text=text..string.format("FSM state = %s\n", self:GetState())
|
text=text..string.format("FSM state = %s\n", self:GetState())
|
||||||
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
|
text=text..string.format("Is alive = %s\n", tostring(self.group:IsAlive()))
|
||||||
@@ -2965,28 +2958,34 @@ end
|
|||||||
--- Add an AIR waypoint to the flight plan.
|
--- Add an AIR waypoint to the flight plan.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
-- @param Core.Point#COORDINATE coordinate The coordinate of the waypoint. Use COORDINATE:SetAltitude(altitude) to define the altitude.
|
||||||
-- @param #number speed Speed in knots. Default 350 kts.
|
-- @param #number Speed Speed in knots. Default 350 kts.
|
||||||
-- @param #number wpnumber Waypoint number. Default at the end.
|
-- @param #number AfterWaypointWithID Insert waypoint after waypoint given ID. Default is to insert as last waypoint.
|
||||||
-- @param #boolean updateroute If true or nil, call UpdateRoute. If false, no call.
|
-- @param #boolean Updateroute If true or nil, call UpdateRoute. If false, no call.
|
||||||
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
-- @return Ops.OpsGroup#OPSGROUP.Waypoint Waypoint table.
|
||||||
function FLIGHTGROUP:AddWaypoint(coordinate, speed, wpnumber, updateroute)
|
function FLIGHTGROUP:AddWaypoint(Coordinate, Speed, AfterWaypointWithID, Updateroute)
|
||||||
|
|
||||||
-- Waypoint number. Default is at the end.
|
-- Set waypoint index.
|
||||||
wpnumber=wpnumber or #self.waypoints+1
|
local wpnumber=#self.waypoints+1
|
||||||
|
if wpnumber then
|
||||||
|
local index=self:GetWaypointIndex(AfterWaypointWithID)
|
||||||
|
if index then
|
||||||
|
wpnumber=index+1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if wpnumber>self.currentwp then
|
if wpnumber>self.currentwp then
|
||||||
self.passedfinalwp=false
|
self.passedfinalwp=false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Speed in knots.
|
-- Speed in knots.
|
||||||
speed=speed or 350
|
Speed=Speed or 350
|
||||||
|
|
||||||
-- Speed at waypoint.
|
-- Speed at waypoint.
|
||||||
local speedkmh=UTILS.KnotsToKmph(speed)
|
local speedkmh=UTILS.KnotsToKmph(Speed)
|
||||||
|
|
||||||
-- Create air waypoint.
|
-- Create air waypoint.
|
||||||
local name=string.format("Added Waypoint #%d", wpnumber)
|
local name=string.format("Added Waypoint #%d", wpnumber)
|
||||||
local wp=coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speedkmh, true, nil, {}, name)
|
local wp=Coordinate:WaypointAir(COORDINATE.WaypointAltType.BARO, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.TurningPoint, speedkmh, true, nil, {}, name)
|
||||||
|
|
||||||
-- Create waypoint data table.
|
-- Create waypoint data table.
|
||||||
local waypoint=self:_CreateWaypoint(wp)
|
local waypoint=self:_CreateWaypoint(wp)
|
||||||
@@ -2995,10 +2994,10 @@ function FLIGHTGROUP:AddWaypoint(coordinate, speed, wpnumber, updateroute)
|
|||||||
self:_AddWaypoint(waypoint, wpnumber)
|
self:_AddWaypoint(waypoint, wpnumber)
|
||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("Adding AIR waypoint #%d, speed=%.1f knots. Last waypoint passed was #%s. Total waypoints #%d", wpnumber, speed, self.currentwp, #self.waypoints))
|
self:T(self.lid..string.format("Adding AIR waypoint #%d, speed=%.1f knots. Last waypoint passed was #%s. Total waypoints #%d", wpnumber, Speed, self.currentwp, #self.waypoints))
|
||||||
|
|
||||||
-- Update route.
|
-- Update route.
|
||||||
if updateroute==nil or updateroute==true then
|
if Updateroute==nil or Updateroute==true then
|
||||||
self:__UpdateRoute(-1)
|
self:__UpdateRoute(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -550,8 +550,8 @@ function NAVYGROUP:onafterSpawned(From, Event, To)
|
|||||||
if self.ai then
|
if self.ai then
|
||||||
|
|
||||||
-- Set default ROE and Alarmstate options.
|
-- Set default ROE and Alarmstate options.
|
||||||
self:SetOptionROE(self.roe)
|
self:SwitchROE(self.option.ROE)
|
||||||
self:SetOptionAlarmstate(self.alarmstate)
|
self:SwitchAlarmstate(self.option.Alarm)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,9 @@
|
|||||||
-- @field Core.Point#COORDINATE position Position of the group at last status check.
|
-- @field Core.Point#COORDINATE position Position of the group at last status check.
|
||||||
-- @field #number traveldist Distance traveled in meters. This is a lower bound!
|
-- @field #number traveldist Distance traveled in meters. This is a lower bound!
|
||||||
-- @field #number traveltime Time.
|
-- @field #number traveltime Time.
|
||||||
-- @field #boolean ispathfinding If true, group is on pathfinding route.
|
|
||||||
--
|
--
|
||||||
|
-- @field Core.Astar#ASTAR Astar path finding.
|
||||||
|
-- @field #boolean ispathfinding If true, group is on pathfinding route.
|
||||||
--
|
--
|
||||||
-- @field #OPSGROUP.Radio radio Current radio settings.
|
-- @field #OPSGROUP.Radio radio Current radio settings.
|
||||||
-- @field #OPSGROUP.Radio radioDefault Default radio settings.
|
-- @field #OPSGROUP.Radio radioDefault Default radio settings.
|
||||||
@@ -69,9 +70,10 @@
|
|||||||
-- @field #boolean iclsOn If true, ICLS is currently active.
|
-- @field #boolean iclsOn If true, ICLS is currently active.
|
||||||
--
|
--
|
||||||
-- @field #OPSGROUP.Option option Current optional settings.
|
-- @field #OPSGROUP.Option option Current optional settings.
|
||||||
-- @field #OPSGROUP.Option optionDefault Default option settings.
|
-- @field #OPSGROUP.Option optionDefault Default option settings.
|
||||||
--
|
--
|
||||||
-- @field Core.Astar#ASTAR Astar path finding.
|
-- @field #OPSGROUP.Callsign callsign Current callsign settings.
|
||||||
|
-- @field #OPSGROUP.Callsign callsignDefault Default callsign settings.
|
||||||
--
|
--
|
||||||
-- @extends Core.Fsm#FSM
|
-- @extends Core.Fsm#FSM
|
||||||
|
|
||||||
@@ -2763,7 +2765,7 @@ function OPSGROUP:SwitchROE(roe)
|
|||||||
|
|
||||||
self.group:OptionROE(self.option.ROE)
|
self.group:OptionROE(self.option.ROE)
|
||||||
|
|
||||||
self:I(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.roe))
|
self:I(self.lid..string.format("Setting current ROE=%d (0=WeaponFree, 1=OpenFireWeaponFree, 2=OpenFire, 3=ReturnFire, 4=WeaponHold)", self.option.ROE))
|
||||||
else
|
else
|
||||||
-- TODO WARNING
|
-- TODO WARNING
|
||||||
end
|
end
|
||||||
@@ -2799,7 +2801,7 @@ function OPSGROUP:SwitchROT(rot)
|
|||||||
|
|
||||||
self.group:OptionROT(self.option.ROT)
|
self.group:OptionROT(self.option.ROT)
|
||||||
|
|
||||||
self:T2(self.lid..string.format("Setting current ROT=%d (0=NoReaction, 1=Passive, 2=Evade, 3=ByPass, 4=AllowAbort)", self.rot))
|
self:T2(self.lid..string.format("Setting current ROT=%d (0=NoReaction, 1=Passive, 2=Evade, 3=ByPass, 4=AllowAbort)", self.option.ROT))
|
||||||
else
|
else
|
||||||
-- TODO WARNING
|
-- TODO WARNING
|
||||||
end
|
end
|
||||||
@@ -2880,10 +2882,11 @@ end
|
|||||||
|
|
||||||
--- Activate TACAN beacon.
|
--- Activate TACAN beacon.
|
||||||
-- @param #OPSGROUP self
|
-- @param #OPSGROUP self
|
||||||
-- @param #number TACANChannel TACAN Channel.
|
-- @param #number Channel TACAN Channel.
|
||||||
-- @param #string TACANMorse TACAN morse code.
|
-- @param #string Morse TACAN morse code.
|
||||||
|
-- @param #string Band TACAN channel mode "X" or "Y". Default is "Y" for aircraft and "X" for ground and naval groups.
|
||||||
-- @return #OPSGROUP self
|
-- @return #OPSGROUP self
|
||||||
function OPSGROUP:SwitchTACAN(TACANChannel, TACANMorse)
|
function OPSGROUP:SwitchTACAN(Channel, Morse, Band)
|
||||||
|
|
||||||
if self:IsAlive() then
|
if self:IsAlive() then
|
||||||
|
|
||||||
@@ -2891,21 +2894,36 @@ function OPSGROUP:SwitchTACAN(TACANChannel, TACANMorse)
|
|||||||
|
|
||||||
if unit and unit:IsAlive() then
|
if unit and unit:IsAlive() then
|
||||||
|
|
||||||
local Type=4
|
|
||||||
local System=5
|
|
||||||
local UnitID=unit:GetID()
|
local UnitID=unit:GetID()
|
||||||
local TACANMode="Y"
|
|
||||||
local Frequency=UTILS.TACANToFrequency(TACANChannel, TACANMode)
|
|
||||||
|
|
||||||
unit:CommandActivateBeacon(Type, System, Frequency, UnitID, TACANChannel, TACANMode, true, TACANMorse, true)
|
local Type=BEACON.Type.TACAN
|
||||||
|
local System=BEACON.System.TACAN
|
||||||
|
|
||||||
|
--local TACANMode="Y"
|
||||||
|
if self.isAircraft then
|
||||||
|
Type=4
|
||||||
|
System=5
|
||||||
|
Band=Band or "Y"
|
||||||
|
else
|
||||||
|
Band=Band or "X"
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Tacan frequency.
|
||||||
|
local Frequency=UTILS.TACANToFrequency(Channel, Band)
|
||||||
|
|
||||||
|
unit:CommandActivateBeacon(Type, System, Frequency, UnitID, Channel, Band, true, Morse, true)
|
||||||
|
|
||||||
self.tacanBeacon=unit
|
self.tacanBeacon=unit
|
||||||
self.tacanChannel=TACANChannel
|
|
||||||
self.tacanMorse=TACANMorse
|
self.tacan.Channel=Channel
|
||||||
|
self.tacan.Morse=Morse
|
||||||
|
self.tacan.Band=Band
|
||||||
|
self.tacan.UnitName=unit:GetName()
|
||||||
|
|
||||||
|
-- TACAN is now on.
|
||||||
self.tacanOn=true
|
self.tacanOn=true
|
||||||
|
|
||||||
self:I(self.lid..string.format("Switching TACAN to Channel %dY Morse %s", self.tacanChannel, tostring(self.tacanMorse)))
|
self:I(self.lid..string.format("Switching TACAN to Channel %d%s Morse %s on unit %s", self.tacan.Channel, self.tacan.Band, tostring(self.tacan.Morse), self.tacan.UnitName))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2963,7 +2981,7 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
|||||||
|
|
||||||
local group=self.group --Wrapper.Group#GROUP
|
local group=self.group --Wrapper.Group#GROUP
|
||||||
|
|
||||||
if not self.radioOn then
|
if self.isAircraft and not self.radioOn then
|
||||||
group:SetOption(AI.Option.Air.id.SILENCE, false)
|
group:SetOption(AI.Option.Air.id.SILENCE, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -2975,7 +2993,7 @@ function OPSGROUP:SwitchRadio(Frequency, Modulation)
|
|||||||
-- Radio is on.
|
-- Radio is on.
|
||||||
self.radioOn=true
|
self.radioOn=true
|
||||||
|
|
||||||
self:I(self.lid..string.format("Switching radio to frequency %.3f MHz %s", self.radioFreq, UTILS.GetModulationName(self.radioModu)))
|
self:I(self.lid..string.format("Switching radio to frequency %.3f MHz %s", self.radio.Freq, UTILS.GetModulationName(self.radio.Modu)))
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
--
|
--
|
||||||
-- # The PROFILER Concept
|
-- # The PROFILER Concept
|
||||||
--
|
--
|
||||||
-- Profile your lua code.
|
-- Profile your lua code. This tells you, which functions are called very often and which consume most CPU time.
|
||||||
|
-- With this information you could optimize the perfomance of your code.
|
||||||
--
|
--
|
||||||
-- # Prerequisites
|
-- # Prerequisites
|
||||||
--
|
--
|
||||||
@@ -56,7 +57,7 @@
|
|||||||
--
|
--
|
||||||
-- X:\User\<Your User Name>\Saved Games\DCS OpenBeta\Logs
|
-- X:\User\<Your User Name>\Saved Games\DCS OpenBeta\Logs
|
||||||
--
|
--
|
||||||
-- ## Sort By
|
-- ## Sort Output
|
||||||
--
|
--
|
||||||
-- By default the output is sorted with respect to the total time a function used.
|
-- By default the output is sorted with respect to the total time a function used.
|
||||||
--
|
--
|
||||||
@@ -64,7 +65,6 @@
|
|||||||
--
|
--
|
||||||
-- PROFILER.sortBy=1
|
-- PROFILER.sortBy=1
|
||||||
--
|
--
|
||||||
-- Lua profiler.
|
|
||||||
-- @field #PROFILER
|
-- @field #PROFILER
|
||||||
PROFILER = {
|
PROFILER = {
|
||||||
ClassName = "PROFILER",
|
ClassName = "PROFILER",
|
||||||
@@ -84,6 +84,7 @@ PROFILER = {
|
|||||||
PROFILER.sortBy=1 -- Sort reports by 0=Count, 1=Total time by function
|
PROFILER.sortBy=1 -- Sort reports by 0=Count, 1=Total time by function
|
||||||
PROFILER.logUnknown=false -- Log unknown functions
|
PROFILER.logUnknown=false -- Log unknown functions
|
||||||
PROFILER.lowCpsThres=5 -- Skip results with less than X calls per second
|
PROFILER.lowCpsThres=5 -- Skip results with less than X calls per second
|
||||||
|
PROFILER.fileName="_LuaProfiler.txt"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Start/Stop Profiler
|
-- Start/Stop Profiler
|
||||||
@@ -95,9 +96,6 @@ function PROFILER.Start()
|
|||||||
PROFILER.startTime=timer.getTime()
|
PROFILER.startTime=timer.getTime()
|
||||||
PROFILER.endTime=0
|
PROFILER.endTime=0
|
||||||
PROFILER.runTime=0
|
PROFILER.runTime=0
|
||||||
|
|
||||||
-- Set hook.
|
|
||||||
debug.sethook(PROFILER.hook, "cr")
|
|
||||||
|
|
||||||
-- Add event handler.
|
-- Add event handler.
|
||||||
world.addEventHandler(PROFILER.eventHandler)
|
world.addEventHandler(PROFILER.eventHandler)
|
||||||
@@ -111,6 +109,12 @@ function PROFILER.Start()
|
|||||||
-- Message.
|
-- Message.
|
||||||
showProfilerRunning()
|
showProfilerRunning()
|
||||||
|
|
||||||
|
-- Info in log.
|
||||||
|
BASE:I('############################ Profiler Started ############################')
|
||||||
|
|
||||||
|
-- Set hook.
|
||||||
|
debug.sethook(PROFILER.hook, "cr")
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Stop profiler.
|
--- Stop profiler.
|
||||||
@@ -207,7 +211,6 @@ end
|
|||||||
function PROFILER._flog(f, txt)
|
function PROFILER._flog(f, txt)
|
||||||
f:write(txt.."\r\n")
|
f:write(txt.."\r\n")
|
||||||
env.info("Profiler Analysis")
|
env.info("Profiler Analysis")
|
||||||
env.info(txt)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Show table.
|
--- Show table.
|
||||||
@@ -235,9 +238,11 @@ end
|
|||||||
function PROFILER.showInfo()
|
function PROFILER.showInfo()
|
||||||
|
|
||||||
-- Output file.
|
-- Output file.
|
||||||
local file=lfs.writedir()..[[Logs\]].."_LuaProfiler.txt"
|
local file=lfs.writedir()..[[Logs\]]..PROFILER.fileName
|
||||||
local f=io.open(file, 'w')
|
local f=io.open(file, 'w')
|
||||||
|
|
||||||
|
BASE:I(string.format("### Profiler: Writing result to file ", file))
|
||||||
|
|
||||||
-- Gather data.
|
-- Gather data.
|
||||||
local t={}
|
local t={}
|
||||||
for func, count in pairs(PROFILER.Counters) do
|
for func, count in pairs(PROFILER.Counters) do
|
||||||
|
|||||||
@@ -258,8 +258,7 @@ end
|
|||||||
|
|
||||||
--- Returns if the unit is activated.
|
--- Returns if the unit is activated.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean true if Unit is activated.
|
-- @return #boolean `true` if Unit is activated. `nil` The DCS Unit is not existing or alive.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:IsActive()
|
function UNIT:IsActive()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
@@ -279,9 +278,7 @@ end
|
|||||||
-- If the Unit is alive and active, true is returned.
|
-- If the Unit is alive and active, true is returned.
|
||||||
-- If the Unit is alive but not active, false is returned.
|
-- If the Unit is alive but not active, false is returned.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean true if Unit is alive and active.
|
-- @return #boolean `true` if Unit is alive and active. `false` if Unit is alive but not active. `nil` if the Unit is not existing or is not alive.
|
||||||
-- @return #boolean false if Unit is alive but not active.
|
|
||||||
-- @return #nil if the Unit is not existing or is not alive.
|
|
||||||
function UNIT:IsAlive()
|
function UNIT:IsAlive()
|
||||||
self:F3( self.UnitName )
|
self:F3( self.UnitName )
|
||||||
|
|
||||||
@@ -300,7 +297,6 @@ end
|
|||||||
--- Returns the Unit's callsign - the localized string.
|
--- Returns the Unit's callsign - the localized string.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #string The Callsign of the Unit.
|
-- @return #string The Callsign of the Unit.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetCallsign()
|
function UNIT:GetCallsign()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
@@ -640,8 +636,7 @@ end
|
|||||||
|
|
||||||
--- Returns the unit sensors.
|
--- Returns the unit sensors.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return DCS#Unit.Sensors
|
-- @return DCS#Unit.Sensors Table of sensors.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetSensors()
|
function UNIT:GetSensors()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
@@ -661,7 +656,6 @@ end
|
|||||||
--- Returns if the unit has sensors of a certain type.
|
--- Returns if the unit has sensors of a certain type.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean returns true if the unit has specified types of sensors. This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.
|
-- @return #boolean returns true if the unit has specified types of sensors. This function is more preferable than Unit.getSensors() if you don't want to get information about all the unit's sensors, and just want to check if the unit has specified types of sensors.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:HasSensors( ... )
|
function UNIT:HasSensors( ... )
|
||||||
self:F2( arg )
|
self:F2( arg )
|
||||||
|
|
||||||
@@ -678,7 +672,6 @@ end
|
|||||||
--- Returns if the unit is SEADable.
|
--- Returns if the unit is SEADable.
|
||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean returns true if the unit is SEADable.
|
-- @return #boolean returns true if the unit is SEADable.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:HasSEAD()
|
function UNIT:HasSEAD()
|
||||||
self:F2()
|
self:F2()
|
||||||
|
|
||||||
@@ -705,7 +698,6 @@ end
|
|||||||
-- @param #UNIT self
|
-- @param #UNIT self
|
||||||
-- @return #boolean Indicates if at least one of the unit's radar(s) is on.
|
-- @return #boolean Indicates if at least one of the unit's radar(s) is on.
|
||||||
-- @return DCS#Object The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
|
-- @return DCS#Object The object of the radar's interest. Not nil only if at least one radar of the unit is tracking a target.
|
||||||
-- @return #nil The DCS Unit is not existing or alive.
|
|
||||||
function UNIT:GetRadar()
|
function UNIT:GetRadar()
|
||||||
self:F2( self.UnitName )
|
self:F2( self.UnitName )
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
Utilities/Routines.lua
|
Utilities/Routines.lua
|
||||||
Utilities/Utils.lua
|
Utilities/Utils.lua
|
||||||
|
Utilities/Enums.lua
|
||||||
|
Utilities/Profiler.lua
|
||||||
|
|
||||||
Core/Base.lua
|
Core/Base.lua
|
||||||
Core/UserFlag.lua
|
Core/UserFlag.lua
|
||||||
|
|||||||
Reference in New Issue
Block a user