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.
This commit is contained in:
Stephen McQuay 2014-03-29 01:24:20 -07:00
parent 330e72c21f
commit a3fa670c3d

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"))