Kaiochao / HazordhuII

Haz2's open source
GNU General Public License v2.0
1 stars 4 forks source link

CPU usage of crop growth #56

Open Kaiochao opened 7 years ago

Kaiochao commented 7 years ago

In Farming.dm, all growing plants are added to a growth loop. The growth loop ticks once every second, looping over every plant added to the loop to make them check their growth. When a plant stops growing (fully-grown or wrong season or wrong z-level), it's removed from the growth loop, so only actively-growing plants are involved.

What more efficient ways are there?

Unwanted4Murder commented 7 years ago

Only real lack of efficiency I see there is that it's checking every second. That could end up being quite a lot of plants. It may not need to check so frequently.

Kaiochao commented 6 years ago

Idea: Update crops once when their chunk is enabled (when a player comes nearby), setting their age to the time since the last season change (plus some random amount). No more looping over every crop in the world every second.

Crops near players should grow using a single (long) delay per crop.