Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SmiLeYre committed Jan 26, 2025
2 parents 31b9363 + d1864e5 commit d1d91df
Show file tree
Hide file tree
Showing 78 changed files with 2,323 additions and 1,519 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/context_flags.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#define FLAG_PM "Private Message"
#define FLAG_SM "Subtle Message"
#define FLAG_GIB "Gib"
#define FLAG_JUMP "Jump To"
#define FLAG_JUMP_GHOST "Jump To As Ghost"
#define FLAG_PP "Player Panel"
#define FLAG_VV "View Variables"
5 changes: 0 additions & 5 deletions code/__HELPERS/files.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//Sends resource files to client cache
/client/proc/getFiles(...)
for(var/file in args)
src << browse_rsc(file)

/client/proc/browse_files(root="data/logs/", max_iterations=10, list/valid_extensions=list("txt","log","htm", "html"))
var/path = root

Expand Down
9 changes: 4 additions & 5 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,10 @@
if(B.allow_random)
GLOB.bark_random_list[B.id] = path

// Backgrounds
for (var/path in subtypesof(/datum/background))
var/datum/background/background = new path()
GLOB.backgrounds[path] = background
sortList(GLOB.backgrounds, GLOBAL_PROC_REF(cmp_text_dsc))
// Loadout items
for (var/path in subtypesof(/datum/loadout_item))
var/datum/loadout_item/loadout_item = new path()
GLOB.loadout_items[path] = loadout_item

//creates every subtype of prototype (excluding prototype) and adds it to list L.
//if no list/L is provided, one is created.
Expand Down
15 changes: 10 additions & 5 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,11 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0
alpha += 25
obj_flags &= ~FROZEN

/// Generate a filename for this asset
/// The same asset will always lead to the same asset name
/// (Generated names do not include file extention.)
/proc/generate_asset_name(file)
return "asset.[md5(fcopy_rsc(file))]"

