Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	corrections.py
  • Loading branch information
maddavo committed Dec 18, 2014
2 parents 2bb2645 + 3f01f61 commit cb711ea
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 73 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
TradeDangerous, Copyright (C) Oliver "kfsone" Smith, July 2014
==============================================================================

v6.2.3 [wip]
. (kfsone) Changed "nav" to show station count with "-v" instead of "--stations"
. (kfsone) Removed the StationLink table - cache builds should be MUCH faster

v6.2.2 Dec 17 2014
. (kfsone) Removed Alloys, Combat Stabilisers, Cotton and Plastics
[there was no entry for them anywhere in the price database]
Expand Down
27 changes: 0 additions & 27 deletions cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,31 +775,6 @@ def processImportFile(tdenv, db, importPath, tableName):
table=tableName)


def generateStationLink(tdenv, db):
tdenv.DEBUG0("Generating StationLink table")
db.create_function("sqrt", 1, math.sqrt)
db.execute("""
INSERT INTO StationLink
SELECT lhs.system_id AS lhs_system_id,
lhs.station_id AS lhs_station_id,
rhs.system_id AS rhs_system_id,
rhs.station_id AS rhs_station_id,
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),
Station AS rhs
INNER JOIN System AS rSys
ON (rhs.system_id = rSys.system_id)
WHERE
lhs.station_id != rhs.station_id
""")
db.commit()


######################################################################

Expand Down Expand Up @@ -858,8 +833,6 @@ def buildCache(tdb, tdenv):
str(pricesPath)
), file=sys.stderr)

generateStationLink(tdenv, tempDB)

tempDB.close()

tdenv.DEBUG0("Swapping out db files")
Expand Down
2 changes: 1 addition & 1 deletion commands/export_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]

# some tables are ignored
ignoreList = [ 'StationLink',
ignoreList = [
]

######################################################################
Expand Down
8 changes: 1 addition & 7 deletions commands/nav_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
'the system that station is in will be avoided instead.',
action='append',
),
ParseArgument('--stations',
help='Show system\'s stations',
dest='showstations',
action='store_true',
default=False
),
]

######################################################################
Expand Down Expand Up @@ -188,7 +182,7 @@ def render(results, cmdenv, tdb):
key=lambda row: row.system.name())
rowFmt.addColumn("JumpLy", '>', '7', '.2f',
key=lambda row: row.jumpLy)
if cmdenv.showstations:
if cmdenv.detail:
rowFmt.addColumn("Stations", '>', 2,
key=lambda row: len(row.system.stations))
if cmdenv.detail:
Expand Down
4 changes: 2 additions & 2 deletions commands/update_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def validate(self, widget):
# It seems that stations usually pay within 25% of the
# asking price as a buy-back price. If the user gives
# us something out of those bounds, check with them.
if paying < int(asking * 0.75) or \
paying < asking - 200:
if paying < int(asking * 0.72) or \
paying < asking - 250:
widget.bell()
ok = mbox.askokcancel(
"Are you sure about that?",
Expand Down
5 changes: 5 additions & 0 deletions corrections.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
'COTTON': DELETED,
'ALLOYS': DELETED,
'PLASTICS': DELETED,
'CONSUMER TECH': 'Consumer Technology',
'DOM. APPLIANCES': 'Domestic Appliances',
'FRUIT AND VEGETABLES': 'Fruit And Vegetables',
'NON-LETHAL WPNS': 'Non-Lethal Weapons',

}

def correctSystem(oldName):
Expand Down
6 changes: 3 additions & 3 deletions data/AltItemNames.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
unq:[email protected]_id,unq:[email protected]_id,unq:alt_name
'Consumer Items','Consumer Tech','consumertechnology'
'Consumer Items','Dom. Appliances','domesticappliances'
'Consumer Items','Consumer Technology','consumertechnology'
'Consumer Items','Domestic Appliances','domesticappliances'
'Legal Drugs','Narcotics','basicnarcotics'
'Machinery','Microbial Furnaces','heliostaticfurnaces'
'Medicines','Agri-Medicines','agriculturalmedicines'
'Technology','H.E. Suits','hazardousenvironmentsuits'
'Technology','Land Enrichment Systems','terrainenrichmentsystems'
'Weapons','Non-Lethal Wpns','nonlethalweapons'
'Weapons','Non-Lethal Weapons','nonlethalweapons'
'Weapons','Reactive Armour','reactivearmour'
8 changes: 4 additions & 4 deletions data/Item.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ unq:[email protected]_id,unq:name,ui_order
'Chemicals','Mineral Oil',3
'Chemicals','Pesticides',4
'Consumer Items','Clothing',1
'Consumer Items','Consumer Tech',2
'Consumer Items','Dom. Appliances',3
'Consumer Items','Consumer Technology',2
'Consumer Items','Domestic Appliances',3
'Foods','Algae',1
'Foods','Animal Meat',2
'Foods','Coffee',3
'Foods','Fish',4
'Foods','Food Cartridges',5
'Foods','Fruit and Vegetables',6
'Foods','Fruit And Vegetables',6
'Foods','Grain',7
'Foods','Synthetic Meat',8
'Foods','Tea',9
Expand Down Expand Up @@ -76,6 +76,6 @@ unq:[email protected]_id,unq:name,ui_order
'Waste','Chemical Waste',2
'Waste','Scrap',3
'Weapons','Battle Weapons',1
'Weapons','Non-Lethal Wpns',2
'Weapons','Non-Lethal Weapons',2
'Weapons','Personal Weapons',3
'Weapons','Reactive Armour',4
29 changes: 0 additions & 29 deletions data/TradeDangerous.sql
Original file line number Diff line number Diff line change
Expand Up @@ -252,19 +252,6 @@ CREATE TABLE StationBuying
/* We're often going to be asking "using (item_id) where buying.price > selling.cost" */
CREATE INDEX idx_buying_price ON StationBuying (item_id, price);

CREATE TABLE StationLink
(
lhs_system_id INTEGER NOT NULL,
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 or lhs_system_id == rhs_system_id),
PRIMARY KEY (lhs_station_id, rhs_station_id)
) WITHOUT ROWID
;
CREATE INDEX idx_stn_dist ON StationLink (lhs_station_id, dist);
CREATE INDEX idx_sys_dist ON StationLink (lhs_system_id, dist, rhs_system_id);

CREATE VIEW vPrice AS
SELECT si.station_id AS station_id,
si.item_id AS item_id,
Expand Down Expand Up @@ -307,21 +294,5 @@ CREATE VIEW vProfits AS
;


CREATE VIEW vProfitableTrades AS
SELECT src.station_id AS src_station_id,
src.item_id AS item_id,
dst.station_id AS dst_station_id,
src.price AS cost,
dst.price - src.price AS profit,
link.dist AS dist
FROM StationSelling AS src
INNER JOIN StationBuying AS dst
ON (src.item_id = dst.item_id AND dst.price > src.price)
INNER JOIN StationLink AS link
ON (src.station_id = link.lhs_station_id
AND dst.station_id = link.rhs_station_id)
;


COMMIT;

0 comments on commit cb711ea

Please sign in to comment.