mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-27 10:02:12 +00:00
* Slightly optimize shroom spreading code (#53652) There were some recent lag events on the servers caused by the timer subsystem jamming up with glowshroom timers. I whined about this but nobody did anything so (Thanos "Fine... I'll do it myself" GIF) There are a few changes here, first we collect the potential turfs for the view call in a single pass, not once per yield run. Second we don't run a second view(1) on every single potential turf, instead we try to randomly pick a turf 3 times during yield phase and check the view then. If we fail to find a potential location then we bail out of that yield phase. This is a tradeoff between processing time spent finding locations and the chance that the glowshroom fails to spread. Finally, we have maximum limit on how many times a glowshroom fails to spread, if it fails to spread at least 5 times over any iteration, it stops processing for spread completely. As a bonus, the timers have been made unique, so we don't accidentally generate multiple timers for a single shroom, other than the two it already needs. This code would benefit from being a separate subsystem and grouping, generations of the plants together as a single ticking entity and just spreading from selected edge plants. However I don't particularly feel like plumbing that together, so this will suit for now. * Slightly optimize shroom spreading code Co-authored-by: oranges <email@oranges.net.nz>