refactor: load/save state as ptr

This commit is contained in:
Ilia Denisov
2026-01-12 19:30:50 +02:00
parent ac60bb3020
commit 4451850f22
18 changed files with 71 additions and 57 deletions
+2 -2
View File
@@ -14,13 +14,13 @@ func GenerateGame(configure func(*controller.Param), races []string) (gameID uui
}
// LoadState used for lock-safe loading game state and may be called concurrently.
func LoadState(configure func(*controller.Param)) (g game.Game, err error) {
func LoadState(configure func(*controller.Param)) (g *game.Game, err error) {
control(configure, func(c *controller.Controller) { g, err = c.Repo.LoadStateSafe() })
return
}
// TODO: command for loading report by players (MUST be limited by router)
func LoadReport(configure func(*controller.Param)) (g game.Game, err error) {
func LoadReport(configure func(*controller.Param)) (g *game.Game, err error) {
control(configure, func(c *controller.Controller) {
c.ExecuteState(func(r controller.Repo) { g, err = c.Repo.LoadState() })
})