Skip to content

Commit

Permalink
[MIRROR] improve randhex (#2943)
Browse files Browse the repository at this point in the history
Co-authored-by: Spookerton <918997+Spookerton@users.noreply.github.com>
  • Loading branch information
SierraHelper and Spookerton authored Dec 2, 2024
1 parent 6e53d62 commit 355e356
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 12 additions & 0 deletions code/_helpers/text.dm
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,18 @@
return "North-Northwest"


/// Returns random hex of char length nibbles
/proc/randhex(nibbles)
var/static/list/chars = list(
"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "a", "b", "c", "d", "e", "f"
)
var/list/result = new (nibbles)
for (var/i = 1 to nibbles)
result[i] = chars[rand(1, 16)]
return jointext(result, "")


/// Check if thing is an SUID. If other is supplied, check if other matches thing.
/proc/is_suid(thing, other)
var/static/regex/suid_check = regex(@"^~[0-9a-zA-Z]{15}$")
Expand Down
6 changes: 0 additions & 6 deletions code/_macros.dm
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,6 @@
#define num2hex(num) num2text(num, 1, 16)


/// Generate random hex up to char length nibbles
/proc/randhex(nibbles)
for (var/i = 1 to nibbles)
. += num2text(rand(0, 15), 1, 16)


/// Increase the size of L by 1 at the end. Is the old last entry index.
#define LIST_INC(L) ((L).len++)

Expand Down

0 comments on commit 355e356

Please sign in to comment.