mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Fixes rare empty gene_mask
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.
This commit is contained in:
@@ -90,10 +90,10 @@ var/global/datum/controller/plants/plant_controller // Set in New().
|
||||
var/list/plant_traits = ALL_GENES
|
||||
while(plant_traits && plant_traits.len)
|
||||
var/gene_tag = pick(plant_traits)
|
||||
var/gene_mask = "[uppertext(num2hex(rand(0,255)))]"
|
||||
var/gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
||||
|
||||
while(gene_mask in used_masks)
|
||||
gene_mask = "[uppertext(num2hex(rand(0,255)))]"
|
||||
gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
||||
|
||||
var/decl/plantgene/G
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ var/global/datum/controller/xenobio/xenobio_controller // Set in New().
|
||||
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)))]"
|
||||
var/gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
||||
|
||||
while(gene_mask in used_masks)
|
||||
gene_mask = "[uppertext(num2hex(rand(0,255)))]"
|
||||
gene_mask = "[uppertext(num2hex(rand(0,255), 2))]"
|
||||
|
||||
used_masks += gene_mask
|
||||
xenobio_traits -= gene_tag
|
||||
|
||||
Reference in New Issue
Block a user