From 797bf0047b8ece2c013a340706927b5ac2a43655 Mon Sep 17 00:00:00 2001 From: Rolf Geuenich Date: Fri, 12 Jan 2024 15:33:27 +0100 Subject: [PATCH 1/3] Down patching of code enhancements from develop to master in Set.lua --- Moose Development/Moose/Core/Set.lua | 45 +++++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 1ad9bdea6..8963d65f3 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -1578,7 +1578,7 @@ do function SET_GROUP:AddInDatabase( Event ) self:F3( { Event } ) - if Event.IniObjectCategory == 1 then + if Event.IniObjectCategory == Object.Category.UNIT then if not self.Database[Event.IniDCSGroupName] then self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName ) self:T3( self.Database[Event.IniDCSGroupName] ) @@ -2641,7 +2641,7 @@ do -- SET_UNIT function SET_UNIT:AddInDatabase( Event ) self:F3( { Event } ) - if Event.IniObjectCategory == 1 then + if Event.IniObjectCategory == Object.Category.UNIT then if not self.Database[Event.IniDCSUnitName] then self.Database[Event.IniDCSUnitName] = UNIT:Register( Event.IniDCSUnitName ) self:T3( self.Database[Event.IniDCSUnitName] ) @@ -4518,7 +4518,7 @@ do -- SET_CLIENT function SET_CLIENT:_EventPlayerEnterUnit(Event) self:I( "_EventPlayerEnterUnit" ) if Event.IniDCSUnit then - if Event.IniObjectCategory == 1 and Event.IniGroup and Event.IniGroup:IsGround() then + if Event.IniObjectCategory == Object.Category.UNIT and Event.IniGroup and Event.IniGroup:IsGround() then -- CA Slot entered local ObjectName, Object = self:AddInDatabase( Event ) self:I( ObjectName, UTILS.PrintTableToLog(Object) ) @@ -4537,7 +4537,7 @@ do -- SET_CLIENT function SET_CLIENT:_EventPlayerLeaveUnit(Event) self:I( "_EventPlayerLeaveUnit" ) if Event.IniDCSUnit then - if Event.IniObjectCategory == 1 and Event.IniGroup and Event.IniGroup:IsGround() then + if Event.IniObjectCategory == Object.Category.UNIT and Event.IniGroup and Event.IniGroup:IsGround() then -- CA Slot left local ObjectName, Object = self:FindInDatabase( Event ) if ObjectName then @@ -7837,6 +7837,29 @@ do -- SET_OPSGROUP return self end + --- Handles the OnBirth event for the Set. + -- @param #SET_OPSGROUP self + -- @param Core.Event#EVENTDATA Event Event data. + function SET_OPSGROUP:_EventOnBirth( Event ) + self:F3( { Event } ) + + if Event.IniDCSUnit and Event.IniDCSGroup then + local DCSgroup=Event.IniDCSGroup --DCS#Group + + if DCSgroup:getInitialSize() == DCSgroup:getSize() then -- This seems to be not a good check as even for the first birth event, getSize returns the total number of units in the group. + + local groupname, group = self:AddInDatabase( Event ) + + if group and group:CountAliveUnits()==DCSgroup:getInitialSize() then + if group and self:IsIncludeObject( group ) then + self:Add( groupname, group ) + end + end + + end + end + end + --- Handles the OnDead or OnCrash event for alive groups set. -- Note: The GROUP object in the SET_OPSGROUP collection will only be removed if the last unit is destroyed of the GROUP. -- @param #SET_OPSGROUP self @@ -7857,12 +7880,12 @@ do -- SET_OPSGROUP --- Handles the Database to check on an event (birth) that the Object was added in the Database. -- This is required, because sometimes the _DATABASE birth event gets called later than the SET_BASE birth event! -- @param #SET_OPSGROUP self - -- @param Core.Event#EVENTDATA Event - -- @return #string The name of the GROUP - -- @return #table The GROUP + -- @param Core.Event#EVENTDATA Event Event data. + -- @return #string The name of the GROUP. + -- @return Wrapper.Group#GROUP The GROUP object. function SET_OPSGROUP:AddInDatabase( Event ) - if Event.IniObjectCategory==1 then + if Event.IniObjectCategory==Object.Category.UNIT then if not self.Database[Event.IniDCSGroupName] then self.Database[Event.IniDCSGroupName] = GROUP:Register( Event.IniDCSGroupName ) @@ -7877,8 +7900,8 @@ do -- SET_OPSGROUP -- This is required, because sometimes the _DATABASE event gets called later than the SET_BASE event or vise versa! -- @param #SET_OPSGROUP self -- @param Core.Event#EVENTDATA Event Event data table. - -- @return #string The name of the GROUP - -- @return #table The GROUP + -- @return #string The name of the GROUP. + -- @return Wrapper.Group#GROUP The GROUP object. function SET_OPSGROUP:FindInDatabase(Event) return Event.IniDCSGroupName, self.Database[Event.IniDCSGroupName] end @@ -8197,7 +8220,7 @@ do -- SET_SCENERY end --- Get a table of alive objects. - -- @param #SET_GROUP self + -- @param #SET_SCENERY self -- @return #table Table of alive objects -- @return Core.Set#SET_SCENERY SET of alive objects function SET_SCENERY:GetAliveSet() From 088436c5ceb27dc9e50ec767dc9f520dd19edeb9 Mon Sep 17 00:00:00 2001 From: Rolf Geuenich Date: Fri, 12 Jan 2024 15:44:28 +0100 Subject: [PATCH 2/3] Downpatching changes from development to master in Arty.lua --- Moose Development/Moose/Core/Set.lua | 1 - Moose Development/Moose/Functional/Artillery.lua | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/Moose Development/Moose/Core/Set.lua b/Moose Development/Moose/Core/Set.lua index 8963d65f3..52c899bec 100644 --- a/Moose Development/Moose/Core/Set.lua +++ b/Moose Development/Moose/Core/Set.lua @@ -7855,7 +7855,6 @@ do -- SET_OPSGROUP self:Add( groupname, group ) end end - end end end diff --git a/Moose Development/Moose/Functional/Artillery.lua b/Moose Development/Moose/Functional/Artillery.lua index 20ed363eb..7425d3212 100644 --- a/Moose Development/Moose/Functional/Artillery.lua +++ b/Moose Development/Moose/Functional/Artillery.lua @@ -3546,9 +3546,7 @@ end -- @param #string To To state. function ARTY:onafterRespawn(Controllable, From, Event, To) self:_EventFromTo("onafterRespawn", Event, From, To) - - env.info("FF Respawning arty group") - + self:I("Respawning arty group") local group=self.Controllable --Wrapper.Group#GROUP -- Respawn group. From bb07e1935e694b761e9ce3917e40fe716ef8edb7 Mon Sep 17 00:00:00 2001 From: Rolf Geuenich Date: Fri, 12 Jan 2024 16:05:14 +0100 Subject: [PATCH 3/3] Downpatching changes from development to master --- Moose Development/Moose/Functional/MissileTrainer.lua | 1 - Moose Development/Moose/Functional/Warehouse.lua | 2 +- Moose Development/Moose/Wrapper/Group.lua | 10 +++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Moose Development/Moose/Functional/MissileTrainer.lua b/Moose Development/Moose/Functional/MissileTrainer.lua index 6fb9ff1a8..f52363ba2 100644 --- a/Moose Development/Moose/Functional/MissileTrainer.lua +++ b/Moose Development/Moose/Functional/MissileTrainer.lua @@ -72,7 +72,6 @@ -- @module Functional.MissileTrainer -- @image Missile_Trainer.JPG - --- -- @type MISSILETRAINER -- @field Core.Set#SET_CLIENT DBClients diff --git a/Moose Development/Moose/Functional/Warehouse.lua b/Moose Development/Moose/Functional/Warehouse.lua index 7ac6e2839..86c1255c7 100644 --- a/Moose Development/Moose/Functional/Warehouse.lua +++ b/Moose Development/Moose/Functional/Warehouse.lua @@ -87,7 +87,7 @@ -- @field #number respawndelay Delay before respawn in seconds. -- @field #number runwaydestroyed Time stamp timer.getAbsTime() when the runway was destroyed. -- @field #number runwayrepairtime Time in seconds until runway will be repaired after it was destroyed. Default is 3600 sec (one hour). --- @field Ops.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse. +-- @field OPS.FlightControl#FLIGHTCONTROL flightcontrol Flight control of this warehouse. -- @extends Core.Fsm#FSM --- Have your assets at the right place at the right time - or not! diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index d232bf604..080467e84 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -689,7 +689,15 @@ function GROUP:GetUnits() local DCSUnits = DCSGroup:getUnits() or {} local Units = {} for Index, UnitData in pairs( DCSUnits ) do - Units[#Units+1] = UNIT:Find( UnitData ) + + local unit=UNIT:Find( UnitData ) + if unit then + Units[#Units+1] = UNIT:Find( UnitData ) + else + local UnitName=UnitData:getName() + unit=_DATABASE:AddUnit(UnitName) + Units[#Units+1]=unit + end end self:T3( Units ) return Units