Skip to content

Commit

Permalink
pick_weight override
Browse files Browse the repository at this point in the history
  • Loading branch information
Absolucy committed Jun 7, 2024
1 parent 4c2798e commit 3957faa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion code/__DEFINES/aneri.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef ANERI

//#define ANERI_OVERRIDE_PICK
#define ANERI_OVERRIDE_PICK_WEIGHT
//#define ANERI_OVERRIDE_SORT
#define ANERI_OVERRIDE_RAND

Expand Down Expand Up @@ -70,9 +71,12 @@
/proc/aneri_replace_chars_prob(input, replacement, probability = 25, skip_whitespace = FALSE)
return ANERI_CALL("replace_chars_prob", input, replacement, probability, skip_whitespace)

#if defined(ANERI_OVERRIDE_PICK) || defined(ANERI_OVERRIDE_PICK_WEIGHT)
#define pick_weight(list) ANERI_CALL("pick_weighted", list)
#endif

#ifdef ANERI_OVERRIDE_PICK
#define pick(list...) _apick(list)
#define pick_weight(list) ANERI_CALL("pick_weighted", list)

/proc/_apick(...)
switch(length(args))
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@
result = first ^ second
return result

#ifndef ANERI_OVERRIDE_PICK
#if !defined(ANERI_OVERRIDE_PICK) && !defined(ANERI_OVERRIDE_PICK_WEIGHT)
/**
* Picks a random element from a list based on a weighting system.
* For example, given the following list:
Expand Down

0 comments on commit 3957faa

Please sign in to comment.