Merge remote-tracking branch 'origin/master' into develop

# Conflicts:
#	Moose Development/Moose/Wrapper/Net.lua
This commit is contained in:
Applevangelist 2023-02-19 17:17:35 +01:00
commit 8e6eb17ef5

View File

@ -62,15 +62,15 @@
-- --
-- @field #CLIENT -- @field #CLIENT
CLIENT = { CLIENT = {
ClassName = "CLIENT", ClassName = "CLIENT",
ClientName = nil, ClientName = nil,
ClientAlive = false, ClientAlive = false,
ClientTransport = false, ClientTransport = false,
ClientBriefingShown = false, ClientBriefingShown = false,
_Menus = {}, _Menus = {},
_Tasks = {}, _Tasks = {},
Messages = {}, Messages = {},
Players = {}, Players = {},
} }
@ -121,13 +121,13 @@ end
-- @return #CLIENT -- @return #CLIENT
-- @usage -- @usage
-- -- Create new Clients. -- -- Create new Clients.
-- local Mission = MISSIONSCHEDULER.AddMission( 'Russia Transport Troops SA-6', 'Operational', 'Transport troops from the control center to one of the SA-6 SAM sites to activate their operation.', 'Russia' ) -- local Mission = MISSIONSCHEDULER.AddMission( 'Russia Transport Troops SA-6', 'Operational', 'Transport troops from the control center to one of the SA-6 SAM sites to activate their operation.', 'Russia' )
-- Mission:AddGoal( DeploySA6TroopsGoal ) -- Mission:AddGoal( DeploySA6TroopsGoal )
-- --
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 1' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 1' ):Transport() )
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 3' ):Transport() )
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*HOT-Deploy Troops 2' ):Transport() )
-- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() ) -- Mission:AddClient( CLIENT:FindByName( 'RU MI-8MTV2*RAMP-Deploy Troops 4' ):Transport() )
function CLIENT:FindByName( ClientName, ClientBriefing, Error ) function CLIENT:FindByName( ClientName, ClientBriefing, Error )
-- Client -- Client
@ -140,7 +140,7 @@ function CLIENT:FindByName( ClientName, ClientBriefing, Error )
ClientFound.MessageSwitch = true ClientFound.MessageSwitch = true
return ClientFound return ClientFound
end end
if not Error then if not Error then
@ -278,8 +278,8 @@ end
-- @param #CLIENT self -- @param #CLIENT self
-- @param #string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client. -- @param #string ClientName Name of the Group as defined within the Mission Editor. The Group must have a Unit with the type Client.
function CLIENT:Reset( ClientName ) function CLIENT:Reset( ClientName )
self:F() self:F()
self._Menus = {} self._Menus = {}
end end
-- Is Functions -- Is Functions
@ -363,85 +363,85 @@ function CLIENT:GetDCSGroup()
self:F3() self:F3()
-- local ClientData = Group.getByName( self.ClientName ) -- local ClientData = Group.getByName( self.ClientName )
-- if ClientData and ClientData:isExist() then -- if ClientData and ClientData:isExist() then
-- self:T( self.ClientName .. " : group found!" ) -- self:T( self.ClientName .. " : group found!" )
-- return ClientData -- return ClientData
-- else -- else
-- return nil -- return nil
-- end -- end
local ClientUnit = Unit.getByName( self.ClientName ) local ClientUnit = Unit.getByName( self.ClientName )
local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) } local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) }
for CoalitionId, CoalitionData in pairs( CoalitionsData ) do for CoalitionId, CoalitionData in pairs( CoalitionsData ) do
self:T3( { "CoalitionData:", CoalitionData } ) self:T3( { "CoalitionData:", CoalitionData } )
for UnitId, UnitData in pairs( CoalitionData ) do for UnitId, UnitData in pairs( CoalitionData ) do
self:T3( { "UnitData:", UnitData } ) self:T3( { "UnitData:", UnitData } )
if UnitData and UnitData:isExist() then if UnitData and UnitData:isExist() then
--self:F(self.ClientName) --self:F(self.ClientName)
if ClientUnit then if ClientUnit then
local ClientGroup = ClientUnit:getGroup() local ClientGroup = ClientUnit:getGroup()
if ClientGroup then if ClientGroup then
self:T3( "ClientGroup = " .. self.ClientName ) self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() and UnitData:getGroup():isExist() then if ClientGroup:isExist() and UnitData:getGroup():isExist() then
if ClientGroup:getID() == UnitData:getGroup():getID() then if ClientGroup:getID() == UnitData:getGroup():getID() then
self:T3( "Normal logic" ) self:T3( "Normal logic" )
self:T3( self.ClientName .. " : group found!" ) self:T3( self.ClientName .. " : group found!" )
self.ClientGroupID = ClientGroup:getID() self.ClientGroupID = ClientGroup:getID()
self.ClientGroupName = ClientGroup:getName() self.ClientGroupName = ClientGroup:getName()
return ClientGroup return ClientGroup
end end
else else
-- Now we need to resolve the bugs in DCS 1.5 ... -- Now we need to resolve the bugs in DCS 1.5 ...
-- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil) -- Consult the database for the units of the Client Group. (ClientGroup:getUnits() returns nil)
self:T3( "Bug 1.5 logic" ) self:T3( "Bug 1.5 logic" )
local ClientGroupTemplate = _DATABASE.Templates.Units[self.ClientName].GroupTemplate local ClientGroupTemplate = _DATABASE.Templates.Units[self.ClientName].GroupTemplate
self.ClientGroupID = ClientGroupTemplate.groupId self.ClientGroupID = ClientGroupTemplate.groupId
self.ClientGroupName = _DATABASE.Templates.Units[self.ClientName].GroupName self.ClientGroupName = _DATABASE.Templates.Units[self.ClientName].GroupName
self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" ) self:T3( self.ClientName .. " : group found in bug 1.5 resolvement logic!" )
return ClientGroup return ClientGroup
end end
-- else -- else
-- error( "Client " .. self.ClientName .. " not found!" ) -- error( "Client " .. self.ClientName .. " not found!" )
end end
else else
--self:F( { "Client not found!", self.ClientName } ) --self:F( { "Client not found!", self.ClientName } )
end end
end end
end end
end
-- For non player clients
if ClientUnit then
local ClientGroup = ClientUnit:getGroup()
if ClientGroup then
self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then
self:T3( "Normal logic" )
self:T3( self.ClientName .. " : group found!" )
return ClientGroup
end
end
end end
-- Nothing could be found :( -- For non player clients
self.ClientGroupID = nil if ClientUnit then
self.ClientGroupName = nil local ClientGroup = ClientUnit:getGroup()
if ClientGroup then
return nil self:T3( "ClientGroup = " .. self.ClientName )
if ClientGroup:isExist() then
self:T3( "Normal logic" )
self:T3( self.ClientName .. " : group found!" )
return ClientGroup
end
end
end
-- Nothing could be found :(
self.ClientGroupID = nil
self.ClientGroupName = nil
return nil
end end
@ -453,7 +453,7 @@ function CLIENT:GetClientGroupID()
-- This updates the ID. -- This updates the ID.
self:GetDCSGroup() self:GetDCSGroup()
return self.ClientGroupID return self.ClientGroupID
end end
@ -465,7 +465,7 @@ function CLIENT:GetClientGroupName()
-- This updates the group name. -- This updates the group name.
self:GetDCSGroup() self:GetDCSGroup()
return self.ClientGroupName return self.ClientGroupName
end end
--- Returns the UNIT of the CLIENT. --- Returns the UNIT of the CLIENT.
@ -474,23 +474,23 @@ end
function CLIENT:GetClientGroupUnit() function CLIENT:GetClientGroupUnit()
self:F2() self:F2()
local ClientDCSUnit = Unit.getByName( self.ClientName ) local ClientDCSUnit = Unit.getByName( self.ClientName )
self:T( self.ClientDCSUnit ) self:T( self.ClientDCSUnit )
if ClientDCSUnit and ClientDCSUnit:isExist() then if ClientDCSUnit and ClientDCSUnit:isExist() then
local ClientUnit=_DATABASE:FindUnit( self.ClientName ) local ClientUnit=_DATABASE:FindUnit( self.ClientName )
return ClientUnit return ClientUnit
end end
return nil return nil
end end
--- Returns the DCSUnit of the CLIENT. --- Returns the DCSUnit of the CLIENT.
-- @param #CLIENT self -- @param #CLIENT self
-- @return DCS#Unit -- @return DCS#Unit
function CLIENT:GetClientGroupDCSUnit() function CLIENT:GetClientGroupDCSUnit()
self:F2() self:F2()
local ClientDCSUnit = Unit.getByName( self.ClientName ) local ClientDCSUnit = Unit.getByName( self.ClientName )
@ -505,29 +505,29 @@ end
-- @param #CLIENT self -- @param #CLIENT self
-- @return #boolean true is a transport. -- @return #boolean true is a transport.
function CLIENT:IsTransport() function CLIENT:IsTransport()
self:F() self:F()
return self.ClientTransport return self.ClientTransport
end end
--- Shows the @{AI.AI_Cargo#CARGO} contained within the CLIENT to the player as a message. --- Shows the @{AI.AI_Cargo#CARGO} contained within the CLIENT to the player as a message.
-- The @{AI.AI_Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system. -- The @{AI.AI_Cargo#CARGO} is shown using the @{Core.Message#MESSAGE} distribution system.
-- @param #CLIENT self -- @param #CLIENT self
function CLIENT:ShowCargo() function CLIENT:ShowCargo()
self:F() self:F()
local CargoMsg = "" local CargoMsg = ""
for CargoName, Cargo in pairs( CARGOS ) do for CargoName, Cargo in pairs( CARGOS ) do
if self == Cargo:IsLoadedInClient() then if self == Cargo:IsLoadedInClient() then
CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight .. "\n" CargoMsg = CargoMsg .. Cargo.CargoName .. " Type:" .. Cargo.CargoType .. " Weight: " .. Cargo.CargoWeight .. "\n"
end end
end end
if CargoMsg == "" then if CargoMsg == "" then
CargoMsg = "empty" CargoMsg = "empty"
end end
self:Message( CargoMsg, 15, "Co-Pilot: Cargo Status", 30 ) self:Message( CargoMsg, 15, "Co-Pilot: Cargo Status", 30 )
end end
@ -542,39 +542,39 @@ end
-- @param #number MessageInterval is the interval in seconds between the display of the @{Core.Message#MESSAGE} when the CLIENT is in the air. -- @param #number MessageInterval is the interval in seconds between the display of the @{Core.Message#MESSAGE} when the CLIENT is in the air.
-- @param #string MessageID is the identifier of the message when displayed with intervals. -- @param #string MessageID is the identifier of the message when displayed with intervals.
function CLIENT:Message( Message, MessageDuration, MessageCategory, MessageInterval, MessageID ) function CLIENT:Message( Message, MessageDuration, MessageCategory, MessageInterval, MessageID )
self:F( { Message, MessageDuration, MessageCategory, MessageInterval } ) self:F( { Message, MessageDuration, MessageCategory, MessageInterval } )
if self.MessageSwitch == true then if self.MessageSwitch == true then
if MessageCategory == nil then if MessageCategory == nil then
MessageCategory = "Messages" MessageCategory = "Messages"
end end
if MessageID ~= nil then if MessageID ~= nil then
if self.Messages[MessageID] == nil then if self.Messages[MessageID] == nil then
self.Messages[MessageID] = {} self.Messages[MessageID] = {}
self.Messages[MessageID].MessageId = MessageID self.Messages[MessageID].MessageId = MessageID
self.Messages[MessageID].MessageTime = timer.getTime() self.Messages[MessageID].MessageTime = timer.getTime()
self.Messages[MessageID].MessageDuration = MessageDuration self.Messages[MessageID].MessageDuration = MessageDuration
if MessageInterval == nil then if MessageInterval == nil then
self.Messages[MessageID].MessageInterval = 600 self.Messages[MessageID].MessageInterval = 600
else else
self.Messages[MessageID].MessageInterval = MessageInterval self.Messages[MessageID].MessageInterval = MessageInterval
end end
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self ) MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
else else
if self:GetClientGroupDCSUnit() and not self:GetClientGroupDCSUnit():inAir() then if self:GetClientGroupDCSUnit() and not self:GetClientGroupDCSUnit():inAir() then
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + 10 then if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + 10 then
MESSAGE:New( Message, MessageDuration , MessageCategory):ToClient( self ) MESSAGE:New( Message, MessageDuration , MessageCategory):ToClient( self )
self.Messages[MessageID].MessageTime = timer.getTime() self.Messages[MessageID].MessageTime = timer.getTime()
end end
else else
if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + self.Messages[MessageID].MessageInterval then if timer.getTime() - self.Messages[MessageID].MessageTime >= self.Messages[MessageID].MessageDuration + self.Messages[MessageID].MessageInterval then
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self ) MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
self.Messages[MessageID].MessageTime = timer.getTime() self.Messages[MessageID].MessageTime = timer.getTime()
end end
end end
end end
else else
MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self ) MESSAGE:New( Message, MessageDuration, MessageCategory ):ToClient( self )
end end
end end
end end