-
-
Notifications
You must be signed in to change notification settings - Fork 377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a recovery reader for the v90 flight log #5763
Add a recovery reader for the v90 flight log #5763
Conversation
Pinging in @JonBooth78 |
|
||
}, { | ||
|
||
version = 90, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this hardcoding of the version need to be updated or changed at some point? Or it's only there while we want to have compatibility with versions prior to 90?
(Sorry, I'm too lazy to read the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This number is here so that the following function is called for saves v90 and newer. Immediately before you can see the function for v89, it will be called when restoring saves v89 and older. This list can grow on both sides to support older and newer save versions.
I'm concerned about a couple of things here. Firstly, I'm not a fan of renaming the |
My second concern here is we're moving to a world where we maintain 2 versions of the flight log code - both serialization and UI, one for in-game and one for restoration. This is very far from ideal as it essentially will make it twice as hard to evolve that part of the game and makes it brittle and hard to maintain. So I'd actually like look at consolidating it all together. I've not had time to dig into this far enough but I think this means that loading of flight-logs should always goes through the 'restore' path somehow, or that we have a common interface for deserialization that they both conform to in order to provide the POD that needs interpreting. Similarly we should provide a 'flightlog' UI element that can be embedded elsewhere and is configurable. All of this is possible and I think we should consider as the architectural end-goal. None of this stops the usefulness of where we are now; I love the restore function and I'm happy for this kind of change until we (perhaps I - I'm happy to add it to my list) have time to address that architectural issue. |
@JonBooth78 regarding the
Regarding the two versions of the UI and deserialization, I agree with you. I would like to note that the problem of GUI reuse most likely relates not to recovery, but to the new game start menu. There are examples of GUI reuse - The problem of reusing deserialization seems to me on the one hand more complex - I think that in order to fully reuse this, we need to run the full process of loading the game, but we can hardly do this for the old save, but that's the essence of recovery. pioneer/data/modules/FlightLog/FlightLog.lua Line 440 in 2619555
The code you wrote to support previous version is not actually needed (just this could be transferred to the recovery area, but the recovery is already there, so you can just delete it). But overall, this is a very interesting topic to think about, and there is definitely room for improvement. |
Note: you could also create one "dummy" metatable per unique
I would strongly recommend this field either remain |
Perhaps I wasn't specific enough, the name |
@Web-eWorks Implemented what was suggested in fixup commit (about metatables). |
Darn, it seems like my change from I think I should look at re-tidying this up. Re: the versioning code; it's actually very handy to have in the flight log as then one can change this without having to recover or version bump the entire thing :-) The whole |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane to me, sorry about the delay in reviewing. I'd suggest this PR also remove the Version == 1
migration code present in the FlightLog itself, since that should now be entirely handled by the savegame recovery code (as saves with the previous version of flight log data are no longer compatible).
In the fixupDoc function, serialized Lua objects are turned into regular tables, and type information is lost. But it turned out to be needed to restore the v90 flight log, since it uses a single "polymorphic" array of records. Therefore we use dummy metatables to store type information.
The v90 flight log uses a hash table for the entries and the names of some fields do not match those from the recovery. Renamed in recovery related routines for compatibility: - rename arbitrary field from 'text' to 'entry' - in the station log, change the 'time' field to 'deptime'
It can't be called anyway, because v89 is considered incompatible and its deserialization doesn't start
101b552
to
98bf8ae
Compare
Forced a fixup commit with a small amendment and removed the in-game migration code. |
Although the flight log is now a single list, it still has the same three types of entries. Therefore it can still be shown without changing the GUI in the start menu, where 3 sections (entry types) are shown separately, depending on the combobox.
It is now possible to determine the log entry type only by the object type, which becomes available after full deserialization. But I would not want to do this, including reusing the actual code from the game, since it may change over time. Information about the object type is contained in the
lua_class
field, which is lost when the save tree is unpickled. In order to save this information, and at the same time not change anything radically in the unpickled tree, it was decided to put all type names into one separate subtable in the save tree,type_names
, the keys in which will be the tables corresponding to the unpickled objects.