diff --git a/Moose Development/Moose/Core/Database.lua b/Moose Development/Moose/Core/Database.lua index 8f031fdd0..db54e8dc2 100644 --- a/Moose Development/Moose/Core/Database.lua +++ b/Moose Development/Moose/Core/Database.lua @@ -1147,10 +1147,13 @@ end -- @param #string GroupName Group name. -- @return #table Group template table. function DATABASE:GetGroupTemplate( GroupName ) - local GroupTemplate = self.Templates.Groups[GroupName].Template - GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID - GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID - GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID + local GroupTemplate=nil + if self.Templates.Groups[GroupName] then + GroupTemplate = self.Templates.Groups[GroupName].Template + GroupTemplate.SpawnCoalitionID = self.Templates.Groups[GroupName].CoalitionID + GroupTemplate.SpawnCategoryID = self.Templates.Groups[GroupName].CategoryID + GroupTemplate.SpawnCountryID = self.Templates.Groups[GroupName].CountryID + end return GroupTemplate end diff --git a/Moose Development/Moose/Ops/Airboss.lua b/Moose Development/Moose/Ops/Airboss.lua index 7217fa131..244e252ed 100644 --- a/Moose Development/Moose/Ops/Airboss.lua +++ b/Moose Development/Moose/Ops/Airboss.lua @@ -14366,32 +14366,55 @@ function AIRBOSS:_GetOnboardNumbers( group, playeronly ) -- Debug text. local text = string.format( "Onboard numbers of group %s:", groupname ) - -- Units of template group. - local units = group:GetTemplate().units + local template=group:GetTemplate() - -- Get numbers. local numbers = {} - for _, unit in pairs( units ) do + if template then - -- Onboard number and unit name. - local n = tostring( unit.onboard_num ) - local name = unit.name - local skill = unit.skill or "Unknown" + -- Units of template group. + local units = template.units - -- Debug text. - text = text .. string.format( "\n- unit %s: onboard #=%s skill=%s", name, n, tostring( skill ) ) + -- Get numbers. + for _, unit in pairs( units ) do - if playeronly and skill == "Client" or skill == "Player" then - -- There can be only one player in the group, so we skip everything else. - return n + -- Onboard number and unit name. + local n = tostring( unit.onboard_num ) + local name = unit.name + local skill = unit.skill or "Unknown" + + -- Debug text. + text = text .. string.format( "\n- unit %s: onboard #=%s skill=%s", name, n, tostring( skill ) ) + + if playeronly and skill == "Client" or skill == "Player" then + -- There can be only one player in the group, so we skip everything else. + return n + end + + -- Table entry. + numbers[name] = n end - -- Table entry. - numbers[name] = n - end + -- Debug info. + self:T2( self.lid .. text ) - -- Debug info. - self:T2( self.lid .. text ) + else + + if playeronly then + return 101 + else + + local units=group:GetUnits() + + for i,_unit in pairs(units) do + local name=_unit:GetName() + + numbers[name]=100+i + + end + + end + + end return numbers end diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index 93bd436a5..714fc2faf 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -1778,10 +1778,14 @@ end --- Returns the group template from the global _DATABASE object (an instance of @{Core.Database#DATABASE}). -- @param #GROUP self --- @return #table +-- @return #table Template table. function GROUP:GetTemplate() local GroupName = self:GetName() - return UTILS.DeepCopy( _DATABASE:GetGroupTemplate( GroupName ) ) + local template=_DATABASE:GetGroupTemplate( GroupName ) + if template then + return UTILS.DeepCopy( template ) + end + return nil end --- Returns the group template route.points[] (the waypoints) from the global _DATABASE object (an instance of @{Core.Database#DATABASE}).