Opened 12 years ago

Closed 12 years ago

#1394 closed defect (fixed)

Instant serialization test failure

Reported by: historic_bruno Owned by: philip
Priority: Release Blocker Milestone: Alpha 10
Component: Core engine Keywords:
Cc: Philip Taylor Patch:

Description

Must enable CSimulation2Impl::m_EnableSerializationTest, then you will get an instant serialization test failure. This is in single player mode, any map, with or without AI. Attaching contents of oos_log.

Attachments (1)

oos_log.7z (142.2 KB ) - added by historic_bruno 12 years ago.

Download all attachments as: .zip

Change History (4)

by historic_bruno, 12 years ago

Attachment: oos_log.7z added

comment:1 by historic_bruno, 12 years ago

Cc: Philip Taylor added

comment:2 by Philip Taylor, 12 years ago

Serialization test mode is incompatible with AI (since we don't serialize AI properly yet), so that's not a relevant case.

The problem occurs on an empty map with a single unit, when you give a command to that unit. AIProxy.changes.unitAIState doesn't get set in the deserialized instance of the game. That's because r11429 added a property to FSM that is a reference to a function assigned by UnitAI.prototype.OnCreate, which is broken since the FSM object is a global object - firstly each newly created unit will overwrite the values any previous units stored in that property of the global UnitFsm, and secondly (since globals aren't serialized) the property will be undefined if no new units were created (e.g. if the game state was recently deserialized).

If FSM.prototype.Init is to store any persistent state, it needs to be per-entity state on obj (like the current obj.fsmStateName). Also the value can't be a function, it'd need to be a string naming the function.

But I don't see any value in having this be a configurable property anyway - FSM can just call something like obj.FsmStateNameChanged(obj.fsmStateName) directly, which is simpler.

comment:3 by philip, 12 years ago

Owner: set to philip
Resolution: fixed
Status: newclosed

In 11802:

Fix #1394 (UnitAI FSM serialization error).
Replace evil eval/uneval with deepcopy.

Note: See TracTickets for help on using tickets.