Merge pull request #38837 from AutomaticFrenzy/patch/rustg-defines

Add and use rust_g API file
This commit is contained in:
Jordan Brown
2018-07-02 06:24:49 -04:00
committed by yogstation13-bot
parent c652de76f1
commit dd5bd37e46
4 changed files with 12 additions and 10 deletions

7
code/__DEFINES/rust_g.dm Normal file
View File

@@ -0,0 +1,7 @@
// rust_g.dm - DM API for rust_g extension library
#define RUST_G "rust_g"
#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)
#define rustg_log_write(fname, text) call(RUST_G, "log_write")(fname, text)
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()

View File

@@ -1,13 +1,10 @@
//location of the rust-g library
#define RUST_G "rust_g"
//wrapper macros for easier grepping
#define DIRECT_OUTPUT(A, B) A << B
#define SEND_IMAGE(target, image) DIRECT_OUTPUT(target, image)
#define SEND_SOUND(target, sound) DIRECT_OUTPUT(target, sound)
#define SEND_TEXT(target, text) DIRECT_OUTPUT(target, text)
#define WRITE_FILE(file, text) DIRECT_OUTPUT(file, text)
#define WRITE_LOG(log, text) call(RUST_G, "log_write")(log, text)
#define WRITE_LOG(log, text) rustg_log_write(log, text)
//print a warning message to world.log
#define WARNING(MSG) warning("[MSG] in [__FILE__] at line [__LINE__] src: [src] usr: [usr].")
@@ -156,7 +153,7 @@
/* Close open log handles. This should be called as late as possible, and no logging should hapen after. */
/proc/shutdown_logging()
call(RUST_G, "log_close_all")()
rustg_log_close_all()
/* Helper procs for building detailed log lines */
@@ -176,6 +173,3 @@
return "[A.loc] [COORD(T)] ([A.loc.type])"
else if(A.loc)
return "[A.loc] (0, 0, 0) ([A.loc.type])"
//this is only used here (for now)
#undef RUST_G

View File

@@ -225,7 +225,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
var/res_name = "spritesheet_[name].css"
var/fname = "data/spritesheets/[res_name]"
call("rust_g", "file_write")(generate_css(), fname)
text2file(generate_css(), fname)
register_asset(res_name, file(fname))
for(var/size_id in sizes)
@@ -249,7 +249,7 @@ GLOBAL_LIST_EMPTY(asset_datums)
// save flattened version
var/fname = "data/spritesheets/[name]_[size_id].png"
fcopy(size[SPRSZ_ICON], fname)
var/error = call("rust_g", "dmi_strip_metadata")(fname)
var/error = rustg_dmi_strip_metadata(fname)
if(length(error))
stack_trace("Failed to strip [name]_[size_id].png: [error]")
size[SPRSZ_STRIPPED] = icon(fname)

View File

@@ -73,6 +73,7 @@
#include "code\__DEFINES\research.dm"
#include "code\__DEFINES\robots.dm"
#include "code\__DEFINES\role_preferences.dm"
#include "code\__DEFINES\rust_g.dm"
#include "code\__DEFINES\say.dm"
#include "code\__DEFINES\shuttles.dm"
#include "code\__DEFINES\sight.dm"