Persist current world history
All checks were successful
build-windows-exe / build (push) Successful in 1m50s

This commit is contained in:
messypy
2026-07-28 00:51:15 +09:00
parent 8e704980c1
commit 70bafabee9
3 changed files with 40 additions and 6 deletions

View File

@@ -25,6 +25,7 @@ type WorldVisit struct {
type worldHistorySnapshot struct {
UpdatedAt time.Time `json:"updated_at"`
Visits []WorldVisit `json:"visits"`
Current *WorldVisit `json:"current,omitempty"`
}
type WorldHistoryTracker struct {
@@ -61,6 +62,10 @@ func (t *WorldHistoryTracker) load() error {
return err
}
t.visits = mergeWorldVisits(snap.Visits)
if snap.Current != nil && !snap.Current.StartedAt.IsZero() {
current := *snap.Current
t.current = &current
}
return nil
}
@@ -188,6 +193,7 @@ func (t *WorldHistoryTracker) persistLocked() error {
return enc.Encode(worldHistorySnapshot{
UpdatedAt: time.Now(),
Visits: mergeWorldVisits(t.visits),
Current: t.current,
})
}