//Converts an icon to base64. Operates by putting the icon in the iconCache savefile,
// exporting it as text, and then parsing the base64 from that.
Expand Down Expand Up @@ -1145,11 +1150,11 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0
if (!isicon(I))
if (isfile(thing)) //special snowflake
var/name = sanitize_filename("[generate_asset_name(thing)].png")
register_asset(name, thing)
SSassets.transport.register_asset(name, thing)
for (var/mob/thing2 in targets)
if(!istype(thing2) || !thing2.client)
continue
send_asset(thing2?.client, key)
SSassets.transport.send_assets(thing2?.client, key)
return "<img class='icon icon-misc' src=\"[url_encode(name)]\">"
var/atom/A = thing
if (isnull(dir))
Expand All @@ -1171,13 +1176,13 @@ GLOBAL_LIST_INIT(freon_color_matrix, list("#2E5E69", "#60A2A8", "#A1AFB1", rgb(0
I = icon(I, icon_state, dir, frame, moving)

key = "[generate_asset_name(I)].png"
register_asset(key, I)
SSassets.transport.register_asset(key, I)
for (var/mob/thing2 in targets)
if(!istype(thing2) || !thing2.client)
continue
send_asset(thing2?.client, key)
SSassets.transport.send_assets(thing2?.client, key)

return "<img class='icon icon-[icon_state]' src=\"[url_encode(key)]\">"
return "<img class='icon icon-[icon_state]' src='[SSassets.transport.get_asset_url(key)]'>"

/proc/icon2base64html(thing)
if (!thing)
Expand Down
5 changes: 5 additions & 0 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@
else //regex everything else (works for /proc too)
return lowertext(replacetext("[the_type]", "[type2parent(the_type)]/", ""))

/// Return html to load a url.
/// for use inside of browse() calls to html assets that might be loaded on a cdn.
/proc/url2htmlloader(url)
return {"<html><head><meta http-equiv="refresh" content="0;URL='[url]'"/></head><body onLoad="parent.location='[url]'"></body></html>"}

/proc/strtohex(str)
if(!istext(str)||!str)
return
Expand Down
2 changes: 2 additions & 0 deletions code/_globalvars/special_traits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ GLOBAL_LIST_INIT(special_traits, build_special_traits())
player = character.client
apply_charflaw_equipment(character, player)
apply_prefs_special(character, player)
if(player.prefs.loadout)
character.mind.special_items[player.prefs.loadout.name] = player.prefs.loadout.path

/proc/apply_charflaw_equipment(mob/living/carbon/human/character, client/player)
if(character.charflaw)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/mouseover.dm
Original file line number Diff line number Diff line change
Expand Up @@ -208,5 +208,5 @@
/client/proc/genmouseobj()
mouseovertext = new /atom/movable/screen/movable/mouseover/maptext
mouseoverbox = new /atom/movable/screen/movable/mouseover
var/datum/asset/stuff = get_asset_datum(/datum/asset/simple/roguefonts)
var/datum/asset/stuff = get_asset_datum(/datum/asset/simple/namespaced/roguefonts)
stuff.send(src)
3 changes: 3 additions & 0 deletions code/controllers/configuration/configuration.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
LoadPolicy()
LoadChatFilter()

if(Master)
Master.OnConfigLoad()

/datum/controller/configuration/proc/full_wipe()
if(IsAdminAdvancedProcCall())
return
Expand Down
5 changes: 5 additions & 0 deletions code/controllers/master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -623,3 +623,8 @@ GLOBAL_REAL(Master, /datum/controller/master) = new
processing = CONFIG_GET(number/mc_tick_rate/base_mc_tick_rate)
else if (client_count > CONFIG_GET(number/mc_tick_rate/high_pop_mc_mode_amount))
processing = CONFIG_GET(number/mc_tick_rate/high_pop_mc_tick_rate)

/datum/controller/master/proc/OnConfigLoad()
for (var/thing in subsystems)
var/datum/controller/subsystem/SS = thing
SS.OnConfigLoad()
3 changes: 3 additions & 0 deletions code/controllers/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,6 @@
if ("queued_priority") //editing this breaks things.
return 0
. = ..()

/// Called after the config has been loaded or reloaded.
/datum/controller/subsystem/proc/OnConfigLoad()
22 changes: 17 additions & 5 deletions code/controllers/subsystem/assets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@ SUBSYSTEM_DEF(assets)
flags = SS_NO_FIRE
var/list/cache = list()
var/list/preload = list()
var/datum/asset_transport/transport = new()

/datum/controller/subsystem/assets/OnConfigLoad()
var/newtransporttype = /datum/asset_transport
switch (CONFIG_GET(string/asset_transport))
if ("webroot")
newtransporttype = /datum/asset_transport/webroot

if (newtransporttype == transport.type)
return

var/datum/asset_transport/newtransport = new newtransporttype ()
if (newtransport.validate_config())
transport = newtransport
transport.Load()

/datum/controller/subsystem/assets/Initialize(timeofday)
for(var/type in typesof(/datum/asset))
var/datum/asset/A = type
if (type != initial(A._abstract))
get_asset_datum(type)

preload = cache.Copy() //don't preload assets generated during the round

for(var/client/C in GLOB.clients)
addtimer(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(getFilesSlow), C, preload, FALSE), 10)
..()
transport.Initialize(cache)
return ..()
33 changes: 11 additions & 22 deletions code/datums/browser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
var/window_options = "can_close=1;can_minimize=1;can_maximize=0;can_resize=1;titlebar=1;" // window option is set using window_id
var/stylesheets[0]
var/scripts[0]
var/title_image
var/head_elements
var/body_elements
var/head_content = ""
var/content = ""
var/no_close_movement = FALSE
var/static/datum/asset/simple/namespaced/common/common_asset = get_asset_datum(/datum/asset/simple/namespaced/common)

/datum/browser/Destroy(force, ...)
. = ..()
Expand Down Expand Up @@ -45,7 +45,6 @@
if (nref)
ref = nref
RegisterSignal(ref, COMSIG_PARENT_QDELETING, PROC_REF(ref_deleted))
add_stylesheet("common", 'html/browser/common.css') // this CSS sheet is common to all UIs

/datum/browser/proc/user_deleted(datum/source)
SIGNAL_HANDLER
Expand All @@ -61,9 +60,6 @@
/datum/browser/proc/set_window_options(nwindow_options)
window_options = nwindow_options

/datum/browser/proc/set_title_image(ntitle_image)
title_image = ntitle_image

/datum/browser/proc/add_stylesheet(name, file)
if (istype(name, /datum/asset/spritesheet))
var/datum/asset/spritesheet/sheet = name
Expand All @@ -74,11 +70,11 @@
stylesheets[asset_name] = file

if (!SSassets.cache[asset_name])
register_asset(asset_name, file)
SSassets.transport.register_asset(asset_name, file)

/datum/browser/proc/add_script(name, file)
scripts["[ckey(name)].js"] = file
register_asset("[ckey(name)].js", file)
SSassets.transport.register_asset("[ckey(name)].js", file)

/datum/browser/proc/set_content(ncontent)
content = ncontent
Expand All @@ -87,16 +83,14 @@
content += ncontent

/datum/browser/proc/get_header()
var/datum/asset/simple/namespaced/common/common_asset = get_asset_datum(/datum/asset/simple/namespaced/common)
var/file
head_content += "<link rel='stylesheet' type='text/css' href='[common_asset.get_url_mappings()["common.css"]]'>"
for (file in stylesheets)
head_content += "<link rel='stylesheet' type='text/css' href='[file]'>"
head_content += "<link rel='stylesheet' type='text/css' href='[SSassets.transport.get_asset_url(file)]'>"

for (file in scripts)
head_content += "<script type='text/javascript' src='[file]'></script>"

var/title_attributes = "class='uiTitle'"
if (title_image)
title_attributes = "class='uiTitle icon' style='background-image: url([title_image]);'"
head_content += "<script type='text/javascript' src='[SSassets.transport.get_asset_url(file)]'></script>"

return {"<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
Expand All @@ -107,7 +101,7 @@
</head>
<body scroll=auto>
<div class='uiWrapper'>
[title ? "<div class='uiTitleWrapper'><div [title_attributes]><tt>[title]</tt></div></div>" : ""]
[title ? "<div class='uiTitleWrapper'><div class='uiTitle'><tt>[title]</tt></div></div>" : ""]
<div class='uiContent'>
"}
//" This is here because else the rest of the file looks like a string in notepad++.
Expand All @@ -133,10 +127,11 @@
var/window_size = ""
if (width && height)
window_size = "size=[width]x[height];"
common_asset.send(user)
if (stylesheets.len)
send_asset_list(user, stylesheets, verify=FALSE)
SSassets.transport.send_assets(user, stylesheets)
if (scripts.len)
send_asset_list(user, scripts, verify=FALSE)
SSassets.transport.send_assets(user, scripts)
user << browse(get_content(), "window=[window_id];[window_size][window_options]")
if (use_onclose)
setup_onclose()
Expand Down Expand Up @@ -445,12 +440,6 @@
if (A.selectedbutton)
return list("button" = A.selectedbutton, "settings" = A.settings)

// This will allow you to show an icon in the browse window
// This is added to mob so that it can be used without a reference to the browser object
// There is probably a better place for this...
/mob/proc/browse_rsc_icon(icon, icon_state, dir = -1)


// Registers the on-close verb for a browse window (client/verb/.windowclose)
// this will be called when the close-button of a window is pressed.
//
Expand Down
1 change: 0 additions & 1 deletion code/game/objects/items/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@
dat += "<A href='?src=[REF(src)];pick=[t]'>A [t].</A><BR>"
dat += "Which card will you remove next?"
var/datum/browser/popup = new(user, "cardhand", "Hand of Cards", 400, 240)
popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state))
popup.set_content(dat)
popup.open()

Expand Down
13 changes: 0 additions & 13 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ GLOBAL_VAR(restart_counter)

log_world("World loaded at [time_stamp()]!")

SetupExternalRSC()

GLOB.config_error_log = GLOB.world_manifest_log = GLOB.world_pda_log = GLOB.world_job_debug_log = GLOB.sql_error_log = GLOB.world_href_log = GLOB.world_runtime_log = GLOB.world_attack_log = GLOB.world_game_log = "data/logs/config_error.[GUID()].log" //temporary file used to record errors with loading config, moved to log directory once logging is set bl

make_datum_references_lists() //initialises global lists for referencing frequently used datums (so that we only ever do it once)
Expand Down Expand Up @@ -118,17 +116,6 @@ GLOBAL_VAR(restart_counter)
#endif
SSticker.OnRoundstart(CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(addtimer), cb, 10 SECONDS))

