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:
Abbie Fland
2018-01-21 23:59:37 +00:00
parent d58b25f1a5
commit 78a1781c8f
2 changed files with 4 additions and 4 deletions

View File

@@ -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

View File

@@ -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