MOOSE icon indicating copy to clipboard operation
MOOSE copied to clipboard

BUG - TASK_CARGO_DISPATCHER:OnAfterCargoDeployed() -> Cargo:Destroy() not working

Open shadowze opened this issue 7 years ago • 24 comments

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

shadowze avatar Sep 18 '18 22:09 shadowze

what help do you need ?

shadowze avatar Oct 21 '18 20:10 shadowze

OK what do we do with this? We can't change cargo so can it be worked around outside of code or not?

thebgpikester avatar Feb 08 '20 17:02 thebgpikester

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

thebgpikester avatar Feb 13 '20 16:02 thebgpikester

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

shadowze avatar Feb 14 '20 13:02 shadowze

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.

baluballa avatar Mar 10 '20 13:03 baluballa

re-opening as the code section that has this error was not completed

shadowze avatar Mar 13 '20 21:03 shadowze

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?

thebgpikester avatar May 15 '20 10:05 thebgpikester

@shadowze Can you plz update status on this issue, and reply to @thebgpikester question. I am currently looking into this?

baluballa avatar Dec 14 '20 15:12 baluballa

been a while since I looked at this, but think that @thebgpikester is correct object physically dissapears but is still on the database

shadowze avatar Dec 14 '20 15:12 shadowze

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 ?

baluballa avatar Dec 14 '20 15:12 baluballa

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

shadowze avatar Dec 14 '20 15:12 shadowze

Right, makes sense.

baluballa avatar Dec 14 '20 15:12 baluballa

When destroying Cargos, the dispatcher reports this: image

Not ok, @shadowze?

baluballa avatar Dec 14 '20 15:12 baluballa

try to see if you can search the database for the "destroyed" objects also try with a cargo crate type object

shadowze avatar Dec 14 '20 16:12 shadowze

Ok

baluballa avatar Dec 14 '20 16:12 baluballa

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

shadowze avatar Dec 14 '20 16:12 shadowze

Indeed, @shadowze nothing happens, when CARGO_REPRESENTABLE:Destroy() is called. Cargo crate remains in game and in the dispatchers tasks list.

baluballa avatar Dec 14 '20 16:12 baluballa

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.

baluballa avatar Dec 14 '20 16:12 baluballa

function CARGO_REPRESENTABLE:Destroy() is not completed.

Un-commenting _EVENTDISPATCHER:CreateEventDeleteCargo( self ) leads to nothing.

baluballa avatar Dec 14 '20 22:12 baluballa

yeah, looks like the code for this stuff is not yet completed

shadowze avatar Dec 15 '20 16:12 shadowze

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.

FlightControl-User avatar Dec 15 '20 18:12 FlightControl-User

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

shadowze avatar Dec 15 '20 18:12 shadowze

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

baluballa avatar Dec 15 '20 19:12 baluballa

@shadowze is this still relevant?

baluballa avatar Jun 05 '22 09:06 baluballa