mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Gene masks (like for plant genes) used unpadded num2hex on a random number 0-255. This had the (technically ok) result of masks for values 1-15 being a single character but also had the (not ok) result of the mask for value 0 being the empty string. This only happened to 1/256 of genes, so was easy to miss. This change pads all of them to 2 characters so this issue won't happen and to line things up nice.
44 lines
1.3 KiB
Plaintext
44 lines
1.3 KiB
Plaintext
//Used to create the gene mask. Shamelessly stolen from the plant controller and cut down.
|
|
|
|
/client/proc/show_xenobio_genes()
|
|
set category = "Debug"
|
|
set name = "Show Xenobio Genes"
|
|
set desc = "Prints the round's plant xenobio masks."
|
|
|
|
if(!holder) return
|
|
|
|
if(!xenobio_controller || !xenobio_controller.gene_tag_masks)
|
|
usr << "Gene masks not set."
|
|
return
|
|
|
|
for(var/mask in xenobio_controller.gene_tag_masks)
|
|
usr << "[mask]: [xenobio_controller.gene_tag_masks[mask]]"
|
|
|
|
var/global/datum/controller/xenobio/xenobio_controller // Set in New().
|
|
|
|
/datum/controller/xenobio
|
|
|
|
var/list/gene_tag_masks = list() // Gene obfuscation for delicious trial and error goodness.
|
|
|
|
/datum/controller/xenobio/New()
|
|
if(xenobio_controller && xenobio_controller != src)
|
|
log_debug("Rebuilding xenobio controller.")
|
|
qdel(xenobio_controller)
|
|
xenobio_controller = src
|
|
setup()
|
|
|
|
|
|
/datum/controller/xenobio/proc/setup()
|
|
|
|
var/list/used_masks = list()
|
|
var/list/xenobio_traits = ALL_XENO_GENES
|
|
while(xenobio_traits && xenobio_traits.len)
|
|
var/gene_tag = pick(xenobio_traits)
|
|
var/gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
|
|
|
while(gene_mask in used_masks)
|
|
gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
|
|
|
used_masks += gene_mask
|
|
xenobio_traits -= gene_tag
|
|
gene_tag_masks[gene_tag] = gene_mask |