Skip to content

Commit 016d9d7

Browse files
committed
Update server template
1 parent 5eede9d commit 016d9d7

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

templates/new/server/Dockerfile.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.18-bullseye
1+
FROM golang:1.19-bullseye
22

33
# Set working directory for source
44
WORKDIR /usr/src/app

templates/new/server/game.go.tmpl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ func (g *Game) Run() {
2525
if !ok {
2626
break
2727
}
28-
g.handleEvent(cmd.Origin, cmd.Cmd)
28+
g.handleCommand(cmd.Origin, cmd.Cmd)
2929
}
3030
}
3131

3232
func (g *Game) handleCommand(origin *cg.Player, cmd cg.Command) {
3333
switch cmd.Name {
3434
default:
35-
player.Send(cg.ErrorEvent, cg.ErrorEventData{
36-
Message: fmt.Sprintf("unexpected command: %s", cmd.Name),
37-
})
35+
origin.Log.ErrorData(cmd, fmt.Sprintf("unexpected command: %s", cmd.Name))
3836
}
3937
}

templates/new/server/main.go.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ func main() {
4141
server.Run(func(cgGame *cg.Game, config json.RawMessage) {
4242
var gameConfig {{.PackageName}}.GameConfig
4343
err := json.Unmarshal(config, &gameConfig)
44-
cgGame.SetConfig(gameConfig)
44+
if err == nil {
45+
cgGame.SetConfig(gameConfig)
46+
} else {
47+
cgGame.Log.Error("Failed to unmarshal game config: %s", err)
48+
}
4549

4650
{{.PackageName}}.NewGame(cgGame, gameConfig).Run()
4751
})

0 commit comments

Comments
 (0)