Browse Source

Fixed warnings generated by go vet

Stephen McQuay 5 years ago
parent
commit
9e1cd272f7
6 changed files with 31 additions and 32 deletions
  1. 1
    1
      control.go
  2. 0
    1
      game.go
  3. 2
    2
      obstacle.go
  4. 1
    1
      protocol.go
  5. 3
    3
      robot.go
  6. 24
    24
      robot_test.go

+ 1
- 1
control.go View File

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

+ 0
- 1
game.go View File

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

+ 2
- 2
obstacle.go View File

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

+ 1
- 1
protocol.go View File

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

+ 3
- 3
robot.go View File

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

+ 24
- 24
robot_test.go View File

@@ -28,24 +28,24 @@ func TestCollision(t *testing.T) {
28 28
 				obstacles: []Obstacle{
29 29
 					Obstacle{
30 30
 						Bounds: v.AABB2d{
31
-							v.Point2d{200, 100},
32
-							v.Point2d{300, 200},
31
+							A: v.Point2d{X: 200, Y: 100},
32
+							B: v.Point2d{X: 300, Y: 200},
33 33
 						},
34 34
 					},
35 35
 					Obstacle{
36 36
 						Bounds: v.AABB2d{
37
-							v.Point2d{400, 200},
38
-							v.Point2d{600, 300},
37
+							A: v.Point2d{X: 400, Y: 200},
38
+							B: v.Point2d{X: 600, Y: 300},
39 39
 						},
40 40
 					},
41 41
 				},
42 42
 			},
43 43
 			r: Robot{
44
-				Position: v.Point2d{100, 100},
44
+				Position: v.Point2d{X: 100, Y: 100},
45 45
 				// Heading:  v.Vector2d{1, 1},
46 46
 			},
47
-			target:    v.Vector2d{900, 350},
48
-			location:  &v.Point2d{200, 138.88889},
47
+			target:    v.Vector2d{X: 900, Y: 350},
48
+			location:  &v.Point2d{X: 200, Y: 138.88889},
49 49
 			collision: true,
50 50
 		},
51 51
 		// shouldn't intersect at all
@@ -56,16 +56,16 @@ func TestCollision(t *testing.T) {
56 56
 				obstacles: []Obstacle{
57 57
 					Obstacle{
58 58
 						Bounds: v.AABB2d{
59
-							v.Point2d{200, 100},
60
-							v.Point2d{300, 200},
59
+							A: v.Point2d{X: 200, Y: 100},
60
+							B: v.Point2d{X: 300, Y: 200},
61 61
 						},
62 62
 					},
63 63
 				},
64 64
 			},
65 65
 			r: Robot{
66
-				Position: v.Point2d{100, 100},
66
+				Position: v.Point2d{X: 100, Y: 100},
67 67
 			},
68
-			target:    v.Vector2d{0, 0},
68
+			target:    v.Vector2d{X: 0, Y: 0},
69 69
 			collision: false,
70 70
 		},
71 71
 	}
@@ -103,40 +103,40 @@ func TestProbeResultType(t *testing.T) {
103 103
 		obstacles: []Obstacle{
104 104
 			Obstacle{
105 105
 				Bounds: v.AABB2d{
106
-					v.Point2d{200, 100},
107
-					v.Point2d{300, 200},
106
+					A: v.Point2d{X: 200, Y: 100},
107
+					B: v.Point2d{X: 300, Y: 200},
108 108
 				},
109 109
 			},
110 110
 			Obstacle{
111 111
 				Bounds: v.AABB2d{
112
-					v.Point2d{400, 200},
113
-					v.Point2d{600, 300},
112
+					A: v.Point2d{X: 400, Y: 200},
113
+					B: v.Point2d{X: 600, Y: 300},
114 114
 				},
115 115
 			},
116 116
 		},
117
-		players: make(map[*player]bool),
117
+		players: make(map[*Player]bool),
118 118
 	}
119 119
 
120 120
 	r1 := Robot{
121
-		Position: v.Point2d{100, 100},
122
-		Probe:    &v.Point2d{900, 350},
121
+		Position: v.Point2d{X: 100, Y: 100},
122
+		Probe:    &v.Point2d{X: 900, Y: 350},
123 123
 		Id:       "Bilbo's Bot",
124 124
 	}
125
-	p1 := player{
125
+	p1 := Player{
126 126
 		Robots: []*Robot{&r1},
127
-		protoTalker: protoTalker{
127
+		ProtoTalker: ProtoTalker{
128 128
 			Id: "bilbo",
129 129
 		},
130 130
 	}
131 131
 
132 132
 	r2 := Robot{
133
-		Position: v.Point2d{100, 200},
134
-		Probe:    &v.Point2d{100, 90},
133
+		Position: v.Point2d{X: 100, Y: 200},
134
+		Probe:    &v.Point2d{X: 100, Y: 90},
135 135
 		Id:       "Frodo's Bot",
136 136
 	}
137
-	p2 := player{
137
+	p2 := Player{
138 138
 		Robots: []*Robot{&r2},
139
-		protoTalker: protoTalker{
139
+		ProtoTalker: ProtoTalker{
140 140
 			Id: "Frodo",
141 141
 		},
142 142
 	}

Loading…
Cancel
Save