From 0aa1e4c6c8e129d79847fe1ff876bbf96eb591d0 Mon Sep 17 00:00:00 2001 From: Lohikar Date: Thu, 14 Sep 2017 13:11:10 -0500 Subject: [PATCH] Fix space vine lag (#3452) Fixes lag from plants processing forever instead of obeying the subsystem's tick interval. Also fixes a glitch where plants didn't continue to grow if not mature. Fixes #3451. --- code/controllers/subsystems/plants.dm | 8 +++++++- .../hydroponics/spreading/spreading_growth.dm | 13 +++++++------ html/changelogs/lohikar-plantlag.yml | 4 ++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 html/changelogs/lohikar-plantlag.yml diff --git a/code/controllers/subsystems/plants.dm b/code/controllers/subsystems/plants.dm index 2ee48773165..354a184d424 100644 --- a/code/controllers/subsystems/plants.dm +++ b/code/controllers/subsystems/plants.dm @@ -15,6 +15,7 @@ var/list/plant_product_sprites = list() // List of all growth sprites plus number of growth stages. var/list/processing = list() + var/list/current = list() /datum/controller/subsystem/plants/New() NEW_SS_GLOBAL(SSplants) @@ -78,7 +79,12 @@ src.plant_product_sprites = SSplants.plant_product_sprites /datum/controller/subsystem/plants/fire(resumed = 0) - var/list/queue = processing + if (!resumed) + var/list/old = current // This should be empty, so might as well just reuse it. + current = processing + processing = old + + var/list/queue = current while (queue.len) var/obj/effect/plant/P = queue[queue.len] queue.len-- diff --git a/code/modules/hydroponics/spreading/spreading_growth.dm b/code/modules/hydroponics/spreading/spreading_growth.dm index 451d3185344..b10177922ba 100644 --- a/code/modules/hydroponics/spreading/spreading_growth.dm +++ b/code/modules/hydroponics/spreading/spreading_growth.dm @@ -17,7 +17,7 @@ if((locate(/obj/effect/plant) in floor.contents) || (locate(/obj/effect/dead_plant) in floor.contents) ) continue if(floor.density) - if(!isnull(seed.chems["pacid"])) + if(seed.chems["pacid"]) addtimer(CALLBACK(floor, /atom/.proc/ex_act, 3), rand(5, 25)) continue if(!Adjacent(floor) || !floor.Enter(src)) @@ -82,14 +82,15 @@ //spread to 1-3 adjacent turfs depending on yield trait. var/max_spread = between(1, round(seed.get_trait(TRAIT_YIELD)*3/14), 3) - addtimer(CALLBACK(src, .proc/do_spread, spread_chance, max_spread), 1) + do_spread(spread_chance, max_spread) // We shouldn't have spawned if the controller doesn't exist. check_health() - if(neighbors.len || health != max_health || buckled_mob) + if(neighbors.len || health != max_health || buckled_mob || !is_mature()) SSplants.add_plant(src) /obj/effect/plant/proc/do_spread(spread_chance, max_spread) + set waitfor = FALSE for(var/i in 1 to max_spread) if(prob(spread_chance)) sleep(rand(3,5)) @@ -105,8 +106,8 @@ neighbor.neighbors -= target_turf /obj/effect/plant/proc/do_move(turf/target, obj/effect/plant/child) - child.loc = target - child.update_icon() + child.forceMove(target) + child.queue_icon_update() /obj/effect/plant/proc/die_off() // Kill off our plant. @@ -119,6 +120,6 @@ neighbor.neighbors |= check_turf SSplants.add_plant(neighbor) - QDEL_IN(src, 1) + qdel(src) #undef NEIGHBOR_REFRESH_TIME diff --git a/html/changelogs/lohikar-plantlag.yml b/html/changelogs/lohikar-plantlag.yml new file mode 100644 index 00000000000..88260acc869 --- /dev/null +++ b/html/changelogs/lohikar-plantlag.yml @@ -0,0 +1,4 @@ +author: Lohikar +delete-after: True +changes: + - bugfix: "Space vines should no longer create comical amounts of lag."