mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
Optimizes changing z level as a ghost by something like 85% (#73005) <!-- Write **BELOW** The Headers and **ABOVE** The comments else it may not be viewable. --> <!-- You can view Contributing.MD for a detailed description of the pull request process. --> ## About The Pull Request <!-- Describe The Pull Request. Please be sure every change is documented or this can delay review and even discourage maintainers from merging your PR! --> Optimizes hud image addition/removal on z change We were doing a lot of repeated work here, not to mention all the proc calls. So I pushed the "operate on loops" behavior into its own proc, so I could ensure we only do some of this stuff once This plus some removal of safeties saves 75% of the cost of z level transitions as a ghost Prevents double on_changed_z_level calls from ghosts and shuttles Reacting to z changes used to be done off doMove or one of those children, timber moved it to Moved, but did not remove the calls that assumed things like abstract_move wouldn't trigger it This means that moving up/down as a ghost was causing a double call of the whole z move stack. Suprised this never broke anything tbh Makes csv stat tracking actually encode numbers properly, cleans up an indev comment from plane group code ## Why It's Good For The Game Speed, and fixes Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
42 lines
1.2 KiB
Plaintext
42 lines
1.2 KiB
Plaintext
// For use with the stopwatch defines
|
|
/proc/render_stats(list/stats, user, sort = GLOBAL_PROC_REF(cmp_generic_stat_item_time))
|
|
sortTim(stats, sort, TRUE)
|
|
|
|
var/list/lines = list()
|
|
|
|
for (var/entry in stats)
|
|
var/list/data = stats[entry]
|
|
lines += "[entry] => [num2text(data[STAT_ENTRY_TIME], 10)]ms ([data[STAT_ENTRY_COUNT]]) (avg:[num2text(data[STAT_ENTRY_TIME]/(data[STAT_ENTRY_COUNT] || 1), 99)])"
|
|
|
|
if (user)
|
|
user << browse("<ol><li>[lines.Join("</li><li>")]</li></ol>", "window=[url_encode("stats:[REF(stats)]")]")
|
|
|
|
. = lines.Join("\n")
|
|
|
|
// For use with the set_cost defines
|
|
/proc/stat_tracking_export_to_json_later(filename, costs, counts)
|
|
if (IsAdminAdvancedProcCall())
|
|
return
|
|
|
|
var/list/output = list()
|
|
|
|
for (var/key in costs)
|
|
output[key] = list(
|
|
"cost" = costs[key],
|
|
"count" = counts[key],
|
|
)
|
|
|
|
rustg_file_write(json_encode(output), "[GLOB.log_directory]/[filename]")
|
|
|
|
/proc/stat_tracking_export_to_csv_later(filename, costs, counts)
|
|
if (IsAdminAdvancedProcCall())
|
|
return
|
|
|
|
var/list/output = list()
|
|
|
|
output += "key, cost, count"
|
|
for (var/key in costs)
|
|
output += "[replacetext(key, ",", "")], [costs[key]], [counts[key]]"
|
|
|
|
rustg_file_write(output.Join("\n"), "[GLOB.log_directory]/[filename]")
|