135 Commits

Author SHA1 Message Date
Aaron Suen
f5a43c580b Make wieldlights lead a forward-moving player slightly
This helps compensate for network latency and makes traveling
with torches less torturous.
2022-10-12 08:32:16 -04:00
Aaron Suen
923f1be464 Hotfix for DNTs not firing
- Clear the cached timer when the timer has fired.
- Simplify the save-timer-save cycle and just rely
  on dnt_timer to do the save, to eliminate
  redundant saves.
2022-09-29 14:12:26 -04:00
Aaron Suen
c407628172 Fix off-by-zero error in dnt timer setting
If the previously set timer is exactly the correct
value for the existing DNT, then don't update/reset
the node timer.

Not sure why this was the way it was before (it
seems like it might have been intentional) but it
caused measurable performance impact, didn't
seem right, and fixing it didn't seem to introduce
new problems in preliminary testing.
2022-09-28 22:45:07 -04:00
Aaron Suen
92afc2c553 Fix inefficient dynamic light checks
Instead of checking to make sure one of the objects
found at a location is the glowing entity (which is
very slow and has to search every object for each
light) just make sure that the entity still exists
(get_pos() does not return nil) and that it's still
within the same node position as before.

This fixes a huge lagspike that was caught on NCC
due to a bunch of dropped glowing lenses.
2022-09-28 22:16:17 -04:00
Aaron Suen
166cfe5f14 Mitigate excess server block sends
The problem was pointed out by Josh
(gitlab.com/krazy-j) in merge request !22.
Apparently MT is not very smart about marking
mapblocks dirty to send to clients based on
calling mt.set_node(), i.e. it will mark them
dirty presumptively even if you set the node to
the same value it had already been.

This behavior can be confirmed by registering
an ABM against a common node like grass and
setting action = minetest.set_node.  This
causes every mapblock containing that node
to be invalidated every interval, causing a big
spike in the packets received each interval
that you can clearly see on the F5 graph.

Rather than just fixing it for the most easily
observed case (fire checks), add utlity functions
to check this for ALL node change situations,
and apply it more or less universally anywhere
that we are not certain that the node is being
changed and we don't need to worry about the
extra overhead cost of the check.

Note that we don't need a
nodecore.set_loud_check call, as set_loud was
only ever being used already in cases where
we were pretty sure we were actually changing
a node.
2022-08-24 20:44:14 -04:00
Aaron Suen
d668c5c06b Certain puffs of smoke can block optics
This can be used to detect some recipe
completions, esp. cooking, cooling, quenching,
and curing.
2022-05-01 00:42:19 -04:00
Aaron Suen
bc2f1f3fb3 Remove dead code that'd be a bug if not dead 2022-05-01 00:23:07 -04:00
Aaron Suen
fa6f9212de Fix get_sky compat warnings 2022-04-06 07:07:35 -04:00
Aaron Suen
dd5127c6c4 Upper limit for "saved" soaking tickle time 2022-02-10 22:13:39 -05:00
Aaron Suen
a2f81d9ee1 DNT auto-start refinements
- Regen with LBM too.
- Allow different delay time for "just loaded" case.
- Use DNT auto-start for more things, replacing
  regen ABM/LBM where possible.

Also tried to improve door ablation reliabiity:
- Use DNT autostart for door ablation.
- Faster DNT check so we don't need the ABM
  neighbor scan anymore.
- On early ablation trigger, set DNT for right after
  cooldown ends instead of letting DNT loop die,
  removing one scenario that could cause
  sponge squeezer stalls.
2022-02-10 22:08:58 -05:00
Aaron Suen
2e6e1dde34 Fix crash on nil dnt_get 2022-01-30 09:56:39 -05:00
Aaron Suen
a8c521caea Add missing dnt_get API 2022-01-30 09:39:43 -05:00
Aaron Suen
9555a1ecba Optimize ABM delay
Only register a single job with after() per tick.
Store actual node processing to do in a much
simpler linear array.
2022-01-23 17:28:48 -05:00
Aaron Suen
91e5c615c2 ABM delay, prevent "prompt critical" ignition
During processing of the flammable ignition ABM,
nodes could ignite, causing the new ember nodes
created by this ignition to trigger fire propagation
instantly during the same tick by nodes still yet
to be processed for ABM checks during the same
scan.  This often caused large areas of flammable
nodes, like wooden plank skyblocks, to be ignited
instantly in a specific direction from any source
ignition.  This led to some "cheap shots" where
players were ruined by fire far more rapidly than
they should be.

