Skip to content

Commit

Permalink
External Lib Fix-Ups (#622)
Browse files Browse the repository at this point in the history
## About The Pull Request

Who knew that being inactive for nearly 6 months would cause things to
slowly break?

tgstation/tgstation#80955
tgstation/tgstation#83635
tgstation/tgstation#88181
  • Loading branch information
RimiNosha authored Dec 23, 2024
1 parent bf6687a commit b9bc840
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 6 deletions.
93 changes: 91 additions & 2 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@
#define rustg_cnoise_generate(percentage, smoothing_iterations, birth_limit, death_limit, width, height) \
call_ext(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height)

/**
* This proc generates a grid of perlin-like noise
*
* Returns a single string that goes row by row, with values of 1 representing an turned on cell, and a value of 0 representing a turned off cell.
*
* Arguments:
* * seed: seed for the function
* * accuracy: how close this is to the original perlin noise, as accuracy approaches infinity, the noise becomes more and more perlin-like
* * stamp_size: Size of a singular stamp used by the algorithm, think of this as the same stuff as frequency in perlin noise
* * world_size: size of the returned grid.
* * lower_range: lower bound of values selected for. (inclusive)
* * upper_range: upper bound of values selected for. (exclusive)
*/
#define rustg_dbp_generate(seed, accuracy, stamp_size, world_size, lower_range, upper_range) \
call_ext(RUST_G, "dbp_generate")(seed, accuracy, stamp_size, world_size, lower_range, upper_range)

#define rustg_dmi_strip_metadata(fname) call_ext(RUST_G, "dmi_strip_metadata")(fname)
#define rustg_dmi_create_png(path, width, height, data) call_ext(RUST_G, "dmi_create_png")(path, width, height, data)
#define rustg_dmi_resize_png(path, width, height, resizetype) call_ext(RUST_G, "dmi_resize_png")(path, width, height, resizetype)
Expand All @@ -111,7 +127,7 @@
#define rustg_dmi_icon_states(fname) call_ext(RUST_G, "dmi_icon_states")(fname)

#define rustg_file_read(fname) call_ext(RUST_G, "file_read")(fname)
#define rustg_file_exists(fname) call_ext(RUST_G, "file_exists")(fname)
#define rustg_file_exists(fname) (call_ext(RUST_G, "file_exists")(fname) == "true")
#define rustg_file_write(text, fname) call_ext(RUST_G, "file_write")(text, fname)
#define rustg_file_append(text, fname) call_ext(RUST_G, "file_append")(text, fname)
#define rustg_file_get_line_count(fname) text2num(call_ext(RUST_G, "file_get_line_count")(fname))
Expand All @@ -122,8 +138,23 @@
#define text2file(text, fname) rustg_file_append(text, "[fname]")
#endif

/// Returns the git hash of the given revision, ex. "HEAD".
#define rustg_git_revparse(rev) call_ext(RUST_G, "rg_git_revparse")(rev)
#define rustg_git_commit_date(rev) call_ext(RUST_G, "rg_git_commit_date")(rev)

/**
* Returns the date of the given revision using the provided format.
* Defaults to returning %F which is YYYY-MM-DD.
*/
/proc/rustg_git_commit_date(rev, format = "%F")
return call_ext(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 call_ext(RUST_G, "rg_git_commit_date_head")(format)

#define RUSTG_HTTP_METHOD_GET "get"
#define RUSTG_HTTP_METHOD_PUT "put"
Expand All @@ -146,6 +177,30 @@

#define rustg_noise_get_at_coordinates(seed, x, y) call_ext(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.
* Args:
* * text: the string to sanitize.
* * attribute_whitelist_json: a json_encode()'d list of HTML attributes to allow in the final string.
* * tag_whitelist_json: a json_encode()'d list of HTML tags to allow in the final string.
*/
#define rustg_sanitize_html(text, attribute_whitelist_json, tag_whitelist_json) RUSTG_CALL(RUST_G, "sanitize_html")(text, attribute_whitelist_json, tag_whitelist_json)

#define rustg_sql_connect_pool(options) call_ext(RUST_G, "sql_connect_pool")(options)
#define rustg_sql_query_async(handle, query, params) call_ext(RUST_G, "sql_query_async")(handle, query, params)
#define rustg_sql_query_blocking(handle, query, params) call_ext(RUST_G, "sql_query_blocking")(handle, query, params)
Expand Down Expand Up @@ -178,3 +233,37 @@
#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 = call_ext(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)))
8 changes: 4 additions & 4 deletions dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ export BYOND_MAJOR=515
export BYOND_MINOR=1639

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

#node version
export NODE_VERSION=16
export NODE_VERSION_PRECISE=18.14.2

# SpacemanDMM git tag
export SPACEMAN_DMM_VERSION=suite-1.8
export SPACEMAN_DMM_VERSION=suite-1.9

# Python version for mapmerge and other tools
export PYTHON_VERSION=3.9.0

#hypnagogic repo
export CUTTER_REPO=actioninja/hypnagogic
export CUTTER_REPO=spacestation13/hypnagogic

#hypnagogic git tag
export CUTTER_VERSION=v3.0.1
export CUTTER_VERSION=v4.0.0
Binary file modified rust_g.dll
Binary file not shown.

0 comments on commit b9bc840

Please sign in to comment.