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:
parent
330e72c21f
commit
a3fa670c3d
@ -66,7 +66,8 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
|
|||||||
g := c.Games.get(requested_game_name)
|
g := c.Games.get(requested_game_name)
|
||||||
if g == nil {
|
if g == nil {
|
||||||
log.Printf("Game '%s' non-existant; making it now", requested_game_name)
|
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 {
|
if err != nil {
|
||||||
log.Printf("problem creating game: %s: %s", requested_game_name, err)
|
log.Printf("problem creating game: %s: %s", requested_game_name, err)
|
||||||
b, _ := json.Marshal(NewFailure("game creation failure"))
|
b, _ := json.Marshal(NewFailure("game creation failure"))
|
||||||
|
Loading…
Reference in New Issue
Block a user