From 158c7d90d8cc622644c445de0ac3489b9ac8bc50 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Tue, 1 Oct 2013 21:37:53 -0700 Subject: [PATCH] fixed tick bombs --- game.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/game.go b/game.go index 021a100..2b2bf83 100644 --- a/game.go +++ b/game.go @@ -74,6 +74,7 @@ func NewGame(id string, width, height float64) *game { func (g *game) run() { var t0, t1 time.Time payload := NewBoardstate() + ticker := time.NewTicker(time.Duration(*tick) * time.Millisecond) for { select { case <-g.kill: @@ -95,7 +96,7 @@ func (g *game) run() { case s := <-g.sunregister: delete(g.spectators, s) close(s.send) - case <-time.Tick(time.Duration(*tick) * time.Millisecond): + case <-ticker.C: // XXX: This is very racy!! It was at bottom of loop and empty // stuff was going out payload.EmptySlices()