Skip to content

Commit

Permalink
Port "SStechtree startup optimisation" (#343)
Browse files Browse the repository at this point in the history
Co-authored-by: SabreML <[email protected]>
  • Loading branch information
Doubleumc and SabreML committed Jul 24, 2024
1 parent ceac4ab commit 1c09c05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
11 changes: 0 additions & 11 deletions code/controllers/subsystem/techtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions code/modules/cm_tech/techtree.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit 1c09c05

Please sign in to comment.