mirror of
https://github.com/SPLURT-Station/S.P.L.U.R.T-Station-13.git
synced 2025-12-12 02:43:49 +00:00
Merge pull request #5706 from Citadel-Station-13/upstream-merge-35754
[MIRROR] Fixes a runtime in "reference decoder" circuit
This commit is contained in:
@@ -12,7 +12,8 @@
|
|||||||
//Returns an integer given a hex input, supports negative values "-ff"
|
//Returns an integer given a hex input, supports negative values "-ff"
|
||||||
//skips preceding invalid characters
|
//skips preceding invalid characters
|
||||||
//breaks when hittin invalid characters thereafter
|
//breaks when hittin invalid characters thereafter
|
||||||
/proc/hex2num(hex)
|
// If safe=TRUE, returns null on incorrect input strings instead of CRASHing
|
||||||
|
/proc/hex2num(hex, safe=FALSE)
|
||||||
. = 0
|
. = 0
|
||||||
var/place = 1
|
var/place = 1
|
||||||
for(var/i in length(hex) to 1 step -1)
|
for(var/i in length(hex) to 1 step -1)
|
||||||
@@ -26,6 +27,9 @@
|
|||||||
num -= 55 //A-F
|
num -= 55 //A-F
|
||||||
if(45)
|
if(45)
|
||||||
return . * -1 // -
|
return . * -1 // -
|
||||||
|
else
|
||||||
|
if(safe)
|
||||||
|
return null
|
||||||
else
|
else
|
||||||
CRASH("Malformed hex number")
|
CRASH("Malformed hex number")
|
||||||
|
|
||||||
@@ -582,12 +586,16 @@
|
|||||||
r+= num2hex(c)
|
r+= num2hex(c)
|
||||||
return r
|
return r
|
||||||
|
|
||||||
/proc/hextostr(str)
|
// Decodes hex to raw byte string.
|
||||||
|
// If safe=TRUE, returns null on incorrect input strings instead of CRASHing
|
||||||
|
/proc/hextostr(str, safe=FALSE)
|
||||||
if(!istext(str)||!str)
|
if(!istext(str)||!str)
|
||||||
return
|
return
|
||||||
var/r
|
var/r
|
||||||
var/c
|
var/c
|
||||||
for(var/i = 1 to length(str)/2)
|
for(var/i = 1 to length(str)/2)
|
||||||
c= hex2num(copytext(str,i*2-1,i*2+1))
|
c = hex2num(copytext(str,i*2-1,i*2+1), safe)
|
||||||
|
if(isnull(c))
|
||||||
|
return null
|
||||||
r += ascii2text(c)
|
r += ascii2text(c)
|
||||||
return r
|
return r
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
|
|
||||||
/obj/item/integrated_circuit/converter/refdecode/do_work()
|
/obj/item/integrated_circuit/converter/refdecode/do_work()
|
||||||
pull_data()
|
pull_data()
|
||||||
dec=XorEncrypt(hextostr(get_pin_data(IC_INPUT, 1)),SScircuit.cipherkey)
|
dec = XorEncrypt(hextostr(get_pin_data(IC_INPUT, 1), TRUE), SScircuit.cipherkey)
|
||||||
set_pin_data(IC_OUTPUT, 1, WEAKREF(locate(dec)))
|
set_pin_data(IC_OUTPUT, 1, WEAKREF(locate(dec)))
|
||||||
push_data()
|
push_data()
|
||||||
activate_pin(2)
|
activate_pin(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user