mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 12:37:26 +01:00
Replace /proc/num2hex with a much faster macro. (#19600)
This commit is contained in:
@@ -242,3 +242,5 @@
|
||||
|
||||
// Gives you the percent of two inputs
|
||||
#define PERCENT_OF(val1, val2) (val1 * (val2 / 100))
|
||||
|
||||
#define num2hex(X, len) uppertext(num2text(X, len, 16))
|
||||
|
||||
@@ -42,23 +42,6 @@
|
||||
i--
|
||||
return num
|
||||
|
||||
//Returns the hex value of a number given a value assumed to be a base-ten value
|
||||
/proc/num2hex(num, placeholder = 2)
|
||||
if(!isnum(num) || num < 0)
|
||||
return
|
||||
|
||||
var/hex = ""
|
||||
while(num)
|
||||
var/val = num % 16
|
||||
num = round(num / 16)
|
||||
|
||||
if(val > 9)
|
||||
val = ascii2text(55 + val) // 65 - 70 correspond to "A" - "F"
|
||||
hex = "[val][hex]"
|
||||
while(length(hex) < placeholder)
|
||||
hex = "0[hex]"
|
||||
return hex || "0"
|
||||
|
||||
//Returns an integer value for R of R/G/B given a hex color input.
|
||||
/proc/color2R(hex)
|
||||
if(!(istext(hex)))
|
||||
|
||||
@@ -1378,9 +1378,7 @@ Standard way to write links -Sayu
|
||||
colour = pick(list("FF0000","FF7F00","FFFF00","00FF00","0000FF","4B0082","8F00FF"))
|
||||
else
|
||||
for(var/i=1;i<=3;i++)
|
||||
var/temp_col = "[num2hex(rand(lower,upper))]"
|
||||
if(length(temp_col )<2)
|
||||
temp_col = "0[temp_col]"
|
||||
var/temp_col = "[num2hex(rand(lower,upper), 2)]"
|
||||
colour += temp_col
|
||||
return colour
|
||||
|
||||
|
||||
@@ -363,7 +363,7 @@ GLOBAL_LIST_EMPTY(bad_blocks)
|
||||
|
||||
|
||||
/proc/EncodeDNABlock(value)
|
||||
return add_zero2(num2hex(value, 1), 3)
|
||||
return num2hex(value, 3)
|
||||
|
||||
/datum/dna/proc/UpdateUI()
|
||||
uni_identity = ""
|
||||
|
||||
@@ -189,7 +189,7 @@
|
||||
return
|
||||
var/datum/data/record/G = new /datum/data/record()
|
||||
G.fields["name"] = "New Record"
|
||||
G.fields["id"] = "[add_zero(num2hex(rand(1, 1.6777215E7)), 6)]"
|
||||
G.fields["id"] = "[num2hex(rand(1, 1.6777215E7), 6)]"
|
||||
G.fields["rank"] = "Unassigned"
|
||||
G.fields["real_rank"] = "Unassigned"
|
||||
G.fields["sex"] = "Male"
|
||||
|
||||
@@ -329,7 +329,7 @@
|
||||
if(ishuman(M))
|
||||
var/mob/living/carbon/human/H = M
|
||||
if(!(NO_BLOOD in H.dna.species.species_traits) && !H.dna.species.exotic_blood)
|
||||
H.dna.species.blood_color = "#[num2hex(rand(0, 255))][num2hex(rand(0, 255))][num2hex(rand(0, 255))]"
|
||||
H.dna.species.blood_color = "#[num2hex(rand(0, 255), 2)][num2hex(rand(0, 255), 2)][num2hex(rand(0, 255), 2)]"
|
||||
return ..()
|
||||
|
||||
/datum/reagent/colorful_reagent/reaction_mob(mob/living/simple_animal/M, method=REAGENT_TOUCH, volume)
|
||||
|
||||
Reference in New Issue
Block a user