Refactor PlaybackSerialiser
Part 3 of my ongoing quest to refactor the mod.
While the first PR (#179) was hooking into the vanilla code,
the second PR (#200) was about storing the inputs and metadata in RAM.
In this PR I will tackle the task of storing all the inputs we recorded to the file.
Current
The current system is (as always) a hardcoded mess of stuff somewhat randomly put together...
Now with a bit more experience under my belt, I should be able to upgrade whatever I wrote 3 years ago...
TODO
CustomSerialisers
- [ ] Create a serialiser registry, so it's easy to create your own TASfile Syntax
- [ ] Create a base class that all serialisers need to extend from
- [ ] Convert the old serialiser to the new format
- [ ] Create new serialiser that supports the new VirtualInputFormat
- [ ] #183
- [ ] #184
PlaybackExtensions
- [ ] Add PlaybackExtensionRegistry
- [ ] Convert DesyncMonitor to extension
- [ ] Convert ControlBytes to extension
Note to self: Do new registry stuff
Note to self: Continue doing registry stuff! Then make a new one for flavors and start writing the new system!
Note to self: Continue on PlaybackFlavorBase and BetaFlavor. Get unit tests up and running for flavors to be able to test them!
Note to self: Deserialiser time!
Alright, code seems to be finished but everything is totally untested..
So now all thats left is writing tests, error handling and documentation... And writing the actual file format but that is quite easy at this point...
Note to self:
- [x] Test mouse deserialisation
- [x] Test camera deserialisation
- [x] Test isNumeric
- [x] Test isFloat
- [x] Test deserialiseContainer
- [x] Add extracting comments and extracting tick
- [x] Test splitContainer
- [x] Add test to PlaybackSerialiser
- [x] Add error handling
- [x] Test stuff with error handling
Read to merge? /j
Note to self:
Remove filecommand parameter nonsense from FlavorBase...
Move all handling to the FileCommandRegistry. Enable file command extensions through that system statically instead passing the list of enabled stuff through the Flavor...
Serialise everything in serialiseInline and serialiseEndline comments. Let's finish this damn module!
Alright, I finally have a somewhat good grip on how to handle filecommands and how to combine 2 APIs together in a good way...
I have now offloaded the handling code to the FileCommandRegistry as that part should not be editable via the API.
Messy serialising code as I somehow have to convert a 2 dimensional list like this:
List {
List{
$desyncMonitor(); // A command handled by the desyncMonitorExtension
$desyncMonitor(); // A second command in the next subtick handled by the desyncMonitorExtension
$desyncMonitor();
$desyncMonitor();
$desyncMonitor();
$desyncMonitor();
}
List{
$interpolation(true); // A command handled by the interpolationExtension
$interpolation(false); // A second command in the next subtick
$interpolation(true);
$interpolation(true);
$interpolation(true);
$interpolation(true);
}
}
which is ideal for storing the commands, when each extension stores all of their PlaybackFileCommands themselves to something like this:
List{
List{ // This is now a list of PlaybackCommands
$desyncMonitor();
$interpolation(true);
}
List{
$desyncMonitor();
$interpolation(false);
}
List{
$desyncMonitor();
$interpolation(true);
}
// etc...
}
which is ideal for serialisation as one List now contains all FileCommands for one subtick...
Now the first subtick can easily be serialised to // $desyncMonitor(); $interpolation(true); A comment!.
Best part is, that I have to do the reverse now for deserialisation...
So, note to self:
- Implement
handleOnDeserialisationin PlaybackRegistry - Fix Disabled tests
- Test the s*** out of everything
Note to self: Allow null in PlaybackFileCommandContainer
Note to self:
Allow null in PlaybackFileCommandContainer Nevermind, fixed it already...
- Test numerical keycodes being serialised and deserialised correctly
- Test and add ErrorHandling
Note to self:
- [x] Test relative values in TASfile
- [x] Test error when flavor can not be found
Final stretch! Note to self:
- [x] Upgrade networking of
/saveand/loadto account for flavors - [x] Add default flavor on client for quicker saving
- [x] Hook up the serialiser with savestates
Note to self:
- [x] Remove camera angle stuff in file ~~- [ ] Add K, M, C~~
Note to self:
- [x] Add command for fileCommands
- [x] Add config option for file commands
:partying_face: :partying_face: :partying_face: :partying_face: :partying_face: you'll be getting my full review in approx 3-5 business days