Skip to content

Commit

Permalink
Fix for error building cache with two stations in the same system
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Nov 21, 2014
1 parent 17dc9b5 commit 3d739de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
14 changes: 5 additions & 9 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,15 +716,11 @@ def generateStationLink(tdenv, db):
lhs.station_id AS lhs_station_id,
rhs.system_id AS rhs_system_id,
rhs.station_id AS rhs_station_id,
case when lhs.system_id != rhs.system_id then
sqrt(
((lSys.pos_x - rSys.pos_x) * (lSys.pos_x - rSys.pos_x)) +
((lSys.pos_y - rSys.pos_y) * (lSys.pos_y - rSys.pos_y)) +
((lSys.pos_z - rSys.pos_z) * (lSys.pos_z - rSys.pos_z))
)
else
0.00
end
sqrt(
((lSys.pos_x - rSys.pos_x) * (lSys.pos_x - rSys.pos_x)) +
((lSys.pos_y - rSys.pos_y) * (lSys.pos_y - rSys.pos_y)) +
((lSys.pos_z - rSys.pos_z) * (lSys.pos_z - rSys.pos_z))
) AS dist
FROM Station AS lhs
INNER JOIN System AS lSys
ON (lhs.system_id = lSys.system_id),
Expand Down
2 changes: 1 addition & 1 deletion data/TradeDangerous.sql
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ CREATE TABLE StationLink
lhs_station_id INTEGER NOT NULL,
rhs_system_id INTEGER NOT NULL,
rhs_station_id INTEGER NOT NULL,
dist DOUBLE NOT NULL CHECK (dist > 0.0),
dist DOUBLE NOT NULL CHECK (dist > 0.0 or lhs_system_id == rhs_system_id),
PRIMARY KEY (lhs_station_id, rhs_station_id)
) WITHOUT ROWID
;
Expand Down

0 comments on commit 3d739de

Please sign in to comment.