Fixed warnings generated by go vet

This commit is contained in:
Stephen McQuay 2014-04-14 00:39:42 -07:00
parent faacfe7fd9
commit 9e1cd272f7
6 changed files with 31 additions and 32 deletions

View File

@ -72,7 +72,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
if req.Method == "POST" { if req.Method == "POST" {
body, err := ioutil.ReadAll(req.Body) body, err := ioutil.ReadAll(req.Body)
if err != nil { if err != nil {
log.Printf("unable to read request body:", err) log.Printf("unable to read request body: %v", err)
} }
req.Body.Close() req.Body.Close()
cfg := struct { cfg := struct {

View File

@ -337,7 +337,6 @@ func (g *Game) run() {
g.sendUpdate(payload) g.sendUpdate(payload)
} }
} }
log.Println("run done")
} }
// sendGameOver is a special method that sends a GameOver object to the clients // sendGameOver is a special method that sends a GameOver object to the clients

View File

@ -18,8 +18,8 @@ func (o Obstacle) distance_from_point(p v.Point2d) float32 {
dist = math.Min(dist, float64(p.Sub(o.Bounds.A).Mag())) dist = math.Min(dist, float64(p.Sub(o.Bounds.A).Mag()))
dist = math.Min(dist, float64(p.Sub(o.Bounds.B).Mag())) dist = math.Min(dist, float64(p.Sub(o.Bounds.B).Mag()))
dist = math.Min(dist, float64(p.Sub(v.Point2d{o.Bounds.A.X, o.Bounds.B.Y}).Mag())) dist = math.Min(dist, float64(p.Sub(v.Point2d{X: o.Bounds.A.X, Y: o.Bounds.B.Y}).Mag()))
dist = math.Min(dist, float64(p.Sub(v.Point2d{o.Bounds.B.X, o.Bounds.A.Y}).Mag())) dist = math.Min(dist, float64(p.Sub(v.Point2d{X: o.Bounds.B.X, Y: o.Bounds.A.Y}).Mag()))
return float32(dist) return float32(dist)
} }

View File

@ -306,7 +306,7 @@ encodingLoops:
Id: c.Idg.Hash(), Id: c.Idg.Hash(),
Name: name, Name: name,
Health: 10, Health: 10,
Heading: v.Vector2d{1, 0}, Heading: v.Vector2d{X: 1, Y: 0},
Scanners: make([]Scanner, 0), Scanners: make([]Scanner, 0),
Delta: c.Conf.Delta, Delta: c.Conf.Delta,
idg: c.Idg, idg: c.Idg,

View File

@ -32,8 +32,8 @@ type Robot struct {
Hit bool `json:"hit"` Hit bool `json:"hit"`
Probe *v.Point2d `json:"probe"` Probe *v.Point2d `json:"probe"`
ProbeResult *Collision `json:"probe_result"` ProbeResult *Collision `json:"probe_result"`
gameStats *BotStats `json:-` gameStats *BotStats `json:"-"`
Delta float32 `json:-` Delta float32 `json:"-"`
idg *IdGenerator idg *IdGenerator
} }
@ -491,7 +491,7 @@ func (r *Robot) reset(g *Game) {
// Check Obstacles // Check Obstacles
retry := false retry := false
for _, obj := range g.obstacles { for _, obj := range g.obstacles {
_, inside, _ := v.RectIntersection(obj.Bounds, r.Position, v.Vector2d{0, 0}) _, inside, _ := v.RectIntersection(obj.Bounds, r.Position, v.Vector2d{X: 0, Y: 0})
if inside { if inside {
retry = true retry = true
} }

View File

@ -28,24 +28,24 @@ func TestCollision(t *testing.T) {
obstacles: []Obstacle{ obstacles: []Obstacle{
Obstacle{ Obstacle{
Bounds: v.AABB2d{ Bounds: v.AABB2d{
v.Point2d{200, 100}, A: v.Point2d{X: 200, Y: 100},
v.Point2d{300, 200}, B: v.Point2d{X: 300, Y: 200},
}, },
}, },
Obstacle{ Obstacle{
Bounds: v.AABB2d{ Bounds: v.AABB2d{
v.Point2d{400, 200}, A: v.Point2d{X: 400, Y: 200},
v.Point2d{600, 300}, B: v.Point2d{X: 600, Y: 300},
}, },
}, },
}, },
}, },
r: Robot{ r: Robot{
Position: v.Point2d{100, 100}, Position: v.Point2d{X: 100, Y: 100},
// Heading: v.Vector2d{1, 1}, // Heading: v.Vector2d{1, 1},
}, },
target: v.Vector2d{900, 350}, target: v.Vector2d{X: 900, Y: 350},
location: &v.Point2d{200, 138.88889}, location: &v.Point2d{X: 200, Y: 138.88889},
collision: true, collision: true,
}, },
// shouldn't intersect at all // shouldn't intersect at all
@ -56,16 +56,16 @@ func TestCollision(t *testing.T) {
obstacles: []Obstacle{ obstacles: []Obstacle{
Obstacle{ Obstacle{
Bounds: v.AABB2d{ Bounds: v.AABB2d{
v.Point2d{200, 100}, A: v.Point2d{X: 200, Y: 100},
v.Point2d{300, 200}, B: v.Point2d{X: 300, Y: 200},
}, },
}, },
}, },
}, },
r: Robot{ r: Robot{
Position: v.Point2d{100, 100}, Position: v.Point2d{X: 100, Y: 100},
}, },
target: v.Vector2d{0, 0}, target: v.Vector2d{X: 0, Y: 0},
collision: false, collision: false,
}, },
} }
@ -103,40 +103,40 @@ func TestProbeResultType(t *testing.T) {
obstacles: []Obstacle{ obstacles: []Obstacle{
Obstacle{ Obstacle{
Bounds: v.AABB2d{ Bounds: v.AABB2d{
v.Point2d{200, 100}, A: v.Point2d{X: 200, Y: 100},
v.Point2d{300, 200}, B: v.Point2d{X: 300, Y: 200},
}, },
}, },
Obstacle{ Obstacle{
Bounds: v.AABB2d{ Bounds: v.AABB2d{
v.Point2d{400, 200}, A: v.Point2d{X: 400, Y: 200},
v.Point2d{600, 300}, B: v.Point2d{X: 600, Y: 300},
}, },
}, },
}, },
players: make(map[*player]bool), players: make(map[*Player]bool),
} }
r1 := Robot{ r1 := Robot{
Position: v.Point2d{100, 100}, Position: v.Point2d{X: 100, Y: 100},
Probe: &v.Point2d{900, 350}, Probe: &v.Point2d{X: 900, Y: 350},
Id: "Bilbo's Bot", Id: "Bilbo's Bot",
} }
p1 := player{ p1 := Player{
Robots: []*Robot{&r1}, Robots: []*Robot{&r1},
protoTalker: protoTalker{ ProtoTalker: ProtoTalker{
Id: "bilbo", Id: "bilbo",
}, },
} }
r2 := Robot{ r2 := Robot{
Position: v.Point2d{100, 200}, Position: v.Point2d{X: 100, Y: 200},
Probe: &v.Point2d{100, 90}, Probe: &v.Point2d{X: 100, Y: 90},
Id: "Frodo's Bot", Id: "Frodo's Bot",
} }
p2 := player{ p2 := Player{
Robots: []*Robot{&r2}, Robots: []*Robot{&r2},
protoTalker: protoTalker{ ProtoTalker: ProtoTalker{
Id: "Frodo", Id: "Frodo",
}, },
} }