31 Commits

Author SHA1 Message Date
Aaron Suen
015b1fafff Digging light sources leaves dynamic light behind briefly
This helps to bridge the latency gap between the dig completing
on the client side, and the server sending the result, which might
include adding dynamic lights from a now-handheld light emitter,
e.g. for torches or lanterns.
2022-10-20 07:22:45 -04:00
Aaron Suen
334946fcdd Increase effect of player wield light leading
When the player is moving forward, take autorun
speed into account for distance to lead, to better
counteract server latency and let players run at higher
speeds.  When standing still, still extend the light in
the player's looking direction a little bit, to get more
favorable "rounding".
2022-10-19 22:36:51 -04:00
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
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
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
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
9fb4cf55b2 Deprecate register_limited_abm
This has just been an alias to minetest.register_abm
for a while now, and all ABM enhancement features
have been added directly to the core API.
2021-07-10 11:09:44 -04:00
Aaron Suen
319a3f7480 Fix dynamic lighting staying after torch goes out 2021-03-09 18:29:32 -05:00
Aaron Suen
dc912f776c Make sure all things have explicit descriptions
This avoids issues with the translation informer
including technical names in the translation source
2020-10-18 11:50:04 -04:00
Aaron Suen
6d39ebb77d Fix dynamic light DNT conversion 2020-09-09 10:15:48 -04:00
Aaron Suen
d95e7bb714 Disable timer-based light check for now 2020-09-09 10:00:13 -04:00
Aaron Suen
5648331c9f Replace all perplayer with playerstep 2020-06-22 22:47:33 -04:00
Aaron Suen
e0156b4742 Add profiler instrumentation metadata everywhere
N.B. the MT built-in profiler doesn't yet actually support reading
labels from bare-function registrations, so a builtin hack is
needed.
2020-06-15 07:21:39 -04:00
Aaron Suen
f78c3d90a8 Make dynamic light air_equivalent too 2020-05-31 15:59:53 -04:00
Aaron Suen
a5752fd9b6 Yet another emergency lighting redo
- Players no longer constantly glow in darkness.
- Players can now place light spots by scaling, faster
  than actual climbing spots.
- Climbing spots appear if player continues placement
  after light appears.
- Floor traversal mechanism is now obsolete.

This allows players to traverse dark caves reasonably
well, still, but only voluntarily, so darkness stealth
mechanics are possible again.
2020-05-30 19:00:22 -04:00
Aaron Suen
05abaf3199 Fix invisible players casting light 2020-05-26 19:32:15 -04:00
Aaron Suen
b1584290a8 Fix light overlap, torch fading in lode crate 2020-05-26 19:26:08 -04:00
Aaron Suen
63d9c3fdec Allow dynamic light displacement
If the node we want to place dynamic light in is occupied (e.g.
player is inside a ladder node space) then allow placement on one
of the 6 face-touching spaces.  This makes dynamic lights work
correctly on most ladders, and may fix other similar situations.
2020-05-26 18:46:06 -04:00
Aaron Suen
620e7c09a4 Change dynamic light API, smoother under lag?
Instead of registering the TTL for a light and expecting
more time to be pushed in, use a fixed TTL of 0.25s and
register a callback to check if the light is still valid, i.e.
lights now pull time as necessary.

This should prevent light flickering that can happen
under heavy server lag, i.e. when the time step is
wider than the dynamic light TTL.

Lights that don't register a callback will be ephemeral,
and will disappear after 0.25 seconds, which can be
used to increase the chance that the server has had an
opportunity to move the light, as per torch destructor.
2020-05-26 07:50:57 -04:00
Aaron Suen
9c9eb4b85a Guard against dummy objects in 5.3+
Some time in the 5.3 dev stream (docs updated at
217f3a42), object refs started being invalidated
immediately on calling obj:remove(), such that
obj:get_pos() starts to return nil instead of the object's
last known position.

This can cause some crashes in NodeCore, where we
assume that our object is still valid (or usable as if it
were still valid) even though we're looping through
handlers and any one of them may have remove()d the
object before other handlers get a chance to fire.

Instead, just watch for unexpected nil returns from
functions we expect would never return nil (e.g.
get_pos or get_properties) and return if we hit one.
We can assume all other calls will be non-nil after that
one, as long as we stay in the same function flow.
2020-05-18 18:36:06 -04:00
Aaron Suen
7dbc22abe7 Centralize some sanity checks 2020-05-12 07:25:58 -04:00
Aaron Suen
3fc187f0e6 Centralize entity glow too
Thrown/falling entities containing a light_source will now cast
a dynamic light glow automatically as well.
2020-05-12 07:22:41 -04:00
Aaron Suen
3484b55cb0 Centralize wield glow logic
- Wield item glow is now handled automatically
- Player glows with same glow level as scaling nodes
2020-05-12 07:13:36 -04:00
Aaron Suen
124aa5e4f4 Dynamic light restructuring
All possible light level nodes are pre-registered at startup time
so that light levels can be determined fully dynamically at run
time, without needing to explicitly declare what light levels will
actually be needed.

Hopefully this will make using dynamic lights a little easier
and lead to some interesting content.
2020-05-12 06:55:11 -04:00
Aaron Suen
48473ea34c A little tighter "airlike" detection. 2020-03-29 20:05:11 -04:00
Aaron Suen
48e7bab366 More torch smoothing.
- Smoother entity light casting.
- Fix flicker on torch pickup.
2020-03-15 08:34:45 -04:00
Aaron Suen
82bc47642e Smoother torch light operation.
Also reduce client packets by tracking dynalight node
ttl in-memory instead of meta.  Lights might flicker out
a bit on area first loading, but some startup judder is
expected on any unloaded area anyway.

Add a "cheat" code for torch testing, and possibly for
other dev uses.
2020-03-15 08:20:56 -04:00
Aaron Suen
3200149cc4 Buff torch and scaling light sources.
- Better compat with low gamma play.
- Torch now emits some light when in inventory, even
  if not actively wielded.
- Dynamic light API for mod use.
2020-02-22 21:57:08 -05:00