From 1c09c053ab3cbd6eb07cc764033fe8830c4ae807 Mon Sep 17 00:00:00 2001 From: Doubleumc Date: Wed, 24 Jul 2024 19:20:24 -0400 Subject: [PATCH] Port "SStechtree startup optimisation" (#343) Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- code/controllers/subsystem/techtree.dm | 11 ----------- code/modules/cm_tech/techtree.dm | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/code/controllers/subsystem/techtree.dm b/code/controllers/subsystem/techtree.dm index 04ac2591bc..5f22373228 100644 --- a/code/controllers/subsystem/techtree.dm +++ b/code/controllers/subsystem/techtree.dm @@ -34,17 +34,6 @@ SUBSYSTEM_DEF(techtree) var/datum/space_level/zpos = SSmapping.add_new_zlevel(tree.name, list(ZTRAIT_TECHTREE)) tree.zlevel = zpos - var/zlevel = zpos.z_value - var/turf/z_min = locate(1, 1, zlevel) - var/turf/z_max = locate(world.maxx, world.maxy, zlevel) - - - - for(var/t in block(z_min, z_max)) - var/turf/Tu = t - Tu.ChangeTurf(/turf/closed/void, list(/turf/closed/void)) - new /area/techtree(Tu) - for(var/tier in tree.tree_tiers) tree.unlocked_techs += tier tree.all_techs += tier diff --git a/code/modules/cm_tech/techtree.dm b/code/modules/cm_tech/techtree.dm index 6c39d8ab9c..a027789185 100644 --- a/code/modules/cm_tech/techtree.dm +++ b/code/modules/cm_tech/techtree.dm @@ -58,16 +58,24 @@ if(longest_tier < tier_length) longest_tier = tier_length - // Clear out the area - for(var/t in block(locate(1, 1, zlevel.z_value), locate(longest_tier * 2 + 1, length(all_techs) * 3 + 1, zlevel.z_value))) + // Clear out and create the area + // (The `+ 2` on both of these is 1 for a buffer tile, and 1 for the outer `/turf/closed/void`.) + var/area_max_x = longest_tier * 2 + 2 + var/area_max_y = length(all_techs) * 3 + 2 + for(var/t in block(locate(1, 1, zlevel.z_value), locate(area_max_x, area_max_y, zlevel.z_value))) var/turf/pos = t for(var/A in pos) qdel(A) - pos.ChangeTurf(/turf/open/blank) - pos.color = "#000000" - + if(pos.x == area_max_x || pos.y == area_max_y) + // The turfs around the edge are closed. + pos.ChangeTurf(/turf/closed/void) + else + pos.ChangeTurf(/turf/open/blank) + pos.color = "#000000" + new /area/techtree(pos) + // Create the tech nodes var/y_offset = 1 for(var/tier in all_techs) var/tier_length = length(all_techs[tier])