diff --git a/code/__defines/integrated_circuits.dm b/code/__defines/integrated_circuits.dm index b2859a232d..03cfa358e3 100644 --- a/code/__defines/integrated_circuits.dm +++ b/code/__defines/integrated_circuits.dm @@ -1,3 +1,4 @@ // Methods of obtaining a circuit. #define IC_SPAWN_DEFAULT 1 // If the circuit comes in the default circuit box and able to be printed in the IC printer. -#define IC_SPAWN_RESEARCH 2 // If the circuit design will be available in the IC printer after upgrading it. \ No newline at end of file +#define IC_SPAWN_RESEARCH 2 // If the circuit design will be available in the IC printer after upgrading it. +#define IC_SPAWN_ILLEGAL 3 // If the circuit design will be available if upgrading the IC printer illegally. \ No newline at end of file diff --git a/code/modules/integrated_electronics/core/assemblies.dm b/code/modules/integrated_electronics/core/assemblies.dm index 69e8b69e18..11f4a53a0d 100644 --- a/code/modules/integrated_electronics/core/assemblies.dm +++ b/code/modules/integrated_electronics/core/assemblies.dm @@ -376,7 +376,7 @@ if(battery) var/lost = battery.use(amount * CELLRATE) net_power -= lost - return lost > 0 + return lost return FALSE // Ditto for giving. diff --git a/code/modules/integrated_electronics/core/printer.dm b/code/modules/integrated_electronics/core/printer.dm index 2089e87afb..f15f9544f6 100644 --- a/code/modules/integrated_electronics/core/printer.dm +++ b/code/modules/integrated_electronics/core/printer.dm @@ -11,11 +11,21 @@ var/debug = FALSE // If true, metal is infinite. var/upgraded = FALSE // When hit with an upgrade disk, will turn true, allowing it to print the higher tier circuits. + var/illegal_upgraded = FALSE // When hit with an illegal upgrade disk, will turn true, allowing it to print the illegal circuits. var/can_clone = FALSE // Same for above, but will allow the printer to duplicate a specific assembly. (Not implemented) // var/static/list/recipe_list = list() var/obj/item/device/electronic_assembly/assembly_to_clone = null // Not implemented x3 var/dirty_items = FALSE +/obj/item/device/integrated_circuit_printer/all_upgrades + upgraded = TRUE + illegal_upgraded = TRUE + can_clone = TRUE + +/obj/item/device/integrated_circuit_printer/illegal + illegal_upgraded = TRUE + can_clone = TRUE + /obj/item/device/integrated_circuit_printer/upgraded upgraded = TRUE can_clone = TRUE @@ -24,6 +34,7 @@ name = "fractal integrated circuit printer" desc = "A portable(ish) machine that makes modular circuitry seemingly out of thin air." upgraded = TRUE + illegal_upgraded = TRUE can_clone = TRUE debug = TRUE @@ -68,6 +79,16 @@ attack_self(user) return TRUE + if(istype(O,/obj/item/weapon/disk/integrated_circuit/upgrade/illegal)) + if(illegal_upgraded) + to_chat(user, span("warning", "\The [src] already has this upgrade.")) + return TRUE + to_chat(user, span("notice", "You install \the [O] into \the [src].")) + illegal_upgraded = TRUE + dirty_items = TRUE + attack_self(user) + return TRUE + if(istype(O,/obj/item/weapon/disk/integrated_circuit/upgrade/clone)) if(can_clone) to_chat(user, span("warning", "\The [src] already has this upgrade.")) @@ -110,6 +131,8 @@ "name" = category, "items" = null ) + if(cat_obj["name"] == "Illegal Parts" && !illegal_upgraded) + continue var/list/circuit_list = SScircuit.circuit_fabricator_recipe_list[category] var/list/items = list() for(var/path in circuit_list) @@ -212,6 +235,12 @@ name = "integrated circuit printer upgrade disk - advanced designs" desc = "Install this into your integrated circuit printer to enhance it. This one adds new, advanced designs to the printer." +/obj/item/weapon/disk/integrated_circuit/upgrade/illegal + name = "integrated circuit printer upgrade disk - illegal designs" + desc = "Install this into your integrated circuit printer to enhance it. This one adds new, but illegal designs to the printer." + icon_state = "upgrade_disk_illegal" + origin_tech = list(TECH_ENGINEERING = 3, TECH_DATA = 4, TECH_ILLEGAL = 1) + // To be implemented later. /obj/item/weapon/disk/integrated_circuit/upgrade/clone name = "integrated circuit printer upgrade disk - circuit cloner" diff --git a/code/modules/integrated_electronics/passive/power.dm b/code/modules/integrated_electronics/passive/power.dm index 631365c5e9..6c5842389e 100644 --- a/code/modules/integrated_electronics/passive/power.dm +++ b/code/modules/integrated_electronics/passive/power.dm @@ -215,7 +215,7 @@ assembly.give_power(amount) else var/amount = assembly.draw_power(throughput) - IO.add_avail(amount) + IO.add_avail(amount / CELLRATE) set_pin_data(IC_OUTPUT, 1, IO.avail()) set_pin_data(IC_OUTPUT, 2, IO.surplus()) diff --git a/code/modules/integrated_electronics/subtypes/cryptography.dm b/code/modules/integrated_electronics/subtypes/cryptography.dm new file mode 100644 index 0000000000..81bc3d150f --- /dev/null +++ b/code/modules/integrated_electronics/subtypes/cryptography.dm @@ -0,0 +1,89 @@ +/obj/item/integrated_circuit/cryptography + complexity = 3 + inputs = list("input" = IC_PINTYPE_STRING) + outputs = list("result" = IC_PINTYPE_STRING) + activators = list("compute" = IC_PINTYPE_PULSE_IN, "on computed" = IC_PINTYPE_PULSE_OUT) + category_text = "Cryptography" + power_draw_per_use = 10 + +// HASH FUNCTIONS + +/obj/item/integrated_circuit/cryptography/hash_md5 + name = "MD5 hash circuit" + desc = "Message-Digest Algorithm 5" + extended_desc = "This circuit will take a string input and generates the MD5 hash of it." + icon_state = "template" + spawn_flags = IC_SPAWN_RESEARCH + +/obj/item/integrated_circuit/cryptography/hash_md5/do_work() + var/result = "" + for(var/datum/integrated_io/I in inputs) + I.pull_data() + if(!isnull(I.data)) + result = md5(I.data) + + set_pin_data(IC_OUTPUT, 1, result) + push_data() + activate_pin(2) + +/obj/item/integrated_circuit/cryptography/hash_sha1 + name = "SHA1 hash circuit" + desc = "Secure Hash Algorithm 1" + extended_desc = "This circuit will take a string input and generates the SHA1 hash of it." + icon_state = "template" + spawn_flags = IC_SPAWN_RESEARCH + power_draw_per_use = 20 + +/obj/item/integrated_circuit/cryptography/hash_sha1/do_work() + var/result = "" + for(var/datum/integrated_io/I in inputs) + I.pull_data() + if(!isnull(I.data)) + result = sha1(I.data) + + set_pin_data(IC_OUTPUT, 1, result) + push_data() + activate_pin(2) + + +// ENCRYPTION/DECRYPTION + +/obj/item/integrated_circuit/cryptography/rot13 + name = "rot13 circuit" + desc = "A very simple encryption circuit." + extended_desc = "The 'rotation' field will default to 13 if no custom number is supplied. This circuit rotates every letter by X in the alphabet." + icon_state = "template" + inputs = list( + "input" = IC_PINTYPE_STRING, + "rotation" = IC_PINTYPE_NUMBER + ) + spawn_flags = IC_SPAWN_RESEARCH + +/obj/item/integrated_circuit/cryptography/rot13/do_work() + var/result = "" + + var/input = get_pin_data(IC_INPUT, 1) + var/rotation = get_pin_data(IC_INPUT, 2) + + var/string_len = length(input) + + if(!isnum(rotation)) + rotation = 13 + + for(var/i = 1, i <= string_len, i++) + var/ascii = text2ascii(input, i) + if(ascii >= 65 && ascii <= 90) + ascii += rotation + if(ascii > 90) + ascii -= 26 + + else if(ascii >= 97 && ascii <= 122) + ascii += rotation + if(ascii > 122) + ascii -= 26 + + result += ascii2text(ascii) + + set_pin_data(IC_OUTPUT, 1, result) + push_data() + activate_pin(2) \ No newline at end of file diff --git a/code/modules/integrated_electronics/subtypes/illegal.dm b/code/modules/integrated_electronics/subtypes/illegal.dm new file mode 100644 index 0000000000..88e3a277d6 --- /dev/null +++ b/code/modules/integrated_electronics/subtypes/illegal.dm @@ -0,0 +1,121 @@ +/obj/item/integrated_circuit/illegal + complexity = 3 + category_text = "Illegal Parts" + power_draw_per_use = 50 + +/* [WIP] +/obj/item/integrated_circuit/illegal/EPv2_Spoofer + name = "\improper EPv2 Spoofer circuit" + desc = "Enables the receiving of messages of other Exonet devices." + extended_desc = "An EPv2 address is a string with the format of XXXX:XXXX:XXXX:XXXX. Data can be received using the \ + second pin, with additonal data reserved for the third pin. When a message is received, the second activation pin \ + will pulse whatever's connected to it. Pulsing the first activation pin will set the given EPv2 address.\ + \ + Note: Receiving messages could cause the circuit to accidentally send malformed data to the target address." + icon_state = "signal_illegal" + complexity = 6 + inputs = list("target EPv2 address" = IC_PINTYPE_STRING) + outputs = list( + "address received" = IC_PINTYPE_STRING, + "data received" = IC_PINTYPE_STRING, + "secondary text received" = IC_PINTYPE_STRING + ) + activators = list("set spoof address" = IC_PINTYPE_PULSE_IN, "on data received" = IC_PINTYPE_PULSE_OUT) + spawn_flags = IC_SPAWN_RESEARCH|IC_SPAWN_ILLEGAL + origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2, TECH_BLUESPACE = 2, TECH_ILLEGAL = 2) + power_draw_per_use = 200 + var/datum/exonet_protocol/exonet = null + var/address_spoofed = FALSE + +/obj/item/integrated_circuit/illegal/EPv2_Spoofer/New() + ..() + exonet = new(src) + exonet.make_address("EPv2_Spoofer_circuit-\ref[src]") + desc += "
This circuit's EPv2 address is: [exonet.address]" + +/obj/item/integrated_circuit/illegal/EPv2_Spoofer/Destroy() + if(exonet) + if(!address_spoofed) // We dont actually want to destroy the regular address + exonet.remove_address() + qdel(exonet) + exonet = null + return ..() + +/obj/item/integrated_circuit/illegal/EPv2_Spoofer/do_work() + var/target_address = get_pin_data(IC_INPUT, 1) + + exonet.address = target_address + address_spoofed = TRUE + +/obj/item/integrated_circuit/illegal/receive_exonet_message(var/atom/origin_atom, var/origin_address, var/message, var/text) + set_pin_data(IC_OUTPUT, 1, origin_address) + set_pin_data(IC_OUTPUT, 2, message) + set_pin_data(IC_OUTPUT, 3, text) + + push_data() + activate_pin(2) + + if(address_spoofed) + var/random = rand(1,100) + if(random > 70) + exonet.send_message(origin_address, message, "[random]") +*/ + +/obj/item/integrated_circuit/illegal/EPv2_Discoverer + name = "\improper EPv2 Discovery circuit" + desc = "Finds all Exonet devices currently connected to the node (even if not publicly listed)." + extended_desc = "An EPv2 address is a string with the format of XXXX:XXXX:XXXX:XXXX. Data can be received using the \ + second pin, with additonal data reserved for the third pin. When a message is received, the second activation pin \ + will pulse whatever's connected to it. Pulsing the first activation pin will set the given EPv2 address.\ + \ + Note: Discovering Exonet Devices sends off a ping to each device, making it a 'noisy' circuit." + icon_state = "signal_illegal" + complexity = 3 + outputs = list("addresses found" = IC_PINTYPE_LIST) + activators = list("start discovery" = IC_PINTYPE_PULSE_IN, "on addresses found" = IC_PINTYPE_PULSE_OUT) + spawn_flags = IC_SPAWN_ILLEGAL + origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2, TECH_BLUESPACE = 2, TECH_ILLEGAL = 1) + power_draw_per_use = 300 + var/datum/exonet_protocol/exonet = null + var/obj/machinery/exonet_node/node = null + +/obj/item/integrated_circuit/illegal/EPv2_Discoverer/proc/get_connection_to_tcomms() + if(node && node.on) + return can_telecomm(src,node) + return 0 + +/obj/item/integrated_circuit/illegal/EPv2_Discoverer/New() + ..() + exonet = new(src) + exonet.make_address("EPv2_Discovery_circuit-\ref[src]") + desc += "
This circuit's EPv2 address is: [exonet.address]" + node = get_exonet_node() + message_admins("A EPv2 Discovery circuit has been created. \ref[src]") + +/obj/item/integrated_circuit/illegal/EPv2_Discoverer/Destroy() + if(exonet) + exonet.remove_address() + qdel(exonet) + exonet = null + return ..() + +/obj/item/integrated_circuit/illegal/EPv2_Discoverer/do_work() + if(!get_connection_to_tcomms()) + set_pin_data(IC_OUTPUT, 1, null) + + push_data() + activate_pin(2) + else + var/list/addresses = list() + + for(var/datum/exonet_protocol/target_exonet in all_exonet_connections) + if(target_exonet.address && istext(target_exonet.address)) + var/random = rand(200,350) + random = random / 10 + exonet.send_message(target_exonet.address, "text", "64 bytes received from [exonet.address] ecmp_seq=1 ttl=51 time=[random] ms") + addresses += target_exonet.address + + set_pin_data(IC_OUTPUT, 1, addresses) + + push_data() + activate_pin(2) \ No newline at end of file diff --git a/code/modules/integrated_electronics/subtypes/input.dm b/code/modules/integrated_electronics/subtypes/input.dm index 855c01c539..e53b1397de 100644 --- a/code/modules/integrated_electronics/subtypes/input.dm +++ b/code/modules/integrated_electronics/subtypes/input.dm @@ -420,7 +420,7 @@ name = "\improper EPv2 circuit" desc = "Enables the sending and receiving of messages on the Exonet with the EPv2 protocol." extended_desc = "An EPv2 address is a string with the format of XXXX:XXXX:XXXX:XXXX. Data can be send or received using the \ - second pin on each side, with additonal data reserved for the third pin. When a message is received, the second activaiton pin \ + second pin on each side, with additonal data reserved for the third pin. When a message is received, the second activation pin \ will pulse whatever's connected to it. Pulsing the first activation pin will send a message.\ \ When messaging Communicators, you must set data to send to the string `text` to avoid errors in reception." @@ -441,12 +441,19 @@ origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2, TECH_BLUESPACE = 2) power_draw_per_use = 50 var/datum/exonet_protocol/exonet = null + var/obj/machinery/exonet_node/node = null + +/obj/item/integrated_circuit/input/EPv2/proc/get_connection_to_tcomms() + if(node && node.on) + return can_telecomm(src,node) + return 0 /obj/item/integrated_circuit/input/EPv2/New() ..() exonet = new(src) exonet.make_address("EPv2_circuit-\ref[src]") desc += "
This circuit's EPv2 address is: [exonet.address]" + node = get_exonet_node() /obj/item/integrated_circuit/input/EPv2/Destroy() if(exonet) @@ -461,7 +468,15 @@ var/text = get_pin_data(IC_INPUT, 3) if(target_address && istext(target_address)) - exonet.send_message(target_address, message, text) + if(!get_connection_to_tcomms()) + set_pin_data(IC_OUTPUT, 1, null) + set_pin_data(IC_OUTPUT, 2, "Error: Cannot connect to Exonet node.") + set_pin_data(IC_OUTPUT, 3, "error") + + push_data() + activate_pin(2) + else + exonet.send_message(target_address, message, text) /obj/item/integrated_circuit/input/receive_exonet_message(var/atom/origin_atom, var/origin_address, var/message, var/text) set_pin_data(IC_OUTPUT, 1, origin_address) diff --git a/icons/obj/integrated_electronics/electronic_components.dmi b/icons/obj/integrated_electronics/electronic_components.dmi index b9b82061ca..07b0cec1b7 100644 Binary files a/icons/obj/integrated_electronics/electronic_components.dmi and b/icons/obj/integrated_electronics/electronic_components.dmi differ diff --git a/icons/obj/integrated_electronics/electronic_tools.dmi b/icons/obj/integrated_electronics/electronic_tools.dmi index 975f2fc9a8..821265accc 100644 Binary files a/icons/obj/integrated_electronics/electronic_tools.dmi and b/icons/obj/integrated_electronics/electronic_tools.dmi differ diff --git a/vorestation.dme b/vorestation.dme index 8a8b4e8531..15966f9575 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -2651,7 +2651,9 @@ #include "code\modules\integrated_electronics\subtypes\arithmetic.dm" #include "code\modules\integrated_electronics\subtypes\built_in.dm" #include "code\modules\integrated_electronics\subtypes\converters.dm" +#include "code\modules\integrated_electronics\subtypes\cryptography.dm" #include "code\modules\integrated_electronics\subtypes\data_transfer.dm" +#include "code\modules\integrated_electronics\subtypes\illegal.dm" #include "code\modules\integrated_electronics\subtypes\input.dm" #include "code\modules\integrated_electronics\subtypes\lists.dm" #include "code\modules\integrated_electronics\subtypes\logic.dm"