Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Fixes the LTSRBT #2521

Merged
merged 1 commit into from
Mar 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions code/controllers/subsystem/blackmarket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,25 @@ SUBSYSTEM_DEF(blackmarket)
switch(purchase.method)
// Find a ltsrbt pad and make it handle the shipping.
if(SHIPPING_METHOD_LTSRBT)
if(!telepads.len)
if(!length(telepads))
continue
// Prioritize pads that don't have a cooldown active.
var/obj/machinery/ltsrbt/free_pad_found
var/obj/machinery/ltsrbt/lowest_cd_pad
// The time left of the shortest cooldown amongst all telepads.
var/lowest_timeleft = INFINITY
for(var/obj/machinery/ltsrbt/pad as anything in telepads)
if(pad.recharge_cooldown)
if(!COOLDOWN_FINISHED(pad, recharge_cooldown))
var/timeleft = COOLDOWN_TIMELEFT(pad, recharge_cooldown)
if(timeleft < lowest_timeleft)
lowest_cd_pad = pad
lowest_timeleft = timeleft
continue
pad.add_to_queue(purchase)
free_pad_found = pad
lowest_cd_pad = pad
break

if(isnull(free_pad_found))
continue
lowest_cd_pad.add_to_queue(purchase)

to_chat(buyer, span_notice("[purchase.uplink] flashes a message noting that the order is being processed by [free_pad_found]."))
to_chat(buyer, span_notice("[purchase.uplink] flashes a message noting that the order is being processed by [lowest_cd_pad]."))

// Get random area, throw it somewhere there.
if(SHIPPING_METHOD_TELEPORT)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/cargo/markets/market_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@
if(ismovable(item))
var/atom/movable/return_item = item
UnregisterSignal(item, COMSIG_QDELETING)
item.visible_message(span_notice("[item] vanishes..."))
do_sparks(8, FALSE, item)
if(isnull(loc))
item.moveToNullspace()
else
do_sparks(8, FALSE, item)
item.visible_message(span_notice("[item] vanishes..."))
item.forceMove(loc)
item = null
return return_item
Expand Down
17 changes: 8 additions & 9 deletions code/modules/cargo/markets/market_telepad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/// Current recharge progress.
COOLDOWN_DECLARE(recharge_cooldown)
/// Base recharge time in seconds which is used to get recharge_time.
var/base_recharge_time = 100
var/base_recharge_time = 10 SECONDS
/// Current /datum/market_purchase being received.
var/datum/market_purchase/receiving
/// Current /datum/market_purchase being sent to the target uplink.
Expand All @@ -43,7 +43,7 @@
/obj/machinery/ltsrbt/Destroy()
SSblackmarket.telepads -= src
// Bye bye orders.
if(SSblackmarket.telepads.len)
if(length(SSblackmarket.telepads))
for(var/datum/market_purchase/P in queue)
SSblackmarket.queue_item(P)
. = ..()
Expand All @@ -53,7 +53,7 @@
recharge_time = base_recharge_time
// On tier 4 recharge_time should be 20 and by default it is 80 as scanning modules should be tier 1.
for(var/datum/stock_part/scanning_module/scanning_module in component_parts)
recharge_time -= scanning_module.tier * 10
recharge_time -= scanning_module.tier * 1 SECONDS
recharge_cooldown = recharge_time

power_efficiency = 0
Expand All @@ -69,9 +69,10 @@
receiving = purchase
else
queue += purchase
RegisterSignal(receiving, COMSIG_QDELETING, PROC_REF(on_receiving_del))

/obj/machinery/ltsrbt/proc/on_receiving_del(datum/market_purchase/purchase)
RegisterSignal(purchase, COMSIG_QDELETING, PROC_REF(on_purchase_del))

/obj/machinery/ltsrbt/proc/on_purchase_del(datum/market_purchase/purchase)
SIGNAL_HANDLER
queue -= purchase
if(receiving == purchase)
Expand All @@ -86,8 +87,6 @@
if(!COOLDOWN_FINISHED(src, recharge_cooldown) && isnull(receiving) && isnull(transmitting))
return

COOLDOWN_START(src, recharge_cooldown, recharge_time)

var/turf/turf = get_turf(src)
if(receiving)

Expand All @@ -102,7 +101,7 @@
transmitting = receiving
receiving = null

recharge_cooldown = recharge_time
COOLDOWN_START(src, recharge_cooldown, recharge_time)
return
if(transmitting)
if(transmitting.item.loc == turf)
Expand All @@ -111,5 +110,5 @@
QDEL_NULL(transmitting)
return

if(queue.len)
if(length(queue))
receiving = pick_n_take(queue)
Loading