Merge pull request #4005 from Citadel-Station-13/upstream-merge-32811

[MIRROR] Fix for list pin in integrated circuits
This commit is contained in:
deathride58
2017-11-19 04:27:43 +00:00
committed by GitHub
5 changed files with 43 additions and 43 deletions
@@ -102,7 +102,7 @@ D [1]/ ||
holder.on_data_written()
else if(islist(new_data))
var/list/new_list = new_data
data = new_list.Copy(1,min( IC_MAX_LIST_LENGTH+1, new_list.len ))
data = new_list.Copy(max(1,new_list.len - IC_MAX_LIST_LENGTH+1),0)
holder.on_data_written()
/datum/integrated_io/proc/push_data()
@@ -110,7 +110,7 @@
/datum/integrated_io/lists/write_data_to_pin(var/new_data)
if(islist(new_data))
var/list/new_list = new_data
data = new_list.Copy(1,min( IC_MAX_LIST_LENGTH+1, new_list.len ))
data = new_list.Copy(max(1,new_list.len - IC_MAX_LIST_LENGTH+1),0)
holder.on_data_written()
/datum/integrated_io/lists/display_pin_type()
@@ -750,13 +750,13 @@
set_pin_data(IC_OUTPUT, 2, null)
set_pin_data(IC_OUTPUT, 3, null)
if(AM)
var/obj/item/stock_parts/cell/cell = get_cell(AM)
if(cell)
var/obj/item/stock_parts/cell/C = AM.get_cell()
if(C)
var/turf/A = get_turf(src)
if(AM in view(A))
push_data()
set_pin_data(IC_OUTPUT, 1, cell.charge)
set_pin_data(IC_OUTPUT, 2, cell.maxcharge)
set_pin_data(IC_OUTPUT, 3, cell.percent())
push_data()
if(get_turf(AM) in view(A))
set_pin_data(IC_OUTPUT, 1, C.charge)
set_pin_data(IC_OUTPUT, 2, C.maxcharge)
set_pin_data(IC_OUTPUT, 3, C.percent())
activate_pin(2)
push_data()
return
@@ -138,12 +138,14 @@
var/list/input_list = get_pin_data(IC_INPUT, 1)
var/index = get_pin_data(IC_INPUT, 2)
var/item = get_pin_data(IC_INPUT, 3)
if(!islist(item)) //crh proof
input_list[index] = item
set_pin_data(IC_OUTPUT, 1, input_list)
if(!islist(item))
var/list/red_list = input_list.Copy() //crash proof
red_list[index] = item
set_pin_data(IC_OUTPUT, 1, red_list)
push_data()
activate_pin(2)
obj/item/integrated_circuit/lists/len
name = "len circuit"
desc = "This circuit will return the length of the list."
@@ -39,38 +39,35 @@
/obj/item/integrated_circuit/power/transmitter/do_work()
var/atom/movable/AM = get_pin_data_as_type(IC_INPUT, 1, /atom/movable)
if(AM)
if(!assembly)
return FALSE // Pointless to do everything else if there's no battery to draw from.
var/obj/item/stock_parts/cell/cell = AM.get_cell()
if(cell)
var/transfer_amount = amount_to_move
var/turf/A = get_turf(src)
var/turf/B = get_turf(AM)
if(A.Adjacent(B))
if(AM.loc != assembly)
transfer_amount *= 0.8 // Losses due to distance.
if(cell.charge == cell.maxcharge)
return FALSE
if(transfer_amount && assembly.draw_power(amount_to_move)) // CELLRATE is already handled in draw_power()
cell.give(transfer_amount * GLOB.CELLRATE)
set_pin_data(IC_OUTPUT, 1, cell.charge)
set_pin_data(IC_OUTPUT, 2, cell.maxcharge)
set_pin_data(IC_OUTPUT, 3, cell.percent())
activate_pin(2)
push_data()
return TRUE
else
set_pin_data(IC_OUTPUT, 1, null)
set_pin_data(IC_OUTPUT, 2, null)
set_pin_data(IC_OUTPUT, 3, null)
if(!AM)
return FALSE
if(!assembly)
return FALSE // Pointless to do everything else if there's no battery to draw from.
var/obj/item/stock_parts/cell/cell = AM.get_cell()
if(cell)
var/transfer_amount = amount_to_move
var/turf/A = get_turf(src)
var/turf/B = get_turf(AM)
if(A.Adjacent(B))
if(AM.loc != assembly)
transfer_amount *= 0.8 // Losses due to distance.
set_pin_data(IC_OUTPUT, 1, cell.charge)
set_pin_data(IC_OUTPUT, 2, cell.maxcharge)
set_pin_data(IC_OUTPUT, 3, cell.percent())
activate_pin(2)
push_data()
return FALSE
return FALSE
if(cell.charge == cell.maxcharge)
return FALSE
if(transfer_amount && assembly.draw_power(amount_to_move)) // CELLRATE is already handled in draw_power()
cell.give(transfer_amount * GLOB.CELLRATE)
return TRUE
else
set_pin_data(IC_OUTPUT, 1, null)
set_pin_data(IC_OUTPUT, 2, null)
set_pin_data(IC_OUTPUT, 3, null)
activate_pin(2)
push_data()
return FALSE
/obj/item/integrated_circuit/power/transmitter/large/do_work()
if(..()) // If the above code succeeds, do this below.
@@ -79,3 +76,4 @@
s.set_up(12, 1, src)
s.start()
visible_message("<span class='warning'>\The [assembly] makes some sparks!</span>")
return TRUE