#1999 closed defect (fixed)
[PATCH] Cleaning of OnDestroy in UnitAI
Reported by: | mimo | Owned by: | leper |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 14 |
Component: | UI & Simulation | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
In UnitAI, when a unit is destroyed, the leave method of its current state is not called, thus forcing to dupplicate some code in the OnDestroy method. Presently, there are some code to clean timers or update some counters. But working on #1391 I would need to add more.These would become useless if we are sure the leave method is always called. Here is a patch to fix that.
Attachments (1)
Change History (8)
by , 11 years ago
Attachment: | destroy.diff added |
---|
comment:1 by , 11 years ago
Milestone: | Backlog → Alpha 15 |
---|
comment:2 by , 11 years ago
Description: | modified (diff) |
---|
comment:3 by , 11 years ago
Summary: | [PATCH]Cleaning of OnDestroy in UnitAI → [PATCH] Cleaning of OnDestroy in UnitAI |
---|
comment:4 by , 11 years ago
Component: | Core engine → UI & Simulation |
---|
comment:5 by , 11 years ago
Not sure the DESTROY state is really usefull. The idea of the patch is to switch to a "nostate" state to be sure to leave all previously entered states, so no need to enter a new state. But if people prefer the DESTROY state, let me know, I can modify the patch.
while we are at it, my first idea was to switch to a really empty state, i.e. SwitchToNextState(this, "") but this gave a crash because I think line 353 of simulation/helpers/FSM.js should be
if (obj.fsmReenter && equalPrefix === toState.length && equalPrefix != 0)
instead of
if (obj.fsmReenter && equalPrefix === toState.length)
comment:7 by , 11 years ago
Keywords: | review removed |
---|---|
Milestone: | Alpha 15 → Alpha 14 |
Good that the FSM has a "" state by default, as that is really the cleanest solution IMO. Thanks for the patch.
Wouldn't introducing a new state (possibly named
DESTROY
) and switching to that be nicer? Apart from that I really like the change.