diff --git a/aurorastation.dme b/aurorastation.dme index 050805ca744..29c073caa5d 100644 --- a/aurorastation.dme +++ b/aurorastation.dme @@ -71,6 +71,7 @@ #include "code\__defines\research.dm" #include "code\__defines\ruin_tags.dm" #include "code\__defines\rust_g.dm" +#include "code\__defines\rust_g_debug.dm" #include "code\__defines\ship_weapons.dm" #include "code\__defines\shuttle.dm" #include "code\__defines\singletons.dm" diff --git a/code/__defines/rust_g.dm b/code/__defines/rust_g.dm index 2d7e2c3c5de..ddbc97cb0e9 100644 --- a/code/__defines/rust_g.dm +++ b/code/__defines/rust_g.dm @@ -41,6 +41,65 @@ /// Gets the version of rust_g /proc/rustg_get_version() return LIBCALL(RUST_G, "get_version")() + +/** + * Sets up the Aho-Corasick automaton with its default options. + * + * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call + * Arguments: + * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls + * * patterns - A non-associative list of strings to search for + * * replacements - Default replacements for this automaton, used with rustg_acreplace + */ +#define rustg_setup_acreplace(key, patterns, replacements) LIBCALL(RUST_G, "setup_acreplace")(key, json_encode(patterns), json_encode(replacements)) + +/** + * Sets up the Aho-Corasick automaton using supplied options. + * + * The search patterns list and the replacements must be of the same length when replace is run, but an empty replacements list is allowed if replacements are supplied with the replace call + * Arguments: + * * key - The key for the automaton, to be used with subsequent rustg_acreplace/rustg_acreplace_with_replacements calls + * * options - An associative list like list("anchored" = 0, "ascii_case_insensitive" = 0, "match_kind" = "Standard"). The values shown on the example are the defaults, and default values may be omitted. See the identically named methods at https://docs.rs/aho-corasick/latest/aho_corasick/struct.AhoCorasickBuilder.html to see what the options do. + * * patterns - A non-associative list of strings to search for + * * replacements - Default replacements for this automaton, used with rustg_acreplace + */ +#define rustg_setup_acreplace_with_options(key, options, patterns, replacements) LIBCALL(RUST_G, "setup_acreplace")(key, json_encode(options), json_encode(patterns), json_encode(replacements)) + +/** + * Run the specified replacement engine with the provided haystack text to replace, returning replaced text. + * + * Arguments: + * * key - The key for the automaton + * * text - Text to run replacements on + */ +#define rustg_acreplace(key, text) LIBCALL(RUST_G, "acreplace")(key, text) + +/** + * Run the specified replacement engine with the provided haystack text to replace, returning replaced text. + * + * Arguments: + * * key - The key for the automaton + * * text - Text to run replacements on + * * replacements - Replacements for this call. Must be the same length as the set-up patterns + */ +#define rustg_acreplace_with_replacements(key, text, replacements) LIBCALL(RUST_G, "acreplace_with_replacements")(key, text, json_encode(replacements)) + +/** + * This proc generates a cellular automata noise grid which can be used in procedural generation methods. + * + * Returns a single string that goes row by row, with values of 1 representing an alive cell, and a value of 0 representing a dead cell. + * + * Arguments: + * * percentage: The chance of a turf starting closed + * * smoothing_iterations: The amount of iterations the cellular automata simulates before returning the results + * * birth_limit: If the number of neighboring cells is higher than this amount, a cell is born + * * death_limit: If the number of neighboring cells is lower than this amount, a cell dies + * * width: The width of the grid. + * * height: The height of the grid. + */ +#define rustg_cnoise_generate(percentage, smoothing_iterations, birth_limit, death_limit, width, height) \ + LIBCALL(RUST_G, "cnoise_generate")(percentage, smoothing_iterations, birth_limit, death_limit, width, height) + #define rustg_dmi_strip_metadata(fname) LIBCALL(RUST_G, "dmi_strip_metadata")(fname) #define rustg_dmi_create_png(path, width, height, data) LIBCALL(RUST_G, "dmi_create_png")(path, width, height, data) #define rustg_dmi_resize_png(path, width, height, resizetype) LIBCALL(RUST_G, "dmi_resize_png")(path, width, height, resizetype) @@ -49,6 +108,8 @@ #define rustg_file_exists(fname) LIBCALL(RUST_G, "file_exists")(fname) #define rustg_file_write(text, fname) LIBCALL(RUST_G, "file_write")(text, fname) #define rustg_file_append(text, fname) LIBCALL(RUST_G, "file_append")(text, fname) +#define rustg_file_get_line_count(fname) text2num(LIBCALL(RUST_G, "file_get_line_count")(fname)) +#define rustg_file_seek_line(fname, line) LIBCALL(RUST_G, "file_seek_line")(fname, "[line]") #ifdef RUSTG_OVERRIDE_BUILTINS #define file2text(fname) rustg_file_read("[fname]") @@ -88,13 +149,45 @@ #define RUSTG_JOB_NO_SUCH_JOB "NO SUCH JOB" #define RUSTG_JOB_ERROR "JOB PANICKED" +#define rustg_json_is_valid(text) (LIBCALL(RUST_G, "json_is_valid")(text) == "true") + #define rustg_log_write(fname, text, format) LIBCALL(RUST_G, "log_write")(fname, text, format) /proc/rustg_log_close_all() return LIBCALL(RUST_G, "log_close_all")() +#define rustg_noise_get_at_coordinates(seed, x, y) LIBCALL(RUST_G, "noise_get_at_coordinates")(seed, x, y) + +#define rustg_sql_connect_pool(options) LIBCALL(RUST_G, "sql_connect_pool")(options) +#define rustg_sql_query_async(handle, query, params) LIBCALL(RUST_G, "sql_query_async")(handle, query, params) +#define rustg_sql_query_blocking(handle, query, params) LIBCALL(RUST_G, "sql_query_blocking")(handle, query, params) +#define rustg_sql_connected(handle) LIBCALL(RUST_G, "sql_connected")(handle) +#define rustg_sql_disconnect_pool(handle) LIBCALL(RUST_G, "sql_disconnect_pool")(handle) +#define rustg_sql_check_query(job_id) LIBCALL(RUST_G, "sql_check_query")("[job_id]") + #define rustg_time_microseconds(id) text2num(LIBCALL(RUST_G, "time_microseconds")(id)) #define rustg_time_milliseconds(id) text2num(LIBCALL(RUST_G, "time_milliseconds")(id)) #define rustg_time_reset(id) LIBCALL(RUST_G, "time_reset")(id) +/proc/rustg_unix_timestamp() + return text2num(LIBCALL(RUST_G, "unix_timestamp")()) + +#define rustg_raw_read_toml_file(path) json_decode(LIBCALL(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_raw_toml_encode(value) json_decode(LIBCALL(RUST_G, "toml_encode")(json_encode(value))) + +/proc/rustg_toml_encode(value) + var/list/output = rustg_raw_toml_encode(value) + if (output["success"]) + return output["content"] + else + CRASH(output["content"]) + #define rustg_udp_send(addr, text) LIBCALL(RUST_G, "udp_send")(addr, text) #define rustg_url_encode(text) LIBCALL(RUST_G, "url_encode")("[text]") diff --git a/code/__defines/rust_g_debug.dm b/code/__defines/rust_g_debug.dm new file mode 100644 index 00000000000..1847ab42759 --- /dev/null +++ b/code/__defines/rust_g_debug.dm @@ -0,0 +1,12 @@ +/** + * Debug verb for our custom UDP module, generally used for gelf logging + */ +/client/proc/rustg_send_udp() + set name = "RUSTG Send UDP" + set category = "Debug" + set desc = "Sends an UDP text packet using our rust_g custom module." + var/destination = input(usr, "Address in ip:port format.", "Address", null) + var/message = input(usr, "Message to send.", "Message", null) + + if(destination && message) + rustg_udp_send(destination, message) diff --git a/code/datums/trading/ai.dm b/code/datums/trading/ai.dm index 33a1c1147cb..55740600e5a 100644 --- a/code/datums/trading/ai.dm +++ b/code/datums/trading/ai.dm @@ -67,7 +67,6 @@ /obj/item/device/depth_scanner = TRADER_BLACKLIST, // Xenoarch /obj/item/device/beacon_locator = TRADER_BLACKLIST, // Telescience /obj/item/device/telepad_beacon = TRADER_BLACKLIST, // Telescience - /obj/item/device/udp_debugger = TRADER_BLACKLIST // Circuits ) possible_trading_items = list( diff --git a/code/modules/admin/admin_verbs.dm b/code/modules/admin/admin_verbs.dm index a249af3e6bc..6adb49c785d 100644 --- a/code/modules/admin/admin_verbs.dm +++ b/code/modules/admin/admin_verbs.dm @@ -226,7 +226,8 @@ var/list/admin_verbs_debug = list( /client/proc/disconnect_ntsl, /turf/proc/view_chunk, /turf/proc/update_chunk, - /client/proc/profiler_start + /client/proc/profiler_start, + /client/proc/rustg_send_udp ) var/list/admin_verbs_paranoid_debug = list( @@ -400,7 +401,8 @@ var/list/admin_verbs_hideable = list( /proc/possess, /proc/release, /client/proc/force_away_mission, - /client/proc/profiler_start + /client/proc/profiler_start, + /client/proc/rustg_send_udp ) var/list/admin_verbs_mod = list( /client/proc/cmd_admin_pm_context, // right-click adminPM interface, @@ -464,7 +466,8 @@ var/list/admin_verbs_dev = list( //will need to be altered - Ryan784 /client/proc/cmd_display_del_log, /client/proc/cmd_display_init_log, /client/proc/create_poll, //Allows to create polls - /client/proc/profiler_start + /client/proc/profiler_start, + /client/proc/rustg_send_udp ) var/list/admin_verbs_cciaa = list( /client/proc/cmd_admin_pm_panel, /*admin-pm list*/ diff --git a/code/modules/udp/ship_udp.dm b/code/modules/udp/ship_udp.dm index 6945dec1445..f24c0317263 100644 --- a/code/modules/udp/ship_udp.dm +++ b/code/modules/udp/ship_udp.dm @@ -70,21 +70,3 @@ log_data.Add(additional_data) var/gelf_log = json_encode(log_data) return send_udp_data(config.log_gelf_addr, gelf_log) - -/obj/item/device/udp_debugger - name = "udp_debugger" - desc = "Used to debug UDP Data sent to the log server." - icon = 'icons/obj/hacktool.dmi' - icon_state = "hacktool-g" - force = 5.0 - w_class = ITEMSIZE_SMALL - throwforce = 5.0 - throw_range = 15 - throw_speed = 3 - desc = "You can use this to debug sending udp logs to the log server" - -/obj/item/device/udp_debugger/proc/raw(addr=config.log_gelf_addr, data="RAW Test String") - return send_udp_data(addr,data) - -/obj/item/device/udp_debugger/proc/gelf(short_message="", long_message="", level = 1) - return send_gelf_log(short_message, long_message, level) diff --git a/html/changelogs/fluffyghost-rustg-120a2.yml b/html/changelogs/fluffyghost-rustg-120a2.yml new file mode 100644 index 00000000000..45bc6071ac4 --- /dev/null +++ b/html/changelogs/fluffyghost-rustg-120a2.yml @@ -0,0 +1,42 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: Fluffyghost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - backend: "Updated the default rust_g dll to 1.2.0+a2 from our other repository release." + - backend: "Added a debug verb for our custom udp send module used in rustg." diff --git a/librust_g.so b/librust_g.so index 73fb778622c..fa052896435 100644 Binary files a/librust_g.so and b/librust_g.so differ diff --git a/rust_g.dll b/rust_g.dll index 948da91d277..ea6678faf74 100644 Binary files a/rust_g.dll and b/rust_g.dll differ