Merge branch 'master' into RAT_trace

This commit is contained in:
Sven Van de Velde 2017-11-30 12:19:10 +01:00 committed by GitHub
commit 967d608b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 299 additions and 97 deletions

View File

@ -198,6 +198,7 @@ BASE = {
ClassID = 0,
Events = {},
States = {},
Debug = debug,
}
@ -717,9 +718,9 @@ do -- Scheduling
nil
)
self._.Schedules[#self.Schedules+1] = ScheduleID
self._.Schedules[#self._.Schedules+1] = ScheduleID
return self._.Schedules
return self._.Schedules[#self._.Schedules]
end
--- Schedule a new time event. Note that the schedule will only take place if the scheduler is *started*. Even for a single schedule event, the scheduler needs to be started also.
@ -751,9 +752,9 @@ do -- Scheduling
Stop
)
self._.Schedules[SchedulerFunction] = ScheduleID
self._.Schedules[#self._.Schedules+1] = ScheduleID
return self._.Schedules
return self._.Schedules[#self._.Schedules]
end
--- Stops the Schedule.
@ -820,7 +821,7 @@ end
-- TODO: Make trace function using variable parameters.
--- Set trace on or off
-- Note that when trace is off, no debug statement is performed, increasing performance!
-- Note that when trace is off, no BASE.Debug statement is performed, increasing performance!
-- When Moose is loaded statically, (as one file), tracing is switched off by default.
-- So tracing must be switched on manually in your mission if you are using Moose statically.
-- When moose is loading dynamically (for moose class development), tracing is switched on by default.
@ -842,7 +843,7 @@ end
-- @return #boolean
function BASE:IsTrace()
if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
if BASE.Debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
return true
else
return false
@ -898,10 +899,10 @@ end
-- @param Arguments A #table or any field.
function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
if BASE.Debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or BASE.Debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then
@ -927,9 +928,9 @@ end
-- @param Arguments A #table or any field.
function BASE:F( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 1 then
self:_F( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -943,9 +944,9 @@ end
-- @param Arguments A #table or any field.
function BASE:F2( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 2 then
self:_F( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -958,9 +959,9 @@ end
-- @param Arguments A #table or any field.
function BASE:F3( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 3 then
self:_F( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -973,10 +974,10 @@ end
-- @param Arguments A #table or any field.
function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
if BASE.Debug and ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" )
local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or BASE.Debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then
@ -1002,9 +1003,9 @@ end
-- @param Arguments A #table or any field.
function BASE:T( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 1 then
self:_T( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -1018,9 +1019,9 @@ end
-- @param Arguments A #table or any field.
function BASE:T2( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 2 then
self:_T( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -1033,9 +1034,9 @@ end
-- @param Arguments A #table or any field.
function BASE:T3( Arguments )
if debug and _TraceOnOff then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug and _TraceOnOff then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
if _TraceLevel >= 3 then
self:_T( Arguments, DebugInfoCurrent, DebugInfoFrom )
@ -1048,9 +1049,9 @@ end
-- @param Arguments A #table or any field.
function BASE:E( Arguments )
if debug then
local DebugInfoCurrent = debug.getinfo( 2, "nl" )
local DebugInfoFrom = debug.getinfo( 3, "l" )
if BASE.Debug then
local DebugInfoCurrent = BASE.Debug.getinfo( 2, "nl" )
local DebugInfoFrom = BASE.Debug.getinfo( 3, "l" )
local Function = "function"
if DebugInfoCurrent.name then
@ -1064,6 +1065,8 @@ function BASE:E( Arguments )
end
env.info( string.format( "%6d(%6d)/%1s:%20s%05d.%s(%s)" , LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) )
else
env.info( string.format( "%1s:%20s%05d(%s)" , "E", self.ClassName, self.ClassID, routines.utils.oneLineSerialize( Arguments ) ) )
end
end

View File

@ -325,7 +325,7 @@ function DATABASE:AddPlayer( UnitName, PlayerName )
if PlayerName then
self:E( { "Add player for unit:", UnitName, PlayerName } )
self.PLAYERS[PlayerName] = UnitName
self.PLAYERUNITS[UnitName] = PlayerName
self.PLAYERUNITS[PlayerName] = self:FindUnit( UnitName )
self.PLAYERSJOINED[PlayerName] = PlayerName
end
end
@ -337,10 +337,48 @@ function DATABASE:DeletePlayer( UnitName, PlayerName )
if PlayerName then
self:E( { "Clean player:", PlayerName } )
self.PLAYERS[PlayerName] = nil
self.PLAYERUNITS[UnitName] = PlayerName
self.PLAYERUNITS[PlayerName] = nil
end
end
--- Get the player table from the DATABASE.
-- The player table contains all unit names with the key the name of the player (PlayerName).
-- @param #DATABASE self
-- @usage
-- local Players = _DATABASE:GetPlayers()
-- for PlayerName, UnitName in pairs( Players ) do
-- ..
-- end
function DATABASE:GetPlayers()
return self.PLAYERS
end
--- Get the player table from the DATABASE, which contains all UNIT objects.
-- The player table contains all UNIT objects of the player with the key the name of the player (PlayerName).
-- @param #DATABASE self
-- @usage
-- local PlayerUnits = _DATABASE:GetPlayerUnits()
-- for PlayerName, PlayerUnit in pairs( PlayerUnits ) do
-- ..
-- end
function DATABASE:GetPlayerUnits()
return self.PLAYERUNITS
end
--- Get the player table from the DATABASE which have joined in the mission historically.
-- The player table contains all UNIT objects with the key the name of the player (PlayerName).
-- @param #DATABASE self
-- @usage
-- local PlayersJoined = _DATABASE:GetPlayersJoined()
-- for PlayerName, PlayerUnit in pairs( PlayersJoined ) do
-- ..
-- end
function DATABASE:GetPlayersJoined()
return self.PLAYERSJOINED
end
--- Instantiate new Groups within the DCSRTE.
-- This method expects EXACTLY the same structure as a structure within the ME, and needs 2 additional fields defined:

View File

@ -562,8 +562,8 @@ do -- FSM
local ErrorHandler = function( errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg )
if debug ~= nil then
env.info( debug.traceback() )
if BASE.Debug ~= nil then
env.info( BASE.Debug.traceback() )
end
return errmsg
@ -860,8 +860,8 @@ do -- FSM_CONTROLLABLE
local ErrorHandler = function( errmsg )
env.info( "Error in SCHEDULER function:" .. errmsg )
if debug ~= nil then
env.info( debug.traceback() )
if BASE.Debug ~= nil then
env.info( BASE.Debug.traceback() )
end
return errmsg
@ -920,8 +920,8 @@ do -- FSM_PROCESS
local ErrorHandler = function( errmsg )
env.info( "Error in FSM_PROCESS call handler:" .. errmsg )
if debug ~= nil then
env.info( debug.traceback() )
if BASE.Debug ~= nil then
env.info( BASE.Debug.traceback() )
end
return errmsg

View File

@ -149,6 +149,32 @@ function MENU_INDEX:ClearGroupMenu( Group, Path )
self.Group[MenuGroupName].Menus[Path] = nil
end
function MENU_INDEX:Refresh( Group )
for MenuID, Menu in pairs( self.MenuMission.Menus ) do
Menu:Refresh()
end
for MenuID, Menu in pairs( self.Coalition[coalition.side.BLUE].Menus ) do
Menu:Refresh()
end
for MenuID, Menu in pairs( self.Coalition[coalition.side.RED].Menus ) do
Menu:Refresh()
end
local GroupName = Group:GetName()
for MenuID, Menu in pairs( self.Group[GroupName].Menus ) do
Menu:Refresh()
end
end
do -- MENU_BASE
@ -267,8 +293,8 @@ do -- MENU_COMMAND_BASE
-- This error handler catches the menu error and displays the full call stack.
local ErrorHandler = function( errmsg )
env.info( "MOOSE error in MENU COMMAND function: " .. errmsg )
if debug ~= nil then
env.info( debug.traceback() )
if BASE.Debug ~= nil then
env.info( BASE.Debug.traceback() )
end
return errmsg
end
@ -342,12 +368,24 @@ do -- MENU_MISSION
local self = BASE:Inherit( self, MENU_BASE:New( MenuText, ParentMenu ) )
MENU_INDEX:SetMissionMenu( Path, self )
self.MenuPath = missionCommands.addSubMenu( MenuText, self.MenuParentPath )
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
self:SetParentMenu( self.MenuText, self )
return self
end
end
--- Refreshes a radio item for a mission
-- @param #MENU_MISSION self
-- @return #MENU_MISSION
function MENU_MISSION:Refresh()
do
missionCommands.removeItem( self.MenuPath )
self.MenuPath = missionCommands.addSubMenu( self.MenuText, self.MenuParentPath )
end
end
--- Removes the sub menus recursively of this MENU_MISSION. Note that the main menu is kept!
-- @param #MENU_MISSION self
@ -375,7 +413,10 @@ do -- MENU_MISSION
self:RemoveSubMenus()
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItem( self.MenuPath )
self:E( { Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItem( self.MenuPath )
end
MENU_INDEX:ClearMissionMenu( self.Path )
self:ClearParentMenu( self.MenuText )
return nil
@ -432,6 +473,18 @@ do -- MENU_MISSION_COMMAND
return self
end
end
--- Refreshes a radio item for a mission
-- @param #MENU_MISSION_COMMAND self
-- @return #MENU_MISSION_COMMAND
function MENU_MISSION_COMMAND:Refresh()
do
missionCommands.removeItem( self.MenuPath )
missionCommands.addCommand( self.MenuText, self.MenuParentPath, self.MenuCallHandler )
end
end
--- Removes a radio command item for a coalition
-- @param #MENU_MISSION_COMMAND self
@ -445,7 +498,10 @@ do -- MENU_MISSION_COMMAND
if MissionMenu == self then
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItem( self.MenuPath )
self:E( { Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItem( self.MenuPath )
end
MENU_INDEX:ClearMissionMenu( self.Path )
self:ClearParentMenu( self.MenuText )
return nil
@ -540,6 +596,18 @@ do -- MENU_COALITION
return self
end
end
--- Refreshes a radio item for a coalition
-- @param #MENU_COALITION self
-- @return #MENU_COALITION
function MENU_COALITION:Refresh()
do
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
missionCommands.addSubMenuForCoalition( self.Coalition, self.MenuText, self.MenuParentPath )
end
end
--- Removes the sub menus recursively of this MENU_COALITION. Note that the main menu is kept!
-- @param #MENU_COALITION self
@ -566,7 +634,10 @@ do -- MENU_COALITION
self:RemoveSubMenus()
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
self:E( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
end
MENU_INDEX:ClearCoalitionMenu( self.Coalition, Path )
self:ClearParentMenu( self.MenuText )
return nil
@ -627,6 +698,19 @@ do -- MENU_COALITION_COMMAND
end
end
--- Refreshes a radio item for a coalition
-- @param #MENU_COALITION_COMMAND self
-- @return #MENU_COALITION_COMMAND
function MENU_COALITION_COMMAND:Refresh()
do
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
missionCommands.addCommandForCoalition( self.Coalition, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
end
end
--- Removes a radio command item for a coalition
-- @param #MENU_COALITION_COMMAND self
@ -638,10 +722,12 @@ do -- MENU_COALITION_COMMAND
local CoalitionMenu = MENU_INDEX:HasCoalitionMenu( self.Coalition, Path )
if CoalitionMenu == self then
self:RemoveSubMenus()
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
self:E( { Coalition = self.Coalition, Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItemForCoalition( self.Coalition, self.MenuPath )
end
MENU_INDEX:ClearCoalitionMenu( self.Coalition, Path )
self:ClearParentMenu( self.MenuText )
return nil
@ -740,7 +826,7 @@ do
MENU_INDEX:PrepareGroup( Group )
local Path = MENU_INDEX:ParentPath( ParentMenu, MenuText )
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
local GroupMenu = MENU_INDEX:HasGroupMenu( Group, Path )
if GroupMenu then
return GroupMenu
@ -757,6 +843,22 @@ do
end
end
--- Refreshes a new radio item for a group and submenus
-- @param #MENU_GROUP self
-- @return #MENU_GROUP
function MENU_GROUP:Refresh()
do
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
missionCommands.addSubMenuForGroup( self.GroupID, self.MenuText, self.MenuParentPath )
for MenuText, Menu in pairs( self.Menus or {} ) do
Menu:Refresh()
end
end
end
--- Removes the sub menus recursively of this MENU_GROUP.
-- @param #MENU_GROUP self
@ -789,7 +891,10 @@ do
self:RemoveSubMenus( MenuTime, MenuTag )
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
self:E( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
end
MENU_INDEX:ClearGroupMenu( self.Group, Path )
self:ClearParentMenu( self.MenuText )
return nil
@ -851,6 +956,18 @@ do
end
end
--- Refreshes a radio item for a group
-- @param #MENU_GROUP_COMMAND self
-- @return #MENU_GROUP_COMMAND
function MENU_GROUP_COMMAND:Refresh()
do
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
missionCommands.addCommandForGroup( self.GroupID, self.MenuText, self.MenuParentPath, self.MenuCallHandler )
end
end
--- Removes a menu structure for a group.
-- @param #MENU_GROUP_COMMAND self
@ -866,7 +983,10 @@ do
if GroupMenu == self then
if not MenuTime or self.MenuTime ~= MenuTime then
if ( not MenuTag ) or ( MenuTag and self.MenuTag and MenuTag == self.MenuTag ) then
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
self:E( { Group = self.GroupID, Text = self.MenuText, Path = self.MenuPath } )
if self.MenuPath ~= nil then
missionCommands.removeItemForGroup( self.GroupID, self.MenuPath )
end
MENU_INDEX:ClearGroupMenu( self.Group, Path )
self:ClearParentMenu( self.MenuText )
return nil

View File

@ -91,8 +91,8 @@ function SCHEDULEDISPATCHER:AddSchedule( Scheduler, ScheduleFunction, ScheduleAr
local ErrorHandler = function( errmsg )
env.info( "Error in timer function: " .. errmsg )
if debug ~= nil then
env.info( debug.traceback() )
if BASE.Debug ~= nil then
env.info( BASE.Debug.traceback() )
end
return errmsg
end

View File

@ -1085,14 +1085,16 @@ do -- DESIGNATE
self.LaserCodesUsed[LaserCode] = LaserCodeIndex
local Spot = RecceUnit:LaseUnit( TargetUnit, LaserCode, Duration )
local AttackSet = self.AttackSet
local DesignateName = self.DesignateName
function Spot:OnAfterDestroyed( From, Event, To )
self:E( "Destroyed Message" )
self.Recce:ToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.", 5, AttackSet, self.DesignateName )
self.Recce:MessageToSetGroup( "Target " .. TargetUnit:GetTypeName() .. " destroyed. " .. TargetSetUnit:Count() .. " targets left.",
5, AttackSet, self.DesignateName )
end
self.Recces[TargetUnit] = RecceUnit
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.", 5, self.AttackSet, self.DesignateName )
RecceUnit:MessageToSetGroup( "Marking " .. TargetUnit:GetTypeName() .. " with laser " .. RecceUnit:GetSpot().LaserCode .. " for " .. Duration .. "s.",
5, self.AttackSet, DesignateName )
-- OK. We have assigned for the Recce a TargetUnit. We can exit the function.
MarkingCount = MarkingCount + 1
local TargetUnitType = TargetUnit:GetTypeName()

View File

@ -63,7 +63,7 @@
--- RAT class
-- @type RAT
-- @field #string ClassName Name of the Class.
-- @field #boolean debug Turn debug messages on or off.
-- @field #boolean Debug Turn debug messages on or off.
-- @field Core.Group#GROUP templategroup Group serving as template for the RAT aircraft.
-- @field #string alias Alias for spawned group.
-- @field #boolean spawninitialized If RAT:Spawn() was already called this RAT object is set to true to prevent users to call it again.
@ -282,7 +282,7 @@
-- @field #RAT
RAT={
ClassName = "RAT", -- Name of class: RAT = Random Air Traffic.
debug=false, -- Turn debug messages on or off.
Debug=false, -- Turn debug messages on or off.
templategroup=nil, -- Template group for the RAT aircraft.
alias=nil, -- Alias for spawned group.
spawninitialized=false, -- If RAT:Spawn() was already called this is set to true to prevent users to call it again.
@ -448,6 +448,7 @@ RAT.ATC={
onfinal=-100,
Nclearance=2,
delay=240,
messages=true,
}
--- Running number of placed markers on the F10 map.
@ -464,7 +465,7 @@ RAT.id="RAT | "
--- RAT version.
-- @field #string version
RAT.version="2.0.1"
RAT.version="2.0.2"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@ -1255,6 +1256,16 @@ function RAT:EnableATC(switch)
self.ATCswitch=switch
end
--- Turn messages from ATC on or off. Default is on. This setting effects all RAT objects and groups!
-- @param #RAT self
-- @param #boolean switch Enable (true) or disable (false) messages from ATC.
function RAT:ATC_Messages(switch)
if switch==nil then
switch=true
end
RAT.ATC.messages=switch
end
--- Max number of planes that get landing clearance of the RAT ATC. This setting effects all RAT objects and groups!
-- @param #RAT self
-- @param #number n Number of aircraft that are allowed to land simultaniously. Default is 2.
@ -1293,7 +1304,7 @@ function RAT:_Debug(switch)
if switch==nil then
switch=true
end
self.debug=switch
self.Debug=switch
end
--- Aircraft report status update messages along the route.
@ -1381,7 +1392,7 @@ function RAT:_InitAircraft(DCSgroup)
local DCStype=DCSunit:getTypeName()
-- Descriptors table of unit.
if self.debug then
if self.Debug then
self:E({"DCSdesc", DCSdesc})
end
@ -1710,8 +1721,7 @@ function RAT:_Respawn(group)
_lastwp=lastwp
end
if self.debug then
local text
if self.Debug then
text=string.format("self.takeoff, takeoff, _takeoff = %s, %s, %s", tostring(self.takeoff), tostring(takeoff), tostring(_takeoff))
text=text.."\n"..string.format("self.landing, landing, _landing = %s, %s, %s", tostring(self.landing), tostring(landing), tostring(_landing))
self:T(RAT.id..text)
@ -2166,7 +2176,7 @@ function RAT:_SetRoute(takeoff, landing, _departure, _destination, _waypoint)
text=text..string.format("Phi (slope) = %6.2f Deg\n", math.deg(phi))
text=text..string.format("Phi climb = %6.2f Deg\n", math.deg(phi_climb))
text=text..string.format("Phi descent = %6.2f Deg\n", math.deg(phi_descent))
if self.debug then
if self.Debug then
-- Max heights and distances if we would travel at FLmax.
local h_climb_max = FLmax - H_departure
local h_descent_max = FLmax - Hh_holding
@ -2407,7 +2417,7 @@ function RAT:_PickDeparture(takeoff)
text="Chosen departure airport: "..departure:GetName().." (ID "..departure:GetID()..")"
end
self:T(RAT.id..text)
if self.debug then
if self.Debug then
MESSAGE:New(text, 30):ToAll()
end
else
@ -2533,7 +2543,7 @@ function RAT:_PickDestination(departure, q, minrange, maxrange, random, landing)
text=string.format("Chosen destination airport: %s (ID %d).", destination:GetName(), destination:GetID())
end
self:T(RAT.id..text)
if self.debug then
if self.Debug then
MESSAGE:New(text, 30):ToAll()
end
@ -2623,7 +2633,7 @@ function RAT:_GetAirportsOfMap()
-- Add airport to table.
table.insert(self.airports_map, _myab)
if self.debug then
if self.Debug then
local text1="MOOSE: Airport ID = ".._myab:GetID().." and Name = ".._myab:GetName()..", Category = ".._myab:GetCategory()..", TypeName = ".._myab:GetTypeName()
--local text2="DCS : Airport ID = "..airbase:getID().." and Name = "..airbase:getName()..", Category = "..airbase:getCategory()..", TypeName = "..airbase:getTypeName()
self:T(RAT.id..text1)
@ -2785,7 +2795,7 @@ function RAT:Status(message, forID)
text=text..string.format("\nTime on ground = %6.0f seconds\n", Tg)
text=text..string.format("Position change = %8.1f m since %3.0f seconds.", Dg, dTlast)
end
if self.debug then
if self.Debug then
self:T(RAT.id..text)
end
if message then
@ -2818,7 +2828,7 @@ function RAT:Status(message, forID)
end
end
else
if self.debug then
if self.Debug then
local text=string.format("Group %i does not exist.", i)
self:T(RAT.id..text)
end
@ -2844,12 +2854,12 @@ function RAT:_GetLife(group)
if unit then
life=unit:GetLife()/unit:GetLife0()*100
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Unit does not exist in RAT_Getlife(). Returning zero.")
end
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT_Getlife(). Returning zero.")
end
end
@ -2915,7 +2925,7 @@ function RAT:_OnBirth(EventData)
end
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnBirthDay().")
end
end
@ -2954,7 +2964,7 @@ function RAT:_EngineStartup(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_EngineStartup().")
end
end
@ -2996,7 +3006,7 @@ function RAT:_OnTakeoff(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnTakeoff().")
end
end
@ -3043,7 +3053,7 @@ function RAT:_OnLand(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnLand().")
end
end
@ -3090,7 +3100,7 @@ function RAT:_OnEngineShutdown(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnEngineShutdown().")
end
end
@ -3124,7 +3134,7 @@ function RAT:_OnDead(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnDead().")
end
end
@ -3164,7 +3174,7 @@ function RAT:_OnCrash(EventData)
end
else
if self.debug then
if self.Debug then
self:E(RAT.id.."ERROR: Group does not exist in RAT:_OnCrash().")
end
end
@ -3295,7 +3305,7 @@ function RAT:_Waypoint(index, Type, Coord, Speed, Altitude, Airport)
text=text..string.format("No airport/zone specified\n")
end
text=text.."******************************************************\n"
if self.debug then
if self.Debug then
self:T(RAT.id..text)
end
@ -3402,7 +3412,7 @@ function RAT:_Routeinfo(waypoints, comment)
text=text..string.format("******************************************************\n")
-- send message
if self.debug then
if self.Debug then
--self:T(RAT.id..text)
end
self:T(RAT.id..text)
@ -3516,7 +3526,7 @@ function RAT._WaypointFunction(group, rat, wp)
if landing==RAT.wp.air then
text=string.format("Activating despawn switch for flight %s! Group will be detroyed soon.", group:GetName())
MESSAGE:New(text, 30):ToAllIf(rat.debug)
MESSAGE:New(text, 30):ToAllIf(rat.Debug)
self:T(RAT.id..text)
-- Enable despawn switch. Next time the status function is called, the aircraft will be despawned.
rat.ratcraft[sdx].despawnme=true
@ -3594,7 +3604,7 @@ function RAT:_FLmax(alpha, beta, d, phi, h0)
local text=string.format("\nFLmax = FL%3.0f = %6.1f m.\n", h1/RAT.unit.FL2m, h1)
text=text..string.format( "FLmax = FL%3.0f = %6.1f m.\n", h2/RAT.unit.FL2m, h2)
text=text..string.format( "FLmax = FL%3.0f = %6.1f m.", h3/RAT.unit.FL2m, h3)
if self.debug then
if self.Debug then
self:T(RAT.id..text)
end
return h3+h0
@ -3784,7 +3794,7 @@ function RAT:_Randomize(value, fac, lower, upper)
local r=math.random(min, max)
-- debug info
if self.debug then
if self.Debug then
local text=string.format("Random: value = %6.2f, fac = %4.2f, min = %6.2f, max = %6.2f, r = %6.2f", value, fac, min, max, r)
self:T(RAT.id..text)
end
@ -3832,7 +3842,7 @@ end
function RAT:_PlaceMarkers(waypoints, index)
for i=1,#waypoints do
self:_SetMarker(self.waypointdescriptions[i], waypoints[i], index)
if self.debug then
if self.Debug then
local text=string.format("Marker at waypoint #%d: %s for flight #%d", i, self.waypointdescriptions[i], index)
self:T(RAT.id..text)
end
@ -3848,7 +3858,7 @@ end
function RAT:_SetMarker(text, wp, index)
RAT.markerid=RAT.markerid+1
self.markerids[#self.markerids+1]=RAT.markerid
if self.debug then
if self.Debug then
self:T(RAT.id..self.SpawnTemplatePrefix..": placing marker with ID "..RAT.markerid..": "..text)
end
-- Convert to coordinate.
@ -4175,7 +4185,7 @@ function RAT:_ATCClearForLanding(airport, flight)
local text1=string.format("ATC %s: Flight %s cleared for landing (flag=%d).", airport, flight, flagvalue)
local text2=string.format("ATC %s: Flight %s you are cleared for landing.", airport, flight)
self:T( RAT.id..text1)
MESSAGE:New(text2, 10):ToAll()
MESSAGE:New(text2, 10):ToAllIf(RAT.ATC.messages)
end
--- Takes care of organisational stuff after a plane has landed.
@ -4219,7 +4229,7 @@ function RAT:_ATCFlightLanded(name)
self:T(RAT.id..text1)
self:T(RAT.id..text2)
self:T(RAT.id..text3)
MESSAGE:New(text4, 10):ToAll()
MESSAGE:New(text4, 10):ToAllIf(RAT.ATC.messages)
end
end

View File

@ -281,8 +281,22 @@ function SCORING:New( GameName )
self:HandleEvent( EVENTS.Dead, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Crash, self._EventOnDeadOrCrash )
self:HandleEvent( EVENTS.Hit, self._EventOnHit )
self:HandleEvent( EVENTS.Birth )
self:HandleEvent( EVENTS.PlayerEnterUnit )
self:HandleEvent( EVENTS.PlayerLeaveUnit )
-- During mission startup, especially for single player,
-- iterate the database for the player that has joined, and add him to the scoring, and set the menu.
-- But this can only be started one second after the mission has started, so i need to schedule this ...
self.ScoringPlayerScan = BASE:ScheduleOnce( 1,
function()
for PlayerName, PlayerUnit in pairs( _DATABASE:GetPlayerUnits() ) do
self:_AddPlayerFromUnit( PlayerUnit )
self:SetScoringMenu( PlayerUnit:GetGroup() )
end
end
)
-- Create the CSV file.
self:OpenCSV( GameName )
@ -569,6 +583,19 @@ function SCORING:SetCoalitionChangePenalty( CoalitionChangePenalty )
end
--- Sets the scoring menu.
-- @param #SCORING self
-- @return #SCORING
function SCORING:SetScoringMenu( ScoringGroup )
local Menu = MENU_GROUP:New( ScoringGroup, 'Scoring' )
local ReportGroupSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report players in group', Menu, SCORING.ReportScoreGroupSummary, self, ScoringGroup )
local ReportGroupDetailed = MENU_GROUP_COMMAND:New( ScoringGroup, 'Detailed report players in group', Menu, SCORING.ReportScoreGroupDetailed, self, ScoringGroup )
local ReportToAllSummary = MENU_GROUP_COMMAND:New( ScoringGroup, 'Summary report all players', Menu, SCORING.ReportScoreAllSummary, self, ScoringGroup )
self:SetState( ScoringGroup, "ScoringMenu", Menu )
return self
end
--- Add a new player entering a Unit.
-- @param #SCORING self
-- @param Wrapper.Unit#UNIT UnitData
@ -811,17 +838,14 @@ function SCORING:_AddMissionScore( Mission, Text, Score )
end
--- Handles the OnPlayerEnterUnit event for the scoring.
-- @param #SCORING self
-- @param Core.Event#EVENTDATA Event
function SCORING:OnEventPlayerEnterUnit( Event )
if Event.IniUnit then
self:_AddPlayerFromUnit( Event.IniUnit )
local Menu = MENU_GROUP:New( Event.IniGroup, 'Scoring' )
local ReportGroupSummary = MENU_GROUP_COMMAND:New( Event.IniGroup, 'Summary report players in group', Menu, SCORING.ReportScoreGroupSummary, self, Event.IniGroup )
local ReportGroupDetailed = MENU_GROUP_COMMAND:New( Event.IniGroup, 'Detailed report players in group', Menu, SCORING.ReportScoreGroupDetailed, self, Event.IniGroup )
local ReportToAllSummary = MENU_GROUP_COMMAND:New( Event.IniGroup, 'Summary report all players', Menu, SCORING.ReportScoreAllSummary, self, Event.IniGroup )
self:SetState( Event.IniUnit, "ScoringMenu", Menu )
self:SetScoringMenu( Event.IniGroup )
end
end
@ -830,7 +854,7 @@ end
-- @param Core.Event#EVENTDATA Event
function SCORING:OnEventPlayerLeaveUnit( Event )
if Event.IniUnit then
local Menu = self:GetState( Event.IniUnit, "ScoringMenu" ) -- Core.Menu#MENU_GROUP
local Menu = self:GetState( Event.IniUnit:GetGroup(), "ScoringMenu" ) -- Core.Menu#MENU_GROUP
if Menu then
-- TODO: Check if this fixes #281.
--Menu:Remove()
@ -1661,9 +1685,11 @@ function SCORING:ReportScoreAllSummary( PlayerGroup )
local PlayerMessage = ""
self:T( "Report Score All Players" )
self:T( { "Summary Score Report of All Players", Players = self.Players } )
for PlayerName, PlayerData in pairs( self.Players ) do
self:T( { PlayerName = PlayerName, PlayerGroup = PlayerGroup } )
if PlayerName then

View File

@ -1 +1,4 @@
MOOSE = {}
function MOOSE.Include()
end

View File

@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20171122_0612' )
env.info( 'Moose Generation Timestamp: 20171130_1029' )
local base = _G

View File

@ -1,5 +1,5 @@
env.info('*** MOOSE DYNAMIC INCLUDE START *** ')
env.info('Moose Generation Timestamp: 20171122_0612')
env.info('Moose Generation Timestamp: 20171130_1029')
local base=_G
MOOSE={}
MOOSE.Include=function(LuaPath,IncludeFile)