Skip to content

Commit

Permalink
Update rust_g to 3.5.1 (tgstation#88181)
Browse files Browse the repository at this point in the history
## About The Pull Request
Kapu told us to do it because it has the function for sound length now.

## Why It's Good For The Game
rust_g updated.

## Changelog
N/A

---------

Co-authored-by: Watermelon914 <[email protected]>
  • Loading branch information
Ghommie and Watermelon914 authored Dec 9, 2024
1 parent fabf382 commit ad7816e
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
71 changes: 68 additions & 3 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,19 @@
#define rustg_git_revparse(rev) RUSTG_CALL(RUST_G, "rg_git_revparse")(rev)

/**
* Returns the date of the given revision in the format YYYY-MM-DD.
* Returns null if the revision is invalid.
* Returns the date of the given revision using the provided format.
* Defaults to returning %F which is YYYY-MM-DD.
*/
#define rustg_git_commit_date(rev) RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev)
/proc/rustg_git_commit_date(rev, format = "%F")
return RUSTG_CALL(RUST_G, "rg_git_commit_date")(rev, format)

/**
* Returns the formatted datetime string of HEAD using the provided format.
* Defaults to returning %F which is YYYY-MM-DD.
* This is different to rustg_git_commit_date because it only needs the logs directory.
*/
/proc/rustg_git_commit_date_head(format = "%F")
return RUSTG_CALL(RUST_G, "rg_git_commit_date_head")(format)

#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
Expand All @@ -187,6 +196,20 @@

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

/**
* Generates a 2D poisson disk distribution ('blue noise'), which is relatively uniform.
*
* params:
* `seed`: str
* `width`: int, width of the noisemap (see world.maxx)
* `length`: int, height of the noisemap (see world.maxy)
* `radius`: int, distance between points on the noisemap
*
* returns:
* a width*length length string of 1s and 0s representing a 2D poisson sample collapsed into a 1D string
*/
#define rustg_noise_poisson_map(seed, width, length, radius) RUSTG_CALL(RUST_G, "noise_poisson_map")(seed, width, length, radius)

/*
* Takes in a string and json_encode()"d lists to produce a sanitized string.
* This function operates on whitelists, there is currently no way to blacklist.
Expand Down Expand Up @@ -238,3 +261,45 @@
#define url_decode(text) rustg_url_decode(text)
#endif

/// Provided a static RSC file path or a raw text file path, returns the duration of the file in deciseconds as a float.
/proc/rustg_sound_length(file_path)
var/static/list/sound_cache
if(isnull(sound_cache))
sound_cache = list()

. = 0

if(!istext(file_path))
if(!isfile(file_path))
CRASH("rustg_sound_length error: Passed non-text object")

if(length("[file_path]")) // Runtime generated RSC references stringify into 0-length strings.
file_path = "[file_path]"
else
CRASH("rustg_sound_length does not support non-static file refs.")

var/cached_length = sound_cache[file_path]
if(!isnull(cached_length))
return cached_length

var/ret = RUSTG_CALL(RUST_G, "sound_len")(file_path)
var/as_num = text2num(ret)
if(isnull(ret))
. = 0
CRASH("rustg_sound_length error: [ret]")

sound_cache[file_path] = as_num
return as_num


#define RUSTG_SOUNDLEN_SUCCESSES "successes"
#define RUSTG_SOUNDLEN_ERRORS "errors"
/**
* Returns a nested key-value list containing "successes" and "errors"
* The format is as follows:
* list(
* RUSTG_SOUNDLEN_SUCCESES = list("sounds/test.ogg" = 25.34),
* RUSTG_SOUNDLEN_ERRORS = list("sound/bad.png" = "SoundLen: Unable to decode file."),
*)
*/
#define rustg_sound_length_list(file_paths) json_decode(RUSTG_CALL(RUST_G, "sound_len_list")(json_encode(file_paths)))
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=515
export BYOND_MINOR=1637

#rust_g git tag
export RUST_G_VERSION=3.3.0
export RUST_G_VERSION=3.5.1

#node version
export NODE_VERSION_LTS=22.11.0
Expand Down
Binary file modified rust_g.dll
Binary file not shown.

0 comments on commit ad7816e

Please sign in to comment.