mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
[FIXED] CTLD. Memory leak adding zones of the same name and type
[FIXED] CSAR. nil pointer
This commit is contained in:
parent
5183fcc316
commit
48b51f21de
@ -1150,11 +1150,11 @@ function CSAR:_EventHandler(EventData)
|
|||||||
|
|
||||||
local initdcscoord = nil
|
local initdcscoord = nil
|
||||||
local initcoord = nil
|
local initcoord = nil
|
||||||
if _event.id == EVENTS.Ejection then
|
if _event.id == EVENTS.Ejection and _event.TgtDCSUnit then
|
||||||
initdcscoord = _event.TgtDCSUnit:getPoint()
|
initdcscoord = _event.TgtDCSUnit:getPoint()
|
||||||
initcoord = COORDINATE:NewFromVec3(initdcscoord)
|
initcoord = COORDINATE:NewFromVec3(initdcscoord)
|
||||||
self:T({initdcscoord})
|
self:T({initdcscoord})
|
||||||
else
|
elseif _event.IniDCSUnit then
|
||||||
initdcscoord = _event.IniDCSUnit:getPoint()
|
initdcscoord = _event.IniDCSUnit:getPoint()
|
||||||
initcoord = COORDINATE:NewFromVec3(initdcscoord)
|
initcoord = COORDINATE:NewFromVec3(initdcscoord)
|
||||||
self:T({initdcscoord})
|
self:T({initdcscoord})
|
||||||
|
|||||||
@ -5670,8 +5670,14 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ctldzone = {} -- #CTLD.CargoZone
|
local exists = true
|
||||||
|
local ctldzone = self:GetCTLDZone(Name, Type) -- #CTLD.CargoZone
|
||||||
|
if not ctldzone then
|
||||||
|
exists = false
|
||||||
|
ctldzone = {}
|
||||||
|
end
|
||||||
|
|
||||||
ctldzone.active = Active or false
|
ctldzone.active = Active or false
|
||||||
ctldzone.color = Color or SMOKECOLOR.Red
|
ctldzone.color = Color or SMOKECOLOR.Red
|
||||||
ctldzone.name = Name or "NONE"
|
ctldzone.name = Name or "NONE"
|
||||||
@ -5697,11 +5703,56 @@ function CTLD:AddCTLDZone(Name, Type, Color, Active, HasBeacon, Shiplength, Ship
|
|||||||
ctldzone.shiplength = Shiplength or 100
|
ctldzone.shiplength = Shiplength or 100
|
||||||
ctldzone.shipwidth = Shipwidth or 10
|
ctldzone.shipwidth = Shipwidth or 10
|
||||||
end
|
end
|
||||||
|
|
||||||
self:AddZone(ctldzone)
|
if not exists then
|
||||||
|
self:AddZone(ctldzone)
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- User function - find #CTLD.CargoZone zone by name.
|
||||||
|
-- @param #CTLD self
|
||||||
|
-- @param #string Name Name of this zone.
|
||||||
|
-- @param #string Type Type of this zone, #CTLD.CargoZoneType
|
||||||
|
-- @return #CTLD.CargoZone self
|
||||||
|
function CTLD:GetCTLDZone(Name, Type)
|
||||||
|
|
||||||
|
if Type == CTLD.CargoZoneType.LOAD then
|
||||||
|
for _, z in pairs(self.pickupZones) do
|
||||||
|
if z.name == Name then
|
||||||
|
return z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Type == CTLD.CargoZoneType.DROP then
|
||||||
|
for _, z in pairs(self.dropOffZones) do
|
||||||
|
if z.name == Name then
|
||||||
|
return z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Type == CTLD.CargoZoneType.SHIP then
|
||||||
|
for _, z in pairs(self.shipZones) do
|
||||||
|
if z.name == Name then
|
||||||
|
return z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif Type == CTLD.CargoZoneType.BEACON then
|
||||||
|
for _, z in pairs(self.droppedBeacons) do
|
||||||
|
if z.name == Name then
|
||||||
|
return z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for _, z in pairs(self.wpZones) do
|
||||||
|
if z.name == Name then
|
||||||
|
return z
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
--- User function - Creates and adds a #CTLD.CargoZone zone for this CTLD instance from an Airbase or FARP name.
|
--- User function - Creates and adds a #CTLD.CargoZone zone for this CTLD instance from an Airbase or FARP name.
|
||||||
-- Zones of type LOAD: Players load crates and troops here.
|
-- Zones of type LOAD: Players load crates and troops here.
|
||||||
-- Zones of type DROP: Players can drop crates here. Note that troops can be unloaded anywhere.
|
-- Zones of type DROP: Players can drop crates here. Note that troops can be unloaded anywhere.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user