/world/proc/SetupExternalRSC()
#if (PRELOAD_RSC == 0)
GLOB.external_rsc_urls = world.file2list("[global.config.directory]/external_rsc_urls.txt","\n")
var/i=1
while(i<=GLOB.external_rsc_urls.len)
if(GLOB.external_rsc_urls[i])
i++
else
GLOB.external_rsc_urls.Cut(i,i+1)
#endif

/world/proc/SetupLogs()
var/override_dir = params[OVERRIDE_LOG_DIRECTORY_PARAMETER]
if(!override_dir)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ GLOBAL_PROTECT(admin_verbs_server)
/client/proc/forcerandomrotate,
/client/proc/adminchangemap,
/client/proc/panicbunker,
/client/proc/toggle_hub
/client/proc/toggle_hub,
/client/proc/toggle_cdn
)
GLOBAL_LIST_INIT(admin_verbs_debug, world.AVerbsDebug())
GLOBAL_PROTECT(admin_verbs_debug)
Expand Down
8 changes: 5 additions & 3 deletions code/modules/admin/permissionedit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
/datum/admins/proc/edit_admin_permissions(action, target, operation, page)
if(!check_rights(R_PERMISSIONS))
return
var/list/output = list("<link rel='stylesheet' type='text/css' href='panels.css'><a href='?_src_=holder;[HrefToken()];editrightsbrowser=1'>\[Permissions\]</a>")
var/datum/asset/asset_cache_datum = get_asset_datum(/datum/asset/group/permissions)
asset_cache_datum.send(usr)
var/list/output = list("<link rel='stylesheet' type='text/css' href='[SSassets.transport.get_asset_url("panels.css")]'><a href='?_src_=holder;[HrefToken()];editrightsbrowser=1'>\[Permissions\]</a>")
if(action)
output += " | <a href='?_src_=holder;[HrefToken()];editrightsbrowserlog=1;editrightspage=0'>\[Log\]</a> | <a href='?_src_=holder;[HrefToken()];editrightsbrowsermanage=1'>\[Management\]</a><hr style='background:#000000; border:0; height:3px'>"
else
Expand Down Expand Up @@ -92,7 +94,7 @@
<head>
<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>
<title>Permissions Panel</title>
<script type='text/javascript' src='search.js'></script>
<script type='text/javascript' src='[SSassets.transport.get_asset_url("search.js")]'></script>
</head>
<body onload='selectTextField();updateSearch();'>
<div id='main'><table id='searchable' cellspacing='0'>
Expand Down Expand Up @@ -137,7 +139,7 @@
if(IsAdminAdvancedProcCall())
to_chat(usr, span_adminprefix("Admin Edit blocked: Advanced ProcCall detected."))
return
var/datum/asset/permissions_assets = get_asset_datum(/datum/asset/simple/permissions)
var/datum/asset/permissions_assets = get_asset_datum(/datum/asset/simple/namespaced/common)
permissions_assets.send(src)
var/admin_key = href_list["key"]
var/admin_ckey = ckey(admin_key)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/admin/sql_message_system.dm
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@
alphatext = "filter: alpha(opacity=[alpha]); opacity: [alpha/100];"
var/list/data = list("<div style='margin:0px;[alphatext]'><p class='severity'>")
if(severity)
data += "<img src='[severity]_button.png' height='24' width='24'></img> "
data += "<img src='[SSassets.transport.get_asset_url("[severity]_button.png")]' height='24' width='24'></img> "
data += "<b>[timestamp] | [server] | [admin_key][secret ? " | <i>- Secret</i>" : ""]"
if(expire_timestamp)
data += " | Expires [expire_timestamp]"
Expand Down
5 changes: 4 additions & 1 deletion code/modules/admin/verbs/beakerpanel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@
if(!check_rights())
return

