Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aneri, take 2 #1618

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
055c3f8
Aneri time~
Absolucy Feb 11, 2024
c5a5907
Update Aneri libraries (from CI run: https://github.com/Absolucy/aner…
Absolucy Apr 8, 2024
430a3f2
Fix DME sorting
Absolucy Apr 9, 2024
d2350fe
Fix detecting `libaneri.so` on Linux
Absolucy Apr 9, 2024
3dc300b
Actually add `libaneri.so` to repo.
Absolucy Apr 9, 2024
9b1370b
ACTUALLY get CI working
Absolucy Apr 9, 2024
adfcb14
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 12, 2024
a74a7ba
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 13, 2024
dba7573
Use `rel-debugging` CI builds for now
Absolucy Apr 13, 2024
1f6e5b5
Aneri update (Fuck it, let's try snmalloc)
Absolucy Apr 14, 2024
1793e08
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 14, 2024
ea2a272
satisfy the outdated linter
Absolucy Apr 14, 2024
51d5223
bleh
Absolucy Apr 14, 2024
c6dbab0
Update `dependencies.sh`; ensure libclang is installed
Absolucy Apr 14, 2024
537a3a9
not relevant, don't touch that
Absolucy Apr 14, 2024
a4ad896
try to fix CI
Absolucy Apr 14, 2024
1d574ab
ensure admins can never mess up aneri keys
Absolucy Apr 14, 2024
553a3e7
Ensure admins can't fuck up `/datum/aneri`.
Absolucy Apr 14, 2024
ea89ad3
bwah
Absolucy Apr 14, 2024
ccb7e6b
... what about just no snmalloc on linux?
Absolucy Apr 14, 2024
496cfe8
Use Aneri instant timers
Absolucy Apr 14, 2024
94b0490
more stuff
Absolucy Apr 14, 2024
195b2cd
Round the seconds, because it's too damned precise otherwise.
Absolucy Apr 14, 2024
4dc8ca4
just round that to prevent inaccuracies
Absolucy Apr 14, 2024
ce095b8
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 15, 2024
aa98021
Offload the infamously slow `stars` proc to aneri, using `aneri_repla…
Absolucy Apr 15, 2024
c1e5e0c
don't use aneri pick for now
Absolucy Apr 15, 2024
e0994b0
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 18, 2024
3ec531a
Revert "don't use aneri pick for now"
Absolucy Apr 18, 2024
435a388
Aneri, now with better reftracking
Absolucy Apr 18, 2024
5ea3bf8
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 18, 2024
6dee7f4
Reapply "don't use aneri pick for now"
Absolucy Apr 19, 2024
74b03c7
Revert "Reapply "don't use aneri pick for now""
Absolucy Apr 20, 2024
a978ddc
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Apr 22, 2024
e1351b9
debuggy wuggy
Absolucy Apr 22, 2024
9f1fa3b
bweh
Absolucy Apr 22, 2024
fc6f309
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 6, 2024
96ee63d
woop woop update time!
Absolucy May 6, 2024
66f42d2
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 7, 2024
3ed0336
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 9, 2024
9dc5b77
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 13, 2024
46e84a5
Update Aneri binaries
Absolucy May 13, 2024
6ca74b1
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 22, 2024
c1b4748
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 24, 2024
cf63f58
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 25, 2024
0f43b91
Update Aneri (pick_weight hopefully works edition)
Absolucy May 25, 2024
7c3c5e2
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 26, 2024
3ff2b30
anrei
Absolucy May 26, 2024
219ebc6
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy May 31, 2024
304b53f
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 1, 2024
db9c74b
Port superior pick_weight implementation
Absolucy Jun 2, 2024
403a555
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 7, 2024
0bcf812
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 7, 2024
e3ad6fc
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 7, 2024
c4fecce
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 7, 2024
b5bc07e
Fix broken weights
Absolucy Jun 7, 2024
4c2798e
Merge branch 'weight-pick-fixes' of https://github.com/Absolucy/Monke…
Absolucy Jun 7, 2024
3957faa
pick_weight override
Absolucy Jun 7, 2024
70c52ad
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jun 7, 2024
5614ac1
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 13, 2024
a28a07c
update aneri
Absolucy Jul 13, 2024
60aecb3
more debug info for SSgamemode
Absolucy Jul 13, 2024
fa2b3af
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 20, 2024
fd2e46a
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 25, 2024
2da3ddc
Update aneri binaries (https://github.com/Absolucy/aneri/actions/runs…
Absolucy Jul 25, 2024
103e86a
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 26, 2024
cb96827
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 26, 2024
418b303
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Jul 29, 2024
e2918e0
Add new regex functions to aneri defines
Absolucy Jul 30, 2024
76cf6e1
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Aug 2, 2024
515efa4
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Aug 13, 2024
c366246
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Aug 20, 2024
d4d7a91
Merge branch 'master' of https://github.com/Monkestation/Monkestation…
Absolucy Aug 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,8 @@ config/dbconfig.txt

# Running OpenDream locally
tgstation.json

meowtonin*

# TODO: REMOVE BEFORE FULL MERGE!!! (this is so CI works)
!/libaneri.so
49 changes: 35 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ RUN dpkg --add-architecture i386 \
&& apt-get upgrade -y \
&& apt-get dist-upgrade -y \
&& apt-get install -y --no-install-recommends \
ca-certificates
ca-certificates

# byond = base + byond installed globally
FROM base AS byond
WORKDIR /byond

RUN apt-get install -y --no-install-recommends \
curl \
unzip \
make \
libstdc++6:i386
curl \
unzip \
make \
libstdc++6:i386

COPY dependencies.sh .

Expand All @@ -35,7 +35,7 @@ FROM byond AS build
WORKDIR /tgstation

RUN apt-get install -y --no-install-recommends \
curl
curl

COPY . .

Expand All @@ -45,7 +45,7 @@ RUN env TG_BOOTSTRAP_NODE_LINUX=1 tools/build/build \
# rust = base + rustc and i686 target
FROM base AS rust
RUN apt-get install -y --no-install-recommends \
curl && \
curl && \
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal \
&& ~/.cargo/bin/rustup target add i686-unknown-linux-gnu

Expand All @@ -54,10 +54,10 @@ FROM rust AS rust_g
WORKDIR /rust_g

RUN apt-get install -y --no-install-recommends \
pkg-config:i386 \
libssl-dev:i386 \
gcc-multilib \
git \
pkg-config:i386 \
libssl-dev:i386 \
gcc-multilib \
git \
&& git init \
&& git remote add origin https://github.com/tgstation/rust-g

Expand All @@ -68,16 +68,37 @@ RUN . ./dependencies.sh \
&& git checkout FETCH_HEAD \
&& env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --target i686-unknown-linux-gnu

# final = byond + runtime deps + rust_g + build
# aneri = base + aneri compiled to /aneri
FROM rust AS aneri
WORKDIR /aneri

RUN apt-get install -y --no-install-recommends \
pkg-config:i386 \
libssl-dev:i386 \
gcc-multilib \
clang \
git \
&& git init \
&& git remote add origin https://github.com/Absolucy/aneri

COPY dependencies.sh .

RUN . ./dependencies.sh \
&& git fetch --depth 1 origin "${ANERI_VERSION}" \
&& git checkout FETCH_HEAD \
&& env PKG_CONFIG_ALLOW_CROSS=1 ~/.cargo/bin/cargo build --release --target i686-unknown-linux-gnu

# final = byond + runtime deps + rust_g + aneri + build
FROM byond
WORKDIR /tgstation

RUN apt-get install -y --no-install-recommends \
libssl1.0.0:i386 \
zlib1g:i386
libssl1.0.0:i386 \
zlib1g:i386

COPY --from=build /deploy ./
COPY --from=rust_g /rust_g/target/i686-unknown-linux-gnu/release/librust_g.so ./librust_g.so
COPY --from=aneri /aneri/target/i686-unknown-linux-gnu/release/libaneri.so ./libaneri.so

VOLUME [ "/tgstation/config", "/tgstation/data" ]
ENTRYPOINT [ "DreamDaemon", "tgstation.dmb", "-port", "1337", "-trusted", "-close", "-verbose" ]
Expand Down
Binary file added aneri.dll
Binary file not shown.
Binary file added aneri.pdb
Binary file not shown.
118 changes: 118 additions & 0 deletions code/__DEFINES/aneri.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#ifndef ANERI

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

/* This comment bypasses grep checks */ /var/__aneri

/proc/__detect_aneri()
if(world.system_type == UNIX)
return __aneri = "libaneri"
else
return __aneri = "aneri"

#define ANERI (__aneri || __detect_aneri())
#define ANERI_CALL(name, args...) call_ext(ANERI, "byond:" + name)(args)

/proc/aneri_version() return ANERI_CALL("aneri_version")
/proc/aneri_features() return ANERI_CALL("aneri_features")
/proc/aneri_cleanup() return ANERI_CALL("cleanup")

#define aneri_log_write(fname, text, format) ANERI_CALL("log_write", "[fname]", text, format)
/proc/aneri_log_close_all() return ANERI_CALL("log_close_all")

#define aneri_json_is_valid(text) ANERI_CALL("json_is_valid", text)

/proc/aneri_hex_encode(input, upper = FALSE)
return ANERI_CALL("hex_encode", input, upper)

#define aneri_hex_decode(input) ANERI_CALL("hex_decode", input)

#define aneri_url_encode(input) ANERI_CALL("url_encode", input)
#define aneri_url_decode(input) ANERI_CALL("url_decode", input)

#define url_encode(text) aneri_url_encode("[text]")
#define url_decode(text) aneri_url_decode("[text]")

#define aneri_base64_encode(input) ANERI_CALL("base64_encode", input)
#define aneri_base64_decode(input) ANERI_CALL("base64_decode", input)
#define aneri_base64url_encode(input) ANERI_CALL("base64url_encode", input)
#define aneri_base64url_decode(input) ANERI_CALL("base64url_decode", input)

/proc/aneri_uuid() return ANERI_CALL("uuid")
/proc/aneri_cuid2(len = null) return ANERI_CALL("cuid2", len)
/proc/aneri_unix_timestamp() return ANERI_CALL("unix_timestamp")

#define aneri_sort(value, sorter) ANERI_CALL("sort", value, sorter)

#define aneri_file_exists(file) ANERI_CALL("file_exists", "[file]")
#define aneri_file_read(file) ANERI_CALL("file_read", "[file]")
#define aneri_file_write(data, file) ANERI_CALL("file_write", "[file]", "[data]")
#define aneri_file_append(data, file) ANERI_CALL("file_append", "[file]", "[data]")
#define aneri_file_get_line_count(file) ANERI_CALL("file_get_line_count", "[file]")
#define aneri_file_seek_line(file, line) ANERI_CALL("file_seek", "[file]", line)
#define aneri_file_delete(file) ANERI_CALL("file_delete", "[file]")
#define aneri_mkdir(path) ANERI_CALL("mkdir", "[path]")
#define aneri_rmdir(path) ANERI_CALL("rmdir", "[path]")

#define aneri_toml_is_valid(toml) ANERI_CALL("aneri_toml_is_valid", "[toml]")
#define aneri_toml_decode(toml) ANERI_CALL("toml_decode", "[toml]")
#define aneri_toml_decode_file(file) ANERI_CALL("toml_decode_file", "[file]")

/// Use instead of REGEX_QUOTE for aneri regex
#define aneri_regex_escape(pattern) ANERI_CALL("regex_escape", "[pattern]")
#define aneri_regex_combine_list(patterns) ANERI_CALL("regex_combine_list", islist(patterns) ? patterns : list(patterns))

//#define file2text(fname) aneri_file_read("[fname]")
//#define text2file(text, fname) aneri_file_append(text, "[fname]")

#define aneri_md5(input) ANERI_CALL("hash", "md5", input)
#define aneri_md5_file(fname) ANERI_CALL("hash_file", "md5", fname)

/proc/aneri_replace_chars_prob(input, replacement, probability = 25, skip_whitespace = FALSE) as text
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_pick_weighted(list)
#endif

#ifdef ANERI_OVERRIDE_PICK
#define pick(list...) _apick(list)

/proc/_apick(...)
switch(length(args))
if(0)
CRASH("pick() called with no arguments")
if(1)
var/list/arg = args[1]
if(!islist(arg))
CRASH("pick() called with non-list argument")
return _aneri_pick(arg)
else
return _aneri_pick(args)
#endif

#ifdef ANERI_OVERRIDE_RAND
/proc/_arand(...)
switch(length(args))
if(0)
return ANERI_CALL("random_float")
if(1)
return ANERI_CALL("random_range_int_unsigned", 0, args[1])
if(2)
return ANERI_CALL("random_range_int_signed", args[1], args[2])
else
CRASH("arand() takes 0-2 arguments")

#define rand(args...) _arand(args)
#define prob(val) ANERI_CALL("prob", val)
#endif

/world/New()
aneri_startup_log()
aneri_cleanup()
..()

#endif
6 changes: 3 additions & 3 deletions code/__DEFINES/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,6 @@
#define SEND_TEXT(target, text) DIRECT_OUTPUT(target, text)
#define WRITE_FILE(file, text) DIRECT_OUTPUT(file, text)
#define READ_FILE(file, text) DIRECT_INPUT(file, text)
//This is an external call, "true" and "false" are how rust parses out booleans
#define WRITE_LOG(log, text) rustg_log_write(log, text, "true")
#define WRITE_LOG_NO_FORMAT(log, text) rustg_log_write(log, text, "false")

#define WRITE_LOG(log, text) aneri_log_write(log, text, TRUE)
#define WRITE_LOG_NO_FORMAT(log, text) aneri_log_write(log, text, FALSE)
26 changes: 13 additions & 13 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@
#define rustg_dmi_icon_states(fname) RUSTG_CALL(RUST_G, "dmi_icon_states")(fname)

#define rustg_file_read(fname) RUSTG_CALL(RUST_G, "file_read")(fname)
#define rustg_file_exists(fname) (RUSTG_CALL(RUST_G, "file_exists")(fname) == "true")
//#define rustg_file_exists(fname) (RUSTG_CALL(RUST_G, "file_exists")(fname) == "true")
#define rustg_file_write(text, fname) RUSTG_CALL(RUST_G, "file_write")(text, fname)
#define rustg_file_append(text, fname) RUSTG_CALL(RUST_G, "file_append")(text, fname)
/*#define rustg_file_append(text, fname) RUSTG_CALL(RUST_G, "file_append")(text, fname)
#define rustg_file_get_line_count(fname) text2num(RUSTG_CALL(RUST_G, "file_get_line_count")(fname))
#define rustg_file_seek_line(fname, line) RUSTG_CALL(RUST_G, "file_seek_line")(fname, "[line]")
#define rustg_file_seek_line(fname, line) RUSTG_CALL(RUST_G, "file_seek_line")(fname, "[line]")*/

#ifdef RUSTG_OVERRIDE_BUILTINS
#define file2text(fname) rustg_file_read("[fname]")
Expand Down Expand Up @@ -166,10 +166,10 @@
#define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB"
#define RUSTG_JOB_ERROR "JOB PANICKED"

#define rustg_json_is_valid(text) (RUSTG_CALL(RUST_G, "json_is_valid")(text) == "true")
//#define rustg_json_is_valid(text) (RUSTG_CALL(RUST_G, "json_is_valid")(text) == "true")

#define rustg_log_write(fname, text, format) RUSTG_CALL(RUST_G, "log_write")(fname, text, format)
/proc/rustg_log_close_all() return RUSTG_CALL(RUST_G, "log_close_all")()
/*#define rustg_log_write(fname, text, format) RUSTG_CALL(RUST_G, "log_write")(fname, text, format)
/proc/rustg_log_close_all() return RUSTG_CALL(RUST_G, "log_close_all")()*/

#define rustg_noise_get_at_coordinates(seed, x, y) RUSTG_CALL(RUST_G, "noise_get_at_coordinates")(seed, x, y)

Expand All @@ -190,13 +190,14 @@
#define rustg_sql_disconnect_pool(handle) RUSTG_CALL(RUST_G, "sql_disconnect_pool")(handle)
#define rustg_sql_check_query(job_id) RUSTG_CALL(RUST_G, "sql_check_query")("[job_id]")

#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
/*#define rustg_time_microseconds(id) text2num(RUSTG_CALL(RUST_G, "time_microseconds")(id))
#define rustg_time_milliseconds(id) text2num(RUSTG_CALL(RUST_G, "time_milliseconds")(id))
#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)
#define rustg_time_reset(id) RUSTG_CALL(RUST_G, "time_reset")(id)*/


/// Returns the timestamp as a string
/proc/rustg_unix_timestamp()
return RUSTG_CALL(RUST_G, "unix_timestamp")()
/*/proc/rustg_unix_timestamp()
return RUSTG_CALL(RUST_G, "unix_timestamp")()*/

#define rustg_raw_read_toml_file(path) json_decode(RUSTG_CALL(RUST_G, "toml_file_to_json")(path) || "null")

Expand All @@ -216,11 +217,10 @@
else
CRASH(output["content"])

#define rustg_url_encode(text) RUSTG_CALL(RUST_G, "url_encode")("[text]")
/*#define rustg_url_encode(text) RUSTG_CALL(RUST_G, "url_encode")("[text]")
#define rustg_url_decode(text) RUSTG_CALL(RUST_G, "url_decode")(text)

#ifdef RUSTG_OVERRIDE_BUILTINS
#define url_encode(text) rustg_url_encode(text)
#define url_decode(text) rustg_url_decode(text)
#endif

#endif*/
4 changes: 2 additions & 2 deletions code/__DEFINES/rust_g_overrides.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// RUSTG_OVERRIDE_BUILTINS is not used since the file APIs don't work well over Linux.
#define url_encode(text) rustg_url_encode("[text]")
#define url_decode(text) rustg_url_decode("[text]")
/*#define url_encode(text) rustg_url_encode("[text]")
#define url_decode(text) rustg_url_decode("[text]")*/
2 changes: 2 additions & 0 deletions code/__HELPERS/_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@
result = first ^ second
return result

#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 All @@ -448,6 +449,7 @@
if(total <= 0)
return item
return null
#endif

/**
* Like pick_weight, but allowing for nested lists.
Expand Down
File renamed without changes.
39 changes: 39 additions & 0 deletions code/__HELPERS/aneri.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/datum/aneri
var/__aneri_key_low
var/__aneri_key_high

/datum/aneri/vv_edit_var(var_name, var_value)
if(var_name == NAMEOF(src, __aneri_key_low) || var_name == NAMEOF(src, __aneri_key_high))
return FALSE // DO. NOT. TOUCH.
return ..()

// contained in its own proc to prevent runtime shittery
/proc/aneri_startup_log()
log_world("Aneri version [aneri_version()] loaded")
log_world("Aneri features: [aneri_features()]")

/proc/assoc_to_weights(list/list_to_pick) as /list
. = list()
for(var/item in list_to_pick)
. += list_to_pick[item]

/proc/_aneri_pick(list/choices, secure = FALSE)
var/choices_len = length(choices)
switch(choices_len)
if(0)
return null
if(1)
return choices[1]
else
var/idx = ANERI_CALL("random_range_int_unsigned", 1, choices_len, secure)
return choices[idx]

/proc/_aneri_pick_weighted(list/list_to_pick, secure = FALSE)
if(!islist(list_to_pick))
stack_trace("Attempted to do a weighted pick from a non-list")
return null
if(!length(list_to_pick))
return null
var/chosen_idx = ANERI_CALL("pick_weighted", assoc_to_weights(list_to_pick), secure)
return list_to_pick[chosen_idx]

6 changes: 2 additions & 4 deletions code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
/proc/random_colour(mode = 0)
switch(mode)
if(0)
return pick("white","black","gray","red","green","blue","brown","yellow","orange","darkred",
"crimson","lime","darkgreen","cyan","navy","teal","purple","indigo")
return pick("white","black","gray","red","green","blue","brown","yellow","orange","darkred","crimson","lime","darkgreen","cyan","navy","teal","purple","indigo")
if(1)
return pick("red","green","blue","brown","yellow","orange","darkred","crimson",
"lime","darkgreen","cyan","navy","teal","purple","indigo")
return pick("red","green","blue","brown","yellow","orange","darkred","crimson", "lime","darkgreen","cyan","navy","teal","purple","indigo")
else
return "white"

Expand Down
10 changes: 2 additions & 8 deletions code/__HELPERS/files.dm
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,13 @@ GLOBAL_VAR_INIT(fileaccess_timer, 0)
/proc/pathflatten(path)
return replacetext(path, "/", "_")

/// Returns the md5 of a file at a given path.
/proc/md5filepath(path)
. = md5(file(path))

/// Save file as an external file then md5 it.
/// Used because md5ing files stored in the rsc sometimes gives incorrect md5 results.
/proc/md5asfile(file)
var/static/notch = 0
// its importaint this code can handle md5filepath sleeping instead of hard blocking, if it's converted to use rust_g.
var/filename = "tmp/md5asfile.[world.realtime].[world.timeofday].[world.time].[world.tick_usage].[notch]"
notch = WRAP(notch+1, 0, 2**15)
var/filename = "tmp/md5asfile.[aneri_uuid()]"
fcopy(file, filename)
. = md5filepath(filename)
. = aneri_md5_file(filename)
fdel(filename)

/**
Expand Down
Loading
Loading