From c81e7c2488c9fc2ad65c7aa17e71e7781cd84f5c Mon Sep 17 00:00:00 2001 From: svenvandevelde Date: Thu, 18 Feb 2016 15:32:29 +0100 Subject: [PATCH] Try to get the DCS bug in 1.5.3 resolved with :isExist for a Client Group Client groups connected remotely to a server, are not generating any birth events on the server. The server therefore thinks that the Group does not exist ... This bug is present since 1.5. Currently building a logic to go "around" that problem using other functions (the coalition:getPlayerUnits() is key for resolvement) --- Moose/Client.lua | 41 +++++++++++++++++++++++++++++++++++------ Moose/Database.lua | 1 + 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Moose/Client.lua b/Moose/Client.lua index f667d43e5..e4bd7933c 100644 --- a/Moose/Client.lua +++ b/Moose/Client.lua @@ -65,16 +65,45 @@ trace.f(self.ClassName) end --- ClientGroup returns the Group of a Client. +-- This function is modified to deal with a couple of bugs in DCS 1.5.3 -- @treturn Group function CLIENT:ClientGroup() --trace.f(self.ClassName) - local ClientData = Group.getByName( self.ClientName ) - if ClientData and ClientData:isExist() then - trace.i( self.ClassName, self.ClientName .. " : group found!" ) - return ClientData - else - return nil +-- local ClientData = Group.getByName( self.ClientName ) +-- if ClientData and ClientData:isExist() then +-- trace.i( self.ClassName, self.ClientName .. " : group found!" ) +-- return ClientData +-- else +-- return nil +-- end + + local ClientGroup = Group.getByName( self.ClientName ) + + if ClientGroup then + + local ClientUnits = ClientGroup:getUnits() + + if ClientGroup:isExist() then + trace.i( self.ClassName, self.ClientName .. " : group found!" ) + return ClientGroup + else + -- Now we need to resolve the bugs in DCS 1.5 ... + local CoalitionsData = { AlivePlayersRed = coalition.getPlayers( coalition.side.RED ), AlivePlayersBlue = coalition.getPlayers( coalition.side.BLUE ) } + for CoalitionId, CoalitionData in pairs( CoalitionsData ) do + trace.i( self.ClassName, CoalitionData ) + for UnitId, UnitData in pairs( CoalitionData ) do + trace.i( self.ClassName, UnitData ) + if UnitData and UnitData:isExist() then + if UnitData:getID() == ClientUnits[1]:getID() then + trace.i( self.ClassName, self.ClientName .. " : group found in bug 1.5 resolvement logic!" ) + return self.ClientGroup + end + end + end + end + end end + return nil end --- Returns the Unit of the @{CLIENT}. diff --git a/Moose/Database.lua b/Moose/Database.lua index 986896a78..99ceb9f36 100644 --- a/Moose/Database.lua +++ b/Moose/Database.lua @@ -13,6 +13,7 @@ DATABASE = { NavPoints = {}, Statics = {}, Players = {}, + ActivePlayers = {}, ClientsByName = {}, ClientsByID = {}, }