LiveSplit / livesplit-core

livesplit-core is a library that provides a lot of functionality for creating a speedrun timer.
https://livesplit.org/
Apache License 2.0
209 stars 57 forks source link

Make invalid timer states unrepresentable #818

Closed CryZe closed 3 months ago

CryZe commented 3 months ago

This refactors the internals of the Timer, such that it's impossible for different fields to contain conflicting information. This is done by factoring out an ActiveAttempt struct that only exists when there is an active attempt. Additionally inside it differentiates between the attempt having ended or not. The not ended state has a split index and an optional pause time, whereas the ended state has the date time of when the attempt ended.

This does not yet touch the public API of the Timer. Factoring out the notion of an active attempt and making sure invalid states are unrepresentable is done so we can soon explore the possibility of storing an active attempt in the splits file.

cc #266 #156