jonoxia / rpgbase

Generic Node.js/HTML5 role-playing game client/server
8 stars 6 forks source link

On saved game load, new PlotManager is created but keyboard input still goes to old PlotManager #94

Closed jonoxia closed 9 years ago

jonoxia commented 9 years ago

This is the cause of the bug where a plot point will freeze. The NPC dialog cannot be dismissed because the keyboard input is going to the old PlotManager's dialoglog (which has no windows to respond to input) while the new PlotManager's dialoglog is the one that contains the dialog windows. This only happens after loading a saved game, however.

It happens because PlotManager is a serializable subobject of GenericRPG, so when GenericRPG is deserialized, a new PlotManager is instantiated. But the inputDispatcher is not changed, and it has callback functions with closures pointing to the old plotManager's dialoglog.

Simplest solution is probably to separate the part of the PlotManager that needs to be serialized (flags, miscStorage) from the part that needs to be an immutable singleton (the dlog)