Instead of processing flammability checks in
sync, delay them until the next tick, so that we
find all flammables to check before any new
igniters are created.  This should tame fire
spreading back down to normal levels.
2022-01-22 16:20:10 -05:00
Aaron Suen
86a53392ec More diagnostic logging
- Log pos of first missed ABM
- Log fire ignitions
2022-01-22 15:30:41 -05:00
Aaron Suen
9c03cf35eb Log format cleanups 2022-01-19 23:30:56 -05:00
Aaron Suen
1ad5bde166 Allow ambiance check to return a simple true
Allow use of true to indicate no custom options.  The check
was originally put in place to allow custom options, but
some mods may use it more simply like the craft check,
where it's meant to be a simple pass/fail.
2022-01-15 23:49:19 -05:00
Aaron Suen
72e417e49d Soil leaching tickling recipe
Also, fix inability to push soaking for leaching
ABMs due to fieldname collision.
2022-01-15 14:07:51 -05:00
Aaron Suen
f0ea46e4f6 Standardize "tickling" rate
Base rate on the natural ABM soaking rate, so
that quality of environment can still be used
to increase rate.
2022-01-15 13:54:11 -05:00
Aaron Suen
acd4156ed8 Soaking "tickle" API, standardize particles 2022-01-15 13:29:50 -05:00
Aaron Suen
ec6a04c1ce Support ambiance pitch variation 2022-01-14 21:33:30 -05:00
Aaron Suen
9a2082f084 Fix soaking ABM push cache incoherence 2021-12-24 22:08:10 -05:00
Aaron Suen
8c027089ae Merge branch 'unloadcheck' into dev 2021-12-18 12:14:08 -05:00
Aaron Suen
17c3f1700f Area load check for AISMs 2021-12-18 12:10:58 -05:00
Aaron Suen
31de8b0fde Add automatic unload testing for DNTs 2021-12-18 12:05:25 -05:00
Aaron Suen
a1b2df3941 Begin standardization of unload bounds check
- New near_unloaded API that supports custom
  distance parameter, map bounds check, and
  some optimizations.
- Add area automatic unload check support to ABM
  API and add to applicable ABMs, replacing many
  old manual checks.

Note that the explicit unload check is only strictly
necessary when something will happen due to
a node NOT being present in the area, e.g. something
igniting due to absent coolant, or soaking quantity
being reset due to missing sources.  In simple cases
where the absence of a thing causes the ABM to do
nothing, then the standard check can work because
the default action is to do nothing anyway.
2021-12-18 11:28:14 -05:00
Aaron Suen
a73d9e4457 Report demuxed ABM amounts too 2021-12-18 10:44:45 -05:00
Aaron Suen
8bfdc211a3 Convert some action logs to info
We were using action log level for a lot of
things because by default MT does not seem
to capture info logs to stderr.  On "production"
servers though this makes too much noise and
makes it hard to find actual player actions.
Servers that want info logging will just have
to configure/compile it in.
2021-12-11 21:26:18 -05:00
Aaron Suen
430f08385c Fix soaking meta cache corruption
This was causing soaking things to finish early
and all fire at the same time.
2021-12-11 21:10:27 -05:00
Aaron Suen
0b3271d2da Significantly simplify ambiance dequeueing
These are just going into the after() queue now so
all the rate-limiting stuff is no longer needed.
2021-12-08 23:43:31 -05:00
Aaron Suen
3e262c0a17 Avoid soaking cache collisions
It's possible multiple soaking ABMs are registered
against a single node, and if this happens, make sure
that the qty and time fields in the cache are kept
separate the same way they are in the node meta.
2021-12-07 23:01:14 -05:00
Aaron Suen
25e0219ad8 Desynchronize node ambient sounds
- Removes repeating patterns, creates a richer and
  fuller sound experience
- Larger areas fill sound volume out better instead of
  just repeating more loudly
- Spread network traffic across multiple ticks better
  to reduce packet spikes

Each node position has a set delay, between 0 and 1
second, that's fixed for that pos but varies more or
less randomly between positions.  This ensures that
sounds loop with the same frequency and alignment
for a given single node, but desync across nodes.
2021-12-07 00:57:33 -05:00
Aaron Suen
ca694993c9 Un-delay inverted ABMs
Instead of queueing inverted ABMs and then running
them out-of-band, run them inside the normal ABM
schedule time.  This should:
- Prevent ABM mux lookup problems caused by nodes
  changing after a delayed inverted ABM schedule and
  the action actually running
