mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2026-07-13 01:03:15 +01:00
The 515 MegaPR early downport (#7783)
Co-authored-by: Selis <selis@xynolabs.com> Co-authored-by: Selis <sirlionfur@hotmail.de> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: SatinIsle <thesatinisle@gmail.com> Co-authored-by: Heroman <alesha3000@list.ru> Co-authored-by: Casey <a.roaming.shadow@gmail.com> Co-authored-by: Raeschen <rycoop29@gmail.com>
This commit is contained in:
@@ -69,7 +69,7 @@
|
||||
// atoms/items/objects can be pretty and whatnot
|
||||
var/atom/A = item
|
||||
if(output_icons && isicon(A.icon) && !ismob(A)) // mobs tend to have unusable icons
|
||||
item_str += "\icon[A][bicon(A)] "
|
||||
item_str += "[bicon(A)] "
|
||||
switch(determiners)
|
||||
if(DET_NONE) item_str += A.name
|
||||
if(DET_DEFINITE) item_str += "\the [A]"
|
||||
|
||||
@@ -327,3 +327,33 @@ GLOBAL_LIST_EMPTY(mannequins)
|
||||
*/
|
||||
//Hexidecimal numbers
|
||||
var/global/list/hexNums = list("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F")
|
||||
|
||||
// Many global vars aren't GLOB type. This puts them there to be more easily inspected.
|
||||
GLOBAL_LIST_EMPTY(legacy_globals)
|
||||
|
||||
/proc/populate_legacy_globals()
|
||||
//Note: these lists cannot be changed to a new list anywhere in code!
|
||||
//If they are, these will cause the old list to stay around!
|
||||
//Check by searching for "<GLOBAL_NAME> =" in the entire codebase
|
||||
GLOB.legacy_globals["player_list"] = player_list
|
||||
GLOB.legacy_globals["mob_list"] = mob_list
|
||||
GLOB.legacy_globals["human_mob_list"] = human_mob_list
|
||||
GLOB.legacy_globals["silicon_mob_list"] = silicon_mob_list
|
||||
GLOB.legacy_globals["ai_list"] = ai_list
|
||||
GLOB.legacy_globals["living_mob_list"] = living_mob_list
|
||||
GLOB.legacy_globals["dead_mob_list"] = dead_mob_list
|
||||
GLOB.legacy_globals["observer_mob_list"] = observer_mob_list
|
||||
GLOB.legacy_globals["listening_objects"] = listening_objects
|
||||
GLOB.legacy_globals["cleanbot_reserved_turfs"] = cleanbot_reserved_turfs
|
||||
GLOB.legacy_globals["cable_list"] = cable_list
|
||||
GLOB.legacy_globals["landmarks_list"] = landmarks_list
|
||||
GLOB.legacy_globals["event_triggers"] = event_triggers
|
||||
GLOB.legacy_globals["side_effects"] = side_effects
|
||||
GLOB.legacy_globals["mechas_list"] = mechas_list
|
||||
GLOB.legacy_globals["mannequins_"] = mannequins_
|
||||
//visual nets
|
||||
GLOB.legacy_globals["visual_nets"] = visual_nets
|
||||
GLOB.legacy_globals["cameranet"] = cameranet
|
||||
GLOB.legacy_globals["cultnet"] = cultnet
|
||||
GLOB.legacy_globals["item_tf_spawnpoints"] = item_tf_spawnpoints
|
||||
GLOB.legacy_globals["existing_solargrubs"] = existing_solargrubs
|
||||
|
||||
+14
-8
@@ -534,6 +534,12 @@ GLOBAL_LIST_EMPTY(cached_examine_icons)
|
||||
CRASH("get_dummy_savefile failed to create a dummy savefile: '[error]'")
|
||||
return get_dummy_savefile(from_failure = TRUE)
|
||||
|
||||
/// 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.
|
||||
@@ -653,12 +659,12 @@ GLOBAL_LIST_EMPTY(cached_examine_icons)
|
||||
//var/name = SANITIZE_FILENAME("[generate_asset_name(thing)].png")
|
||||
var/name = "[generate_asset_name(thing)].png"
|
||||
if (!SSassets.cache[name])
|
||||
register_asset(name, thing)
|
||||
SSassets.transport.register_asset(name, thing)
|
||||
for (var/thing2 in targets)
|
||||
send_asset(thing2, name)
|
||||
SSassets.transport.send_assets(thing2, name)
|
||||
if(sourceonly)
|
||||
return get_asset_url(name)
|
||||
return "<img class='[extra_classes] icon icon-misc' src='[get_asset_url(name)]'>"
|
||||
return SSassets.transport.get_asset_url(name)
|
||||
return "<img class='[extra_classes] icon icon-misc' src='[SSassets.transport.get_asset_url(name)]'>"
|
||||
|
||||
//its either an atom, image, or mutable_appearance, we want its icon var
|
||||
icon2collapse = thing.icon
|
||||
@@ -695,12 +701,12 @@ GLOBAL_LIST_EMPTY(cached_examine_icons)
|
||||
key = "[name_and_ref[3]].png"
|
||||
|
||||
if(!SSassets.cache[key])
|
||||
register_asset(key, rsc_ref, file_hash, icon_path)
|
||||
SSassets.transport.register_asset(key, rsc_ref, file_hash, icon_path)
|
||||
for (var/client_target in targets)
|
||||
send_asset(client_target, key)
|
||||
SSassets.transport.send_assets(client_target, key)
|
||||
if(sourceonly)
|
||||
return get_asset_url(key)
|
||||
return "<img class='[extra_classes] icon icon-[icon_state]' src='[get_asset_url(key)]'>"
|
||||
return SSassets.transport.get_asset_url(key)
|
||||
return "<img class='[extra_classes] icon icon-[icon_state]' src='[SSassets.transport.get_asset_url(key)]'>"
|
||||
|
||||
/proc/icon2base64html(target, var/custom_classes = "")
|
||||
if (!target)
|
||||
|
||||
@@ -8,10 +8,14 @@
|
||||
if(toIndex <= 0)
|
||||
toIndex += L.len + 1
|
||||
|
||||
sortInstance.L = L
|
||||
sortInstance.cmp = cmp
|
||||
sortInstance.associative = associative
|
||||
var/datum/sort_instance/SI = GLOB.sortInstance
|
||||
if(!SI)
|
||||
SI = new
|
||||
|
||||
sortInstance.timSort(fromIndex, toIndex)
|
||||
SI.L = L
|
||||
SI.cmp = cmp
|
||||
SI.associative = associative
|
||||
|
||||
SI.timSort(fromIndex, toIndex)
|
||||
|
||||
return L
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
#define MIN_GALLOP 7
|
||||
|
||||
//This is a global instance to allow much of this code to be reused. The interfaces are kept separately
|
||||
var/datum/sortInstance/sortInstance = new()
|
||||
/datum/sortInstance
|
||||
GLOBAL_DATUM_INIT(sortInstance, /datum/sort_instance, new())
|
||||
/datum/sort_instance
|
||||
//The array being sorted.
|
||||
var/list/L
|
||||
|
||||
//The comparator proc-reference
|
||||
var/cmp = /proc/cmp_numeric_asc
|
||||
var/cmp = GLOBAL_PROC_REF(cmp_numeric_asc)
|
||||
|
||||
//whether we are sorting list keys (0: L[i]) or associated values (1: L[L[i]])
|
||||
var/associative = 0
|
||||
@@ -32,7 +32,7 @@ var/datum/sortInstance/sortInstance = new()
|
||||
var/list/runLens = list()
|
||||
|
||||
|
||||
/datum/sortInstance/proc/timSort(start, end)
|
||||
/datum/sort_instance/proc/timSort(start, end)
|
||||
runBases.Cut()
|
||||
runLens.Cut()
|
||||
|
||||
@@ -97,7 +97,7 @@ lo the index of the first element in the range to be sorted
|
||||
hi the index after the last element in the range to be sorted
|
||||
start the index of the first element in the range that is not already known to be sorted
|
||||
*/
|
||||
/datum/sortInstance/proc/binarySort(lo, hi, start)
|
||||
/datum/sort_instance/proc/binarySort(lo, hi, start)
|
||||
//ASSERT(lo <= start && start <= hi)
|
||||
if(start <= lo)
|
||||
start = lo + 1
|
||||
@@ -134,7 +134,7 @@ For its intended use in a stable mergesort, the strictness of the
|
||||
definition of "descending" is needed so that the call can safely
|
||||
reverse a descending sequence without violating stability.
|
||||
*/
|
||||
/datum/sortInstance/proc/countRunAndMakeAscending(lo, hi)
|
||||
/datum/sort_instance/proc/countRunAndMakeAscending(lo, hi)
|
||||
//ASSERT(lo < hi)
|
||||
|
||||
var/runHi = lo + 1
|
||||
@@ -164,7 +164,7 @@ reverse a descending sequence without violating stability.
|
||||
|
||||
//Returns the minimum acceptable run length for an array of the specified length.
|
||||
//Natural runs shorter than this will be extended with binarySort
|
||||
/datum/sortInstance/proc/minRunLength(n)
|
||||
/datum/sort_instance/proc/minRunLength(n)
|
||||
//ASSERT(n >= 0)
|
||||
var/r = 0 //becomes 1 if any bits are shifted off
|
||||
while(n >= MIN_MERGE)
|
||||
@@ -177,7 +177,7 @@ reverse a descending sequence without violating stability.
|
||||
// runLen[i-2] > runLen[i-1]
|
||||
//This method is called each time a new run is pushed onto the stack.
|
||||
//So the invariants are guaranteed to hold for i<stackSize upon entry to the method
|
||||
/datum/sortInstance/proc/mergeCollapse()
|
||||
/datum/sort_instance/proc/mergeCollapse()
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n-1] <= runLens[n] + runLens[n+1])
|
||||
@@ -192,7 +192,7 @@ reverse a descending sequence without violating stability.
|
||||
|
||||
//Merges all runs on the stack until only one remains.
|
||||
//Called only once, to finalise the sort
|
||||
/datum/sortInstance/proc/mergeForceCollapse()
|
||||
/datum/sort_instance/proc/mergeForceCollapse()
|
||||
while(runBases.len >= 2)
|
||||
var/n = runBases.len - 1
|
||||
if(n > 1 && runLens[n-1] < runLens[n+1])
|
||||
@@ -203,7 +203,7 @@ reverse a descending sequence without violating stability.
|
||||
//Merges the two consecutive runs at stack indices i and i+1
|
||||
//Run i must be the penultimate or antepenultimate run on the stack
|
||||
//In other words, i must be equal to stackSize-2 or stackSize-3
|
||||
/datum/sortInstance/proc/mergeAt(i)
|
||||
/datum/sort_instance/proc/mergeAt(i)
|
||||
//ASSERT(runBases.len >= 2)
|
||||
//ASSERT(i >= 1)
|
||||
//ASSERT(i == runBases.len - 1 || i == runBases.len - 2)
|
||||
@@ -257,7 +257,7 @@ reverse a descending sequence without violating stability.
|
||||
|
||||
Returns the index at which to insert element 'key'
|
||||
*/
|
||||
/datum/sortInstance/proc/gallopLeft(key, base, len, hint)
|
||||
/datum/sort_instance/proc/gallopLeft(key, base, len, hint)
|
||||
//ASSERT(len > 0 && hint >= 0 && hint < len)
|
||||
|
||||
var/lastOffset = 0
|
||||
@@ -316,7 +316,7 @@ reverse a descending sequence without violating stability.
|
||||
* @param c the comparator used to order the range, and to search
|
||||
* @return the int k, 0 <= k <= n such that a[b + k - 1] <= key < a[b + k]
|
||||
*/
|
||||
/datum/sortInstance/proc/gallopRight(key, base, len, hint)
|
||||
/datum/sort_instance/proc/gallopRight(key, base, len, hint)
|
||||
//ASSERT(len > 0 && hint >= 0 && hint < len)
|
||||
|
||||
var/offset = 1
|
||||
@@ -368,7 +368,7 @@ reverse a descending sequence without violating stability.
|
||||
|
||||
//Merges two adjacent runs in-place in a stable fashion.
|
||||
//For performance this method should only be called when len1 <= len2!
|
||||
/datum/sortInstance/proc/mergeLo(base1, len1, base2, len2)
|
||||
/datum/sort_instance/proc/mergeLo(base1, len1, base2, len2)
|
||||
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
|
||||
|
||||
var/cursor1 = base1
|
||||
@@ -470,7 +470,7 @@ reverse a descending sequence without violating stability.
|
||||
//ASSERT(len1 > 1)
|
||||
|
||||
|
||||
/datum/sortInstance/proc/mergeHi(base1, len1, base2, len2)
|
||||
/datum/sort_instance/proc/mergeHi(base1, len1, base2, len2)
|
||||
//ASSERT(len1 > 0 && len2 > 0 && base1 + len1 == base2)
|
||||
|
||||
var/cursor1 = base1 + len1 - 1 //start at end of sublists
|
||||
@@ -570,7 +570,7 @@ reverse a descending sequence without violating stability.
|
||||
//ASSERT(len2 > 0)
|
||||
|
||||
|
||||
/datum/sortInstance/proc/mergeSort(start, end)
|
||||
/datum/sort_instance/proc/mergeSort(start, end)
|
||||
var/remaining = end - start
|
||||
|
||||
//If array is small, do an insertion sort
|
||||
@@ -615,7 +615,7 @@ reverse a descending sequence without violating stability.
|
||||
|
||||
return L
|
||||
|
||||
/datum/sortInstance/proc/mergeAt2(i)
|
||||
/datum/sort_instance/proc/mergeAt2(i)
|
||||
var/cursor1 = runBases[i]
|
||||
var/cursor2 = runBases[i+1]
|
||||
|
||||
|
||||
@@ -355,10 +355,10 @@
|
||||
return tagdesc
|
||||
if(!text_tag_cache[tagname])
|
||||
var/icon/tag = icon(text_tag_icons, tagname)
|
||||
text_tag_cache[tagname] = bicon(tag, TRUE, "text_tag")
|
||||
text_tag_cache[tagname] = tag
|
||||
if(!C.tgui_panel.is_ready() || C.tgui_panel.oldchat)
|
||||
return "<IMG src='\ref[text_tag_icons]' class='text_tag' iconstate='[tagname]'" + (tagdesc ? " alt='[tagdesc]'" : "") + ">"
|
||||
return text_tag_cache[tagname]
|
||||
return icon2html(text_tag_cache[tagname], C, extra_classes = "text_tag")
|
||||
|
||||
/proc/create_text_tag_old(var/tagname, var/tagdesc = tagname, var/client/C = null)
|
||||
if(!(C && C.is_preference_enabled(/datum/client_preference/chat_tags)))
|
||||
|
||||
@@ -423,3 +423,9 @@
|
||||
catch(var/exception/E)
|
||||
if(error_on_invalid_return)
|
||||
error("Exception when loading file as string: [E]")
|
||||
|
||||
|
||||
/// 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>"}
|
||||
|
||||
Reference in New Issue
Block a user