Browse Source

Fixed scoping issue

The bug here was that when you would try to start a game it would still be nil
after the block where g was redefined. Just me being sloppy.
master
Stephen McQuay 6 years ago
parent
commit
a3fa670c3d
1 changed files with 2 additions and 1 deletions
  1. +2
    -1
      control.go

+ 2
- 1
control.go View File

@ -66,7 +66,8 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
g := c.Games.get(requested_game_name)
if g == nil {
log.Printf("Game '%s' non-existant; making it now", requested_game_name)
g, err := NewGame(requested_game_name, width, height, obstacles, c.Conf.Tick, maxPoints, mode)
var err error
g, err = NewGame(requested_game_name, width, height, obstacles, c.Conf.Tick, maxPoints, mode)
if err != nil {
log.Printf("problem creating game: %s: %s", requested_game_name, err)
b, _ := json.Marshal(NewFailure("game creation failure"))

Loading…
Cancel
Save