Opened 17 years ago

Closed 17 years ago

#196 closed task (duplicate)

Atlas: Problem when removing/deleting units

Reported by: Jan Wassenberg Owned by: Philip Taylor
Priority: Should Have Milestone:
Component: Atlas editor Keywords:
Cc: Patch:

Description

how to duplicate:

load cinematic feb 2007 map
delete all red troops in middle of stream and a few rocks as well
  (rocks are optional, happens with or without them deleted)
start simulation. in debug mode, nothing happens for ~5sec, then it starts
arrows/spears from the invisible removed guys fly
the blue guys are apparently engaging some of these invisible removed guys
after 1..2min, some of the red ones reappear (first one, then clumps of
  2..3 at a  time several seconds apart)
exit without resetting sim state => crash in objecthandlers:722
problem is ~cDeleteObject()'s delete m_UnitInLimbo: the CUnit has
  apparently already been freed and its fields are mostly 0xCDCDCDCD.

DeleteObject::Redo says:

HACK: I don't know the proper way of undoably deleting entities...

And does: unit->GetEntity()->entf_set(ENTF_DESTROYED); I note that CEntity::Kill is doing a lot more work, especially

g_EntityManager.m_refd[me.m_handle] = false; refd must be made false when DESTROYED is set

Could this be the problem, that it's not doing that?

Change History (2)

comment:1 by Philip Taylor, 17 years ago

I think the flag-setting system is just too fragile in this case (where entities are sort-of deleted except not really deleted because it has to be possible to resurrect them), since it depends on the internal details of entity liveness/referencedness/deletedness.

As suggested on the forums, I believe it'll be best for Atlas entity-deletion to just serialise the relevant entity state (like ViewGame::SaveState) then delete the entity for real, and 'undo' can deserialise and recreate the entity. Then Atlas won't have any CEntity* hanging around for longer than one function call, so it won't be able to crash like this.

(I think non-entity deletion should be fine like it is already, just removing the unit from the UnitManager so it doesn't get rendered, since there's nothing fancy going on there; but maybe it'd be nicer for consistency if they were (de)serialised too.)

comment:2 by Philip Taylor, 17 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #189.

Note: See TracTickets for help on using tickets.