MOOSE
MOOSE copied to clipboard
BUG - TASK_CARGO_DISPATCHER:OnAfterCargoDeployed() -> Cargo:Destroy() not working
When using spawned static cargo and using it it tasks it all works great, but for some reason I cannot seem to get rid of Cargo when it is finished with ( I want to remove it from DCS and MOOSE) eg
function TaskDispatcherCargo:OnAfterCargoDeployed( From, Event, To, Task, TaskPrefix, TaskUnit, Cargo, DeployZone )
Cargo:Destroy() -- this does not work end -- EOF
If I use Cargo.CargoObject:Destroy(), it will remove the object from DCS (it dissapears - but I think it is still "alive" inside MOOSE
what help do you need ?
OK what do we do with this? We can't change cargo so can it be worked around outside of code or not?
If I use Cargo.CargoObject:Destroy(), it will remove the object from DCS (it dissapears - but I think it is still "alive" inside MOOSE
Impact? Will autoclose in 1 week
cargo still exists in moose database and in the sim engine , need to change Cargo:Destroy() to directly call the destroy API function (destroys the cargo properly) and then remove that cargo at same time from moose database
Maybe document Cargo:Destroy() better. Cargo:Destroy does not de-spawns the Positionable representing the Cargo. as far as I can see from Docs or Code.
re-opening as the code section that has this error was not completed
so let me get this straight. CARGO:Destroy() works as it destroy() the physical object using the SSE API, but does not trigger the deletion of the object from the MOOSE database? Is this it?
@shadowze Can you plz update status on this issue, and reply to @thebgpikester question. I am currently looking into this?
been a while since I looked at this, but think that @thebgpikester is correct object physically dissapears but is still on the database
Ok
cargo still exists in moose database and in the sim engine , need to change Cargo:Destroy() to directly call the destroy API function (destroys the cargo properly) and then remove that cargo at same time from moose database
What flaws causes this, if I might ask? What should I look fro when debugging @shadowze ?
Cargo:Destroy() (where Cargo is a cargo type dcs object) called from TaskDispatcherCargo:OnAfterCargoDeployed function when a cargo has been deployed is where this was observed, franky had a look thru MOOSE and noticed some code to do with class cargo and the destroy method were never finished ... I think
Right, makes sense.
When destroying Cargos, the dispatcher reports this:

Not ok, @shadowze?
try to see if you can search the database for the "destroyed" objects also try with a cargo crate type object
Ok
tihnk this is what were were looking at
function CARGO_REPRESENTABLE:Destroy()
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
self:F( { CargoName = self:GetName() } )
--_EVENTDISPATCHER:CreateEventDeleteCargo( self )
return self
end
this is probably where this is fucked, if you look at other destroy methods eg function STATIC:Destroy( GenerateEvent ) you see they do something that triggers a database removal, cargo aint got that
Indeed, @shadowze nothing happens, when CARGO_REPRESENTABLE:Destroy() is called. Cargo crate remains in game and in the dispatchers tasks list.
I see in function the CreateEvent call is commented.
--- CARGO_REPRESENTABLE Destructor.
-- @param #CARGO_REPRESENTABLE self
-- @return #CARGO_REPRESENTABLE
function CARGO_REPRESENTABLE:Destroy()
-- Cargo objects are deleted from the _DATABASE and SET_CARGO objects.
self:F( { CargoName = self:GetName() } )
--_EVENTDISPATCHER:CreateEventDeleteCargo( self )
return self
end
Ill try un-comment and see whats happening.
function CARGO_REPRESENTABLE:Destroy() is not completed.
Un-commenting _EVENTDISPATCHER:CreateEventDeleteCargo( self ) leads to nothing.
yeah, looks like the code for this stuff is not yet completed
It was never completed because the dcs sim could not delete the crates. Bugs ... I simply gave up.
Get Outlook for Androidhttps://aka.ms/ghei36
From: Shadowze [email protected] Sent: Tuesday, 15 December 2020, 17:38 To: FlightControl-Master/MOOSE Cc: Subscribed Subject: Re: [FlightControl-Master/MOOSE] BUG - TASK_CARGO_DISPATCHER:OnAfterCargoDeployed() -> Cargo:Destroy() not working (#987)
yeah, looks like the code for this stuff is not yet completed
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/FlightControl-Master/MOOSE/issues/987#issuecomment-745411850, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ADIOPF7NQCLIJTHAYIBKMJ3SU6GJ3ANCNFSM4FV3U2NQ.
Yeah but DCS API does now delete the crates ...... its just the moose code not removing the cargo from the database is the issue .. I think
It was never completed because the dcs sim could not delete the crates. Bugs ... I simply gave up.
Hehe, right bug... Still hope you are doing well!
Anyway, Ill dig into the Moose's "destruction department" when on my way for Christmas holiday to see if I understand the logic. It seems create events of some type. "death" I think While tracing I found this comment long comment in Moose.lua:
-- However, in the loading logic, an S_EVENT_DEAD is also generated after a Destroy() call.
-- And this is a problem because it will remove all entries from the SET_CARGOs.
-- To prevent this from happening, the Cargo object has a flag NoDestroy.
-- When true, the SET_CARGO won't Remove the Cargo object from the set.
-- But we need to switch that flag off after the event handlers have been called.
Seems to be in this long function function EVENT:onEvent( Event ) just above
if Event.id == EVENTS.DeleteCargo then
Event.Cargo.NoDestroy = nil
end
@shadowze is this still relevant?