mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Update Templates
- Added nil check if client template does not exist in `WAREHOUSE` class - Added nil checks in `DATABASE` if client template does not exist - Fixed `SET_CLIENT:IsIncludeObject()` function if client template does not exist
This commit is contained in:
parent
1033b975f8
commit
62ef56684b
@ -1271,24 +1271,36 @@ end
|
|||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Coalition ID.
|
-- @return #number Coalition ID.
|
||||||
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
function DATABASE:GetCoalitionFromClientTemplate( ClientName )
|
||||||
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
return self.Templates.ClientsByName[ClientName].CoalitionID
|
return self.Templates.ClientsByName[ClientName].CoalitionID
|
||||||
end
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Get category ID from client name.
|
--- Get category ID from client name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Category ID.
|
-- @return #number Category ID.
|
||||||
function DATABASE:GetCategoryFromClientTemplate( ClientName )
|
function DATABASE:GetCategoryFromClientTemplate( ClientName )
|
||||||
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
return self.Templates.ClientsByName[ClientName].CategoryID
|
return self.Templates.ClientsByName[ClientName].CategoryID
|
||||||
end
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Get country ID from client name.
|
--- Get country ID from client name.
|
||||||
-- @param #DATABASE self
|
-- @param #DATABASE self
|
||||||
-- @param #string ClientName Name of the Client.
|
-- @param #string ClientName Name of the Client.
|
||||||
-- @return #number Country ID.
|
-- @return #number Country ID.
|
||||||
function DATABASE:GetCountryFromClientTemplate( ClientName )
|
function DATABASE:GetCountryFromClientTemplate( ClientName )
|
||||||
|
if self.Templates.ClientsByName[ClientName] then
|
||||||
return self.Templates.ClientsByName[ClientName].CountryID
|
return self.Templates.ClientsByName[ClientName].CountryID
|
||||||
end
|
end
|
||||||
|
self:E("ERROR: Template does not exist for client "..tostring(ClientName))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- Airbase
|
--- Airbase
|
||||||
|
|
||||||
|
|||||||
@ -4729,8 +4729,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCoalition = false
|
local MClientCoalition = false
|
||||||
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
for CoalitionID, CoalitionName in pairs( self.Filter.Coalitions ) do
|
||||||
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
local ClientCoalitionID = _DATABASE:GetCoalitionFromClientTemplate( MClientName )
|
||||||
|
if ClientCoalitionID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCoalitionID=MClient:GetCoalition()
|
||||||
|
end
|
||||||
self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
self:T3( { "Coalition:", ClientCoalitionID, self.FilterMeta.Coalitions[CoalitionName], CoalitionName } )
|
||||||
if self.FilterMeta.Coalitions[CoalitionName] and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then
|
if self.FilterMeta.Coalitions[CoalitionName] and ClientCoalitionID and self.FilterMeta.Coalitions[CoalitionName] == ClientCoalitionID then
|
||||||
MClientCoalition = true
|
MClientCoalition = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -4742,8 +4745,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCategory = false
|
local MClientCategory = false
|
||||||
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
for CategoryID, CategoryName in pairs( self.Filter.Categories ) do
|
||||||
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
local ClientCategoryID = _DATABASE:GetCategoryFromClientTemplate( MClientName )
|
||||||
|
if ClientCategoryID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCategoryID=MClient:GetCategory()
|
||||||
|
end
|
||||||
self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
self:T3( { "Category:", ClientCategoryID, self.FilterMeta.Categories[CategoryName], CategoryName } )
|
||||||
if self.FilterMeta.Categories[CategoryName] and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then
|
if self.FilterMeta.Categories[CategoryName] and ClientCategoryID and self.FilterMeta.Categories[CategoryName] == ClientCategoryID then
|
||||||
MClientCategory = true
|
MClientCategory = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -4767,8 +4773,11 @@ do -- SET_CLIENT
|
|||||||
local MClientCountry = false
|
local MClientCountry = false
|
||||||
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
for CountryID, CountryName in pairs( self.Filter.Countries ) do
|
||||||
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
local ClientCountryID = _DATABASE:GetCountryFromClientTemplate( MClientName )
|
||||||
|
if ClientCountryID==nil and MClient:IsAlive()~=nil then
|
||||||
|
ClientCountryID=MClient:GetCountry()
|
||||||
|
end
|
||||||
self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } )
|
self:T3( { "Country:", ClientCountryID, country.id[CountryName], CountryName } )
|
||||||
if country.id[CountryName] and country.id[CountryName] == ClientCountryID then
|
if country.id[CountryName] and ClientCountryID and country.id[CountryName] == ClientCountryID then
|
||||||
MClientCountry = true
|
MClientCountry = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -7946,6 +7946,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
local clients=_DATABASE.CLIENTS
|
local clients=_DATABASE.CLIENTS
|
||||||
for clientname, client in pairs(clients) do
|
for clientname, client in pairs(clients) do
|
||||||
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
||||||
|
if template then
|
||||||
local units=template.units
|
local units=template.units
|
||||||
for i,unit in pairs(units) do
|
for i,unit in pairs(units) do
|
||||||
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
||||||
@ -7953,6 +7954,7 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
return coords
|
return coords
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user