Documentation
¶
Overview ¶
Package save persists and restores the simulation World as JSON.
The on-disk envelope ships a richer header from day one — version, generator, clock_t0, body_catalog_hash, payload — so future schema migrations and the v0.6 multiplayer `session` block can land without bumping every caller. See docs/state-of-game.md §3 v0.4.0 for the rationale.
Index ¶
Constants ¶
const SchemaVersion = 1
SchemaVersion is the on-disk version. v0.4.0 ships v1; later schema changes bump and migrate.
Variables ¶
var ( ErrSchemaMismatch = errors.New("save: schema version mismatch") ErrCatalogMismatch = errors.New("save: body catalog hash mismatch") ErrCraftPrimary = errors.New("save: craft primary not found in loaded systems") )
Errors returned by Load.
Functions ¶
func DefaultPath ¶
DefaultPath returns the platform-appropriate save path. Honors $XDG_STATE_HOME on linux/macOS; falls back to ~/.local/state. Windows users can set $XDG_STATE_HOME explicitly.
Types ¶
type ActiveBurn ¶
type ActiveBurn struct {
Mode int `json:"mode"`
DVRemaining float64 `json:"dv_remaining"`
EndTimeNano int64 `json:"end_time_unix_nano"`
PrimaryID string `json:"primary_id"`
}
ActiveBurn mirrors sim.ActiveBurn.
type Craft ¶
type Craft struct {
Name string `json:"name"`
DryMass float64 `json:"dry_mass"`
Fuel float64 `json:"fuel"`
Isp float64 `json:"isp"`
Thrust float64 `json:"thrust"`
PrimaryID string `json:"primary_id"`
R Vec3 `json:"r"`
V Vec3 `json:"v"`
M float64 `json:"m"`
}
Craft mirrors spacecraft.Spacecraft. Primary is referenced by ID; the rehydrated value is looked up across loaded systems on Load.
type File ¶
type File struct {
Version int `json:"version"`
Generator string `json:"generator"`
ClockT0 int64 `json:"clock_t0"`
BodyCatalogHash string `json:"body_catalog_hash"`
Payload Payload `json:"payload"`
}
File is the on-disk envelope.
type Node ¶
type Node struct {
TriggerTimeNano int64 `json:"trigger_time_unix_nano"`
Mode int `json:"mode"`
DV float64 `json:"dv"`
DurationNano int64 `json:"duration_nano"`
PrimaryID string `json:"primary_id"`
}
Node mirrors sim.ManeuverNode.
type Payload ¶
type Payload struct {
SystemIdx int `json:"system_idx"`
SimTimeNano int64 `json:"sim_time_unix_nano"`
BaseStepNano int64 `json:"base_step_nano"`
WarpIdx int `json:"warp_idx"`
Paused bool `json:"paused"`
Focus Focus `json:"focus"`
Craft *Craft `json:"craft,omitempty"`
Nodes []Node `json:"nodes,omitempty"`
ActiveBurn *ActiveBurn `json:"active_burn,omitempty"`
}
Payload carries the live simulation state. Anything derivable from the catalog (Systems, Calculator) is reconstructed on Load.