mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-30 11:32:20 +00:00
The asset cache will now store json on the player's computer with info on what browser assets they have, all non-active assets (anything but .js(m) and .htm(l)) are reused in further connections. Browser assets in byond persist for an individual dream seeker instance, and are destoryed when the window is closed (so this only helps reconnects and round restarts) The data is stored in the client's asset folder to ensure its current and retrieved using javascript and sent back to the server using ajax(XHR).
The md5 of the asset files are generated on the server and stored on the client. It is used to validate the asset hasn't changed from a code update, and is not re-checked client side.
To ensure this can't be used by a malicious byond server to override javascript assets before redirecting people to /tg/ (where the attacker's javascript would then be allowed to run verbs and spoof topics) we do not mark javascript as pre-loaded when loading the client's asset cache json file on connection.
Other Changes
I moved some things around, the asset cache file was getting thicc:
Put new asset cache datums into code/modules/asset_cache/asset_list_items.dm
Find the asset cache datum abstract definitions inside code/modules/asset_cache/asset_list.dm
I fixed a bug where blocking asset sends would not block later calls to send the same asset while the send was still underway - todo: have it bind to the first send rather then initating its own.
The small file sent to the client to verify it got all pending asset sends will no longer use random names. This should keep the client's asset folder from exploding with hundreds of random htm files, much to the joy of oranges.
Passively loading assets no longer batches.
Unified the two procs.
29 lines
787 B
HTML
29 lines
787 B
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
</head>
|
|
<body>
|
|
<script>
|
|
//this is used over window.location because window.location has a character limit in IE.
|
|
function sendbyond(text) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', '?'+text, true);
|
|
xhr.send(null);
|
|
}
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', 'asset_data.json', true);
|
|
xhr.responseType = 'text';
|
|
xhr.onreadystatechange = function () {
|
|
if (xhr.readyState === 4) {
|
|
var status = xhr.status;
|
|
if (status >= 200 && status < 400) {
|
|
sendbyond('asset_cache_preload_data=' + encodeURIComponent(xhr.responseText));
|
|
}
|
|
}
|
|
};
|
|
xhr.send(null);
|
|
</script>
|
|
|
|
</body>
|
|
</html> |