Beginning of circuitry update

- Added Illegal Tech Disk / Illegal Circuitry Category
- Added Simple Hash functions
- Added (Very) simple encryption is possible thanks to Rot13

- Fixed EPv2 Circuits not having unlimited range anymore
This commit is contained in:
ItsSelis
2022-04-21 01:35:51 +02:00
parent a95b970bd5
commit aea8c65c77
6 changed files with 118 additions and 1 deletions
@@ -121,6 +121,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)
@@ -226,6 +228,8 @@
/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
@@ -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)
@@ -0,0 +1,7 @@
/obj/item/integrated_circuit/illegal
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 = "Illegal Parts"
power_draw_per_use = 50
@@ -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 += "<br>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)