- Allow the ABM scheduler to better account for the
  time spent running inverted ABM actions, to ensure
  that they properly count against the default 0.2s
  ABM runtime budget and can't spike lag up higher.
2021-12-05 14:11:01 -05:00
Aaron Suen
bf744aab8b Fix excess meta writes in soaking API
It didn't seem to affect many test cases, but avoid
excess calls to meta:set_*() due to 0/nil disagreement.
2021-12-05 09:10:43 -05:00
Aaron Suen
f412b7f570 More extensive ABM statistic reporting 2021-12-05 09:04:17 -05:00
Aaron Suen
8bf23e6f0a Fix DNTs not being reset on node replace
Invalidate DNT cache when nodes are changed and
force it to be re-read from meta, as meta was also
likely cleared during that operation.
2021-12-03 23:02:31 -05:00
Aaron Suen
f7461414d2 Move lazy raycast into playerstep API 2021-08-06 21:33:23 -04:00
Aaron Suen
a0d2abfe3a Fix missed DNTs 2021-08-05 21:09:01 -04:00
Aaron Suen
4f9d756c3f Fix DNTs not firing without nodenames 2021-08-05 20:50:03 -04:00
Aaron Suen
81ef696bce Clear soaking meta cache on node replacement
Ensure that when meta is implicitly cleared by node replacement,
the cache doesn't keep an old copy and fast-forward through
soaking recipes if the old node is re-replaced later
2021-08-05 08:10:42 -04:00
Aaron Suen
6aafecf475 Optimize soaking check for dirt leaching
This was triggering on all dirt nodes everywhere, so optimize the
most common code path, i.e. one where there is no water above
and the soaking data must be reset.
2021-08-05 08:02:48 -04:00
Aaron Suen
0435e6af32 Rewrite core DNT API
- Store next runtime instead of countdown, so metadata always has
  one canonical representation for a given target time, allowing
  us to more easily avoid rewriting the same data with different
  representation.
- Tons of caching and duplicate write avoidance, reduced resetting
  of node timers, and MT API calls in general.
2021-08-05 07:36:14 -04:00
Aaron Suen
ffb25a9162 More exact DNT names
Keep actual name of DNTs distinct and self-describing instead of
relying on modname, which sometimes changes when things are
refactored.
2021-08-05 07:35:20 -04:00
Aaron Suen
dd009343f9 Fix DNT retriggering bug 2021-08-04 17:15:04 -04:00
Aaron Suen
19652c2fe1 Begin major rework of nodenames matching, autostart DNTs
- Unify logic for expanding nodenames/itemnames lists into indexes
  of matching names, and comparing item names/defs to lists,
  with group expansion and deferral.
- Add "autostart" option to DNTs which registers construction traps
  and a patrol ABM automatically, use for some things that are a
  good match.
- Note that some things are doing more complex logic in ABMs, such
  as determining if a node is eligible, or custom timing logic;
  leave these as-is for now.
2021-08-04 07:41:00 -04:00
Aaron Suen
964f2c5044 Make sure glass DNTs are queued 2021-08-03 21:08:57 -04:00
Aaron Suen
00b3dc477a Unified fluid wandering system
- New fluid wandering API, mostly unified logic, only needs
  some parameters, plus the "generation check".
- More sophisticated behavior seeking down-slopes beyond simple
  immediate flowing node reach ("subtle slope" detection).
- More reliable timing using DNTs.
- Set firm movement rate of concrete, molten glass.
- Reduce molten glass generations, since it can now be more
  reliably directed.
2021-08-02 07:17:51 -04:00
Aaron Suen
1f913bf402 Merge branch 'dev' into fluidwander 2021-08-02 07:55:11 -04:00
Aaron Suen
068e9b6995 Remove debugging code 2021-07-11 14:51:35 -04:00
Aaron Suen
e24112a2d9 Fix soaking with cache
Soaking recipe fails will result in a lot of clearing
of old soaking values out of node meta, which is
very slow in the common case of e.g. dirt that's
not near water and thus should not be soaking in
the first place.

Skip node meta writes if the node meta already
contains the correct data, by doing a cached read
and check before writing, instead of blindly
writing.
2021-07-11 14:50:33 -04:00