From 124f7ee17b7577a6f657d89c0dbb9e8ef8f4d64a Mon Sep 17 00:00:00 2001 From: "sentry[bot]" <39604003+sentry[bot]@users.noreply.github.com> Date: Mon, 1 Jun 2026 10:36:40 +0000 Subject: [PATCH] Hydroponics: Fix invalid plant icon state from negative growth (#22523) * Please describe the intent of your changes in a clear fashion. This PR addresses a server crash caused by an invalid icon state being requested for certain plants, specifically those with spreading traits like biomass vines. **Root Cause:** The `refresh_icon()` proc for `/obj/effect/plant` was directly decrementing the instance variable `max_growth` based on fringe conditions (`spread_distance` and `at_fringe`). This meant that `max_growth` could become negative over multiple processing ticks. When `seed.get_icon()` was subsequently called with a negative growth stage (e.g., -2), it constructed an invalid icon state string (e.g., `biomass--2`), leading to a crash. **Solution:** To prevent `max_growth` from being permanently altered, a local variable `effective_max` is now used within `refresh_icon()`. This local variable is initialized with the current `max_growth` and then decremented based on the fringe conditions. The `growth` calculation and subsequent icon state generation now use `effective_max`, ensuring that the persistent `max_growth` variable remains stable and positive, thus preventing the generation of invalid negative icon states. * Please make sure that, in the case of mapping changes, you include images of these changes in the PR's description. * Please make sure to mark your PR as wip or review required by making a comment with !wip or !review required * If you include sprites/sounds/... (assets) that you have not created yourself specify the license and original author below. * Ensure that you also credit them in the appropriate location / changelog as specified in the contributor guidelines ### Asset Licenses The following assets that **have not** been created by myself are included in this PR: | Path | Original Author | License | | --- | --- | --- | | icons/example.dmi | ExamplePerson (Example Station) | CC0 | Fixes SERVER-PROD-TJ --------- Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com> Co-authored-by: VMSolidus --- code/modules/hydroponics/spreading/spreading.dm | 14 ++++++++------ html/changelogs/hellfirejag-vines-bugfix.yml | 4 ++++ 2 files changed, 12 insertions(+), 6 deletions(-) create mode 100644 html/changelogs/hellfirejag-vines-bugfix.yml diff --git a/code/modules/hydroponics/spreading/spreading.dm b/code/modules/hydroponics/spreading/spreading.dm index 734e5b201e4..9dc331b4afe 100644 --- a/code/modules/hydroponics/spreading/spreading.dm +++ b/code/modules/hydroponics/spreading/spreading.dm @@ -188,15 +188,17 @@ SHOULD_NOT_SLEEP(TRUE) overlays.Cut() - var/growth = 0 - if(growth_threshold) - growth = min(max_growth, round(health/growth_threshold)) + var/effective_max = max_growth var/at_fringe = get_dist(src,parent) if(spread_distance > 5) if(at_fringe >= (spread_distance-3)) - max_growth-- + effective_max-- if(at_fringe >= (spread_distance-2)) - max_growth-- + effective_max-- + + var/growth = 0 + if(growth_threshold) + growth = min(effective_max, round(health/growth_threshold)) var/image/our_icon = seed.get_icon(growth) @@ -205,7 +207,7 @@ AddOverlays(our_icon) - if(growth>2 && growth == max_growth) + if(growth>2 && growth == effective_max) layer = (seed && seed.force_layer) ? seed.force_layer : 5 if(growth_type in list(GROWTH_VINES,GROWTH_BIOMASS)) opacity = 1 diff --git a/html/changelogs/hellfirejag-vines-bugfix.yml b/html/changelogs/hellfirejag-vines-bugfix.yml new file mode 100644 index 00000000000..ff64a418ccf --- /dev/null +++ b/html/changelogs/hellfirejag-vines-bugfix.yml @@ -0,0 +1,4 @@ +author: Hellfirejag +delete-after: True +changes: + - bugfix: "Fixed vines spamming runtime errors after they are 'damaged' by a player."