From 25d142fb8af48a9529086eace3fa0157ee7097fe Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sat, 8 Jun 2019 23:31:39 +0000 Subject: [PATCH] get rid of system distances function --- scan.go | 4 ++-- system.go | 31 ------------------------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/scan.go b/scan.go index c44749b..fa795fe 100644 --- a/scan.go +++ b/scan.go @@ -43,7 +43,7 @@ func NewScan(origin *System, n Neighborhood) *scan { return &scan{ origin: origin, start: time.Now(), - results: make([]scanResult, 0, len(origin.Distances())), + results: make([]scanResult, 0, len(n)), neighborhood: n, } } @@ -55,7 +55,7 @@ func (s *scan) Tick(game *Game) { } func (s *scan) Dead() bool { - return s.nextEchoIndex >= len(s.origin.Distances()) + return s.neighborhood == nil } func (s *scan) String() string { diff --git a/system.go b/system.go index 8daa006..fc93c1e 100644 --- a/system.go +++ b/system.go @@ -120,37 +120,6 @@ type Ray struct { dist float64 // distance in parsecs } -func (s *System) Distances() []Ray { - if s.distances == nil { - s.distances = make([]Ray, 0, 551) - rows, err := db.Query(` - select edges.id_2, edges.distance - from edges - where edges.id_1 = ? - order by distance - ;`, s.id) - if err != nil { - log_error("unable to query for system distances: %v", err) - return nil - } - for rows.Next() { - var ( - r Ray - id int - dist float64 - ) - if err := rows.Scan(&id, &dist); err != nil { - log_error("unable to unpack Ray from sql result: %v", err) - continue - } - r.s = index[id] - r.dist = dist - s.distances = append(s.distances, r) - } - } - return s.distances -} - func (s *System) Bombed(bomber *Connection, frame int64) { if s.Shield != nil { if s.Shield.Hit() {