From 1dc2950eb9284df214f3c0600d7eeaeccdf36d52 Mon Sep 17 00:00:00 2001 From: Jack Edge Date: Sun, 26 Jun 2016 20:08:50 +0100 Subject: [PATCH] Fixes all bugs; exports now work --- code/modules/cargo/export_scanner.dm | 23 +++++++++-------------- code/modules/cargo/exports.dm | 11 +++++++---- code/modules/shuttle/supply.dm | 19 ++++++++++--------- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/code/modules/cargo/export_scanner.dm b/code/modules/cargo/export_scanner.dm index ffbfa05fe1c..490a4af375f 100644 --- a/code/modules/cargo/export_scanner.dm +++ b/code/modules/cargo/export_scanner.dm @@ -25,18 +25,13 @@ else if(!istype(cargo_console)) user << "You must link [src] to a cargo console first!" else - var/obj/docking_port/mobile/supply/supply = SSshuttle.supply - if(!supply) - user << "Falied to connect to exports database!" - return + // Before you fix it: + // yes, checking manifests is a part of intended functionality. + var/price = export_item_and_contents(O, cargo_console.contraband, cargo_console.emagged, dry_run=TRUE) - user << "Scanned [O]." - - // Before you fix it: yes, checking manifests is a part of intended functionality. - var/price = export_item_and_contents(O, supply.exports, cargo_console.contraband, cargo_console.emagged, dry_run=TRUE) - - if(price) - user << "Export value: [price] \ - credits." - if(O.contents.len) - user << "(contents included)" + if(price) + user << "Scanned [O], value: [price] \ + credits[O.contents.len ? " (contents included)" : ""]." + else + user << "Scanned [O], no export value. \ + " diff --git a/code/modules/cargo/exports.dm b/code/modules/cargo/exports.dm index 98f4e14099e..b920c6dd4c1 100644 --- a/code/modules/cargo/exports.dm +++ b/code/modules/cargo/exports.dm @@ -26,7 +26,10 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they then the player gets the profit from selling his own wasted time. */ -/proc/export_item_and_contents(atom/movable/AM, exports, contraband, emagged, dry_run=FALSE) +/proc/export_item_and_contents(atom/movable/AM, contraband, emagged, dry_run=FALSE) + if(!exports_list.len) + setupExports() + var/sold_str = "" var/cost = 0 @@ -34,8 +37,8 @@ Credit dupes that require a lot of manual work shouldn't be removed, unless they // We go backwards, so it'll be innermost objects sold first for(var/i in reverseRange(contents)) - var/atom/movable/thing - for(var/datum/export/E in exports) + var/atom/movable/thing = i + for(var/datum/export/E in exports_list) if(!E) continue if(E.applies_to(thing, contraband, emagged)) @@ -135,4 +138,4 @@ var/list/exports_list = list() for(var/subtype in subtypesof(/datum/export)) var/datum/export/E = new subtype if(E.export_types && E.export_types.len) // Exports without a type are invalid/base types - exports += E + exports_list += E diff --git a/code/modules/shuttle/supply.dm b/code/modules/shuttle/supply.dm index f4c2511d63c..b4077d52028 100644 --- a/code/modules/shuttle/supply.dm +++ b/code/modules/shuttle/supply.dm @@ -26,8 +26,6 @@ var/list/blacklisted_cargo_types = typecacheof(list( height = 7 roundstart_move = "supply_away" - var/list/exports = list() - // When TRUE, these vars allow exporting emagged/contraband items, and add some special interactions to existing exports. var/contraband = FALSE var/emagged = FALSE @@ -41,10 +39,12 @@ var/list/blacklisted_cargo_types = typecacheof(list( return check_blacklist(areaInstance) return ..() -/obj/docking_port/mobile/supply/proc/check_blacklist(atom/A) - for(var/thing in list(A) | A.GetAllContents()) - if(is_type_in_typecache(thing, blacklisted_cargo_types)) - return TRUE +/obj/docking_port/mobile/supply/proc/check_blacklist(areaInstance) + for(var/trf in areaInstance) + var/turf/T = trf + for(var/a in T.GetAllContents()) + if(is_type_in_typecache(a, blacklisted_cargo_types)) + return TRUE return FALSE /obj/docking_port/mobile/supply/request() @@ -96,7 +96,8 @@ var/list/blacklisted_cargo_types = typecacheof(list( /obj/docking_port/mobile/supply/proc/sell() var/presale_points = SSshuttle.points - if(!exports.len) // No exports list? Generate it! + if(!exports_list.len) // No exports list? Generate it! + setupExports() var/msg = "" var/sold_atoms = "" @@ -104,12 +105,12 @@ var/list/blacklisted_cargo_types = typecacheof(list( for(var/atom/movable/AM in areaInstance) if(AM.anchored) continue - sold_atoms += export_item_and_contents(AM, exports, contraband, emagged, dry_run = FALSE) + sold_atoms += export_item_and_contents(AM, contraband, emagged, dry_run = FALSE) if(sold_atoms) sold_atoms += "." - for(var/a in exports) + for(var/a in exports_list) var/datum/export/E = a var/export_text = E.total_printout() if(!export_text)