Files
Bubberstation/code/modules/shuttle/computer.dm
SkyratBot e8bfe6eb68 [MIRROR] [Ready] CDN browser assets! (#312)
* [Ready] CDN browser assets! (#52681)

Rewrites the asset_cache system to handle sending assets to a CDN via a webroot.

see https://github.com/MrStonedOne/tgstation/blob/asset-cdn/code/modules/asset_cache/readme.md

Fixed a lot of bugs with assets, removed some dead code.

Changes:
    Moved asset cache code to transport datums, the currently loaded one is located at SSassets.transport, asset cache calls made before the config is loaded use the simple browse_rsc transport.
    Added subsystem call for when the config loads or reloads.
    Added a webroot CDN asset transport. assets are saved to a file in a format based on the file's hash (currently md5).
    Assets that don't use get_asset_url or get_url_mappings (such as browser assets referred to by static html files like changelog.html or static css files) can be saved to browse_rsc even when in cdn asset mode by setting legacy to TRUE on the datum returned by register_assets
    Added a system for saving assets on a cdn in a hash based namespace (folder), assets within the same namespace will always be able to refer to each other by relative names. (used to allow cdn'ing font awesome without having to make something that regenerates it's css files.).
    The simple/namespaced asset cache datum helper will handle generating a namespace composed of the combined md5 of everything in the same datum, as well as registering them properly.
    Moved external resource from a snowflake loaded file to a config entry, added it to resources.txt
    To ensure the system breaks in local testing in any situation that wouldn't work in cdn mode, the simple transport will mutate the filenames of non-legacy and non-namespaced assets and return this with get_asset_url.
    Simple transport's passive send of all roundstart assets to all clients is now a config that defaults to off. this is to break race conditions during local testings from devs accidentally relying on this instead of using send() properly.

cl
refactor: Interface assets (js/css/images) can now be managed using an external webserver instead of byond's one at a time file transfer queue.
admin: Adds admin verb toggle-cdn that allows admins to disable the external webserver asset transport and revert to the old system. Useful if the webserver backing this goes down (thanks cloudflare).
config: New config file, resources.txt, (must be loaded by an $include statement from the main config)
server: The external_rsc_urls.txt config has been moved to the main config system.
/cl
Porting notes:

Interface webpages must refer to their assets (css/js/image/etc) by a generated url, or the asset must register itself as a legacy asset. The system is designed to break in localtest (on simple/legacy mode) in most situations that would break in cdn mode.

Requires latest tgui.

The webserver must set the proper CORS headers for font files or font awesome (and other fonts) won't load.

/tg/'s webserver config: https://gist.github.com/MrStonedOne/523388b2f161af832292d98a8aad0eae

* [Ready] CDN browser assets!

Co-authored-by: Kyle Spier-Swenson <kyleshome@gmail.com>
2020-08-12 11:32:37 +01:00

82 lines
3.2 KiB
Plaintext

/obj/machinery/computer/shuttle
name = "shuttle console"
desc = "A shuttle control computer."
icon_screen = "shuttle"
icon_keyboard = "tech_key"
light_color = LIGHT_COLOR_CYAN
req_access = list( )
var/shuttleId
var/possible_destinations = ""
var/admin_controlled
var/no_destination_swap = 0
/obj/machinery/computer/shuttle/ui_interact(mob/user)
. = ..()
var/list/options = params2list(possible_destinations)
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
var/dat = "<small><i>Donk Co. Transportation Division</small></i><br>Status: [M ? M.getStatusText() : "*Missing*"]<br><br>"
if(M)
var/destination_found
for(var/obj/docking_port/stationary/S in SSshuttle.stationary)
if(!options.Find(S.id))
continue
if(!M.check_dock(S, silent=TRUE))
continue
destination_found = 1
dat += "<A href='?src=[REF(src)];move=[S.id]'>Send to [S.name]</A><br>"
if(!destination_found)
dat += "<B>Shuttle Locked</B><br>"
if(admin_controlled)
dat += "Authorized personnel only<br>"
dat += "<A href='?src=[REF(src)];request=1]'>Request Authorization</A><br>"
dat += "<a href='?src=[REF(user)];mach_close=computer'>Close</a>"
var/datum/browser/popup = new(user, "computer", M ? M.name : "shuttle", 300, 200)
popup.set_content("<center>[dat]</center>")
popup.open()
/obj/machinery/computer/shuttle/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(!allowed(usr))
to_chat(usr, "<span class='danger'>Access denied.</span>")
return
if(href_list["move"])
var/obj/docking_port/mobile/M = SSshuttle.getShuttle(shuttleId)
if(M.launch_status == ENDGAME_LAUNCHED)
to_chat(usr, "<span class='warning'>You've already escaped. Never going back to that place again!</span>")
return
if(no_destination_swap)
if(M.mode == SHUTTLE_RECHARGING)
to_chat(usr, "<span class='warning'>Shuttle engines are not ready for use.</span>")
return
if(M.mode != SHUTTLE_IDLE)
to_chat(usr, "<span class='warning'>Shuttle already in transit.</span>")
return
if(!(href_list["move"] in params2list(possible_destinations)))
log_admin("[usr] attempted to forge a target location through a href exploit on [src] with target location \"[href_list["move"]]\"")
message_admins("[ADMIN_FULLMONTY(usr)] attempted to forge a target location through a href exploit on [src]")
return
switch(SSshuttle.moveShuttle(shuttleId, href_list["move"], 1))
if(0)
say("Shuttle departing. Please stand away from the doors.")
log_shuttle("[key_name(usr)] has sent shuttle \"[M]\" towards \"[href_list["move"]]\", using [src].")
if(1)
to_chat(usr, "<span class='warning'>Invalid shuttle requested.</span>")
else
to_chat(usr, "<span class='warning'>Unable to comply.</span>")
/obj/machinery/computer/shuttle/emag_act(mob/user)
if(obj_flags & EMAGGED)
return
req_access = list()
obj_flags |= EMAGGED
to_chat(user, "<span class='notice'>You fried the consoles ID checking system.</span>")
/obj/machinery/computer/shuttle/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock, idnum, override=FALSE)
if(port && (shuttleId == initial(shuttleId) || override))
shuttleId = port.id