Fixed warnings generated by go vet
This commit is contained in:
parent
faacfe7fd9
commit
9e1cd272f7
@ -72,7 +72,7 @@ func (c *Controller) StartGame(w http.ResponseWriter, req *http.Request) {
|
||||
if req.Method == "POST" {
|
||||
body, err := ioutil.ReadAll(req.Body)
|
||||
if err != nil {
|
||||
log.Printf("unable to read request body:", err)
|
||||
log.Printf("unable to read request body: %v", err)
|
||||
}
|
||||
req.Body.Close()
|
||||
cfg := struct {
|
||||
|
1
game.go
1
game.go
@ -337,7 +337,6 @@ func (g *Game) run() {
|
||||
g.sendUpdate(payload)
|
||||
}
|
||||
}
|
||||
log.Println("run done")
|
||||
}
|
||||
|
||||
// sendGameOver is a special method that sends a GameOver object to the clients
|
||||
|
@ -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.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{o.Bounds.B.X, o.Bounds.A.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{X: o.Bounds.B.X, Y: o.Bounds.A.Y}).Mag()))
|
||||
|
||||
return float32(dist)
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ encodingLoops:
|
||||
Id: c.Idg.Hash(),
|
||||
Name: name,
|
||||
Health: 10,
|
||||
Heading: v.Vector2d{1, 0},
|
||||
Heading: v.Vector2d{X: 1, Y: 0},
|
||||
Scanners: make([]Scanner, 0),
|
||||
Delta: c.Conf.Delta,
|
||||
idg: c.Idg,
|
||||
|
6
robot.go
6
robot.go
@ -32,8 +32,8 @@ type Robot struct {
|
||||
Hit bool `json:"hit"`
|
||||
Probe *v.Point2d `json:"probe"`
|
||||
ProbeResult *Collision `json:"probe_result"`
|
||||
gameStats *BotStats `json:-`
|
||||
Delta float32 `json:-`
|
||||
gameStats *BotStats `json:"-"`
|
||||
Delta float32 `json:"-"`
|
||||
idg *IdGenerator
|
||||
}
|
||||
|
||||
@ -491,7 +491,7 @@ func (r *Robot) reset(g *Game) {
|
||||
// Check Obstacles
|
||||
retry := false
|
||||
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 {
|
||||
retry = true
|
||||
}
|
||||
|
@ -28,24 +28,24 @@ func TestCollision(t *testing.T) {
|
||||
obstacles: []Obstacle{
|
||||
Obstacle{
|
||||
Bounds: v.AABB2d{
|
||||
v.Point2d{200, 100},
|
||||
v.Point2d{300, 200},
|
||||
A: v.Point2d{X: 200, Y: 100},
|
||||
B: v.Point2d{X: 300, Y: 200},
|
||||
},
|
||||
},
|
||||
Obstacle{
|
||||
Bounds: v.AABB2d{
|
||||
v.Point2d{400, 200},
|
||||
v.Point2d{600, 300},
|
||||
A: v.Point2d{X: 400, Y: 200},
|
||||
B: v.Point2d{X: 600, Y: 300},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
r: Robot{
|
||||
Position: v.Point2d{100, 100},
|
||||
Position: v.Point2d{X: 100, Y: 100},
|
||||
// Heading: v.Vector2d{1, 1},
|
||||
},
|
||||
target: v.Vector2d{900, 350},
|
||||
location: &v.Point2d{200, 138.88889},
|
||||
target: v.Vector2d{X: 900, Y: 350},
|
||||
location: &v.Point2d{X: 200, Y: 138.88889},
|
||||
collision: true,
|
||||
},
|
||||
// shouldn't intersect at all
|
||||
@ -56,16 +56,16 @@ func TestCollision(t *testing.T) {
|
||||
obstacles: []Obstacle{
|
||||
Obstacle{
|
||||
Bounds: v.AABB2d{
|
||||
v.Point2d{200, 100},
|
||||
v.Point2d{300, 200},
|
||||
A: v.Point2d{X: 200, Y: 100},
|
||||
B: v.Point2d{X: 300, Y: 200},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
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,
|
||||
},
|
||||
}
|
||||
@ -103,40 +103,40 @@ func TestProbeResultType(t *testing.T) {
|
||||
obstacles: []Obstacle{
|
||||
Obstacle{
|
||||
Bounds: v.AABB2d{
|
||||
v.Point2d{200, 100},
|
||||
v.Point2d{300, 200},
|
||||
A: v.Point2d{X: 200, Y: 100},
|
||||
B: v.Point2d{X: 300, Y: 200},
|
||||
},
|
||||
},
|
||||
Obstacle{
|
||||
Bounds: v.AABB2d{
|
||||
v.Point2d{400, 200},
|
||||
v.Point2d{600, 300},
|
||||
A: v.Point2d{X: 400, Y: 200},
|
||||
B: v.Point2d{X: 600, Y: 300},
|
||||
},
|
||||
},
|
||||
},
|
||||
players: make(map[*player]bool),
|
||||
players: make(map[*Player]bool),
|
||||
}
|
||||
|
||||
r1 := Robot{
|
||||
Position: v.Point2d{100, 100},
|
||||
Probe: &v.Point2d{900, 350},
|
||||
Position: v.Point2d{X: 100, Y: 100},
|
||||
Probe: &v.Point2d{X: 900, Y: 350},
|
||||
Id: "Bilbo's Bot",
|
||||
}
|
||||
p1 := player{
|
||||
p1 := Player{
|
||||
Robots: []*Robot{&r1},
|
||||
protoTalker: protoTalker{
|
||||
ProtoTalker: ProtoTalker{
|
||||
Id: "bilbo",
|
||||
},
|
||||
}
|
||||
|
||||
r2 := Robot{
|
||||
Position: v.Point2d{100, 200},
|
||||
Probe: &v.Point2d{100, 90},
|
||||
Position: v.Point2d{X: 100, Y: 200},
|
||||
Probe: &v.Point2d{X: 100, Y: 90},
|
||||
Id: "Frodo's Bot",
|
||||
}
|
||||
p2 := player{
|
||||
p2 := Player{
|
||||
Robots: []*Robot{&r2},
|
||||
protoTalker: protoTalker{
|
||||
ProtoTalker: ProtoTalker{
|
||||
Id: "Frodo",
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user