Skip to content

Commit

Permalink
Integrated circuits fixes and changes (#5962)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

This PR aims to bring integrated circuits not only to a more up to date
version but also fix some features that weren't working.
For this I have used Baystations current circuits as a working
reference. I have compiled, tested and checked for runtimes.

Fixes include

- Tile analyzer and examiner being able to handle tiles
- Reference encoder and decoders doing their job
- Advanced pathfinder being able to path through access restricted doors
- The EPv2 circuit using an incompatible name for cloning

As a consequence for the advanced pathfinder I had to readjust how
access is given to circuits which now allows them to read the passkey of
ID's, store them, send them and so on. A minor tweak also adjusts the
TTS circuit to 1 second. Additionally, I have added an advanced signaler
that while it behaves identical to EPv2 it is able to work the moment
you print it without having to set an address (Not to mention that EPv2
often fails to create an address upon print)



<!-- Both 🆑's are required for the changelog to work! You can put
your name to the right of the first 🆑 if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Dimasw99 committed Sep 15, 2023
1 parent 9efcaed commit ac1106c
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 140 deletions.
4 changes: 2 additions & 2 deletions code/controllers/subsystem/pathfinder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ SUBSYSTEM_DEF(pathfinder)
instance.ss13_with_access = potential_id.access?.Copy()
return run_pathfinding(instance)

/datum/controller/subsystem/pathfinder/proc/default_circuit_pathfinding(obj/item/electronic_assembly/assembly, turf/goal, min_dist = 1, max_path = 128)
/datum/controller/subsystem/pathfinder/proc/default_circuit_pathfinding(obj/item/electronic_assembly/assembly, turf/goal, min_dist = 1, max_path = 128, var/list/access)
var/datum/pathfinding/jps/instance = new(assembly, get_turf(assembly), goal, min_dist, max_path)
instance.ss13_with_access = assembly.access_card?.access?.Copy()
instance.ss13_with_access = access.Copy()
return jps_output_turfs(run_pathfinding(instance))

/datum/controller/subsystem/pathfinder/proc/default_bot_pathfinding(mob/living/bot/bot, turf/goal, min_dist = 1, max_path = 128)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/integrated_electronics/core/assemblies.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@
/obj/item/electronic_assembly/Bump(atom/AM)
collw = AM
.=..()
if((istype(collw, /obj/machinery/door/airlock) || istype(collw, /obj/machinery/door/window)) && (!isnull(access_card)))
if(istype(collw, /obj/machinery/door/airlock) || istype(collw, /obj/machinery/door/window))
var/obj/machinery/door/D = collw
if(D.check_access(access_card))
if(D.check_access(src))
D.open()

/obj/item/electronic_assembly/Initialize(mapload)
Expand Down
20 changes: 11 additions & 9 deletions code/modules/integrated_electronics/core/helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,14 @@

return get_pin_ref(parameters[1], parameters[2], parameters[3], components)

/// Used to obfuscate object refs imported/exported as strings.
/// Not very secure, but if someone still finds a way to abuse refs, they deserve it.
/proc/XorEncrypt(string, key)
if(!string || !key ||!istext(string)||!istext(key))
return
var/r
for(var/i = 1 to length(string))
r += ascii2text(text2ascii(string,i) ^ text2ascii(key,(i-1)%length(string)+1))
return r
// this is for data validation of stuff like ref encodes and more importantly ID access lists

/proc/compute_signature(data)
return md5(SScircuit.cipherkey + data)

/proc/add_data_signature(data)
var/signature = compute_signature(data)
return "[signature]:[data]"

/proc/check_data_signature(signature, data)
return (compute_signature(data) == signature)
13 changes: 10 additions & 3 deletions code/modules/integrated_electronics/subtypes/converters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
var/result = null
var/atom/A = get_pin_data(IC_INPUT, 1)
if(A && istype(A))
result = num2hex(4,5)
result = strtohex(XorEncrypt(REF(A), SScircuit.cipherkey))
result = add_data_signature("\ref[A]")

set_pin_data(IC_OUTPUT, 1, result)
push_data()
activate_pin(2)
Expand All @@ -94,7 +94,14 @@
var/dec

/obj/item/integrated_circuit/converter/refdecode/do_work()
dec = XorEncrypt(hextostr(get_pin_data(IC_INPUT, 1), TRUE), SScircuit.cipherkey)

var/list/signature_and_data = splittext(get_pin_data(IC_INPUT, 1), ":")
var/signature = signature_and_data[1]
var/dec = signature_and_data[2]

if(!check_data_signature(signature, dec))
return FALSE

set_pin_data(IC_OUTPUT, 1, WEAKREF(locate(dec)))
push_data()
activate_pin(2)
Expand Down
Loading

0 comments on commit ac1106c

Please sign in to comment.