TASmod icon indicating copy to clipboard operation
TASmod copied to clipboard

Refactor PlaybackSerialiser

Open ScribbleTAS opened this issue 1 year ago • 4 comments

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

ScribbleTAS avatar Apr 14 '24 12:04 ScribbleTAS

Note to self: Do new registry stuff

ScribbleTAS avatar May 07 '24 20:05 ScribbleTAS

Note to self: Continue doing registry stuff! Then make a new one for flavors and start writing the new system!

ScribbleTAS avatar May 08 '24 20:05 ScribbleTAS

Note to self: Continue on PlaybackFlavorBase and BetaFlavor. Get unit tests up and running for flavors to be able to test them!

ScribbleTAS avatar May 09 '24 20:05 ScribbleTAS

Note to self: Deserialiser time!

ScribbleTAS avatar May 10 '24 20:05 ScribbleTAS

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

ScribbleTAS avatar May 20 '24 19:05 ScribbleTAS

Read to merge? /j

PancakeTAS avatar May 20 '24 20:05 PancakeTAS

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!

ScribbleTAS avatar Jun 07 '24 20:06 ScribbleTAS

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 handleOnDeserialisation in PlaybackRegistry
  • Fix Disabled tests
  • Test the s*** out of everything

ScribbleTAS avatar Jun 08 '24 19:06 ScribbleTAS

Note to self: Allow null in PlaybackFileCommandContainer

ScribbleTAS avatar Jun 13 '24 13:06 ScribbleTAS

Note to self:

Allow null in PlaybackFileCommandContainer Nevermind, fixed it already...

  • Test numerical keycodes being serialised and deserialised correctly
  • Test and add ErrorHandling

ScribbleTAS avatar Jun 13 '24 13:06 ScribbleTAS

Note to self:

  • [x] Test relative values in TASfile
  • [x] Test error when flavor can not be found

ScribbleTAS avatar Jun 20 '24 21:06 ScribbleTAS

Final stretch! Note to self:

  • [x] Upgrade networking of /save and /load to account for flavors
  • [x] Add default flavor on client for quicker saving
  • [x] Hook up the serialiser with savestates

ScribbleTAS avatar Jun 28 '24 18:06 ScribbleTAS

Note to self:

  • [x] Remove camera angle stuff in file ~~- [ ] Add K, M, C~~

ScribbleTAS avatar Jul 03 '24 19:07 ScribbleTAS

Note to self:

  • [x] Add command for fileCommands
  • [x] Add config option for file commands

ScribbleTAS avatar Jul 08 '24 21:07 ScribbleTAS

:partying_face: :partying_face: :partying_face: :partying_face: :partying_face: you'll be getting my full review in approx 3-5 business days

PancakeTAS avatar Jul 10 '24 22:07 PancakeTAS