mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Configuration Controller (#7857)
This commit is contained in:
@@ -29,6 +29,12 @@
|
||||
return FALSE
|
||||
|
||||
return TRUE
|
||||
|
||||
/// Returns the top (last) element from the list, does not remove it from the list. Stack functionality.
|
||||
/proc/peek(list/target_list)
|
||||
var/list_length = length(target_list)
|
||||
if(list_length != 0)
|
||||
return target_list[list_length]
|
||||
//CHOMPEdit End
|
||||
|
||||
//Returns a list in plain english as a string
|
||||
|
||||
@@ -23,27 +23,28 @@
|
||||
|
||||
//print a testing-mode debug message to world.log
|
||||
/proc/testing(msg)
|
||||
if (config.log_debug) //CHOMPEdit
|
||||
if (CONFIG_GET(flag/log_debug)) //CHOMPEdit
|
||||
to_world_log("## TESTING: [msg]")
|
||||
|
||||
/proc/log_admin(text)
|
||||
admin_log.Add(text)
|
||||
if (config.log_admin)
|
||||
if (CONFIG_GET(flag/log_admin)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "ADMIN: [text]")
|
||||
|
||||
/proc/log_adminpm(text, client/source, client/dest)
|
||||
admin_log.Add(text)
|
||||
if (config.log_admin)
|
||||
if (CONFIG_GET(flag/log_admin)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "ADMINPM: [key_name(source)]->[key_name(dest)]: [html_decode(text)]")
|
||||
|
||||
/proc/log_pray(text, client/source)
|
||||
admin_log.Add(text)
|
||||
if (config.log_admin)
|
||||
if (CONFIG_GET(flag/log_admin)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "PRAY: [key_name(source)]: [text]")
|
||||
|
||||
/proc/log_debug(text)
|
||||
if (config.log_debug)
|
||||
WRITE_LOG(debug_log, "DEBUG: [sanitize(text)]")
|
||||
//if (CONFIG_GET(flag/log_debug)) // CHOMPEdit
|
||||
// WRITE_LOG(debug_log, "DEBUG: [sanitize(text)]")
|
||||
WRITE_LOG(debug_log, "DEBUG: [sanitize(text)]")
|
||||
|
||||
for(var/client/C in GLOB.admins)
|
||||
if(C.is_preference_enabled(/datum/client_preference/debug/show_debug_logs))
|
||||
@@ -52,25 +53,25 @@
|
||||
html = "<span class='filter_debuglog'>DEBUG: [text]</span>")
|
||||
|
||||
/proc/log_game(text)
|
||||
if (config.log_game)
|
||||
if (CONFIG_GET(flag/log_game)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "GAME: [text]")
|
||||
|
||||
/proc/log_vote(text)
|
||||
if (config.log_vote)
|
||||
if (CONFIG_GET(flag/log_vote)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "VOTE: [text]")
|
||||
|
||||
/proc/log_access_in(client/new_client)
|
||||
if (config.log_access)
|
||||
if (CONFIG_GET(flag/log_access)) // CHOMPEdit
|
||||
var/message = "[key_name(new_client)] - IP:[new_client.address] - CID:[new_client.computer_id] - BYOND v[new_client.byond_version]"
|
||||
WRITE_LOG(diary, "ACCESS IN: [message]") //VOREStation Edit
|
||||
|
||||
/proc/log_access_out(mob/last_mob)
|
||||
if (config.log_access)
|
||||
if (CONFIG_GET(flag/log_access)) // CHOMPEdit
|
||||
var/message = "[key_name(last_mob)] - IP:[last_mob.lastKnownIP] - CID:Logged Out - BYOND Logged Out"
|
||||
WRITE_LOG(diary, "ACCESS OUT: [message]")
|
||||
|
||||
/proc/log_say(text, mob/speaker)
|
||||
if (config.log_say)
|
||||
if (CONFIG_GET(flag/log_say)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "SAY: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
|
||||
//Log the message to in-game dialogue logs, as well. //CHOMPEdit Begin
|
||||
@@ -91,7 +92,7 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_ooc(text, client/user)
|
||||
if (config.log_ooc)
|
||||
if (CONFIG_GET(flag/log_ooc)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "OOC: [user.simple_info_line()]: [html_decode(text)]")
|
||||
if(!SSdbcore.IsConnected())
|
||||
establish_db_connection()
|
||||
@@ -107,7 +108,7 @@
|
||||
//GLOB.round_text_log += "<b>([time_stamp()])</b> (<b>[user]</b>) <u>OOC:</u> - <span style=\"color:blue\"><b>[text]</b></span>"
|
||||
|
||||
/proc/log_aooc(text, client/user)
|
||||
if (config.log_ooc)
|
||||
if (CONFIG_GET(flag/log_ooc)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "AOOC: [user.simple_info_line()]: [html_decode(text)]")
|
||||
if(!SSdbcore.IsConnected())
|
||||
establish_db_connection()
|
||||
@@ -123,7 +124,7 @@
|
||||
//GLOB.round_text_log += "<b>([time_stamp()])</b> (<b>[user]</b>) <u>AOOC:</u> - <span style=\"color:red\"><b>[text]</b></span>"
|
||||
|
||||
/proc/log_looc(text, client/user)
|
||||
if (config.log_ooc)
|
||||
if (CONFIG_GET(flag/log_ooc)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "LOOC: [user.simple_info_line()]: [html_decode(text)]")
|
||||
if(!SSdbcore.IsConnected())
|
||||
establish_db_connection()
|
||||
@@ -139,7 +140,7 @@
|
||||
//GLOB.round_text_log += "<b>([time_stamp()])</b> (<b>[user]</b>) <u>LOOC:</u> - <span style=\"color:orange\"><b>[text]</b></span>"
|
||||
|
||||
/proc/log_whisper(text, mob/speaker)
|
||||
if (config.log_whisper)
|
||||
if (CONFIG_GET(flag/log_whisper)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "WHISPER: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
|
||||
if(speaker.client)
|
||||
@@ -158,7 +159,7 @@
|
||||
qdel(query_insert)
|
||||
|
||||
/proc/log_emote(text, mob/speaker)
|
||||
if (config.log_emote)
|
||||
if (CONFIG_GET(flag/log_emote)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "EMOTE: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -178,23 +179,23 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_attack(attacker, defender, message)
|
||||
if (config.log_attack)
|
||||
if (CONFIG_GET(flag/log_attack)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "ATTACK: [attacker] against [defender]: [message]")
|
||||
|
||||
/proc/log_adminsay(text, mob/speaker)
|
||||
if (config.log_adminchat)
|
||||
if (CONFIG_GET(flag/log_adminchat)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "ADMINSAY: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
|
||||
/proc/log_modsay(text, mob/speaker)
|
||||
if (config.log_adminchat)
|
||||
if (CONFIG_GET(flag/log_adminchat)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "MODSAY: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
|
||||
/proc/log_eventsay(text, mob/speaker)
|
||||
if (config.log_adminchat)
|
||||
if (CONFIG_GET(flag/log_adminchat)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "EVENTSAY: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
|
||||
/proc/log_ghostsay(text, mob/speaker)
|
||||
if (config.log_say)
|
||||
if (CONFIG_GET(flag/log_say)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "DEADCHAT: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -215,7 +216,7 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_ghostemote(text, mob/speaker)
|
||||
if (config.log_emote)
|
||||
if (CONFIG_GET(flag/log_emote)) // CHMOPEdit
|
||||
WRITE_LOG(diary, "DEADEMOTE: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -233,11 +234,11 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_adminwarn(text)
|
||||
if (config.log_adminwarn)
|
||||
if (CONFIG_GET(flag/log_adminwarn)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "ADMINWARN: [html_decode(text)]")
|
||||
|
||||
/proc/log_pda(text, mob/speaker)
|
||||
if (config.log_pda)
|
||||
if (CONFIG_GET(flag/log_pda)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "PDA: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -259,8 +260,9 @@
|
||||
|
||||
/proc/log_to_dd(text)
|
||||
to_world_log(text) //this comes before the config check because it can't possibly runtime
|
||||
if(config.log_world_output)
|
||||
WRITE_LOG(diary, "DD_OUTPUT: [text]")
|
||||
//if(CONFIG_GET(flag/log_world_output)) // CHOMPEdit
|
||||
// WRITE_LOG(diary, "DD_OUTPUT: [text]")
|
||||
WRITE_LOG(diary, "DD_OUTPUT: [text]")
|
||||
|
||||
/proc/log_error(text)
|
||||
to_world_log(text)
|
||||
|
||||
11
code/_helpers/logging/debug_ch.dm
Normal file
11
code/_helpers/logging/debug_ch.dm
Normal file
@@ -0,0 +1,11 @@
|
||||
/// Logging for config errors
|
||||
/// Rarely gets called; just here in case the config breaks.
|
||||
/proc/log_config(text, list/data)
|
||||
var/entry = "CONFIG: "
|
||||
|
||||
entry += text
|
||||
entry += " | DATA: "
|
||||
entry += data
|
||||
|
||||
WRITE_LOG(diary, entry)
|
||||
SEND_TEXT(world.log, text)
|
||||
@@ -1,5 +1,5 @@
|
||||
/proc/log_nsay(text, inside, mob/speaker)
|
||||
if (config.log_say)
|
||||
if (CONFIG_GET(flag/log_say)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "NSAY (NIF:[inside]): [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -17,7 +17,7 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_nme(text, inside, mob/speaker)
|
||||
if (config.log_emote)
|
||||
if (CONFIG_GET(flag/log_emote)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "NME (NIF:[inside]): [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
@@ -35,7 +35,7 @@
|
||||
//CHOMPEdit End
|
||||
|
||||
/proc/log_subtle(text, mob/speaker)
|
||||
if (config.log_emote)
|
||||
if (CONFIG_GET(flag/log_emote)) // CHOMPEdit
|
||||
WRITE_LOG(diary, "SUBTLE: [speaker.simple_info_line()]: [html_decode(text)]")
|
||||
//CHOMPEdit Begin
|
||||
if(speaker.client)
|
||||
|
||||
@@ -374,7 +374,7 @@ Proc for attack log creation, because really why not
|
||||
cached_character_icons[cachekey] = .
|
||||
|
||||
/proc/not_has_ooc_text(mob/user)
|
||||
if (config.allow_Metadata && (!user.client?.prefs?.metadata || length(user.client.prefs.metadata) < 15))
|
||||
if (CONFIG_GET(flag/allow_metadata) && (!user.client?.prefs?.metadata || length(user.client.prefs.metadata) < 15)) // CHOMPEdit
|
||||
to_chat(user, "<span class='warning'>Please set informative OOC notes related to RP/ERP preferences. Set them using the 'OOC Notes' button on the 'General' tab in character setup.</span>")
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
11
code/_helpers/nameof_ch.dm
Normal file
11
code/_helpers/nameof_ch.dm
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* NAMEOF: Compile time checked variable name to string conversion
|
||||
* evaluates to a string equal to "X", but compile errors if X isn't a var on datum.
|
||||
* datum may be null, but it does need to be a typed var.
|
||||
**/
|
||||
#define NAMEOF(datum, X) (#X || ##datum.##X)
|
||||
|
||||
/**
|
||||
* NAMEOF that actually works in static definitions because src::type requires src to be defined
|
||||
*/
|
||||
#define NAMEOF_STATIC(datum, X) (nameof(type::##X))
|
||||
@@ -92,8 +92,8 @@ var/religion_name = null
|
||||
new_station_name += pick("13","XIII","Thirteen")
|
||||
|
||||
|
||||
if (config && config.server_name)
|
||||
world.name = "[config.server_name]: [name]"
|
||||
if (config && CONFIG_GET(string/servername)) // CHOMPEdit
|
||||
world.name = "[CONFIG_GET(string/servername)]: [name]" // CHOMPEdit
|
||||
else
|
||||
world.name = new_station_name
|
||||
|
||||
@@ -104,8 +104,8 @@ var/religion_name = null
|
||||
|
||||
using_map.station_name = name
|
||||
|
||||
if (config && config.server_name)
|
||||
world.name = "[config.server_name]: [name]"
|
||||
if (config && CONFIG_GET(string/servername)) // CHOMPEdit
|
||||
world.name = "[CONFIG_GET(string/servername)]: [name]" // CHOMPEdit
|
||||
else
|
||||
world.name = name
|
||||
|
||||
|
||||
@@ -620,3 +620,10 @@ GLOBAL_LIST_EMPTY(text_tag_cache)
|
||||
paper_text = replacetext(paper_text, "<br>", "\n")
|
||||
paper_text = strip_html_properly(paper_text) // Get rid of everything else entirely.
|
||||
return paper_text
|
||||
|
||||
//json decode that will return null on parse error instead of runtiming.
|
||||
/proc/safe_json_decode(data)
|
||||
try
|
||||
return json_decode(data)
|
||||
catch
|
||||
return null
|
||||
|
||||
@@ -1,11 +1,43 @@
|
||||
/*
|
||||
* Holds procs designed to change one type of value, into another.
|
||||
* Contains:
|
||||
* file2list
|
||||
* type2top
|
||||
* hex2num & num2hex
|
||||
* file2list
|
||||
* angle2dir
|
||||
*/
|
||||
|
||||
// CHOMPEdit Start
|
||||
//Splits the text of a file at seperator and returns them in a list.
|
||||
//returns an empty list if the file doesn't exist
|
||||
/world/proc/file2list(filename, seperator="\n", trim = TRUE)
|
||||
if (trim)
|
||||
return splittext(trim(file2text(filename)),seperator)
|
||||
return splittext(file2text(filename),seperator)
|
||||
|
||||
//returns a string the last bit of a type, without the preceeding '/'
|
||||
/proc/type2top(the_type)
|
||||
//handle the builtins manually
|
||||
if(!ispath(the_type))
|
||||
return
|
||||
switch(the_type)
|
||||
if(/datum)
|
||||
return "datum"
|
||||
if(/atom)
|
||||
return "atom"
|
||||
if(/obj)
|
||||
return "obj"
|
||||
if(/mob)
|
||||
return "mob"
|
||||
if(/area)
|
||||
return "area"
|
||||
if(/turf)
|
||||
return "turf"
|
||||
else //regex everything else (works for /proc too)
|
||||
return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", ""))
|
||||
// CHOMPEdit End
|
||||
|
||||
// Returns an integer given a hexadecimal number string as input.
|
||||
/proc/hex2num(hex)
|
||||
if (!istext(hex))
|
||||
|
||||
@@ -1390,7 +1390,7 @@ var/mob/dview/dview_mob = new
|
||||
#undef HAS_FLAG
|
||||
|
||||
//datum may be null, but it does need to be a typed var
|
||||
#define NAMEOF(datum, X) (#X || ##datum.##X)
|
||||
//#define NAMEOF(datum, X) (#X || ##datum.##X) // CHOMPEdit: Moved to nameof_ch.dm
|
||||
|
||||
#define VARSET_LIST_CALLBACK(target, var_name, var_value) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___callbackvarset), ##target, ##var_name, ##var_value)
|
||||
//dupe code because dm can't handle 3 level deep macros
|
||||
|
||||
@@ -43,26 +43,26 @@
|
||||
|
||||
//Sender is optional
|
||||
/proc/admin_chat_message(var/message = "Debug Message", var/color = "#FFFFFF", var/sender)
|
||||
if (!config.chat_webhook_url || !message)
|
||||
if (!CONFIG_GET(string/chat_webhook_url) || !message) // CHOMPEdit
|
||||
return
|
||||
spawn(0)
|
||||
var/query_string = "type=adminalert"
|
||||
query_string += "&key=[url_encode(config.chat_webhook_key)]"
|
||||
query_string += "&key=[url_encode(CONFIG_GET(string/chat_webhook_key))]" // CHOMPEdit
|
||||
query_string += "&msg=[url_encode(message)]"
|
||||
query_string += "&color=[url_encode(color)]"
|
||||
if(sender)
|
||||
query_string += "&from=[url_encode(sender)]"
|
||||
world.Export("[config.chat_webhook_url]?[query_string]")
|
||||
world.Export("[CONFIG_GET(string/chat_webhook_url)]?[query_string]") // CHOMPEdit
|
||||
|
||||
/proc/admin_action_message(var/admin = "INVALID", var/user = "INVALID", var/action = "INVALID", var/reason = "INVALID", var/time = "INVALID")
|
||||
if (!config.chat_webhook_url || !action)
|
||||
if (!CONFIG_GET(string/chat_webhook_url) || !action) // CHOMPEdit
|
||||
return
|
||||
spawn(0)
|
||||
var/query_string = "type=adminaction"
|
||||
query_string += "&key=[url_encode(config.chat_webhook_key)]"
|
||||
query_string += "&key=[url_encode(CONFIG_GET(string/chat_webhook_key))]" // CHOMPEdit
|
||||
query_string += "&admin=[url_encode(admin)]"
|
||||
query_string += "&user=[url_encode(user)]"
|
||||
query_string += "&action=[url_encode(action)]"
|
||||
query_string += "&reason=[url_encode(reason)]"
|
||||
query_string += "&time=[url_encode(time)]"
|
||||
world.Export("[config.chat_webhook_url]?[query_string]")
|
||||
world.Export("[CONFIG_GET(string/chat_webhook_url)]?[query_string]") // CHOMPEdit
|
||||
|
||||
Reference in New Issue
Block a user