var/datum/asset/asset_datum = get_asset_datum(/datum/asset/simple/namespaced/common)
asset_datum.send()
//Could somebody tell me why this isn't using the browser datum, given that it copypastes all of browser datum's html
var/dat = {"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<head>
<link rel='stylesheet' type='text/css' href='common.css'>
<link rel='stylesheet' type='text/css' href='[SSassets.transport.get_asset_url("common.css")]'>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/js/select2.full.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.7/css/select2.min.css">
Expand Down
28 changes: 28 additions & 0 deletions code/modules/admin/verbs/diagnostics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,31 @@
load_admins()
SSblackbox.record_feedback("tally", "admin_verb", 1, "Reload All Admins") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
message_admins("[key_name_admin(usr)] manually reloaded admins")

/client/proc/toggle_cdn()
set name = "Toggle CDN"
set category = "Server"
var/static/admin_disabled_cdn_transport = null
if (alert(usr, "Are you sure you want to toggle the CDN asset transport?", "Confirm", "Yes", "No") != "Yes")
return
var/current_transport = CONFIG_GET(string/asset_transport)
if (!current_transport || current_transport == "simple")
if (admin_disabled_cdn_transport)
CONFIG_SET(string/asset_transport, admin_disabled_cdn_transport)
admin_disabled_cdn_transport = null
SSassets.OnConfigLoad()
message_admins("[key_name_admin(usr)] re-enabled the CDN asset transport")
log_admin("[key_name(usr)] re-enabled the CDN asset transport")
else
to_chat(usr, "<span class='adminnotice'>The CDN is not enabled!</span>")
if (alert(usr, "The CDN asset transport is not enabled! If you having issues with assets you can also try disabling filename mutations.", "The CDN asset transport is not enabled!", "Try disabling filename mutations", "Nevermind") == "Try disabling filename mutations")
SSassets.transport.dont_mutate_filenames = !SSassets.transport.dont_mutate_filenames
message_admins("[key_name_admin(usr)] [(SSassets.transport.dont_mutate_filenames ? "disabled" : "re-enabled")] asset filename transforms")
log_admin("[key_name(usr)] [(SSassets.transport.dont_mutate_filenames ? "disabled" : "re-enabled")] asset filename transforms")
else
admin_disabled_cdn_transport = current_transport
CONFIG_SET(string/asset_transport, "simple")
SSassets.OnConfigLoad()
SSassets.transport.dont_mutate_filenames = TRUE
message_admins("[key_name_admin(usr)] disabled the CDN asset transport")
log_admin("[key_name(usr)] disabled the CDN asset transport")
Loading

0 comments on commit d1d91df

Please sign in to comment.