Skip to content

Commit

Permalink
Take Two: The word filter now verbosely describes config failure (Rus…
Browse files Browse the repository at this point in the history
…t-g 1.0.2 Edition) (tgstation#68690)

A resuscitation of tgstation#67474 since Arm is not presently able to do it.

rustg_read_toml_file has backwards dependency to support older cases that checked for lack of list (the old sign the rust fn went wrong).

Fixes tgstation#67446

The configuration for the word filter now verbosely describes the error from the bad toml to the logs, allowing problems with it to be identified quicker and resolved.
Why It's Good For The Game

BLAZING
Ferris warning
Changelog

cl Armhulen/Armhulenn/Bazelart/Tralezab, san7890
admin: Word filters incorrectly set up will now have their errors actually described. Please, tell your server ops when you see it so they may fix the configuration.
server: Rust-g on this codebase is now on the 1.0.2 version, prepare accordingly.
/cl

I also bump rust-g's DLL to 1.0.2 in this PR as well.
  • Loading branch information
san7890 authored Jul 31, 2022
1 parent 3292cae commit 1e540f3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
9 changes: 8 additions & 1 deletion code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@
#define rustg_time_milliseconds(id) text2num(call(RUST_G, "time_milliseconds")(id))
#define rustg_time_reset(id) call(RUST_G, "time_reset")(id)

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

/proc/rustg_read_toml_file(path)
var/list/output = rustg_raw_read_toml_file(path)
if (output["success"])
return json_decode(output["content"])
else
CRASH(output["content"])

#define rustg_url_encode(text) call(RUST_G, "url_encode")("[text]")
#define rustg_url_decode(text) call(RUST_G, "url_decode")(text)
Expand Down
8 changes: 4 additions & 4 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ Example config:
return

log_config("Loading config file word_filter.toml...")

var/list/word_filter = rustg_read_toml_file("[directory]/word_filter.toml")
if (!islist(word_filter))
var/message = "The word filter configuration did not output a list, contact someone with configuration access to make sure it's setup properly."
var/list/result = rustg_read_toml_file("[directory]/word_filter.toml")
if(!result["success"])
var/message = "The word filter is not configured correctly! [result["content"]]"
log_config(message)
DelayedMessageAdmins(message)
return
var/list/word_filter = result["content"]

ic_filter_reasons = try_extract_from_word_filter(word_filter, "ic")
ic_outside_pda_filter_reasons = try_extract_from_word_filter(word_filter, "ic_outside_pda")
Expand Down
2 changes: 1 addition & 1 deletion dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export BYOND_MAJOR=514
export BYOND_MINOR=1560

#rust_g git tag
export RUST_G_VERSION=0.5.0
export RUST_G_VERSION=1.0.2

#node version
export NODE_VERSION=14
Expand Down
Binary file modified rust_g.dll
Binary file not shown.

0 comments on commit 1e540f3

Please sign in to comment.