fix(saveslot): carry accrued playtime onto a copied slot - #785
Open
buildthomas wants to merge 1 commit into
Open
fix(saveslot): carry accrued playtime onto a copied slot#785buildthomas wants to merge 1 commit into
buildthomas wants to merge 1 commit into
Conversation
Copying a slot -- PromiseDuplicateSlot, or an export/import round trip -- seeded the new slot with only its name and summary, so the copy read as 0 time played even though it carries the same progress. Playtime now travels with the progress it measures: SaveSlotCreateMetadata takes an optional TimePlayed, the duplicate and import paths pass the source's value through, and the export carries it as `timePlayed`. Both paths flush the live play session first, so copying the active slot includes the current session rather than only what was last saved. Backwards compatible in both directions: exports written before this lack `timePlayed` and import exactly as they did before (a slot with no accrued playtime), and the field is validated as an optional number so a malformed one is still refused. Timestamps and session counters (PlayCount, LastSessionLength) still start fresh on a copy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Copying a save slot loses its playtime — the copy shows as 0 time played even though it carries the same progress.
Both copy paths seed the new slot with only
SlotNameandSummary:HasSaveSlots.PromiseDuplicateSlotpasses those two toPromiseCreateSlotPromiseExportSlotbuilds aSaveSlotExportof{data, slotName, summary}, andPromiseImportSlotseeds the new slot from thoseTimePlayedis never part of that hand-off, so it starts nil on every copy.Fix
Playtime travels with the progress it measures:
SaveSlotCreateMetadatatakes an optionalTimePlayed, applied inPromiseCreateSlot(it is already one ofMUTABLE_METADATA_KEYS, so_buildSlotpersists it like any other metadata field)PromiseDuplicateSlotandPromiseImportSlotpass the source's value throughSaveSlotExportgainstimePlayed, written byPromiseExportSlotand validated as an optional number byisSaveSlotExport_flushPlaytime()first, so copying the active slot includes the running session rather than only what the last save wroteTimestamps and session counters (
PlayCount,LastSessionLength) still start fresh on a copy — those describe the new slot's own sessions, not the progress being copied.Backwards compatibility
timePlayed; they still validate and import to a slot with no accrued playtime, exactly as they did when writtenTimePlayedwas already an optional attribute, this only seeds it at creationSaveSlotExportUtils.creategained a trailing optional parameter, so existing 3-argument callers are unaffectedTimePlayedin the create metadata is not a new trust surface:PromiseSetSlotMetadatais already client-callable and accepts the fullSaveSlotMetadata,TimePlayedincluded.Tests
New coverage in
HasSaveSlots.spec.lua(duplicate carries playtime including the unflushed live session; a never-played slot's copy still has none),HasSaveSlots.ExportImport.spec.lua(export/import round-trips playtime, exports the live session, imports a pre-change export, refuses a non-numerictimePlayed), andSaveSlotExportUtils.spec.lua(create/validation).stylua and selene pass. I could not run
nevermore test --cloudhere — no Open Cloud key in this environment, and the localrojoshim is broken on this machine — so the new specs have not been executed against the engine.