From 40be4145c4144ea234f493b6017cf91f105c0150 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Mon, 9 Feb 2026 21:30:28 -0300 Subject: [PATCH 1/3] push --- code/datums/components/_component.dm | 31 ++--- code/datums/elements/_element.dm | 2 +- code/game/objects/items/pet_carrier.dm | 2 +- code/modules/admin/topic.dm | 2 +- code/modules/clothing/head/jobs.dm | 2 +- code/modules/clothing/head/misc.dm | 2 +- .../integrated_electronics/core/helpers.dm | 27 ++-- .../core/integrated_circuit.dm | 4 +- .../integrated_electronics/subtypes/input.dm | 48 +++++--- .../subtypes/manipulation.dm | 115 ++++++++++-------- .../code/modules/reagents/objects/clothes.dm | 2 +- 11 files changed, 141 insertions(+), 96 deletions(-) diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm index 6b99cf8318..3796965673 100644 --- a/code/datums/components/_component.dm +++ b/code/datums/components/_component.dm @@ -324,25 +324,26 @@ // The type arg is casted so initial works, you shouldn't be passing a real instance into this /** - * Return any component assigned to this datum of the exact given type - * This will throw an error if it's possible to have more than one component of that type on the parent - * - * Arguments: - * * datum/component/c_type The typepath of the component you want to get a reference to - */ + * Return any component assigned to this datum of the exact given type + * + * This will throw an error if it's possible to have more than one component of that type on the parent + * + * Arguments: + * * datum/component/c_type The typepath of the component you want to get a reference to + */ /datum/proc/GetExactComponent(datum/component/c_type) RETURN_TYPE(c_type) - if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED || initial(c_type.dupe_mode) == COMPONENT_DUPE_SELECTIVE) + var/initial_type_mode = initial(c_type.dupe_mode) + if(initial_type_mode == COMPONENT_DUPE_ALLOWED || initial_type_mode == COMPONENT_DUPE_SELECTIVE) stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]") - var/list/dc = datum_components - if(!dc) + var/list/all_components = datum_components + if(!all_components) return null - var/datum/component/C = dc[c_type] - if(C) - if(length(C)) - C = C[1] - if(C.type == c_type) - return C + var/datum/component/potential_component + if(length(all_components)) + potential_component = all_components[c_type] + if(potential_component?.type == c_type) + return potential_component return null /** diff --git a/code/datums/elements/_element.dm b/code/datums/elements/_element.dm index a77a519909..7fbd9d00de 100644 --- a/code/datums/elements/_element.dm +++ b/code/datums/elements/_element.dm @@ -28,9 +28,9 @@ /// Deactivates the functionality defines by the element on the given datum /datum/element/proc/Detach(datum/source, force) SIGNAL_HANDLER + SHOULD_CALL_PARENT(TRUE) SEND_SIGNAL(source, COMSIG_ELEMENT_DETACH, src) - SHOULD_CALL_PARENT(TRUE) UnregisterSignal(source, COMSIG_PARENT_QDELETING) /datum/element/Destroy(force) diff --git a/code/game/objects/items/pet_carrier.dm b/code/game/objects/items/pet_carrier.dm index 138472a4c8..9dc18fb996 100644 --- a/code/game/objects/items/pet_carrier.dm +++ b/code/game/objects/items/pet_carrier.dm @@ -308,7 +308,7 @@ if(isanimal(occupant)) var/mob/living/simple_animal/animal = occupant - occupant_gas_supply[GAS_O2] = 0.0064 //make sure it has some gas in so it isn't depressurized + occupant_gas_supply.set_moles(GAS_O2, 0.0064) //make sure it has some gas in so it isn't depressurized occupant_gas_supply.set_temperature(animal.minbodytemp) //simple animals only care about temperature/pressure when their turf isnt a location if(ishuman(occupant)) //humans require resistance to cold/heat and living in no air while inside, and lose this when outside diff --git a/code/modules/admin/topic.dm b/code/modules/admin/topic.dm index 90573b44a0..acccf1674c 100644 --- a/code/modules/admin/topic.dm +++ b/code/modules/admin/topic.dm @@ -2649,7 +2649,7 @@ if(response.body == "[]") dat += "
0 bans detected for [ckey]
" else - bans = json_decode(response["body"]) + bans = json_decode(response.body) //Ignore bans from non-whitelisted sources, if a whitelist exists var/list/valid_sources diff --git a/code/modules/clothing/head/jobs.dm b/code/modules/clothing/head/jobs.dm index db9eda055d..11508f975b 100644 --- a/code/modules/clothing/head/jobs.dm +++ b/code/modules/clothing/head/jobs.dm @@ -229,7 +229,7 @@ . = ..() UnregisterSignal(M, COMSIG_MOB_SAY) -/obj/item/clothing/head/warden/drill/proc/handle_speech(datum/source, mob/speech_args) +/obj/item/clothing/head/warden/drill/proc/handle_speech(datum/source, list/speech_args) var/message = speech_args[SPEECH_MESSAGE] if(message[1] != "*") switch (mode) diff --git a/code/modules/clothing/head/misc.dm b/code/modules/clothing/head/misc.dm index d24e004802..d31562ad5f 100644 --- a/code/modules/clothing/head/misc.dm +++ b/code/modules/clothing/head/misc.dm @@ -364,7 +364,7 @@ . = ..() UnregisterSignal(M, COMSIG_MOB_SAY) -/obj/item/clothing/head/frenchberet/proc/handle_speech(datum/source, mob/speech_args) +/obj/item/clothing/head/frenchberet/proc/handle_speech(datum/source, list/speech_args) var/message = speech_args[SPEECH_MESSAGE] if(message[1] != "*") message = " [message]" diff --git a/code/modules/integrated_electronics/core/helpers.dm b/code/modules/integrated_electronics/core/helpers.dm index 5fcb6fede8..dec13b22a8 100644 --- a/code/modules/integrated_electronics/core/helpers.dm +++ b/code/modules/integrated_electronics/core/helpers.dm @@ -22,16 +22,21 @@ /obj/item/integrated_circuit/proc/set_pin_data(pin_type, pin_number, datum/new_data) if(islist(new_data)) - for(var/i in 1 to length(new_data)) - if (istype(new_data) && !isweakref(new_data)) - new_data[i] = WEAKREF(new_data[i]) - if (istype(new_data) && !isweakref(new_data)) + var/list/new_data_list = new_data + var/list/output = list() + for(var/data_iterator in 1 to length(new_data_list)) + if (isdatum(new_data_list[data_iterator]) && !isweakref(new_data_list[data_iterator])) + output[data_iterator] = WEAKREF(new_data_list[data_iterator]) + new_data = output + else if (isdatum(new_data) && !isweakref(new_data)) new_data = WEAKREF(new_data) var/datum/integrated_io/pin = get_pin_ref(pin_type, pin_number) return pin.write_data_to_pin(new_data) /obj/item/integrated_circuit/proc/get_pin_data(pin_type, pin_number) var/datum/integrated_io/pin = get_pin_ref(pin_type, pin_number) + if(QDELETED(pin)) + return var/data = pin.get_data() if(istext(data)) data = sanitize_text(data) @@ -39,6 +44,8 @@ /obj/item/integrated_circuit/proc/get_pin_data_as_type(pin_type, pin_number, as_type) var/datum/integrated_io/pin = get_pin_ref(pin_type, pin_number) + if(QDELETED(pin)) + return return pin.data_as_type(as_type) /obj/item/integrated_circuit/proc/activate_pin(pin_number) @@ -63,10 +70,14 @@ /datum/integrated_io/proc/get_data() if(islist(data)) - for(var/i in 1 to length(data)) - if(isweakref(data[i])) - data[i] = data[i].resolve() - if(isweakref(data)) + var/list/data_list = data + var/list/output = list() + for(var/data_iterator in 1 to length(data_list)) + if(isweakref(data_list[data_iterator])) + var/datum/weakref/data_weakref = data_list[data_iterator] + output[data_iterator] = data_weakref.resolve() + data = output + else if(isweakref(data)) return data.resolve() return data diff --git a/code/modules/integrated_electronics/core/integrated_circuit.dm b/code/modules/integrated_electronics/core/integrated_circuit.dm index 7e667b3d09..e229442217 100644 --- a/code/modules/integrated_electronics/core/integrated_circuit.dm +++ b/code/modules/integrated_electronics/core/integrated_circuit.dm @@ -267,10 +267,10 @@ a creative player the means to solve many problems. Circuits are held inside an if(href_list["link"]) linked = locate(href_list["link"]) in pin.linked - if(istype(held_item, /obj/item/integrated_electronics) || held_item.tool_behaviour == TOOL_MULTITOOL) + if(!QDELETED(held_item) && (istype(held_item, /obj/item/integrated_electronics) || held_item.tool_behaviour == TOOL_MULTITOOL)) pin.handle_wire(linked, held_item, href_list["act"], usr) else - to_chat(usr, "You can't do a whole lot without the proper tools.") + to_chat(usr, span_warning("You can't do a whole lot without the proper tools.")) success = FALSE if(success && assembly) assembly.add_allowed_scanner(usr.ckey) diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index ad8ef4ab21..c81f766d88 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -1068,6 +1068,9 @@ push_data() activate_pin(3) +#define PIN_ACTIVATOR_OUTPUT_ON_SCANNED 2 +#define PIN_ACTIVATOR_OUTPUT_NOT_SCANNED 3 + /obj/item/integrated_circuit/input/matscan name = "material scanner" desc = "This special module is designed to get information about material containers of different machinery, \ @@ -1086,9 +1089,8 @@ "Solid Plasma" = IC_PINTYPE_NUMBER, "Uranium" = IC_PINTYPE_NUMBER, "Bananium" = IC_PINTYPE_NUMBER, - "Titanium" = IC_PINTYPE_NUMBER, + "Titanium" = IC_PINTYPE_NUMBER, "Bluespace Mesh" = IC_PINTYPE_NUMBER, - "Biomass" = IC_PINTYPE_NUMBER, "Plastic" = IC_PINTYPE_NUMBER ) activators = list( @@ -1098,25 +1100,43 @@ ) spawn_flags = IC_SPAWN_RESEARCH power_draw_per_use = 40 - var/list/mtypes = list(/datum/material/iron, /datum/material/glass, /datum/material/silver, /datum/material/gold, /datum/material/diamond, /datum/material/plasma, /datum/material/uranium, /datum/material/bananium, /datum/material/titanium, /datum/material/bluespace, /datum/material/biomass, /datum/material/plastic) + var/list/mtypes = list( + /datum/material/iron, + /datum/material/glass, + /datum/material/silver, + /datum/material/gold, + /datum/material/diamond, + /datum/material/plasma, + /datum/material/uranium, + /datum/material/bananium, + /datum/material/titanium, + /datum/material/bluespace, + /datum/material/plastic, + ) /obj/item/integrated_circuit/input/matscan/do_work() - var/atom/movable/H = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) - var/turf/T = get_turf(src) - var/datum/component/material_container/mt = H.GetComponent(/datum/component/material_container) - if(!mt) //Invalid input + var/atom/movable/scanned_thing = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) + if(!scanned_thing) + activate_pin(PIN_ACTIVATOR_OUTPUT_NOT_SCANNED) return - if(H in view(T)) // This is a camera. It can't examine thngs,that it can't see. - for(var/I in mtypes) - if(I in mt.materials) - set_pin_data(IC_OUTPUT, I, mt.materials[I]) + var/datum/component/material_container/scanned_storage = scanned_thing.GetComponent(/datum/component/material_container) + if(!scanned_storage) //Invalid input + activate_pin(PIN_ACTIVATOR_OUTPUT_NOT_SCANNED) + return + if(scanned_thing in view(drop_location())) // This is a camera. It can't examine thngs,that it can't see. + for(var/material_iterator in length(mtypes)) + if(material_iterator in scanned_storage.materials) + set_pin_data(IC_OUTPUT, material_iterator, scanned_storage.materials[SSmaterials.GetMaterialRef(mtypes[material_iterator])] || 0) else - set_pin_data(IC_OUTPUT, I, null) + set_pin_data(IC_OUTPUT, material_iterator, null) push_data() - activate_pin(2) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_SCANNED) else - activate_pin(3) + activate_pin(PIN_ACTIVATOR_OUTPUT_NOT_SCANNED) + +#undef PIN_ACTIVATOR_OUTPUT_ON_SCANNED +#undef PIN_ACTIVATOR_OUTPUT_NOT_SCANNED /obj/item/integrated_circuit/input/atmospheric_analyzer name = "atmospheric analyzer" diff --git a/code/modules/integrated_electronics/subtypes/manipulation.dm b/code/modules/integrated_electronics/subtypes/manipulation.dm index bc49a5fbe6..1ce8d05662 100644 --- a/code/modules/integrated_electronics/subtypes/manipulation.dm +++ b/code/modules/integrated_electronics/subtypes/manipulation.dm @@ -352,6 +352,13 @@ A.throwforce = initial(A.throwforce) A.embedding = initial(A.embedding) +#define PIN_ACTIVATOR_INPUT_INSERT_SHEET 1 +#define PIN_ACTIVATOR_INPUT_TRANSFER_MATS 2 +#define PIN_ACTIVATOR_OUTPUT_ON_SUCCESS 3 +#define PIN_ACTIVATOR_OUTPUT_ON_FAILURE 4 +#define PIN_ACTIVATOR_INPUT_PUSH_REF 5 +#define PIN_ACTIVATOR_OUTPUT_ON_PUSH_REF 6 + /obj/item/integrated_circuit/manipulation/matman name = "material manager" desc = "This circuit is designed for automatic storage and distribution of materials." @@ -370,11 +377,11 @@ "Silver" = IC_PINTYPE_NUMBER, "Gold" = IC_PINTYPE_NUMBER, "Diamond" = IC_PINTYPE_NUMBER, - "Uranium" = IC_PINTYPE_NUMBER, "Solid Plasma" = IC_PINTYPE_NUMBER, - "Bluespace Mesh" = IC_PINTYPE_NUMBER, + "Uranium" = IC_PINTYPE_NUMBER, "Bananium" = IC_PINTYPE_NUMBER, "Titanium" = IC_PINTYPE_NUMBER, + "Bluespace Mesh" = IC_PINTYPE_NUMBER, "Plastic" = IC_PINTYPE_NUMBER ) outputs = list( @@ -385,20 +392,20 @@ "Silver" = IC_PINTYPE_NUMBER, "Gold" = IC_PINTYPE_NUMBER, "Diamond" = IC_PINTYPE_NUMBER, - "Uranium" = IC_PINTYPE_NUMBER, "Solid Plasma" = IC_PINTYPE_NUMBER, - "Bluespace Mesh" = IC_PINTYPE_NUMBER, + "Uranium" = IC_PINTYPE_NUMBER, "Bananium" = IC_PINTYPE_NUMBER, "Titanium" = IC_PINTYPE_NUMBER, + "Bluespace Mesh" = IC_PINTYPE_NUMBER, "Plastic" = IC_PINTYPE_NUMBER - ) + ) activators = list( "insert sheet" = IC_PINTYPE_PULSE_IN, "transfer mats" = IC_PINTYPE_PULSE_IN, "on success" = IC_PINTYPE_PULSE_OUT, "on failure" = IC_PINTYPE_PULSE_OUT, "push ref" = IC_PINTYPE_PULSE_IN, - "on push ref" = IC_PINTYPE_PULSE_IN + "on push ref" = IC_PINTYPE_PULSE_OUT ) spawn_flags = IC_SPAWN_RESEARCH power_draw_per_use = 40 @@ -410,81 +417,87 @@ /datum/material/silver, /datum/material/gold, /datum/material/diamond, - /datum/material/uranium, /datum/material/plasma, - /datum/material/bluespace, + /datum/material/uranium, /datum/material/bananium, /datum/material/titanium, - /datum/material/plastic - ) + /datum/material/bluespace, + /datum/material/plastic, + ) /obj/item/integrated_circuit/manipulation/matman/ComponentInitialize() - var/datum/component/material_container/materials = AddComponent(/datum/component/material_container, mtypes, 100000, FALSE, /obj/item/stack, CALLBACK(src, PROC_REF(is_insertion_ready)), CALLBACK(src, PROC_REF(AfterMaterialInsert))) + var/datum/component/material_container/materials = AddComponent(/datum/component/material_container, mtypes.Copy(), 100000, FALSE, /obj/item/stack, CALLBACK(src, PROC_REF(is_insertion_ready)), CALLBACK(src, PROC_REF(AfterMaterialInsert))) materials.precise_insertion = TRUE - .=..() + return ..() /obj/item/integrated_circuit/manipulation/matman/proc/AfterMaterialInsert(type_inserted, id_inserted, amount_inserted) var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) set_pin_data(IC_OUTPUT, 2, materials.total_amount) - for(var/I in 1 to mtypes.len) - var/datum/material/M = materials.materials[SSmaterials.GetMaterialRef(I)] - var/amount = materials[M] - if(M) - set_pin_data(IC_OUTPUT, I+2, amount) + for(var/material_iterator in 1 to length(mtypes)) + var/amount = materials.materials[SSmaterials.GetMaterialRef(mtypes[material_iterator])] + set_pin_data(IC_OUTPUT, material_iterator+2, amount || 0) push_data() /obj/item/integrated_circuit/manipulation/matman/proc/is_insertion_ready(mob/user) return TRUE -/obj/item/integrated_circuit/manipulation/matman/do_work(ord) - var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) - var/atom/movable/H = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) - if(!check_target(H)) - activate_pin(4) +/obj/item/integrated_circuit/manipulation/matman/do_work(activated_input_pin) + var/datum/component/material_container/local_storage = GetComponent(/datum/component/material_container) + var/atom/movable/scanned_thing = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) + if(QDELETED(scanned_thing)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) return - var/turf/T = get_turf(H) - switch(ord) - if(1) - var/obj/item/stack/sheet/S = H - if(!S) - activate_pin(4) + if(!check_target(scanned_thing)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + return + switch(activated_input_pin) + if(PIN_ACTIVATOR_INPUT_INSERT_SHEET) + var/obj/item/stack/sheet/sheet = scanned_thing + if(QDELETED(sheet)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) return - if(materials.insert_item(S, clamp(get_pin_data(IC_INPUT, 2),0,100), multiplier = 1) ) + if(local_storage.insert_stack(sheet, clamp(get_pin_data(IC_INPUT, 2),0,100), 1)) AfterMaterialInsert() - activate_pin(3) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_SUCCESS) else - activate_pin(4) - if(2) - var/datum/component/material_container/mt = H.GetComponent(/datum/component/material_container) - var/suc - for(var/I in 1 to mtypes.len) - var/datum/material/M = materials.materials[mtypes[I]] - if(M) - var/U = clamp(get_pin_data(IC_INPUT, I+2),-100000,100000) - if(!U) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + if(PIN_ACTIVATOR_INPUT_TRANSFER_MATS) + var/datum/component/material_container/scanned_storage = scanned_thing.GetComponent(/datum/component/material_container) + var/successful_transfer + for(var/material_iterator in 1 to length(mtypes)) + var/datum/material/material_to_transfer = SSmaterials.GetMaterialRef(mtypes[material_iterator]) + if(material_to_transfer) + var/amount = clamp(get_pin_data(IC_INPUT, material_iterator + 2), -100000, 100000) + if(!amount) continue - if(!mt) //Invalid input - if(U>0) - if(materials.retrieve_sheets(U, SSmaterials.GetMaterialRef(mtypes[I]), T)) - suc = TRUE + if(!scanned_storage) //Invalid input + if(amount > 0) + if(local_storage.retrieve_sheets(amount, material_to_transfer, drop_location())) + successful_transfer = TRUE else - if(mt.transer_amt_to(materials, U, mtypes[I])) - suc = TRUE - if(suc) + if(scanned_storage.transer_amt_to(local_storage, amount, material_to_transfer)) + successful_transfer = TRUE + if(successful_transfer) AfterMaterialInsert() - activate_pin(3) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_SUCCESS) else - activate_pin(4) - if(5) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + if(PIN_ACTIVATOR_INPUT_PUSH_REF) set_pin_data(IC_OUTPUT, 1, WEAKREF(src)) AfterMaterialInsert() - activate_pin(6) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_PUSH_REF) /obj/item/integrated_circuit/manipulation/matman/Destroy() var/datum/component/material_container/materials = GetComponent(/datum/component/material_container) materials.retrieve_all() - .=..() + return ..() +#undef PIN_ACTIVATOR_INPUT_INSERT_SHEET +#undef PIN_ACTIVATOR_INPUT_TRANSFER_MATS +#undef PIN_ACTIVATOR_OUTPUT_ON_SUCCESS +#undef PIN_ACTIVATOR_OUTPUT_ON_FAILURE +#undef PIN_ACTIVATOR_INPUT_PUSH_REF +#undef PIN_ACTIVATOR_OUTPUT_ON_PUSH_REF //Hippie Ported Code-------------------------------------------------------------------------------------------------------- diff --git a/modular_citadel/code/modules/reagents/objects/clothes.dm b/modular_citadel/code/modules/reagents/objects/clothes.dm index 2fb61749f8..a029ada752 100644 --- a/modular_citadel/code/modules/reagents/objects/clothes.dm +++ b/modular_citadel/code/modules/reagents/objects/clothes.dm @@ -52,7 +52,7 @@ var/mob/living/simple_animal/hostile/mimic/M = loc M.say(pick("Whooee! Time for a hootenanny!", "Rough 'em up boys!", "Yeehaw! Freedom at last!", "Y'all about to get a good old fashioned spanking!")) -/obj/item/clothing/head/hattip/proc/handle_speech(datum/source, mob/speech_args) +/obj/item/clothing/head/hattip/proc/handle_speech(datum/source, list/speech_args) var/message = speech_args[SPEECH_MESSAGE] var/mob/living/carbon/C = get_wearer()//user var/obj/item/organ/tongue/T = C.getorganslot(ORGAN_SLOT_TONGUE) From 929aae0cd1e20a00681f12b09c0b04ffdbe5a761 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Tue, 10 Feb 2026 00:05:04 -0300 Subject: [PATCH 2/3] i found out that remote_materials is a thing --- code/__HELPERS/materials.dm | 11 ++++ code/datums/components/material_container.dm | 15 +----- .../integrated_electronics/subtypes/input.dm | 14 +++--- .../subtypes/manipulation.dm | 50 +++++++++++++------ tgstation.dme | 1 + 5 files changed, 54 insertions(+), 37 deletions(-) create mode 100644 code/__HELPERS/materials.dm diff --git a/code/__HELPERS/materials.dm b/code/__HELPERS/materials.dm new file mode 100644 index 0000000000..96b9b5edc8 --- /dev/null +++ b/code/__HELPERS/materials.dm @@ -0,0 +1,11 @@ +/// Turns a material amount into the amount of sheets it should output +/proc/amount2sheet(amount) + if(amount >= MINERAL_MATERIAL_AMOUNT) + return round(amount / MINERAL_MATERIAL_AMOUNT) + return FALSE + +/// Turns an amount of sheets into the amount of material amount it should output +/proc/sheet2amount(sheet_amount) + if(sheet_amount > 0) + return sheet_amount * MINERAL_MATERIAL_AMOUNT + return FALSE diff --git a/code/datums/components/material_container.dm b/code/datums/components/material_container.dm index aac8075209..ec847d515b 100644 --- a/code/datums/components/material_container.dm +++ b/code/datums/components/material_container.dm @@ -326,7 +326,7 @@ return total_amount_save - total_amount /// For spawning mineral sheets at a specific location. Used by machines to output sheets. -/datum/component/material_container/proc/retrieve_sheets(sheet_amt, var/datum/material/M, target = null) +/datum/component/material_container/proc/retrieve_sheets(sheet_amt, datum/material/M, target = null) if(!M.sheet_type) return FALSE //Add greyscale sheet handling here later if(sheet_amt <= 0) @@ -410,19 +410,6 @@ return TRUE return FALSE -/// Turns a material amount into the amount of sheets it should output -/datum/component/material_container/proc/amount2sheet(amt) - if(amt >= MINERAL_MATERIAL_AMOUNT) - return round(amt / MINERAL_MATERIAL_AMOUNT) - return FALSE - -/// Turns an amount of sheets into the amount of material amount it should output -/datum/component/material_container/proc/sheet2amount(sheet_amt) - if(sheet_amt > 0) - return sheet_amt * MINERAL_MATERIAL_AMOUNT - return FALSE - - ///returns the amount of material relevant to this container; if this container does not support glass, any glass in 'I' will not be taken into account /datum/component/material_container/proc/get_item_material_amount(obj/item/I) if(!istype(I) || !I.custom_materials) diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index c81f766d88..e75a925529 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -1122,14 +1122,14 @@ return var/datum/component/material_container/scanned_storage = scanned_thing.GetComponent(/datum/component/material_container) if(!scanned_storage) //Invalid input - activate_pin(PIN_ACTIVATOR_OUTPUT_NOT_SCANNED) - return + var/datum/component/remote_materials/remote_storage = scanned_thing.GetComponent(/datum/component/remote_materials) + if(QDELETED(remote_storage)) + activate_pin(PIN_ACTIVATOR_OUTPUT_NOT_SCANNED) + return + scanned_storage = remote_storage.mat_container if(scanned_thing in view(drop_location())) // This is a camera. It can't examine thngs,that it can't see. - for(var/material_iterator in length(mtypes)) - if(material_iterator in scanned_storage.materials) - set_pin_data(IC_OUTPUT, material_iterator, scanned_storage.materials[SSmaterials.GetMaterialRef(mtypes[material_iterator])] || 0) - else - set_pin_data(IC_OUTPUT, material_iterator, null) + for(var/material_iterator in 1 to length(mtypes)) + set_pin_data(IC_OUTPUT, material_iterator, scanned_storage.materials[SSmaterials.GetMaterialRef(mtypes[material_iterator])] || 0) push_data() activate_pin(PIN_ACTIVATOR_OUTPUT_ON_SCANNED) else diff --git a/code/modules/integrated_electronics/subtypes/manipulation.dm b/code/modules/integrated_electronics/subtypes/manipulation.dm index 1ce8d05662..2d259099fd 100644 --- a/code/modules/integrated_electronics/subtypes/manipulation.dm +++ b/code/modules/integrated_electronics/subtypes/manipulation.dm @@ -362,11 +362,15 @@ /obj/item/integrated_circuit/manipulation/matman name = "material manager" desc = "This circuit is designed for automatic storage and distribution of materials." - extended_desc = "The first input takes a ref of a machine with a material container. \ - Second input is used for inserting material stacks into the internal material storage. \ - Inputs 3-13 are used to transfer materials between target machine and circuit storage. \ - Positive values will take that number of materials from another machine. \ - Negative values will fill another machine from internal storage. Outputs show current stored amounts of mats." + extended_desc = \ + "The first input takes a ref of a machine with a material container.
\ + Second input is used for inserting material stacks into the internal material storage.
\ + Inputs 3-13 are used to transfer materials between target machine and circuit storage.
\ + Positive values will take that number of materials from another machine.
\ + Negative values will fill another machine from internal storage.
\ + Unless target is null, which will have the machine drop the material on the floor.
\ + Outputs show current stored amounts of mats.
\ + Corporate note, %MINERAL_MATERIAL_AMOUNT%cm³ makes a sheet, any less than that cannot be retrieved." icon_state = "grabber" complexity = 16 inputs = list( @@ -425,6 +429,10 @@ /datum/material/plastic, ) +/obj/item/integrated_circuit/manipulation/matman/Initialize(mapload) + . = ..() + extended_desc = replacetext(extended_desc, "%MINERAL_MATERIAL_AMOUNT%", MINERAL_MATERIAL_AMOUNT) + /obj/item/integrated_circuit/manipulation/matman/ComponentInitialize() var/datum/component/material_container/materials = AddComponent(/datum/component/material_container, mtypes.Copy(), 100000, FALSE, /obj/item/stack, CALLBACK(src, PROC_REF(is_insertion_ready)), CALLBACK(src, PROC_REF(AfterMaterialInsert))) materials.precise_insertion = TRUE @@ -444,16 +452,13 @@ /obj/item/integrated_circuit/manipulation/matman/do_work(activated_input_pin) var/datum/component/material_container/local_storage = GetComponent(/datum/component/material_container) var/atom/movable/scanned_thing = get_pin_data_as_type(IC_INPUT, 1, /atom/movable) - if(QDELETED(scanned_thing)) - activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) - return - if(!check_target(scanned_thing)) - activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) - return switch(activated_input_pin) if(PIN_ACTIVATOR_INPUT_INSERT_SHEET) var/obj/item/stack/sheet/sheet = scanned_thing - if(QDELETED(sheet)) + if(QDELETED(sheet) || !istype(sheet)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + return + if(!check_target(scanned_thing, exclude_components = TRUE, exclude_self = TRUE)) activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) return if(local_storage.insert_stack(sheet, clamp(get_pin_data(IC_INPUT, 2),0,100), 1)) @@ -462,7 +467,11 @@ else activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) if(PIN_ACTIVATOR_INPUT_TRANSFER_MATS) - var/datum/component/material_container/scanned_storage = scanned_thing.GetComponent(/datum/component/material_container) + var/datum/component/material_container/scanned_storage = scanned_thing?.GetComponent(/datum/component/material_container) + if(QDELETED(scanned_storage)) + var/datum/component/remote_materials/remote_storage = scanned_thing?.GetComponent(/datum/component/remote_materials) + if(!QDELETED(remote_storage)) + scanned_storage = remote_storage.mat_container var/successful_transfer for(var/material_iterator in 1 to length(mtypes)) var/datum/material/material_to_transfer = SSmaterials.GetMaterialRef(mtypes[material_iterator]) @@ -470,13 +479,22 @@ var/amount = clamp(get_pin_data(IC_INPUT, material_iterator + 2), -100000, 100000) if(!amount) continue - if(!scanned_storage) //Invalid input + if(isnull(scanned_thing)) if(amount > 0) - if(local_storage.retrieve_sheets(amount, material_to_transfer, drop_location())) + if(local_storage.retrieve_sheets(amount2sheet(amount), material_to_transfer, drop_location())) successful_transfer = TRUE - else + else if(!QDELETED(scanned_storage)) + if(QDELETED(scanned_thing)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + return + // exclude_contents = FALSE, if someone EVER makes literal tom's storage in SS13, i'm evilly giving you this. + if(!check_target(scanned_thing, exclude_components = TRUE, exclude_self = TRUE)) + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) + return if(scanned_storage.transer_amt_to(local_storage, amount, material_to_transfer)) successful_transfer = TRUE + else + activate_pin(PIN_ACTIVATOR_OUTPUT_ON_FAILURE) if(successful_transfer) AfterMaterialInsert() activate_pin(PIN_ACTIVATOR_OUTPUT_ON_SUCCESS) diff --git a/tgstation.dme b/tgstation.dme index 14b128e4c8..a6e2d53bf3 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -218,6 +218,7 @@ #include "code\__HELPERS\level_traits.dm" #include "code\__HELPERS\lighting.dm" #include "code\__HELPERS\markov.dm" +#include "code\__HELPERS\materials.dm" #include "code\__HELPERS\matrices.dm" #include "code\__HELPERS\mobs.dm" #include "code\__HELPERS\mouse_control.dm" From 788f705ca7e2e392ef908a5a2214cf3ef75cbe45 Mon Sep 17 00:00:00 2001 From: SandPoot Date: Tue, 10 Feb 2026 00:11:27 -0300 Subject: [PATCH 3/3] pusher --- Dockerfile | 2 +- tools/ci/download_byond.sh | 2 +- tools/ci/install_byond.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ae4f82be8..c100d499b7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get install -y --no-install-recommends \ COPY dependencies.sh . RUN . ./dependencies.sh \ - && curl "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip \ + && curl -H "User-Agent: tgstation/1.0 CI Script" "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip \ && unzip byond.zip \ && cd byond \ && sed -i 's|install:|&\n\tmkdir -p $(MAN_DIR)/man6|' Makefile \ diff --git a/tools/ci/download_byond.sh b/tools/ci/download_byond.sh index 19b7f20170..d927c314ee 100755 --- a/tools/ci/download_byond.sh +++ b/tools/ci/download_byond.sh @@ -2,4 +2,4 @@ set -e source dependencies.sh echo "Downloading BYOND version $BYOND_MAJOR.$BYOND_MINOR" -curl "http://www.byond.com/download/build/$BYOND_MAJOR/$BYOND_MAJOR.${BYOND_MINOR}_byond.zip" -o C:/byond.zip +curl -H "User-Agent: tgstation/1.0 CI Script" "http://www.byond.com/download/build/$BYOND_MAJOR/$BYOND_MAJOR.${BYOND_MINOR}_byond.zip" -o C:/byond.zip diff --git a/tools/ci/install_byond.sh b/tools/ci/install_byond.sh index 4a688755d3..31d4a0dda7 100755 --- a/tools/ci/install_byond.sh +++ b/tools/ci/install_byond.sh @@ -11,7 +11,7 @@ else rm -rf "$HOME/BYOND" mkdir -p "$HOME/BYOND" cd "$HOME/BYOND" - curl "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip + curl -H "User-Agent: tgstation/1.0 CI Script" "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip unzip byond.zip rm byond.zip cd byond